- alias: 'Light on if Tv is on at Sunset'
trigger:
- platform: sun
event: sunset
offset: '-01:00:00'
condition:
condition: and
conditions:
- condition: state
entity_id: sun.sun
state: 'below_horizon'
- condition: state
entity_id: media_player.living_room_un65ks9500
state: 'on'
- condition: time
after: '17:00:00'
before: '20:00:00'
action:
service: light.turn_on
entity_id: group.all_lights
I am not sure what I am doing wrong but nothing happens
I got also some problems with this kind of automation, lights should turn on when turning on TV after sunset AND if the TV is already on at sunset, but it’s not working for me, what am I doing wrong? Or do I’ve to set up two different automations for this?
alias: 'Wohnzimmer: LED an wenn TV an'
trigger:
- event: sunset
platform: sun
condition:
- condition: state
entity_id: media_player.vu_zero4k
state: 'on'
- after: sunset
condition: sun
action:
- data:
entity_id:
- light.yeelight_strip1_7811dce2c50d
- light.yeelight_strip1_7811dcfb701f
- light.lowboard
service: light.turn_on
Here is one of mine. I would recommend that you use the sun elevation, rather than a time before sunset. The suns angle changes through the year, so I find it works better through the seasons.
@Matt112 This should work for you, depending on your location, adjust the sun angle higher or lower to get it close to 1 hr before Sunset.
add sun: to your configuration.yaml file.
- alias: 'Light on if Tv is on at Sunset'
trigger:
platform: numeric_state
entity_id: sun.sun
value_template: "{{ state.attributes.elevation }}"
below: 10.0
condition:
condition: state
entity_id: media_player.living_room_un65ks9500
state: 'on'
action:
service: homeassistant.turn_on
entity_id: group.all_lights