I’m having some difficulty creating automation that will turn the lights out from 45 mins before sunset but only when I’m home (also when we get back after sunset).
The config I currently have is:
alias: ‘Lampen aan bij donker.’
trigger:
platform: sun
event: sunset
offset: “-00:45:00”
platform: state
entity_id: group.tracking
from: ‘not_home’
to: ‘home’
condition:
condition: state
entity_id: group.tracking
state: home
action:
service: scene.turn_on
entity_id: scene.lampen_aan
This will turn on the lights 45 mins before sunset, but also always when I get home (my own devices are in the group tracking). My problem is that I only want the light to turn on when it’s 45 mins before sunset or later if I arrive home.
Is there any way to make this happen? Thank you for your time.
condition:
condition: and
conditions:
- condition: state
entity_id: group.tracking
to: 'home'
from: 'not_home'
- condition: sun
after: sunset
after_offset: "-00:45:00"
I’m doing this freehand, so I might not have it exactly correct - I don’t have any conditions where I use a sun condition. I grabbed the “after_offset” stuff from here.
Then you’re basically saying: trigger whenever I get home or when it’s 45 min to sunset, but stop unless someone’s home or it’s around sunset.
I’ve put in the config (see below), but unfortunately it is not working.
On start I’m getting the following error in the log (and HASS does not start): 16-10-26 16:24:44 homeassistant.util.yaml: mapping values are not allowed here
in “/home/hass/.homeassistant/automation.yaml”, line 13, column 18
alias: ‘Lampen aan bij donker.’
trigger:
platform: sun
event: sunset
offset: “-00:45:00”
platform: state
entity_id: group.tracking
from: ‘not_home’
to: ‘home’
condition: and
condition: state
entity_id: group.tracking
state: home
- alias: 'Lampen aan bij donker.'
trigger:
- platform: sun
event: sunset
offset: "-00:45:00"
- platform: state
entity_id: group.tracking
from: 'not_home'
to: 'home'
condition:
conditions: and
- condition: state
entity_id: group.tracking
state: home
- condition: sun
after: sunset
after_offset: "-00:45:00"
action:
service: scene.turn_on
entity_id: scene.lampen_aan
And I’ve also tried without conditions (changing the indent).