Sun positions and offsets in triggers

I’m still having issues about time platforms regarding sun.
there is sun and sensor.sun_xxx for sun related events.

My goal is to trigger an event one hour before solar noon.

The problem is how to implement and offset for noon because you can either time platform:


  - platform: time
    at: sensor.sun_next_noon

Its there a way to add a delay in the at: line? f.e. sensor.sun_next_noon - 1200
Because it seems you have to convert sensor.sun:_next_noon to seconds, then use the offset and then back to string HH%MM%SS.

Platform: time, does not allow an offset, only a delay, but delay cannot be negative.

The alternative is to use sun platform:

  - platform: sun
    event: sunset
    offset: "-04:00"

but events are only: sunrise, and sunset.

sun only has two events?

You look at the documentation of “sun”

and talks about dusk and dawn, but not noon.

There is this petition about integrating more states to sun, but its almost 4 years old:

  - platform: template
    value_template: "{{ now() >= states('sensor.sun_next_noon')|as_datetime - timedelta(hours=1) }}"

You could use a template sensor:

  - platform: template
    value_template: "{{ now() > states('sensor.sun_next_noon')|as_datetime - timedelta( hours = 1 ) }}"

TYVM, I’ll give it a try as a workaround may work.
It seems to work properly.
Still, It may not work with possitive offsets, its never: now > next noon + some time.

I’ve been looking for suggestions or features request regarding sun improvements.

I’ve been planning to set up most consumptions based on available-sun-power and sun position (as prediction) to modulate along the year. To do it you have to modulate the loads from noon to both sides of the curve attending on available sun hours. Right now this seems to be a rather difficult task in part because how sun is integrated.

You may want to take a look at the Sun2 custom integration, its available sensors are a little more helpful than the core Sun integration for things like this.

1 Like

Thank you.
I was trying to implement daylight with the current tools of sun and I found it a mess!

Sun2 incorporates such feature and more. Ty again.