pnbruckner/ha-sun2

Sun_Phase Sensor not updating correctly

rlewis187 opened this issue · 19 comments

For a couple of days my sun phase sensor has been failing to update correctly in the morning.

It is just missing out some of the phases, I still get updates at noon and in the evening, but its staying at night until solar noon.
Error log:

This error originated from a custom integration.

Logger: custom_components.sun2.sensor
Source: custom_components/sun2/sensor.py:125
Integration: sun2
First occurred: November 4, 2022 at 23:52:43 (6 occurrences)
Last logged: November 4, 2022 at 23:52:43

London Sun Phase: Failed to find the time at elev: -12.000
London Sun Phase: Failed to find the time at elev: -6.000
London Sun Phase: Failed to find the time at elev: -4.000
London Sun Phase: Failed to find the time at elev: -0.833
London Sun Phase: Failed to find the time at elev: 6.000

my .yaml configuration:


- platform: sun2
  entity_namespace: London
  latitude: #########
  longitude: ########
  time_zone: Europe/London
  elevation: 11
  monitored_conditions:
    - sunrise
    - sunset
    - sun_phase
    - dawn
    - dusk
    - solar_noon
    - solar_midnight
    - daylight
    - night

@rlewis187 thanks for letting me know!

Could you please enable debug for this integration, restart HA, and look for any messages in home-assistant.log related to this? In particular, after the error message, you should see something like this:

2022-11-05 10:01:22 DEBUG (MainThread) [custom_components.sun2.sensor] Sun2 Sun Phase: tL = 2022-11-05 00:36:22-05:00/-64.182, cur = 2022-11-05 10:01:22-05:00/22.269, tR = 2022-11-05 12:36:21-05:00/32.421, rising = True

If you can share those messages, or at least one of them, I can try to figure out the problem from that. It might, however, help if you could share the latitude & longitude you're using. You can send that to me via a private message either on the HA community forum (user pnbruckner), or via e-mail (pnbruckner@gmail.com.)

Thanks for the fast response!

I emailed you my Lat/Long info.

Sorry, I'm a hardware guy, I only play with this kind of thing, can you please tell me how to enable debugging for this integration?

I should also add that a restart of HA does force an update to the correct value.

I emailed you my Lat/Long info.

Thanks! I'll add those to my test system.

can you please tell me how to enable debugging for this integration?

Sure. Add the following to your configuration.yaml file:

logger:
  default: info
  logs:
    custom_components.sun2: debug

For more details on configuring the logger:

https://www.home-assistant.io/integrations/logger/

I should also add that a restart of HA does force an update to the correct value.

Ok, that's interesting. But do the errors always come back, and if so, approximately when? Are there other errors that typically precede these errors?

Basically, let me know whatever you think will help me to reproduce the errors. Also, what version of HA are you running?

I added the debug to configuration.yaml and restarted. Heres the log:


2022-11-05 15:44:20.814 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.sun2
2022-11-05 15:44:21.085 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: tL = 2022-11-05 11:52:42+00:00/22.068, cur = 2022-11-05 15:44:21+00:00/5.769, tR = 2022-11-05 23:52:46+00:00/-53.681, rising = False
2022-11-05 15:44:21.085 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: trg = -0.833: t0 = 2022-11-05 16:30:55+00:00/ +0.031, t1 = 2022-11-05 16:40:55+00:00/ -1.760 -> est = 2022-11-05 16:35:44+00:00/ -0.932[ -0.099]
2022-11-05 15:44:21.086 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: trg = -0.833: t0 = 2022-11-05 16:30:55+00:00/ +0.031, t1 = 2022-11-05 16:35:44+00:00/ -0.932 -> est = 2022-11-05 16:35:14+00:00/ -0.845[ -0.012]
2022-11-05 15:44:21.086 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: trg = -0.833: t0 = 2022-11-05 16:30:55+00:00/ +0.031, t1 = 2022-11-05 16:35:14+00:00/ -0.845 -> est = 2022-11-05 16:35:10+00:00/ -0.834[ -0.001]
2022-11-05 15:44:21.087 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: trg = -4.000: t0 = 2022-11-05 16:51:04+00:00/ -3.269, t1 = 2022-11-05 17:01:04+00:00/ -4.732 -> est = 2022-11-05 16:56:04+00:00/ -4.001[ -0.001]
2022-11-05 15:44:21.088 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: trg = -6.000: t0 = 2022-11-05 17:04:43+00:00/ -5.267, t1 = 2022-11-05 17:14:43+00:00/ -6.738 -> est = 2022-11-05 17:09:42+00:00/ -5.999[ +0.001]
2022-11-05 15:44:21.088 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: trg = -12.000: t0 = 2022-11-05 17:44:56+00:00/-11.246, t1 = 2022-11-05 17:54:56+00:00/-12.758 -> est = 2022-11-05 17:49:55+00:00/-11.998[ +0.002]
2022-11-05 15:44:21.089 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: trg = -18.000: t0 = 2022-11-05 18:24:17+00:00/-17.233, t1 = 2022-11-05 18:34:17+00:00/-18.766 -> est = 2022-11-05 18:29:17+00:00/-17.999[ +0.001]
2022-11-05 15:44:21.090 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: _update time: 0:00:00.005859

