- id: '1574608465562'
alias: Living Floor Lamp Turn on at Sunset - Home Empty
description: Living Floor Lamp Turn on at Sunset - Home Empty
trigger:
- event: sunset
offset: +00:15:00
platform: sun
- entity_id: binary_sensor.people_home
from: 'off'
platform: state
to: 'on'
Triggers are OR. The automation will be triggered when either of those triggers happens. If you want the automation to do what your description and alias are saying, try this:
trigger:
- platform: sun
event: sunset
offset: +00:15:00
condition:
- condition: state
entity_id: binary_sensor.people_home
state: 'off'
(This is assuming off
means people are not home. Change accordingly if that’s not the case.)
thanks!
i was looking into it maybe I can merge some automations together
I often write my automations so that if either trigger occurs, it’ll check states for both entities, and then finally do the action. Because what if it was already after 15 minutes post-sunset and then somebody comes home. Eg:
- id: '1574608465562'
alias: Living Floor Lamp Turn on at Sunset - Home Empty
description: Living Floor Lamp Turn on at Sunset - Home Empty
trigger:
- event: sunset
offset: +00:15:00
platform: sun
- entity_id: binary_sensor.people_home
from: 'off'
platform: state
to: 'on'
condition:
- condition: sun
after: sunset
after_offset: '00:15:00'
- condition: state
entity_id: binary_sensor.people_home
state: 'on'
action:
- service: light.turn_on
data:
entity_id: light.living_floor_lamp
Yep, that’s a good way of doing it. Template triggers can also be used (in some cases) to accomplish the same thing.
can someone kindly take a look at the following and let me know if there is something wrong because this is not being triggered?
- id: '1574608465562'
alias: Living Floor Lamp Turn on
description: Living Floor Lamp Turn on
trigger:
- event: sunset
offset: +00:15:00
platform: sun
- entity_id: binary_sensor.people_home
from: 'on'
platform: state
to: 'off'
condition:
- after: sunset
after_offset: +00:15:00
before: sunrise
before_offset: -07:00:00
condition: sun
- condition: state
entity_id: binary_sensor.people_home
state: 'off'
action:
- device_id: 9e4e8d1dd6d942aeae2c6cc3bbec
domain: switch
entity_id: switch.living_floor_lamp
type: turn_on
It can’t be both after sunset and before sunrise. You need to make that sun condition an OR condition. See the second example here.
Although, why do you have such a large offset for sunrise? Almost looks like you’re trying to make the end time for that condition midnight (or close to it). If that’s the case you could just use after: sunset
.
The bottom of the section I linked above also provides a chart showing when the sun conditions will be true.
thanks … what I had in mind is; automation should work between sunset+offset and sunrise-offset.
removed the sunrise and it worked fine. thanks!