How to keep track of STATE of dual momentary relays on one device [Gas Logs controller]

Very good to know. I did a full reboot from the ssh command line (#sudo reboot) . I should have said I rebooted the RPi instead of HA. Inaccurate choice of words lol. If this happens again, I will try your suggestions first. Thanks!

1 Like

I created a new thread about this in Configuration.

I need help with almost the same, but I only have one relay switch. This turns on the device(coffee machine) when the relay(connected in parallel to the physical button) turns on via ESPHome. The same process is used to turn it off, either the device’s button is pressed or the relay (controlled by ESP32 via HA) is triggered again.

So I need to know if the device is on. That means a “value” or boolean_,switch that keeps track of the device state. That is: this device turns on via the relay and the “value” gets assigned a “true”, even though the relay was turned on and off, within on second. This “value” should stay true, until the same relay turns on and off again, then only should the “value” change to “false” - stating the status of the devices’ power.

I do not know how to keep track of the physical device state yet. The device have a power LED that is on while the power is turned on. If I can somehow know that, I can base the “value” on the state of the LED instead.

But I first need to know the state of “value” between the two triggers of the relay.

How can I accomplish that?
This is my code:

> switch:    # power-switch - B1: GPIO16
>   - platform: gpio
>     id: power
>     pin:
>       number: 16
>     name: power
>     icon: ""
>     restore_mode: ALWAYS_OFF
>     on_turn_on:
>       - delay: 500ms
> #value needs to be set to "true" which can be used to display the device state as "powered" or "on" until the relay is triggered again
>       - switch.turn_off: power

The problem I have with this code is the “value” is only “true” for 500ms, while the relay receives a signal.