The errors seem to be happening around midnight so I guess I'll leave it until tomorrow, see if it happens again and post back here in the morning?

I'm on the latest version of Home assistant.

I'm beginning to think that this may be something outside of HA. Flaky internet connection perhaps?

Great, thanks!

I'm actually seeing the exact same messages now on my test system, so hopefully when it fails for you it will also fail in the same way on my test system.

I'm beginning to think that this may be something outside of HA. Flaky internet connection perhaps?

Nope. This integration doesn't rely on the Internet. It's simply using the same astral Python package that HA uses to calculate sun related events. I'm sure my algorithms are not properly handling some corner case that I wasn't able to create in my previous testing.

Let me know what you see if/when it fails next. I'm guessing (hoping!) mine will fail the same way so I can figure out what's wrong and fix it.

Will do, interested to see if it happens at 0:00:00.005859

interested to see if it happens at 0:00:00.005859

That's actually the amount of time it took (i.e., 5.8 msec) to figure out when the sensor should update in the next part of the sun elevation curve; i.e., it's not a time.

If you look at this output:

tL = 2022-11-05 11:52:42+00:00/22.068, cur = 2022-11-05 15:44:21+00:00/5.769, tR = 2022-11-05 23:52:46+00:00/-53.681

The "tR" (time right) variable is the end of the current part of the elevation curve (i.e., when it switches from rising to falling or vice versa.) So, in this case, the interesting time should be 2022-11-05 23:52:46+00:00.

Ok, that's within 3 seconds of the fault occurring last night

That makes sense since the sun's elevation curve doesn't change much from day to day.

Just a bit of background explanation. This sensor works by finding the solar noon or solar midnight that come before and after the current time (i.e., tL & tR, or time left and time right) when it starts up. Of course, whether tL is solar midnight or solar noon depends on what the current time is, and hence whether the sun is rising or falling (and vice versa for tR.) Then it calculates when the sun will be at the various elevations between the current time and the next solar midnight/noon (i.e., tR.) The elevations are the ones that mark the boundaries between the various phases of the sun.

So, between the current time and tR it doesn't have to do any calculations. It just updates the sensor based on the times it calculated.

When tR comes around the sun switches from rising to falling or vice versa, and it calculates a new set of times based on a new tL/tR pair (where, of course, the new tL becomes the old tR.)

So all those debug messages will only be spit out when the system first starts, and whenever it reaches the next solar midnight or solar noon. In this case, the sun is falling (for you), so at 23:52:46 UTC is the next solar midnight, and that's when it does the next batch of calculations.

Ok, it failed:

