Hi dear community,
for years I have a working solution controlling my lights in the hallway though from time to time I have issues because I had to setup it as a switch and not as a light component.
Several tries to solve this as a light component failed.
The lights in the hall way are triggered with a latching switch and my ESPhome device just acts as an other trigger switch for this latching switch. It also includes a sensor circuit connected to the line the latching switch controls so it knows if the light is on even it didn’t trigger itself.
Here is an excerpt of my config:
binary_sensor:
- platform: gpio
id: sensor1
pin:
number: 4
inverted: true
device_class: power
filters:
- delayed_on: 50ms
- delayed_off: 50ms
output:
- platform: gpio
id: relay1
pin: 12
- platform: template
id: trigger_relay1
type: binary
write_action:
- output.turn_on: relay1
- delay: 250ms
- output.turn_off: relay1
switch:
- platform: template
id: switch_relay1
name: ${friendly_name}1
lambda: |-
return id(sensor1).state;
turn_on_action:
if:
condition:
binary_sensor.is_off: sensor1
then:
output.turn_on: trigger_relay1
turn_off_action:
if:
condition:
binary_sensor.is_on: sensor1
then:
output.turn_off: trigger_relay1
The problem for me to change this to the light component is that there is not template light like there is for a switch. I need that because the state of the output does not reflect the state of the light because the output just triggers the external latching switch.
With a template switch I can do this using a lambda expression.
So going over and over this I have no idea how to do this with a light in the end.
But I’d really love to have this as a real light because for example using a light card, which looks and acts a little different than a switch card and using a switch cards mixed with all the other lights.
Any ideas?
~Alexander