Binary_sensor state change

Hi all and Happy New Year.

I’m having some automation ideas that would be triggered based on different events. Integral part of my automation idea is creation of the binary sensors and manipulate their state. However when I’m trying to update state of my binary sensor it doesn’t work. Ideally what I want to achieve is to rely on different entity state to turn my binary sensor “On”. Then I want to kick off the automation that will do what’s needed and at the same time turn my binary sensor to “Off” state. However whatever I try, I cannot find a way to update my sensor state from the automation.
This is my sensor code:

    - name: "Sensor Test"
      state: "{{ On }}"
      device_class: motion
      auto_off: "00:00:05"

When I restart HA, nothing happens to this entity. When I change its state manually to “On” it doesn’t get back to “Off” at all.

I tried to run “Home Assistant Core Integration: Generic turn on” and “Home Assistant Core Integration: Generic turn off” service to update my binary sensor, but no luck. Nothing happens.

I bet my understanding of binary sensors is a bit wrong, hence explanation and help is highly appreciated.

All the best. Regards, J.

You don’t update sensor states. Use an input boolean instead.

Thank you Tom. Problem is, input boolean service states there is no matching entities.

Don’t use the service on a binary sensor use it on an input boolean helper.

Forget the binary sensor. Your are not supposed to change them.

Thank you Tom for enlightening me :slight_smile: . I have some ideas that I can use now :slight_smile: .

I use binary sensor to emulate door bell in home kit and ot only accept binary sensors not input booleans , any ide how to set it state apart of doing it in yml?

im kinda in the same boat

tuya human presence zigbee sensor gets stuck on ‘detected’ (using ZHA) so i figured i’d try and automation to clear it, eg: if state goes from clear to detected for 5 seconds, action = set binary sensor (occupancy) to off. easy enough to do via dev tools / states, but not in an automation.

I get its more of a workaround, but am at a loss to why the TZE204_mtoaryre sensor doesnt reset to clear after a certain time period. i know moving to Z2M is a workable option, but really want to stick with zha

That is not a permanent change. It is intended for testing only. A reload or restart will wipe out your change.

There is no service for this as you are not supposed to alter binary sensor entity states. The state changes come from the integration. If the integration is not working open an issue. If the physical device itself is not working check if there are settings for occupancy time you can change.

All good thanks Tom, I ended up experimenting with various versions of github quirks for the sensor and eventually found the right one that works as expected. Good to know re above though, thanks!