Cannot Get UniFi Person Detected Lighting Automation to Work

I have a HomeKit enabled home lighting system. I have setup an automation where the G4 person detection should trigger the chosen lighting circuit to activate between the hours of sun down and sun up. When I ‘run action’, the lights come on, but once the automation is turned on, the person detection doesn’t seem to be registered by HA. Person detection is however registered on the Unifi Protect App. Non-Smart Motion detection seems to work fine, but is too sensitve and just keeps coming on due to cars passing my frotn door. Anyone have any ideas to steer me in the right direction to get this working please?

 - id: '1657145723067'
  alias: Doorbell Light Up
  description: ''
  trigger:
  - platform: device
    type: turned_on
    device_id: 9aa2eed80f7eef0ec786c20195213852
    entity_id: switch.g4_doorbell_detections_person
    domain: switch
  condition:
  - condition: sun
    after: sunset
    after_offset: 00:01:00
  - condition: or
    conditions:
    - condition: sun
      before: sunrise
  action:
  - service: scene.turn_on
    target:
      entity_id: scene.new_scene
    metadata: {}
  - delay:
      hours: 0
      minutes: 1
      seconds: 0
      milliseconds: 0
  - service: scene.turn_on
    target:
      entity_id: scene.driveway_lights_duplicate
    metadata: {}
  mode: single

So if I understand it correctly.
When you run the shown automation by triggering it manually, it runs as expected. But it doesn’t trigger when the state of switch.g4_doorbell_detections_person changes to on.

Can you see the actual status of the switch in HA (for ex. using ‘Developer Tools → States’)?
If so, do you see it change there when you toggle the state of the switch?
If not, then it makes sense that there is nothing triggered. Perhaps someone with HomeKit knowledge can help you further.

If you do see the change, you might want to test using a State trigger instead. Use the to field to enter the state exactly as it is shown in the ‘Developer Tools → States’.

1 Like

Yep - That’s right. Doorbell person detection should trigger a light to come on once person detection trigger is activated. All works fine when manually hitting run, but doesn’t work as expected in actual usage.

Thanks for this suggestion. I never knew about it. Weird as looks like the Doorbell Detection Person Entity is showing as perpetually on. Except when I changed it’s current state to off using the States tab in developer tools.

Could that be why it never acts as a trigger - its not changing states.

It seems like the status is never updated/changed. If the status never changes, an automation will never be triggered. Cause it needs a status change that matches the trigger condition to trigger.

So the question is, why… I am not familiar with the sensor and UniFi protect integration, so I am not sure…
Could it be that the “person detect” isn’t “recognizing” a human being and therefor not triggers?

I do see the motion detect change. Maybe you could do a test run using that and meanwhile figure out what the person detector needs to detect persons :slight_smile:

I can imagine that it’s just a small config thing in UniFi. It’s clear that the other sensors do update, so in general the integration works.

1 Like

What is strange is that the Unifi Protect app registers person triggers all the time. It’s just the HA integration that seems to be missing them.

Hi there

This baffled me for a while too, but it is as suggested it is an issue to do with “state” being required for the trigger not device

So set it as state and while you can avoid “from” the field for “to” needs to read “person” and if you wanted to do one for vehicle then it needs to read to “vehicle”

Good luck ! LMK if it works (it should !)

1 Like

The switch is to turn on or off person detection. Use the detected object sensor when it changes to person from none

2 Likes

Tried a few permutations - including nothing in the from field and ‘person’ for to field, no dice.

You don’t want to use the switch.g4_doorbell_detections_person entity. You want to use entity that is referenced by the doorbell detected object Changing states from none to person works for me.

Tried this, but no joy.

platform: state
entity_id:
  - sensor.g4_doorbell_detected_object
from: None
to: Person

Triggers fine when I hit ‘Run Action’

Wait… attributes are case sensitive?

I think it just worked :partying_face:. Will recheck.

Finally working as expected, albeit slightly laggy.

Any ideas how to speed up the scene recall?

Regardless, thank you all who took the time to assist. Much appreciated.

Is it the scene or the trigger being slow?

My experience is that all the Unifi motion sensors tried to date are slow (aka >1 sec detection). Therefore if your trigger is slow, the entire automation will be behind realtime.

This just runs the actions and not the trigger or conditions

One more potentially silly question, but where can I find a list of all the available states for each entity? I would never have known about the ‘person’ to ‘none’ and figured it might be ‘on’ to ‘off’

Look at the sensors section here:

Thanks @Holdestmade. It was there staring me in the face all along…

RichieDon, I am having the same issue - automation runs when triggered in HA but does not fire when I try it. I’ve tried the sensor…detected object and tried Off - On, “none” to “person”, “None” to “Person” and nothing.

Please advise on your final config.