i’ve been racking my brain (or whats left of it) trying to work out where i have gone wrong here… it’s probably something really simple like formatting but I cant see it.
anyway… i have this automation that turns the lights off at 9.30pm if the sun has already set. that works perfectly… but now i’m trying to add a condition of only if the tv is turned off… to often have i been watching a program on tv and the lights go out on me so i want to change that. problem is that when i tried to do it i got hit with all kinds of errors… so… please help…
- id: '1542575515582'
alias: turn off lounge lamps at 21:30
hide_entity: true
trigger:
- at: '21:30'
platform: time
condition:
- condition: sun
after: sunset
- condition: state
entity_id: media_player.sony_bravia_tv
state: off
action:
- service: switch.turn_off
entity_id:
- switch.corner_lamp
- switch.tall_lamp
- switch.fan_lamp
Just a thought. Would you want to turn the lights off when 1) it’s 21:30, 2) the sun sets, or 3) when the tv has been off for some amount of time (say 10 minutes), whichever comes last? If so, how about this:
- id: '1542575515582'
alias: turn off lounge lamps
hide_entity: true
trigger:
- at: '21:30'
platform: time
- platform: sun
event: sunset
- platform: state
entity_id: media_player.sony_bravia_tv
to: 'off'
for:
minutes: 10
condition:
- condition: time
after: '21:30'
- condition: sun
after: sunset
- condition: state
entity_id: media_player.sony_bravia_tv
state: 'off'
for:
minutes: 10
action:
- service: switch.turn_off
entity_id:
- switch.corner_lamp
- switch.tall_lamp
- switch.fan_lamp
Of course I have to wonder, where are you where sunset might happen after 21:30?