2022-11-05 18:52:46.001 DEBUG (MainThread) [custom_components.sun2.sensor] F Sun Phase: tL = 2022-11-05 23:52:46+00:00/-53.681, cur = 2022-11-05 23:52:46+00:00/-53.681, tR = 2022-11-06 11:52:43+00:00/21.768, rising = True
2022-11-05 18:52:46.001 DEBUG (MainThread) [custom_components.sun2.sensor] F Sun Phase: trg = -18.000: t0 = 2022-11-05 23:52:46+00:00/-53.681, t1 = 2022-11-05 05:20:18+00:00/-17.236 -> est = 2022-11-05 05:43:38+00:00/-13.679[ +4.321]
2022-11-05 18:52:46.001 DEBUG (MainThread) [custom_components.sun2.sensor] F Sun Phase: trg = -18.000: t0 = 2022-11-05 23:52:46+00:00/-53.681, t1 = 2022-11-05 05:20:18+00:00/-17.236 -> outside range
2022-11-05 18:52:46.001 ERROR (MainThread) [custom_components.sun2.sensor] F Sun Phase: Failed to find the time at elev: -18.000
2022-11-05 18:52:46.002 DEBUG (MainThread) [custom_components.sun2.sensor] F Sun Phase: trg = -12.000: t0 = 2022-11-05 23:52:46+00:00/-53.681, t1 = 2022-11-05 05:59:44+00:00/-11.245 -> est = 2022-11-05 06:18:49+00:00/ -8.390[ +3.610]
2022-11-05 18:52:46.002 DEBUG (MainThread) [custom_components.sun2.sensor] F Sun Phase: trg = -12.000: t0 = 2022-11-05 23:52:46+00:00/-53.681, t1 = 2022-11-05 05:59:44+00:00/-11.245 -> outside range
2022-11-05 18:52:46.002 ERROR (MainThread) [custom_components.sun2.sensor] F Sun Phase: Failed to find the time at elev: -12.000
2022-11-05 18:52:46.003 DEBUG (MainThread) [custom_components.sun2.sensor] F Sun Phase: trg =  -6.000: t0 = 2022-11-05 23:52:46+00:00/-53.681, t1 = 2022-11-05 06:39:59+00:00/ -5.268 -> est = 2022-11-05 06:55:36+00:00/ -2.984[ +3.016]
2022-11-05 18:52:46.003 DEBUG (MainThread) [custom_components.sun2.sensor] F Sun Phase: trg =  -6.000: t0 = 2022-11-05 23:52:46+00:00/-53.681, t1 = 2022-11-05 06:39:59+00:00/ -5.268 -> outside range
2022-11-05 18:52:46.003 ERROR (MainThread) [custom_components.sun2.sensor] F Sun Phase: Failed to find the time at elev: -6.000
2022-11-05 18:52:46.003 DEBUG (MainThread) [custom_components.sun2.sensor] F Sun Phase: trg =  -4.000: t0 = 2022-11-05 23:52:46+00:00/-53.681, t1 = 2022-11-05 06:53:39+00:00/ -3.270 -> est = 2022-11-05 07:08:25+00:00/ -1.031[ +2.969]
2022-11-05 18:52:46.003 DEBUG (MainThread) [custom_components.sun2.sensor] F Sun Phase: trg =  -4.000: t0 = 2022-11-05 23:52:46+00:00/-53.681, t1 = 2022-11-05 06:53:39+00:00/ -3.270 -> outside range
2022-11-05 18:52:46.003 ERROR (MainThread) [custom_components.sun2.sensor] F Sun Phase: Failed to find the time at elev: -4.000
2022-11-05 18:52:46.003 DEBUG (MainThread) [custom_components.sun2.sensor] F Sun Phase: trg =  -0.833: t0 = 2022-11-05 23:52:46+00:00/-53.681, t1 = 2022-11-05 07:13:50+00:00/ +0.032 -> est = 2022-11-05 07:29:55+00:00/ +1.963[ +2.796]
2022-11-05 18:52:46.003 DEBUG (MainThread) [custom_components.sun2.sensor] F Sun Phase: trg =  -0.833: t0 = 2022-11-05 23:52:46+00:00/-53.681, t1 = 2022-11-05 07:13:50+00:00/ +0.032 -> outside range
2022-11-05 18:52:46.003 ERROR (MainThread) [custom_components.sun2.sensor] F Sun Phase: Failed to find the time at elev: -0.833
2022-11-05 18:52:46.003 DEBUG (MainThread) [custom_components.sun2.sensor] F Sun Phase: trg =  +6.000: t0 = 2022-11-05 23:52:46+00:00/-53.681, t1 = 2022-11-05 08:07:20+00:00/ +6.613 -> est = 2022-11-05 08:16:57+00:00/ +7.766[ +1.766]
2022-11-05 18:52:46.003 DEBUG (MainThread) [custom_components.sun2.sensor] F Sun Phase: trg =  +6.000: t0 = 2022-11-05 23:52:46+00:00/-53.681, t1 = 2022-11-05 08:07:20+00:00/ +6.613 -> outside range
2022-11-05 18:52:46.003 ERROR (MainThread) [custom_components.sun2.sensor] F Sun Phase: Failed to find the time at elev: 6.000
2022-11-05 18:52:46.003 DEBUG (MainThread) [custom_components.sun2.sensor] F Sun Phase: _update time: 0:00:00.002367

This should help me figure out what's wrong. I might not get to it, though, until Monday.

Same here, exactly when you predicted it would.

