Hi,
I’d like to control a simple relay based on the output from GPIOs. I have a relay controlled by ESP8266, and its on GPIO0. Based on a state of GPIO1, 2 and 3 I’d like to turn on/off the relay. E.g. if GPIO1, GPIO2 are in a low state, I’d like to turn on a relay, if any of them are in a high state, I want to turn off the relay.
I defined all GPIOs as binary sensors as below, but I have no idea how can I make relay e.g. turned on while all of the binary sensors are in a low state. Could you please help me out here? I have that logic written in C++ and it works. Right now I’d like to make it in Esphome but unfortunately I don’t understand the idea how it can be done.
Thank you for the answer. Finally, I modified the code and right now it works as expected but… Is there any possibility write the logic for the relay in one place instead of in each binary sensor block?
For that I posted link to template sensor documentation.
You can leave binary sensors without any automation and do everything in one template sensor with C++ code in lambda. It’s equal to code in Arduino loop.