Hello everyone,
I’ve been trying for three days to get a latching relay system working, controlled by an ESP-based relay with feedback from the lamp’s status. I’m using one of the latching relay’s poles connected as a dry contact to a GPIO configured with a pull-up to get the lamp’s state.
Everything works perfectly. However, in Home Assistant, I see the lamp state on one side (via a binary_sensor) and the switch on the other (via a switch).
What I’d like is to have everything on a single line, like with any other light: the toggle button and the lamp state combined. I tried using the light component, but it doesn’t work because the output parameter requires an output component, not a switch component.
The issue with the output component is that it can’t be activated for just 500ms (to trigger the latching relay) and then deactivated. I tried to manipulate the states to force this behavior, but it didn’t work.
Do you know how I can create a light component that, when I press the toggle button, activates the relay for 500ms and that’s it?
Right now with my current configuration the status is in sync with the lamp when I turn it on on the UI. then when I toggle it to off the status goes to off but the lamp on the wall stay on. When I retoggle it to on the lamp on the wall goes off status (on UI) briefly goes to on then goes off.
my current configuration (part of it) :
light:
- platform: binary
output: Relay
id: Light
name: "Light"
on_turn_off:
- logger.log: "turn off starts"
- output.turn_on:
id: Relay
- delay: 500ms
- output.turn_off:
id: Relay
- logger.log: "turn off ends"
on_turn_on:
- logger.log: "turn on starts"
- output.turn_on:
id: Relay
- delay: 500ms
- output.turn_off:
id: Relay
- logger.log: "turn on ends"
binary_sensor:
- platform: gpio
pin:
number: GPIO18
mode: INPUT_PULLUP
inverted: True
name: "Light Status"
device_class: light
trigger_on_initial_state : true
on_press:
- logger.log: "Light On - Force the status of light to be in sync"
- if:
condition:
light.is_on: Light
then:
- logger.log: "Light status set to off"
- light.turn_on: Light
on_release:
- logger.log: "Light Off - Force the status of light to be in sync"
- if:
condition:
light.is_on: Light
then:
- logger.log: "Light status set to off"
- light.turn_off: Light
# Individual outputs
output:
- platform: gpio
id: Relay
pin:
xl9535: xl9535_hub
number: 10
mode:
output: true
inverted: false
May be it’s not at all the way how to make this happens.
Any help would be greatly appreciated. Thanks!