pnbruckner / ha-sun2

Home Assistant Sun2 Sensor
The Unlicense
236 stars 22 forks source link

Phase not changing during Night #99

Closed emandtf closed 1 year ago

emandtf commented 1 year ago

I tried to get a Nautical or Astronomical Twilight but the "Phase" remains only at "Night" during the whole night. Here are 00:18am, elevation is -64° but still "Night". If it helps: its next change is scheduled at 05:30.

pnbruckner commented 1 year ago

See the description of how the sun phase sensor works, and in particular, what states it can be and when (based on the sun's elevation):

https://github.com/pnbruckner/ha-sun2#sun-phase-sensor

Is it possible the sun doesn't rise above -18 degrees where you are at this time of year? Or did you just not wait until it rose above -18 degrees?

emandtf commented 1 year ago

Is it possible the sun doesn't rise above -18 degrees where you are at this time of year? Or did you just not wait until it rose above -18 degrees?

I wrote that the current elevation at that time was -64 degrees, so -18 was passed. However maybe it changes only when current time cross specific interval and not when HA is started withing two states. In fact tonight I notice to successfully receive Astronomical Twilight, but first day (when I installed Sun2) it didnt' worked.

pnbruckner commented 1 year ago

The state of the sun phase sensor depends on the current elevation of the sun. As the sun rises and falls, the sun phase sensor will update as the sun's elevation passes through certain levels. E.g., when HA starts if the sun's elevation is below -18 degrees, the state will be Night. Then when the sun rises and its elevation changes to a value above -18 degrees, the state of the sensor will change to Astronomical Night. Then as the sun rises above -12 degrees, the state of the sun phase sensor will change to Nautical Night, etc. So, it's not dependent on any time periods. It is just dependent on the current elevation of the sun and when it crosses the boundaries between the different periods of twilight.