Problem with Sunset and Day of Week Schedule as a Trigger

Hello,

I have a Day of week trigger that triggers only on Friday's and I have it set to Sunset -40. The issue is that as the weeks go by, the trigger stays on the same time and does not update itself with the current time of sunset for that week. The Sunset time though in Settings > Hub Details is correct and does properly update itself every day. Here is an example of this type of trigger which I setup a few weeks ago as a test. The time has stayed at 3:52pm every week. If I go to edit the trigger, then it will update to the proper Sunset time minus 40, but it doesn't do it automatically. This used to work in the past, so I am wondering if an update may have broken this functionality.

image

I have a day/time trigger set to sunset -30 on one of my apps that seems to be working fine.

Is it possible that since Dec 21 is the day of the year with the least daylight that the sunset increment is so small around that day that the time is essentially the same (depends how far south you are)? Looking at my sunset times in the northeast, there are quite a few days in a row that are showing the same time, rounded to a minute. But I guess if you’re hub details sunset time is showing differently but your app isn’t, that’s probably not the issue.

If that’s not it, have you tried a reboot of hub, or shutdown, unplug for 1 minute, and restart? If all else fails, you could try recreating the app from scratch, which isn’t too bad now that you can export your entire set of actions and paste into the new app.

1 Like

The sunset time in hub details is properly changing day to day, but not in the trigger. The trigger will only update if I click on edit and retype the offset number of 40, then the time will immediately change on the trigger to accurately reflect the current Sunset time with an -40 offset.

I have tried rebooting and shutting down.

I will look into recreating the app. I do have a lot of 4.1 & 4.0 rules in Rule Machine Legacy, so I want to make sure that won't get affected.

I created a test rule to see if I can replicate your findings; it may take a couple days to really see results, given the trigger at hand. From the app status, I don't see anything concerning: I have a scheduled job for shortly after midnight, which should fetch the new sun times, calculate the negative offset, and schedule a job then. That should happen every day, so it should keep changing.

To be clear, are you actually seeing the rule run at the unexpected time? I believe some or all of the displayed values (in parentheses after certain items) are cached and may not necessarily be constantly updated, though page load does seem to be one of those times. Turning "Display current values" off and then on also seems to do it. But this display alone is not necessarily indicative of what the rule will do when executed, just at the time this data was fetched (again, normally including page load, so there could still be something odd here).

1 Like

It should work as-is, but what if you set the Required Expression to Friday (you have Thursday in your rule). Then change Trigger to just Sunset -40.

Turn on all logging, and see what happens. You might want to do a test rule for tomorrow so you don't have to wait a full week.

There is definitely something wrong with Rule machine and Sunset calculations.

Ignore the screen shot time, I’m interstate in a different time zone ATM. Anyway it’s 10:48am at my house, and Rule machine thinks it’s between 6:43pm and 6:45pm.

Sunrise seems to be working correctly.

Ps. I just upgraded to .127 and the issue is still present.

Actually looks like "between 6:45 PM and 6:43 PM," which is true every minute except 6:44 PM, so this rule appears to be evaluating things correctly as far as I can see from your screenshot. If you want the other behavior, as you presumably do, you should switch the position of these two times in your "between" for sunset.

1 Like

Ah right, doh :man_facepalming:

Cheers for the heads up.

Edit: thanks for that, totally user error on my part.

1 Like

The displayed values in parentheses never seem to change unless I actually edit the trigger and then click on save.

Regarding if the rule actually runs at the unexpected time or not, I will double check the scheduled job on the day of the week that it is set to run to see if it is the same cached time being reported in the parentheses or if it is the properly calculated time and will report back.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.