Hey Will,
Did you fix the turn on lights at dusk? I would really like to be able to automate that.
Thanks!
Hey Will,
Did you fix the turn on lights at dusk? I would really like to be able to automate that.
Thanks!
I’ve fixed it.
Here’s how I did it
alias: Front Stairs on dusk
description: ''
trigger:
- platform: state
entity_id: sun.sun
attribute: next_dusk
condition: []
action:
- type: turn_on
device_id: 9b90ebd0a6d1fe1021f792e438d913c3
entity_id: light.front_stairs
domain: light
mode: single
Alright,
Actually I tried that today. The lights went on just about 2 hours later than dusk. Do you have any ideas?
Have you set your house coordinates correctly in home assistant / configuration / general?
Also check the Timezone just below that setting on the same page … and possibly elevation might play a part in the calculation too
Yes,
Checked everything there. All set correctly…
This is what it said today:
next_dusk: ‘2021-09-10T18:19:56.880598+00:00’
Light automation triggered 8:22:54 PM
What do you see when you go here in dev tools?
Ok, Those times are in utc, to convert the time stamp, instead try pasting this in dev tools / template
Next Dusk will be at
{{ as_timestamp(state_attr("sun.sun","next_dusk")) | timestamp_custom('%I:%M:%S %p') }}
I’ve updated the code.
Try
Next setting will be at
{{ as_timestamp(state_attr("sun.sun","next_setting")) | timestamp_custom('%I:%M:%S %p') }}
Next Dusk will be at
{{ as_timestamp(state_attr("sun.sun","next_dusk")) | timestamp_custom('%I:%M:%S %p') }}
trigger:
- platform: state
entity_id: sun.sun
attribute: next_dusk
The trigger you have will trigger when the ‘next_dusk’ attribute changes, not at the time the attribute refers to. You need to look at a time trigger or a template trigger.
I disagree. This trigger works perfectly for me everyday.
I guess it would change when the current ‘next_dusk’ time passes. Fair enough
Thats what I figured.
Then I should wait and see what happens tomorrow?
Well, is the time of 8:19pm what you expected for dusk or not? I don’t live where you live so I don’t know what is normal where you live.
Did you try the updated template that shows setting and dusk times?
I have double checked now.
Dusk where I live is at 20:19.
However. This is what the su.sun attributes says: next_dusk: ‘2021-09-10T18:19:56.880598+00:00’
That’s fine. That time is in utc which ha is fine with
The time in the attribute is also in GMT/UTC. What is your offset?
This is why I asked you to check your Timezone as this affects the utc conversion