2022-11-05 23:52:46.019 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: tL = 2022-11-05 23:52:46+00:00/-53.681, cur = 2022-11-05 23:52:46+00:00/-53.681, tR = 2022-11-06 11:52:43+00:00/21.768, rising = True
2022-11-05 23:52:46.020 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: trg = -18.000: t0 = 2022-11-05 23:52:46+00:00/-53.681, t1 = 2022-11-05 05:20:18+00:00/-17.236 -> est = 2022-11-05 05:43:38+00:00/-13.679[ +4.321]
2022-11-05 23:52:46.020 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: trg = -18.000: t0 = 2022-11-05 23:52:46+00:00/-53.681, t1 = 2022-11-05 05:20:18+00:00/-17.236 -> outside range
2022-11-05 23:52:46.020 ERROR (MainThread) [custom_components.sun2.sensor] London Sun Phase: Failed to find the time at elev: -18.000
2022-11-05 23:52:46.027 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: trg = -12.000: t0 = 2022-11-05 23:52:46+00:00/-53.681, t1 = 2022-11-05 05:59:44+00:00/-11.245 -> est = 2022-11-05 06:18:49+00:00/ -8.390[ +3.610]
2022-11-05 23:52:46.027 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: trg = -12.000: t0 = 2022-11-05 23:52:46+00:00/-53.681, t1 = 2022-11-05 05:59:44+00:00/-11.245 -> outside range
2022-11-05 23:52:46.027 ERROR (MainThread) [custom_components.sun2.sensor] London Sun Phase: Failed to find the time at elev: -12.000
2022-11-05 23:52:46.032 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: trg = -6.000: t0 = 2022-11-05 23:52:46+00:00/-53.681, t1 = 2022-11-05 06:39:59+00:00/ -5.268 -> est = 2022-11-05 06:55:36+00:00/ -2.984[ +3.016]
2022-11-05 23:52:46.033 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: trg = -6.000: t0 = 2022-11-05 23:52:46+00:00/-53.681, t1 = 2022-11-05 06:39:59+00:00/ -5.268 -> outside range
2022-11-05 23:52:46.033 ERROR (MainThread) [custom_components.sun2.sensor] London Sun Phase: Failed to find the time at elev: -6.000
2022-11-05 23:52:46.035 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: trg = -4.000: t0 = 2022-11-05 23:52:46+00:00/-53.681, t1 = 2022-11-05 06:53:39+00:00/ -3.270 -> est = 2022-11-05 07:08:25+00:00/ -1.031[ +2.969]
2022-11-05 23:52:46.036 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: trg = -4.000: t0 = 2022-11-05 23:52:46+00:00/-53.681, t1 = 2022-11-05 06:53:39+00:00/ -3.270 -> outside range
2022-11-05 23:52:46.036 ERROR (MainThread) [custom_components.sun2.sensor] London Sun Phase: Failed to find the time at elev: -4.000
2022-11-05 23:52:46.039 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: trg = -0.833: t0 = 2022-11-05 23:52:46+00:00/-53.681, t1 = 2022-11-05 07:13:50+00:00/ +0.032 -> est = 2022-11-05 07:29:55+00:00/ +1.963[ +2.796]
2022-11-05 23:52:46.040 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: trg = -0.833: t0 = 2022-11-05 23:52:46+00:00/-53.681, t1 = 2022-11-05 07:13:50+00:00/ +0.032 -> outside range
2022-11-05 23:52:46.040 ERROR (MainThread) [custom_components.sun2.sensor] London Sun Phase: Failed to find the time at elev: -0.833
2022-11-05 23:52:46.042 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: trg = +6.000: t0 = 2022-11-05 23:52:46+00:00/-53.681, t1 = 2022-11-05 08:07:20+00:00/ +6.613 -> est = 2022-11-05 08:16:57+00:00/ +7.766[ +1.766]
2022-11-05 23:52:46.043 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: trg = +6.000: t0 = 2022-11-05 23:52:46+00:00/-53.681, t1 = 2022-11-05 08:07:20+00:00/ +6.613 -> outside range
2022-11-05 23:52:46.043 ERROR (MainThread) [custom_components.sun2.sensor] London Sun Phase: Failed to find the time at elev: 6.000
2022-11-05 23:52:46.046 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: _update time: 0:00:00.028068

Heres my logs in case its helpful.

Logs after re-start:

