When I open the door the light comes on: perfect
When I close the door, unfortunately it stays on when it should go out…
AND when I open the door again the light comes off!
I would like to believe you but for a few seconds, not after a delay of more than 3 minutes
Does anyone know how to force an initial return at the end of the code?
Sure, just fix the automations. The “problem” is that the “on” automation runs for four minutes, and you can’t re-trigger an automation that’s already running.
# Turn light on when the door opens
- alias: 'light on'
initial_state: 'on'
trigger:
- platform: state
entity_id: binary_sensor.door_window_sensor_158d0002431944
from: 'off'
to: 'on'
action:
- service: light.turn_on
entity_id: light.yeelight_strip1_7811dcfdc835
# Turn the light off if the door is left open for four minutes
- alias: 'light on after four'
initial_state: 'on'
trigger:
- platform: state
entity_id: binary_sensor.door_window_sensor_158d0002431944
to: 'on'
for: '00:04:00'
action:
- service: light.turn_off
entity_id: light.yeelight_strip1_7811dcfdc835
# Turn the light off when the door closes
- alias: 'light off'
trigger:
- platform: state
entity_id: binary_sensor.door_window_sensor_158d0002431944
to: 'closed'
condition:
- condition: state
entity_id: light.yeelight_strip1_7811dcfdc835
state: 'on'
action:
- service: light.turn_off
entity_id: light.yeelight_strip1_7811dcfdc835
I’ve also fixed the random indenting problem you had there
@Tinkerer thank you for your time! but with your code, the light turn on when I open the door but after impossible to turn off the light, even door though open and close the door several times, the light stay on
Thank you all for your contributions ^^ @echopage yes I do but it does not correct my problem @jungervin thank you, interesting, I test it when I get home !