-
Notifications
You must be signed in to change notification settings - Fork 58
Trigger for Solar Noon #742
-
Hi there,
I was wondering if anyone has already figured out how to get a trigger, which, well, triggers at Solar Noon which is when the Sun passes the south, instead of the current Noon Trigger @time_trigger("once(noon)")
which triggers at exactly 12:00.
Beta Was this translation helpful? Give feedback.
All reactions
The problem is those are ISO format timestamps, which as you noticed pyscript can't parse, unless you extract just the time of day. @dbsdbs93 proposed a good solution. To trigger once when the azimuth crosses 180 you could do this (untested):
@state_trigger("float(sun.sun.old.azimuth) < 180 <= float(sun.sun.azimuth)")
azimuth
only updates every couple of minutes, so it won't be exact.
Replies: 1 comment 4 replies
-
The sun.sun entity has an azimuth attribute. Solar noon happens just around an azimuth of 180 every day. So you can do a trigger based on that.
Beta Was this translation helpful? Give feedback.
All reactions
-
I second this. You can rely on sun.sun attributes or at most you can try find an integration that provides the "solar noon" sensor.
Beta Was this translation helpful? Give feedback.
All reactions
-
There is also a sensor.sun_next_noon
available which is a timestamp: '2025-07-06T11:07:17+00:00'
. But I couldn't figure out, how to use that timestamp to trigger the function. Or at least my naive implementation wouldn't work.
I tried @time_trigger(sensor.sun_next_noon)
which resulted in Can't parse 2025年07月29日T11:09:02+00:00 in time_trigger check
And @time_trigger(f"once({sensor.sun_next_noon})")
results in can't parse time offset t11:09:02+00:00
Beta Was this translation helpful? Give feedback.
All reactions
-
The problem is those are ISO format timestamps, which as you noticed pyscript can't parse, unless you extract just the time of day. @dbsdbs93 proposed a good solution. To trigger once when the azimuth crosses 180 you could do this (untested):
@state_trigger("float(sun.sun.old.azimuth) < 180 <= float(sun.sun.azimuth)")
azimuth
only updates every couple of minutes, so it won't be exact.
Beta Was this translation helpful? Give feedback.
All reactions
-
I tried that for today, and it worked like a charm. Thank you!
Although, might it be a possibility to get like a once(solarnoon)
or similar trigger in the future?
In any case, thanks for your help!
Beta Was this translation helpful? Give feedback.