2022-11-06 06:43:53.511 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration sun2 which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2022-11-06 06:44:07.836 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.sun2
2022-11-06 06:44:08.095 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: tL = 2022-11-05 23:52:46+00:00/-53.681, cur = 2022-11-06 06:44:08+00:00/-4.911, tR = 2022-11-06 11:52:43+00:00/21.768, rising = True
2022-11-06 06:44:08.096 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: trg = -4.000: t0 = 2022-11-06 06:45:22+00:00/ -4.731, t1 = 2022-11-06 06:55:22+00:00/ -3.274 -> est = 2022-11-06 06:50:23+00:00/ -4.000[ +0.000]
2022-11-06 06:44:08.097 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: trg = -0.833: t0 = 2022-11-06 07:05:38+00:00/ -1.754, t1 = 2022-11-06 07:15:38+00:00/ +0.029 -> est = 2022-11-06 07:10:48+00:00/ -0.933[ -0.100]
2022-11-06 06:44:08.097 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: trg = -0.833: t0 = 2022-11-06 07:10:48+00:00/ -0.933, t1 = 2022-11-06 07:15:38+00:00/ +0.029 -> est = 2022-11-06 07:11:18+00:00/ -0.847[ -0.014]
2022-11-06 06:44:08.097 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: trg = -0.833: t0 = 2022-11-06 07:11:18+00:00/ -0.847, t1 = 2022-11-06 07:15:38+00:00/ +0.029 -> est = 2022-11-06 07:11:22+00:00/ -0.835[ -0.002]
2022-11-06 06:44:08.098 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: trg = +6.000: t0 = 2022-11-06 07:59:26+00:00/ +5.392, t1 = 2022-11-06 08:09:26+00:00/ +6.608 -> est = 2022-11-06 08:04:26+00:00/ +6.003[ +0.003]
2022-11-06 06:44:08.098 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: _update time: 0:00:00.004363

Failed again:

This error originated from a custom integration.

Logger: custom_components.sun2.sensor
Source: custom_components/sun2/sensor.py:125
Integration: sun2 (documentation, issues)
First occurred: November 6, 2022 at 23:52:49 (6 occurrences)
Last logged: November 6, 2022 at 23:52:49

