VPC
January 6, 2021, 10:30pm
1
So I have an automation that has a condition “after sunset”. This is working great.
Except…
When we stayed up to watch the new year (after midnight) the automation didn’t work as I guess it was then “before sunrise”.
How is everyone handling this? Is there an easy way to define the period of time between sunset and sunrise?
Thanks!
qoheleth
(Russell Smith)
January 7, 2021, 12:05am
2
The easiest way to do this is by using elevation as follows:
- alias: 'timing-Porch light on at dusk'
trigger:
platform: numeric_state
entity_id: sun.sun
attribute: elevation
below: -1.0
action:
service: switch.turn_on
entity_id: switch.front_porch_light
It’s reliable and it doesn’t mess up because of the change of day at midnight.
1 Like
Or use an input_boolean “helper”, toggled on at sunset and off at sunrise.
finity
January 8, 2021, 6:11pm
4
If you don’t like the elevation suggestion above (But it is the easiest) then you can just create another condition for “before: sunrise” and make the two conditions an “or”.
Or even easier than the elevation you could use the sun state as below_horizon and get the same effect.