In my household, not everyone has simulate in using voice cmd and or the app to turn on/off lights. I have a hallway lights that I want to turn off in x minutes when turn on. The following code does just that ONLY if the lights have been turn on via voice cmd (alexa) or from the phone app. It does not turn off if the light was turn on from the wall switch (non-smart switch). I have added a condition that say if light.h_1
is in the on
state. Unfortunately, that does not work. Maybe this isn’t the correct way. Is there another code I can try?
- alias: 'turn hallway lights off'
trigger:
platform: state
entity_id: light.hallway
to: 'on'
for:
hours: 0
minutes: 8
condition:
- condition: time
after: '06:31:00'
before: '06:14:00'
- condition: or
conditions:
- condition: state
entity_id:
- input_boolean.duc_home
- input_boolean.eri_home
state: 'on'
- condition: state
entity_id: light.h_1
state: 'on'
action:
service: light.turn_off
entity_id: light.hallway