London Sun Phase: Failed to find the time at elev: -12.000
London Sun Phase: Failed to find the time at elev: -6.000
London Sun Phase: Failed to find the time at elev: -4.000
London Sun Phase: Failed to find the time at elev: -0.833
London Sun Phase: Failed to find the time at elev: 6.000
2022-11-06 06:43:53.511 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration sun2 which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2022-11-06 06:44:07.836 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.sun2
2022-11-06 06:44:08.095 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: tL = 2022-11-05 23:52:46+00:00/-53.681, cur = 2022-11-06 06:44:08+00:00/-4.911, tR = 2022-11-06 11:52:43+00:00/21.768, rising = True
2022-11-06 06:44:08.096 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: trg = -4.000: t0 = 2022-11-06 06:45:22+00:00/ -4.731, t1 = 2022-11-06 06:55:22+00:00/ -3.274 -> est = 2022-11-06 06:50:23+00:00/ -4.000[ +0.000]
2022-11-06 06:44:08.097 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: trg = -0.833: t0 = 2022-11-06 07:05:38+00:00/ -1.754, t1 = 2022-11-06 07:15:38+00:00/ +0.029 -> est = 2022-11-06 07:10:48+00:00/ -0.933[ -0.100]
2022-11-06 06:44:08.097 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: trg = -0.833: t0 = 2022-11-06 07:10:48+00:00/ -0.933, t1 = 2022-11-06 07:15:38+00:00/ +0.029 -> est = 2022-11-06 07:11:18+00:00/ -0.847[ -0.014]
2022-11-06 06:44:08.097 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: trg = -0.833: t0 = 2022-11-06 07:11:18+00:00/ -0.847, t1 = 2022-11-06 07:15:38+00:00/ +0.029 -> est = 2022-11-06 07:11:22+00:00/ -0.835[ -0.002]
2022-11-06 06:44:08.098 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: trg = +6.000: t0 = 2022-11-06 07:59:26+00:00/ +5.392, t1 = 2022-11-06 08:09:26+00:00/ +6.608 -> est = 2022-11-06 08:04:26+00:00/ +6.003[ +0.003]
2022-11-06 06:44:08.098 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: _update time: 0:00:00.004363
2022-11-06 11:52:43.016 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: tL = 2022-11-06 11:52:43+00:00/21.768, cur = 2022-11-06 11:52:43+00:00/21.768, tR = 2022-11-06 23:52:49+00:00/-53.979, rising = False
2022-11-06 11:52:43.017 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: trg = +6.000: t0 = 2022-11-06 15:35:26+00:00/ +6.607, t1 = 2022-11-06 15:45:26+00:00/ +5.390 -> est = 2022-11-06 15:40:25+00:00/ +6.004[ +0.004]
2022-11-06 11:52:43.018 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: trg = -0.833: t0 = 2022-11-06 16:29:12+00:00/ +0.028, t1 = 2022-11-06 16:39:12+00:00/ -1.757 -> est = 2022-11-06 16:34:01+00:00/ -0.932[ -0.099]
2022-11-06 11:52:43.018 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: trg = -0.833: t0 = 2022-11-06 16:29:12+00:00/ +0.028, t1 = 2022-11-06 16:34:01+00:00/ -0.932 -> est = 2022-11-06 16:33:31+00:00/ -0.846[ -0.013]
2022-11-06 11:52:43.022 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: trg = -0.833: t0 = 2022-11-06 16:29:12+00:00/ +0.028, t1 = 2022-11-06 16:33:31+00:00/ -0.846 -> est = 2022-11-06 16:33:27+00:00/ -0.835[ -0.002]
2022-11-06 11:52:43.023 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: trg = -4.000: t0 = 2022-11-06 16:49:26+00:00/ -3.273, t1 = 2022-11-06 16:59:26+00:00/ -4.731 -> est = 2022-11-06 16:54:25+00:00/ -4.000[ +0.000]
2022-11-06 11:52:43.024 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: trg = -6.000: t0 = 2022-11-06 17:03:07+00:00/ -5.269, t1 = 2022-11-06 17:13:07+00:00/ -6.736 -> est = 2022-11-06 17:08:06+00:00/ -5.999[ +0.001]
2022-11-06 11:52:43.025 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: trg = -12.000: t0 = 2022-11-06 17:43:25+00:00/-11.246, t1 = 2022-11-06 17:53:25+00:00/-12.755 -> est = 2022-11-06 17:48:25+00:00/-12.000[ +0.000]
2022-11-06 11:52:43.026 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: trg = -18.000: t0 = 2022-11-06 18:22:49+00:00/-17.233, t1 = 2022-11-06 18:32:49+00:00/-18.766 -> est = 2022-11-06 18:27:49+00:00/-17.999[ +0.001]
2022-11-06 11:52:43.027 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: _update time: 0:00:00.011846
2022-11-06 23:52:49.017 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: tL = 2022-11-06 23:52:49+00:00/-53.979, cur = 2022-11-06 23:52:49+00:00/-53.979, tR = 2022-11-07 11:52:46+00:00/21.473, rising = True
2022-11-06 23:52:49.018 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: trg = -18.000: t0 = 2022-11-06 23:52:49+00:00/-53.979, t1 = 2022-11-06 05:21:52+00:00/-17.234 -> est = 2022-11-06 05:45:01+00:00/-13.709[ +4.291]
2022-11-06 23:52:49.018 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: trg = -18.000: t0 = 2022-11-06 23:52:49+00:00/-53.979, t1 = 2022-11-06 05:21:52+00:00/-17.234 -> outside range
2022-11-06 23:52:49.018 ERROR (MainThread) [custom_components.sun2.sensor] London Sun Phase: Failed to find the time at elev: -18.000
2022-11-06 23:52:49.026 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: trg = -12.000: t0 = 2022-11-06 23:52:49+00:00/-53.979, t1 = 2022-11-06 06:01:19+00:00/-11.249 -> est = 2022-11-06 06:20:09+00:00/ -8.436[ +3.564]
2022-11-06 23:52:49.026 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: trg = -12.000: t0 = 2022-11-06 23:52:49+00:00/-53.979, t1 = 2022-11-06 06:01:19+00:00/-11.249 -> outside range
2022-11-06 23:52:49.026 ERROR (MainThread) [custom_components.sun2.sensor] London Sun Phase: Failed to find the time at elev: -12.000
2022-11-06 23:52:49.030 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: trg = -6.000: t0 = 2022-11-06 23:52:49+00:00/-53.979, t1 = 2022-11-06 06:41:41+00:00/ -5.268 -> est = 2022-11-06 06:57:11+00:00/ -3.008[ +2.992]
2022-11-06 23:52:49.030 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: trg = -6.000: t0 = 2022-11-06 23:52:49+00:00/-53.979, t1 = 2022-11-06 06:41:41+00:00/ -5.268 -> outside range
2022-11-06 23:52:49.031 ERROR (MainThread) [custom_components.sun2.sensor] London Sun Phase: Failed to find the time at elev: -6.000
2022-11-06 23:52:49.033 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: trg = -4.000: t0 = 2022-11-06 23:52:49+00:00/-53.979, t1 = 2022-11-06 06:55:22+00:00/ -3.274 -> est = 2022-11-06 07:09:57+00:00/ -1.075[ +2.925]
2022-11-06 23:52:49.034 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: trg = -4.000: t0 = 2022-11-06 23:52:49+00:00/-53.979, t1 = 2022-11-06 06:55:22+00:00/ -3.274 -> outside range
2022-11-06 23:52:49.034 ERROR (MainThread) [custom_components.sun2.sensor] London Sun Phase: Failed to find the time at elev: -4.000
2022-11-06 23:52:49.037 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: trg = -0.833: t0 = 2022-11-06 23:52:49+00:00/-53.979, t1 = 2022-11-06 07:15:38+00:00/ +0.029 -> est = 2022-11-06 07:31:33+00:00/ +1.930[ +2.763]
2022-11-06 23:52:49.037 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: trg = -0.833: t0 = 2022-11-06 23:52:49+00:00/-53.979, t1 = 2022-11-06 07:15:38+00:00/ +0.029 -> outside range
2022-11-06 23:52:49.038 ERROR (MainThread) [custom_components.sun2.sensor] London Sun Phase: Failed to find the time at elev: -0.833
2022-11-06 23:52:49.044 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: trg = +6.000: t0 = 2022-11-06 23:52:49+00:00/-53.979, t1 = 2022-11-06 08:09:26+00:00/ +6.608 -> est = 2022-11-06 08:18:54+00:00/ +7.735[ +1.735]
2022-11-06 23:52:49.044 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: trg = +6.000: t0 = 2022-11-06 23:52:49+00:00/-53.979, t1 = 2022-11-06 08:09:26+00:00/ +6.608 -> outside range
2022-11-06 23:52:49.045 ERROR (MainThread) [custom_components.sun2.sensor] London Sun Phase: Failed to find the time at elev: 6.000
2022-11-06 23:52:49.048 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: _update time: 0:00:00.031924

