I’m playing with a wireless button, configured with Zigbee gateway.
HA sees it as a sensor with 3 different states possible: click, double_click, and press.
I would like to basically do something when the button is clicked. However, it seems that I don’t see anything happening when the sensor remains with the same value.
For instance, if I perform consecutive clicks after a double_click, I’ll only be able to see the first one happening. Then nothing would be trigger as the state doesn’t change.
My idea was then to “consume” the state:
1 sec after the click, I want to set the state of the sensor to “none”, so any click happening after this manual set should be seen, as the state changes.
I tried to use service: homeassistant.update_entity but I can’t make it work.
Though, I think it’s possible because I can manually achieve that in Development tools / states, but I don’t really know how it works under the hood.
Which Zigbee integration are you using, ZHA or Zigbee2MQTT?
What is the wireless button’s manufacturer and model?
By design, a sensor entity’s state value is read-only. Only its underlying integration is meant to change the entity’s value.
That’s useful for testing purposes only (such as to test an automation’s State Trigger by forcing the entity’s value to a desired state as opposed to waiting for it to occur naturally).
It does it in a way that is temporary (the new value can’t survive a restart) and without being vetted by the entity’s integration (you can set values that make no sense for the entity’s purpose).
I am not familiar with that method of integrating a Zigbee-based device with Home Assistant. It is responsible for how the device is created within Home Assistant and how the device’s states are represented.
According to the documentation, Zigbee2MQTT reports two button actions: single and double.
Based on my experience with Zigbee2MQTT, the button would appear as a sensor in Home Assistant. The sensor’s value would normally be an empty string. If you were to quickly press the button twice, the sensor’s value would briefly become double and then promptly revert to an empty string. This quick state-change from nothing to double to nothing allows you to use a State Trigger to detect one or more double events.
It seems your TuYa/Zigbee system doesn’t behave the same way and the sensor simply reports the last button event (so you can’t detect the a second identical button event).