Unifi protect to Home Assistant (without plugin)

How to create a trigger for a UniFi doorbell that calls a Home Assistant webhook to turn on a light.
There is a Home Assistant integration available for UniFi Protect that can do this automatically, but real-world experience shows that this integration often breaks, stops updating, or consumes a noticeable amount of resources. This happens because the integration relies on polling: Home Assistant constantly asks UniFi Protect for updates instead of receiving events instantly. Polling increases CPU and network usage on both Home Assistant and the Protect controller, and it can introduce small but noticeable delays.

A far more reliable and efficient method is to use a webhook. Webhooks are event-driven, meaning UniFi Protect pushes the doorbell event to Home Assistant the very moment the button is pressed. There is no waiting, no repeated checks, and no extra system load. The automation triggers almost instantly—so fast, in fact, that in most setups the light will turn on before the UniFi Protect chime has even finished reacting. To be fair, we’re only talking about a difference of a few milliseconds, but it still feels amusingly impressive the first time you see the porch light come on before the doorbell sound itself.

This guide explains how to set up your UniFi Protect doorbell so that it sends a webhook to Home Assistant when the doorbell is pressed. Home Assistant then receives the webhook and runs an automation, such as turning on a light at the front door. This approach removes the dependency on the Protect integration for this specific task and gives you a fast, reliable, low-overhead trigger that behaves almost instantly—sometimes comically faster than the doorbell’s own chime.

Requirements:

  • UniFi Protect doorbell (such as G4 Doorbell)
  • UniFi Protect controller on UniFi OS
  • Home Assistant
  • Local network access between UniFi Protect and Home Assistant

Step 1: Create a webhook in Home Assistant

  1. In Home Assistant, go to Settings, then Automations & Scenes, then create a new automation.
  2. Choose “Create automation from scratch.”
  3. Add a trigger of type “Webhook.”
  4. Set the webhook ID to something simple, such as: unifi-doorbell-pressed

Home Assistant will create a webhook URL for you. It will look like:
https://YOUR_HOME_ASSISTANT_URL/api/webhook/unifi-doorbell-pressed
or
http://192.168.1.X:8123/api/webhook/unifi-doorbell-pressed

Step 2: Add the action to turn on a light

  1. In the same automation, add an action.
  2. Choose the light device you want to turn on.
  3. Set the action to turn the light on.
  4. Save the automation.

Home Assistant is now waiting for the webhook to be called.

Step 3: Configure UniFi Protect to call the webhook

  1. Open UniFi Protect.
  2. Go to Settings, then Notifications, then Webhooks.
  3. Add a new webhook.
  4. Give it a name such as “Home Assistant Doorbell.”
  5. Enter your Home Assistant webhook URL in the URL field.
  6. Select the event type “Doorbell Press.”
  7. Save the webhook.

Step 4: Test the setup

  1. Press the UniFi doorbell button.
  2. UniFi Protect should send a POST request to Home Assistant.
  3. Home Assistant should receive the webhook and run your automation.
  4. The light should turn on.

Optional improvements:

  • Add a delay and a second action to turn the light off after a few minutes.
  • Add conditions so the light only turns on at night.
  • Add more actions, such as playing audio or sending a notification.

You now have a working setup where a UniFi doorbell triggers a Home Assistant webhook and turns on a light.

Below is a more advanced example of a HomeAssistant webhook that only turns on the lights after sunset, and if the lights are already on increases the brightness.

alias: Deurbel 3
description: ""
triggers:
  - trigger: webhook
    allowed_methods:
      - POST
      - PUT
    local_only: true
    webhook_id: deurbel-3-PW_6NMChiFbFuDjAlaNKGp4r
conditions:
  - condition: sun
    after: sunset
    after_offset: "-00:30:00"
    before: sunrise
    enabled: false
actions:
  - choose:
      - conditions:
          - condition: state
            entity_id: light.hal_voordeur_tuya2_l1
            state: "off"
        sequence:
          - target:
              entity_id: light.hal_voordeur_tuya2_l1
            data:
              brightness_pct: 100
            action: light.turn_on
          - delay: "00:05:00"
          - target:
              entity_id: light.hal_voordeur_tuya2_l1
            action: light.turn_off
      - conditions:
          - condition: state
            entity_id: light.hal_voordeur_tuya2_l1
            state: "on"
        sequence:
          - variables:
              previous_brightness: "{{ state_attr('light.hal_voordeur_tuya2_l1','brightness') }}"
          - target:
              entity_id: light.hal_voordeur_tuya2_l1
            data:
              brightness_pct: 100
            action: light.turn_on
          - delay: "00:05:00"
          - target:
              entity_id: light.hal_voordeur_tuya2_l1
            data:
              brightness: "{{ previous_brightness }}"
            action: light.turn_on
mode: parallel
max: 10