I would like some help with my automation for turning on a group of lights. I copied the sample automation form the docs section at the Home Assistant website and changed it as necessary for my setup. The problem I am having is that the automation just isn’t working . Specifically I was waiting for the lights to come on an hour before sunset but that time came and went and nothing happened. I have verified that group.all_devices (One of the Triggers) is working and is showing “home” and if I manually trigger the automation the lights I defined come on. Here is the automation.
alias: ‘Lights On In Evening When We Get Home’
trigger:
platform: sun
event: sunset
offset: ‘-01:00:00’
platform: state
entity_id: group.all_devices
to: ‘home’
condition:
condition: state
entity_id: group.all_devices
state: ‘home’
I would suggest making the trigger only be about the device going to a state of ‘home’ and put the sunset offset into the conditions. for example I have this automation to turn on my lounge room LIFX bulb when either my wife or my phone comes home (specifically keeping those two devices in a separate group).
alias: Turn on lounge light when we come home
trigger:
platform: state
entity_id: group.parentsp
from: 'not_home'
to: 'home'
condition:
condition: and
conditions:
- condition: sun
after: sunset
after_offset: "-00:30:00"
- condition: time
before: "21:00:00"
- condition: state
entity_id: input_boolean.lighting_by_presence
state: 'on'
action:
service: scene.turn_on
entity_id: scene.welcome_home
You can then also write another automation if you’re already home that simply turns on the light(s) at a certain time.
#Turn on lounge light before sunset
- alias: Turn on lounge light before sunset
trigger:
platform: sun
event: sunset
offset: "-00:25:00"
condition:
condition: and
conditions:
- condition: state
entity_id: group.parentsp
state: home
- condition: state
entity_id: input_boolean.lighting_by_presence
state: 'on'
action:
service: scene.turn_on
entity_id: scene.welcome_home