How can I get a switch to perform just once?
Here is my section of code, it’s the line after ‘condition’ I’m struggling with. I’m wanting the condition to be true if the ESP’s led is on. I started with the line …
lambda: 'return id(light1).state =="off";'
but that didn’t work either.
on_press:
then:
- if:
condition:
# Should return either true or false
switch.is_off: light1
then:
- light.toggle: light1
- delay: 2s
- switch.turn_on: tvtoggle
- delay: 30s
- light.toggle: light1
- switch.turn_on: tvtoggle
light:
- platform: binary
name: “TV led”
output: led1
internal: True
id: light1
output:
- platform: gpio
id: led1
pin: D2