I can’t get an event to fire a trigger with an event_object
Attribute change, but all the pieces seem to be working as expected. This automation is trying to use the SecuritySpy for Home Assistant integration, but it’s not clear if that is where the problem lies.
My setup
- Home Assistant 2022.3.3 in Home Assistant OS via a VirtualBox VM on a Mac. Screen shot of Config > Info.
- SecuritySpy 5.4.1 on the same Mac, connected to Home Assistant via the SecuritySpy for Home Assistant integration. Here’s my Trigger config in SecuritySpy for this camera.
Goal
SecuritySpy will detect if a human is present, and fire an event – I’d like to have Home Assistant do something when this happens. For example, someone walks up to the front door and it turns the porch light to 100%, sends me a notification, etc. For now (while testing) I just have it set up to send me a notification.
Automation YAML
alias: 'cam1 / Front Door: person detected – TEST'
description: ''
trigger:
- platform: state
entity_id: binary_sensor.cam1_front_door_motion
attribute: event_object
to: human
condition: []
action:
- service: camera.snapshot
data:
entity_id: camera.cam1_front_door
filename: /config/www/cam_captures/frontdoor.jpg
- service: notify.mobile_app_benish
data:
message: Person at Front Door
data:
image: /local/cam_captures/frontdoor.jpg
url: securityspy:///live?cameraNum=2
actions:
- action: URI
title: Large Image (latest capture)
uri: >-
https://myNabuCasaUniqueIDobfuscated.ui.nabu.casa/local/cam_captures/frontdoor.jpg
- action: URI
title: Live Video in Security Spy
uri: securityspy:///live?cameraNum=2
mode: single
The Automation is enabled. The Trigger is a direct copy of the example on the SecuritySpy for Home Assistant README (but with my entity_id
).
All the pieces seem to be working individually:
- If I click Run Actions from the Automation detail page, the Actions work as expected (I get a notification on my phone with the specified image and notification actions).
- There are no Conditions, so I guess we can say those work.
- SecuritySpy will send me a native notification when a human is detected with this camera, so the human detection is working as expected in SecuritySpy.
- If I get rid of
attribute: event_object
andto: human
in the above Automation – i.e. just use regular motion detection without checking for a human – it fires the trigger as expected. In fact it fires a ton of them in quick succession. So thebinary_sensor.cam1_front_door_motion
created by SecuritySpy for Home Assistant does work: regular motion is detected and the corresponding event will fire. - If I look at the
binary_sensor.cam1_front_door_motion
Entity in Developer Tools > States I can see theevent_object
Attribute change tohuman
as expected when I walk in front of the camera as seen in this video screen capture. Of note,event_object
rapidly changes betweenhuman
andNone
and theevent_length
never goes above0
when it’s athuman
. I suspect this might be the root of the issue? But I don’t have afor:
setup for the Trigger, so I’d expect it to trigger regardless of theevent_length
? Out of desperation I did try settingfor:
to0
seconds, but that had no effect so I removed it. - If I manually set the state to
on
withevent_object: human
via Developer Tools > States > Set State, it will trigger the Automation. Also of note, it takes about 4 seconds for the notification to show up when I manually set the State like this. In contrast, notifications directly from SecuritySpy and the motion-only test Automation in Home Assistant (withoutevent_object: human
) both trigger / notify much faster (less than a second).
I enabled Debug Logging for SecuritySpy for Home Assistant, but I don’t see anything useful there.
I’m new to Home Assistant and very new to YAML, so apologies for any mistakes regarding terminology. Any help is greatly appreciated.