I found the problem. I'm working on a fix. I hope to release a beta version with the fix soon.

Please try 2.1.3b0 and let me know if it fixes the problem for you.

Sorry missed this last night, have downloaded it now and will report back tomorrow.

Ok. FWIW, in my testing it seems to have solved the problem:

2022-11-08 05:52:50.002 DEBUG (MainThread) [custom_components.sun2.sensor] F Sun Phase: tL = 2022-11-08 11:52:50+00:00/21.182, cur = 2022-11-08 11:52:50+00:00/21.182, tR = 2022-11-08 23:52:57+00:00/-54.563, rising = False
2022-11-08 05:52:50.003 DEBUG (MainThread) [custom_components.sun2.sensor] F Sun Phase: trg =  +6.000: t0 = 2022-11-08 15:31:28+00:00/ +6.598, t1 = 2022-11-08 15:41:28+00:00/ +5.400 -> est = 2022-11-08 15:36:27+00:00/ +6.004[ +0.004]
2022-11-08 05:52:50.003 DEBUG (MainThread) [custom_components.sun2.sensor] F Sun Phase: trg =  -0.833: t0 = 2022-11-08 16:25:51+00:00/ +0.024, t1 = 2022-11-08 16:35:51+00:00/ -1.750 -> est = 2022-11-08 16:30:41+00:00/ -0.935[ -0.102]
2022-11-08 05:52:50.003 DEBUG (MainThread) [custom_components.sun2.sensor] F Sun Phase: trg =  -0.833: t0 = 2022-11-08 16:25:51+00:00/ +0.024, t1 = 2022-11-08 16:30:41+00:00/ -0.935 -> est = 2022-11-08 16:30:10+00:00/ -0.846[ -0.013]
2022-11-08 05:52:50.003 DEBUG (MainThread) [custom_components.sun2.sensor] F Sun Phase: trg =  -0.833: t0 = 2022-11-08 16:25:51+00:00/ +0.024, t1 = 2022-11-08 16:30:10+00:00/ -0.846 -> est = 2022-11-08 16:30:06+00:00/ -0.835[ -0.002]
2022-11-08 05:52:50.003 DEBUG (MainThread) [custom_components.sun2.sensor] F Sun Phase: trg =  -4.000: t0 = 2022-11-08 16:46:15+00:00/ -3.279, t1 = 2022-11-08 16:56:15+00:00/ -4.727 -> est = 2022-11-08 16:51:14+00:00/ -4.000[ -0.000]
2022-11-08 05:52:50.004 DEBUG (MainThread) [custom_components.sun2.sensor] F Sun Phase: trg =  -6.000: t0 = 2022-11-08 17:00:01+00:00/ -5.274, t1 = 2022-11-08 17:10:01+00:00/ -6.731 -> est = 2022-11-08 17:05:00+00:00/ -5.999[ +0.001]
2022-11-08 05:52:50.004 DEBUG (MainThread) [custom_components.sun2.sensor] F Sun Phase: trg = -12.000: t0 = 2022-11-08 17:40:30+00:00/-11.249, t1 = 2022-11-08 17:50:30+00:00/-12.753 -> est = 2022-11-08 17:45:30+00:00/-11.999[ +0.001]
2022-11-08 05:52:50.004 DEBUG (MainThread) [custom_components.sun2.sensor] F Sun Phase: trg = -18.000: t0 = 2022-11-08 18:20:00+00:00/-17.236, t1 = 2022-11-08 18:30:00+00:00/-18.766 -> est = 2022-11-08 18:25:00+00:00/-18.000[ -0.000]
2022-11-08 05:52:50.004 DEBUG (MainThread) [custom_components.sun2.sensor] F Sun Phase: _update time: 0:00:00.002636

