Hello.
In the room I want to place the esp, there is a normal switch where the esp will be installed, and I want to be also capable of controlling the light with the switch that is already there, but the thing is I don’t know how to program it, since as a normal wall switch, it just stays “on” or “off”, no pulsations whatsoever like the examples of binary sensor. Any idea of how to do this? thanks
You have not told us anywhere near enough.
Are both the light and switch connected to the ESP?
Do you want the light to be on when the switch is on?
Assuming the light is connected, and you do want switch on → light on, then automate the light like this:
output:
- platform: gpio
pin: GPIOXX
id: light_output
light:
- platform: binary
name: "Light"
id: light_1
output: light_output
binary_sensor:
- platform: gpio
pin: GPIOYY
name: "Light Switch"
filters:
- delayed_on_off: # debounce the switch
time_on: 50ms
time_off: 50ms
on_press:
then:
- light.turn_on: light_1
on_release:
then:
- light.turn_off: light_1
sorry.
The wiring would be a relay connected to the esp which also would drive the main bulb, and the switch that is originally on the socket will now be connected as an input to the esp (For example, a “turn on” on the switch would send 3.3v to a GPIO of the esp) and what I want from the switch is a toggle. For example; I turn on the light from the switch on the wall, but then I turn off the light from the dashboard without touching the switch, and if I press the switch again, the light would turn on. It would be kind of “if the switch changes voltage/state–>toggle the relay”
Then like this:
binary_sensor:
- platform: gpio
pin: GPIOYY
name: "Light Switch"
filters:
- delayed_on_off: # debounce the switch
time_on: 50ms
time_off: 50ms
on_press:
then:
- light.toggle: light_1
on_release:
then:
- light.toggle: light_1