Thanks Although the normal sun.sun has next_setting, so as_timestamp(states.sun.sun.attributes.next_setting)
works as well. Thatâs how i ended up with the next_setting initially. I thought i can access the âNext setting in x hoursâ info thatâs on the (normal) sun popup, but couldnât get it to work. Your solution is more precise
I donât know what youâre trying to do with the information, but just be aware that the next_setting
attribute changes at sunset. So for most of the day it indicates when the sun will set today. But at sunset it changes to tomorrowâs sunset. In some use cases that may be fine, but in many itâs not, which is the whole reason I came up with my custom sun component. It provides a sunset
attribute which stays constant the whole day and indicates todayâs sunset, even if it has already occurred.
Man, thatâs what i like so much about home automation in general, you realize there is so much more under every stone you turn. For me, i was simply thinking about an automation to hide the offset at sunset since i deemed the information useless after the sun has set. Of course it makes sense for different applications than my narrow use case. Iâm using it simply to show on a card how much sunlight i have left to go on a run/ride.
Iâm trying to do something similar but much less complicated.
Iâm simply want to change the offset if itâs a sunny day or not.
Iâve already made a helper binary sensor that determines if itâs sunny or not.
Iâm just not sure how to change the offset using that binary.
This is my automation so far, it always erases my logic for the offset so I think I need to do this another way. Iâm not sure.
alias: Daily Lights
description: ""
trigger:
- platform: sun
event: sunset
offset: {{ '-1:00:00' if is_state('binary_sensor.is_sunny', 'off') else '+0:00:00' }}
id: sunset
- platform: sun
event: sunrise
offset: "-03:00:00"
id: sunrise
condition: []
action:
- choose:
- conditions:
- condition: trigger
id:
- sunrise
sequence:
- service: script.all_off
metadata: {}
data: {}
- conditions:
- condition: trigger
id:
- sunset
sequence:
- service: script.all_on
metadata: {}
data: {}
mode: single