getSunriseAndSunset bug

This morning I noticed that some light was turned on unexpectedly. The light was controlled by my custom app, it worked in the past for a long time without issue, and I didn't make any changes to hubitat yesterday. So I debugged it a bit and found that it might be a bug that also affects any apps using the getSunriseAndSunset function.

Here's the debugging code that simply logs the current sunset, sunrise & now:

The actual log is: Sunrise: Thu May 21 05:54:00 PDT 2020, Sunset: Thu May 21 20:16:00 PDT 2020, Now: Fri May 22 09:18:46 PDT 2020


You may have noticed that both sunset & sunrise is for yesterday.

This triggers time check like "from sunset to 10PM" because it's translated to "from sunset yesterday to 10PM today".

The system events for sunset/sunrise:

I then created a simple automation test rule to see if this bug affected to other app, and it did. The SA rule have time restriction "From sunset to 10PM":



It was then triggered @9:25AM:

As this happens only today but not yesterday, and I didn't make any change, I suspect the bug may go away if I reboot the hub, but it might be useful for debugging not to reboot for now if any further information is needed. The last systemStart event is at 2020-05-16 06:47:37.475 PM PDT

What release of the platform are you running on?

Currently running version: 2.2.0.128

It turns out that sth happens around 12:00am fixed this issue automatically. The sunrise/sunset time was still for May 21 when logged at 11:44PM May 22, but it was changed to May 23 when logged at 12:01AM May 23:

2020-05-22 11:44:04.815 pm debugSunrise: Thu May 21 05:54:00 PDT 2020, Sunset: Thu May 21 20:16:00 PDT 2020, Now: Fri May 22 23:44:04 PDT 2020
2020-05-23 12:01:56.650 am debugSunrise: Sat May 23 05:53:00 PDT 2020, Sunset: Sat May 23 20:17:00 PDT 2020, Now: Sat May 23 00:01:56 PDT 2020

Does getSunriseAndSunset depend on sth at 12:00AM? And somehow that event / code executed at that event was not reliable? The events I can see on my side were just mode change to NIGHT, and HSM armed night.