I’m trying to build a push button to switch on my lights of my bathroom. The light has an relais with esphome. A switch for thuis light is also available on the dashboard of HA.
The configuration of the esphome on the relais module is:
If I look at the log of the button module I see that it sends a : ~ state: ON ~ when I push the button. The moment I release the button it sends ~ state: OFF ~ .
You have a momentary switch. GPIO0 is high (on) when you press it. GPIO is low when you release it (off).
Change your on-press automation to:
service: switch.turn_on
How are you going to switch it off? delay or another press? I think you then have to write something that will see whether the switch is “on” or “off”. So it would be a state call to HA to check.
I actually have the same question? I have a pump switch I want to be able to call and test in the routine. So another call to homeassistant.service but from within a condition.
I would be interested if somebody had an answer to this simple but actually quite complex question!!!
I understood that the toggle command meant that the state would change. So when it is on it changes to off and vicaversa. So the first time I push the button it will go on en the second time it will go off. Am I wrong?