Changing the value of a entity in a automation

I have a ONVIF device that will report when a person enters a defined zone on my Hikvision IP camera.

The Hikvision Camera nicely reports when the person enters the zone by setting the ‘binary_sensor.voorkant_field_detection_2’ to ‘detected’.

But it stays in that state, even if the person has left. It stays in the detected state for days. The only way to resolve this is to reset Home Assistant. I’ve checked this with the ONVIF tool, the ‘enter zone’ is reported. But it never reports when someone is leaving the zone.

So to resolve this, I think a simple automation would be nice till a more permanent solution is availble.

So the question is;

How can I set the state of the ‘binary_sensor.voorkant_field_detection_2’ to clear in a automation?

So far I have this;

alias: Clear field detection
description: ""
  - platform: state
      - binary_sensor.voorkant_field_detection_2
    to: "on"
      hours: 0
      minutes: 1
      seconds: 0
condition: []

I would report this as a bug in Home Assistant’s Core repository on GitHub.

I’m not sure if it’s a HA bug, the Hikvision doesn’t send the detection cleared pacakge…

If an event is created, ignore the binary sensor all together and create your own template binary sensor. You can make the state of that do whatever you want with the options that template binary sensors have.

provide auto_off with a time and it will automatically go off after that period.

Maybe I have misunderstood the application; please help me understand how a Template Binary Sensor mitigates the Hikvision binary sensor (that is ‘stuck’ at on).

I can see how the Template Binary Sensor can be used to report off, after the first time the Hikvision binary_sensor changes from off to on. However, how will it report on again given that the Hikvision binary_sensor remains stuck at on and produces no additional state-changes (to update the Template Binary Sensor)?

1 Like

I don’t think a event is created;

Only once, the first time, after that, it’s not creating events…

If an event in HA is created, you can use the event to trigger instead of the binary sensor. He mentioned an onvif event

THat’s the binary sensor, no? An event would be something entirely different that would potentially show up in the devices logbook

Thanks, understood; a Trigger-based Template Binary Sensor should listen for events produced by the Hikvision integration indicating when the binary sensor’s state is being set to on.

I need more help on that, what would trigger the Template Sensor to fire a event?,

I have no idea, you mentioned an event. If that event doesn’t exist then the method I mentioned won’t work.

Starting to think 123 Taras might be right, it’s one thing that the status doesn’t change back. But it’s an other thing that the event is not re-fired. Even it’s from ‘detected’ to ‘detected’.

With re-detection, the Hikvision camera does send another package via ONVIF. It’s HA that doesn’t do anything with it, also not process a event.

Look in your event tab for onvif events, it looks like the integration registers events. One of them may be a motion event.

Open your Home Assistant instance and show your event developer tools.

1 Like

Thanks Petro, I’ll see if I can find something there.

Meanwhile, I reported; ONVIF redection event doesn't fire · Issue #90173 · home-assistant/core · GitHub