@rlewis187 it seems I created the release incorrectly. I accidentally tagged the master branch w/ 2.4.0b1 instead of the entity-based branch. I don't think I can fix that, so I'll just have to create a new release (2.4.0.b2) to supersede the bad one. Sorry!

Never mind. I'm working on too many things at once and getting confused. The releases in this repo are fine. I made a mistake in a different custom integration.

Ok, looks like you fixed it:

Heres my logs:


2022-11-08 23:52:57.014 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: tL = 2022-11-08 23:52:57+00:00/-54.563, cur = 2022-11-08 23:52:57+00:00/-54.563, tR = 2022-11-09 11:52:54+00:00/20.895, rising = True
2022-11-08 23:52:57.015 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: trg = -18.000: t0 = 2022-11-09 05:16:29+00:00/-18.763, t1 = 2022-11-09 05:26:29+00:00/-17.236 -> est = 2022-11-09 05:21:29+00:00/-17.999[ +0.001]
2022-11-08 23:52:57.016 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: trg = -12.000: t0 = 2022-11-09 05:56:04+00:00/-12.752, t1 = 2022-11-09 06:06:04+00:00/-11.252 -> est = 2022-11-09 06:01:05+00:00/-11.998[ +0.002]
2022-11-08 23:52:57.017 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: trg = -6.000: t0 = 2022-11-09 06:36:42+00:00/ -6.729, t1 = 2022-11-09 06:46:42+00:00/ -5.276 -> est = 2022-11-09 06:41:43+00:00/ -5.999[ +0.001]
2022-11-08 23:52:57.018 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: trg = -4.000: t0 = 2022-11-09 06:50:32+00:00/ -4.722, t1 = 2022-11-09 07:00:32+00:00/ -3.280 -> est = 2022-11-09 06:55:33+00:00/ -3.999[ +0.001]
2022-11-08 23:52:57.019 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: trg = -0.833: t0 = 2022-11-09 07:11:02+00:00/ -1.744, t1 = 2022-11-09 07:21:02+00:00/ +0.022 -> est = 2022-11-09 07:16:11+00:00/ -0.935[ -0.102]
2022-11-08 23:52:57.019 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: trg = -0.833: t0 = 2022-11-09 07:16:11+00:00/ -0.935, t1 = 2022-11-09 07:21:02+00:00/ +0.022 -> est = 2022-11-09 07:16:42+00:00/ -0.847[ -0.014]
2022-11-08 23:52:57.019 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: trg = -0.833: t0 = 2022-11-09 07:16:42+00:00/ -0.847, t1 = 2022-11-09 07:21:02+00:00/ +0.022 -> est = 2022-11-09 07:16:46+00:00/ -0.836[ -0.003]
2022-11-08 23:52:57.022 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: trg = +6.000: t0 = 2022-11-09 08:05:45+00:00/ +5.404, t1 = 2022-11-09 08:15:45+00:00/ +6.594 -> est = 2022-11-09 08:10:46+00:00/ +6.004[ +0.004]
2022-11-08 23:52:57.022 DEBUG (MainThread) [custom_components.sun2.sensor] London Sun Phase: _update time: 0:00:00.009470

Many thanks for sorting this out, it is a key part of all my lighting controls so is very important to me.