OK, now I have a better handle on the issue.
To put it bluntly, this is due to a deficiency in Home Assistant. To be fair, it’s not only Home Assistant, openHAB shares the same blind spot.
I’ve been using another Home Automation system for many years and it does not have this deficiency, namely the lack of a basic pushbutton.
It’s not an on/off switch, nor a binary_sensor, nor some other attempt to fit a ‘square peg in a round hole’, in its simplest form it’s a ‘momentary boolean’. Enable it and it goes true
and then, a moment later, goes back to false
. It has a hundred and one real-world applications.
A more sophisticated model is not ‘momentary’ but supports states and duration such as press, release, hold, and doubletap. However, for your purposes, a basic ‘momentary boolean’ would easily resolve this issue.
In Premise, here’s how I specify that a boolean, called ‘Activated’, is momentary (you just tick a box). Done. I can later render it in the UI with a pushbutton widget.
It puzzles me why this ‘primitive’ is missing in both openHAB and Home Assistant. In both systems, a ‘momentary boolean’ is simulated by, quite frankly, very roundabout techniques. Anyone who takes issue with my use of the word ‘roundabout’ only needs to look at Steve’s solution (above). That’s pretty much the standard way of simulating a pushbutton in Home Assistant.
In addition, Feature Requests have been made over the years, typically for a pushbutton widget for Frontend UI, and nothing has resulted other than replies saying you can already do that (not really), followed by a lengthy example involving scripts and automations.
Unfortunately, none of what I said helps you. Plus, this all probably sounded like a rant, except that’s not my intention. I’d like to have a beer with the core developers and ask what kind of house they live in where none of their gadgetry has pushbuttons.
Perhaps I ought to submit a Feature Request to enhance Input Boolean. It could benefit from having a ‘momentary’ type
. When momentary, it’s default state is always false
. Calling input_boolean.turn_on
or input_boolean.toggle
(existing services) would make it momentarily change state to true
then return to false
. The service input_boolean.turn_off
would do nothing. The UI widget for it would be a simple pushbutton (like what we already see in the alarm panel’s keypad).