another newbie question here, that exceeds my googleing-skill:
I do have an installation where a push button (“taster”) toggles lights. This I wanted to smartify and I added an ESP with a relay switch that I temporarily switch on using a chain of binary_sensor/gpio (physical switch), light/binary (for the state), output/template (for resetting the GPIO/relais) and output/gpio (for actually triggering the physical light)
Does this approach fit into the esphome best practices or am I over-engineering things? Especially for (re-)storing the state.
More importantly: on every reboot/reflash of the ESP, the output is being triggered, toggling the light. I do not see anything related in the logs though.
That is not really a very clear statement of what you want to do.
It sound’s like you have an existing something that has a push button or is this something completely new.
Your code/config looks more complicated than it probably needs to be.
Why don’t you start by describing your existing hardware and exactly what behavior you want it to have. A light controlled by a single push button is hard to automate, since it is easy to get out of sync. A human can usually figure out they need to press the button again to turn it on (or off). Automation usually doesn’t really know.
thanks for the answer. I agree that “knowing” the state of a bush button controlled light is difficult for automation. And I understand that it can get out of sync. My hope is to have a way to “reset” the state by “restarting” the ESP or by force-set the state. But this can come at a later date and is not relevant for now.
Additionally, the setup described below is a minimal setup with all relevant devices. There are more in the setup that are either duplicates or are already handled.
Oh, and I just realized that I assumed the wrong translation. In german we call a “relay switch” a “relais”. And I assumed that this was the English word as well…
To the current setup:
I have a campervan with a light circuit that is triggered by one push button. The push button is going into a black box (electronic block) that probably contains at least one relay keeping the state. I only have access to the cuircut from the push button to the black box.
The ESP should be the single source of truth and hold the current state. Coming out of sync with the physical world is acceptable.
I want to keep the current push button, but triggering the ESP. The ESP then should temporarily trigger a relay switch that will trigger the “black box”.
There are several ways of doing what you are looking for. I personally would probably use gpio binary sensor >> template switch >> gpio switch.
In any case you need to apply restore_mode on your setup.
You could post what exact relay / relay module you are using and how it’s wired.
This did the trick sufficiently enough . I now have restore_mode: ALWAYS_ON on my light component. It will still “toggle” the relay, but now the light will be set to on.
As a reboot normally will happen during day time when the light is “normally off”, this is good enough for me.