So, I have an over arching automation to control power to our AV systems at home when we are there and not there. Conditions with presence detection work in all cases except one that is intended to wait for 45 (short delay in place for testing) minutes before taking action. If the “for” keyword is used the action never fires, if the keyword is removed it fires as it should.
According to the docs, this should work.Conditions
Here is the automation, sorry but it is long and has some comments where I have tested things and failed. The set that fails is condition 1.
- id: tv power control
alias: TV power control
initial_state: true
trigger:
- platform: state
entity_id:
- group.family
- platform: time
at:
- "00:30:00"
- "06:30:00"
mode: restart
action:
- choose:
### Turn TV's on @ 6:30am and before 12:15am if someone home
- conditions:
- condition: state
entity_id: group.family
state: "home"
- condition: state
entity_id: 'switch.bnc60_2_switch'
state: 'off'
- condition: time
after: '06:30:00'
before: '00:15:00'
sequence:
- service: switch.turn_on
entity_id: switch.bnc60_2_switch
- service: switch.turn_on
entity_id: switch.tg_02
- delay: '00:02:00'
- service: media_player.turn_off
entity_id: media_player.yamaha_receiver
### Turn TV's off if nobody home for 45 minutes
- conditions:
- condition: state
entity_id: 'media_player.sony_bravia_tv'
state: 'off'
- condition: state
entity_id: group.family
state: "not_home"
for:
hours: 0
minutes: 01
seconds: 00
sequence:
- service: switch.turn_off
entity_id: switch.bnc60_2_switch
- service: switch.turn_off
entity_id: switch.tg_02
### Turn TV's off after 12:30am for the night
- conditions:
- condition: state
entity_id: 'media_player.sony_bravia_tv'
state: 'off'
- condition: state
entity_id: group.family
state: "home"
- condition: numeric_state
entity_id: " sensor.tg_02_energy_current"
below: .1
- condition: time
weekday:
- mon
- tue
- wed
- thu
- fri
- sat
- sun
- condition: time
after: "00:30:00"
before: "06:30:00"
sequence:
- service: switch.turn_off
entity_id: switch.bnc60_2_switch
- service: switch.turn_off
entity_id: switch.tg_02
If I leave the delay in and change the state of group.family to “not_home”, this is my trace of the automation:
If I comment out the delay and change the state of group.family to “not_home”, this is the trace: