I have a device that I control with a relay and an esp8266 and I want to be able to control it with both home assistant and a physical switch.
Currently, I am using Adafruit IO and it works fine but I want to move it to my home assistant using esphome.
I set up the switch on esphome as a binary sensor and it works fine until I turn on/off the dive via Hassio, then I have to turn the switch twice for it to work.
I think this is a very dumb problem but I am pretty new to Hassio and esphome and I don’t know how to fix this, can someone help me?
Without seeing your actual configuration, it’s a bit of guesswork on what to do. However, given the description of your use case I would implement this as:
A switch component for the relay, which turns the relay output on and off, and which is exposed to Home Assistant.
A binary_sensor, connected to the physical switch, which togges the switch component in an on_press automation.
I used the gpio platform for switch, making the setup a bit simpler by removing the separate output.
I removed the name from the binary_sensor, and added an id in place of it. This will prevent the binary_sensor state from being published to Home Assistant (I presume there’s no need for that).
I added the on_press automation trigger to the binary_sensor, to toggle the relay when the physical button is pressed.
If the behavior of the button is erroneous, you might have to add some filtering to the binary_sensor to do debouncing → filter documentation