Sunrise+Offset rule not updating timing

Hi, @orangebucket
The Engineering Team has been evaluating your case. They mention that this Rule of yours seems to be in a strange state and they believe this might be the root cause of the issue. Can you please delete that Rule and create it again to see if this still happens? We would appreciate it a lot. Please keep us updated.

No problem. One of the joys of the Rules API is how trivial that is to do.

The new Rule ran for the first time at 5:59am yesterday (Thursday) which was strictly speaking already a couple of minutes late relative to the actual sunrise yesterday morning. As I wasn’t sure whether to expect ‘sunrise’ to be correct for the day or it to be the previous day’s time plus 24 hours, that was unremarkable.

Today (Friday) it also ran at 5:59am which is four or five minutes late, and more significantly hasn’t changed. My understanding is that the time should be updated daily (I know sun times in Automations/Routines used to be allowed to drift by a few minutes, but that was quite some time ago).

Update: Saturday it ran at 5:59am.
Update: Sunday it ran at 5:59am.
Update: Monday it ran at … (drum roll) … 5:59am.

Hi, @orangebucket

Does the rule still execute every day at the exact same minute? Several of us try reproducing this issue but weren’t able to. All of us had the same results. The sunrise changes a minute or so every day. In my case, for example, I make two Rules, one that turns on a switch every sunrise, and another one that turns off the same switch every sunset. Here you can see the history of that switch attached. It is updated every single day:

Yes, currently 5:59am as it has been since I last recreated the Rule. The rule uses ‘every’ and it is an offset of 31 minutes after sunrise, not sunrise itself. Sunrise was about 4:58am this morning.

It used to work fine then just stopped last September.

Apart from this one Rule, I only use sunrise/sunset offsets to restrict the active period for motion controlled lighting. I can’t remember if those were also affected as I just used to restart them all every so often just in case.

@orangebucket let’s continue this conversation on DM, I need to ask you for some personal information to check the logs.

I feel more and more that someone should rewrite Hello Home in LUA for local execution.

I cannot believe that the sun state is a so complicated thing that it cannot be run locally without any issues.

@TAustin or @Mariano_Colmenarejo don’t you want to give a stab on this?

1 Like

The rule I am having problems with runs in the cloud. I probably ought to do some more diagnosis of my own but it is a bit tedious waiting 24 hours for results.

Sorry, my emphasis was on without issues.

Anyhow, it fails to update the time correctly, disregarding that it is cloud or local. This should be a basic feature without any issues. It is like home automation 101.

There is probably something subtle about the problem given there aren’t gazillions of complaints and it could well be something I’ve done wrong, though if it is then it wasn’t so wrong that it didn’t once work.

Thanks for the information, I find it very interesting.
I’ll try to see if it works.

It is summer time on the Northern Hemisphere, people do not realise sun state changes, as it is really out of their interest by having long hours of sun.

If you did it wrong then anybody else can do it wrong, and at the end it leads to frustration from people who are starting with home automation with SmartThings. (because they think that must be the easiest for their use, and then they realise that a simple sun state is not working…)

Do a search with the phrase sunrise sunset LUA, some other code samples will come up. Might be even something built-in as well.

I have doubts how time of day can be passed from a device to a rule and processed there…

What could be done is a custom capability that emits a value at sunrise and another at sunset.

To make it usable with positive and negative offsets, something else would have to be added, perhaps two capabilities with +/- time refence to sunset and sunrise emitted every minute.

@GSzabados,

These are the calculations that the code does for my location.
I will check to see if they are correct

2022-05-25T11:48:47.320289521+00:00 DEBUG Zigbee Thing Sun  driver device thread event handled
2022-05-25T11:48:56.454049192+00:00 PRINT Zigbee Thing Sun  <<<< Sun Altitud >>>>       69.816489503901
2022-05-25T11:48:56.469599859+00:00 PRINT Zigbee Thing Sun  <<<< Sun Azimuth >>>>       164.56738279508
2022-05-25T11:48:56.474988525+00:00 DEBUG Zigbee Thing Sun  Lidl Plug device thread event handled
2022-05-25T11:49:17.329852535+00:00 DEBUG Zigbee Thing Sun  driver device thread event handled
2022-05-25T11:49:47.339814883+00:00 DEBUG Zigbee Thing Sun  driver device thread event handled
2022-05-25T11:49:56.441382221+00:00 PRINT Zigbee Thing Sun  <<<< Sun Altitud >>>>       69.866013756437
2022-05-25T11:49:56.449669887+00:00 PRINT Zigbee Thing Sun  <<<< Sun Azimuth >>>>       165.22889411018
2022-05-25T11:49:56.460164554+00:00 DEBUG Zigbee Thing Sun  Lidl Plug device thread event handled
2022-05-25T11:50:17.339789897+00:00 DEBUG Zigbee Thing Sun  driver device thread event handled
2022-05-25T11:50:47.349828912+00:00 DEBUG Zigbee Thing Sun  driver device thread event handled
2022-05-25T11:50:56.445967249+00:00 PRINT Zigbee Thing Sun  <<<< Sun Altitud >>>>       69.91341671413
2022-05-25T11:50:56.459850916+00:00 PRINT Zigbee Thing Sun  <<<< Sun Azimuth >>>>       165.89324306897
2022-05-25T11:50:56.465539249+00:00 DEBUG Zigbee Thing Sun  Lidl Plug device thread event handled
2022-05-25T11:51:17.349808593+00:00 DEBUG Zigbee Thing Sun  driver device thread event handled
2022-05-25T11:51:47.360280607+00:00 DEBUG Zigbee Thing Sun  driver device thread event handled
2022-05-25T11:51:56.521819494+00:00 PRINT Zigbee Thing Sun  <<<< Sun Altitud >>>>       69.958683085198
2022-05-25T11:51:56.529642403+00:00 PRINT Zigbee Thing Sun  <<<< Sun Azimuth >>>>       166.56032433335

It could be a custom capability as minutes to sunset or minutes to sunrise than a comparison could be added to a rule like, if less than 30 (minutes), turn on light.
After sunset/sunrise could be negative numbers and reset at midnight.

I am not depending on this, it could just dodge the time to time broken sunrise/sunset rules.

@GSzabados
I made a new thread so as not to break this one.

1 Like

I haven’t visited this thread for months. If anyone is wondering, the problem (sunrise not updating daily in a cloud executing Rule) still seems to exist…

@nayelyz Is this issue in the queue? Sunrise and Sunset are static values when written into rules. They get the value for the times when the rules are posted, and then they never update.

For example

“actions”:[
{
“every”:{
“specific”:{
“reference”:“sunset”,
“offset”:{
“value”:{
“integer”:0
},
“unit”:“Minute”
}
},

This was posted when sunset was 5:07 (1707). Sunset is now 5:15 (1715) but the rule is still executing at 5:07.

Thank you.

It had better be, I’ve been waiting a long time now. @andresg was working the problem. I’ve not heard anything new for several months but at that point they had been able to reliably repeat the problem once they realised it was only affecting rules running in the cloud.