Rules not triggering with Sunrise/Sunset

This is the latest hub I deployed and it's giving me all sorts of grief with rules that are around Sunrise / Sunset. First I tried mode manager and after a day anything that was related to Sunrise/Sunset wouldn't fire. I then disabled that app and went to rule machine and create this rule which is based on the same code I use at my home and working just fine.

It to worked for about a week and now it's no longer triggering. I have logging turned up for triggered events and actions.

The Day mode portion should have triggered at 7:10 AM and the logs show absolutely no trigger event happening at that time here are the logs between midnight at 8:00 am this morning:

[app:130](http://hubitat.vargofamily-mi/logs/past#app130)2020-08-22 08:28:01.353 am [info](http://hubitat.vargofamily-mi/installedapp/configure/130)Action: Cancel Delayed Actions

[app:130](http://hubitat.vargofamily-mi/logs/past#app130)2020-08-22 08:28:01.281 am [info](http://hubitat.vargofamily-mi/installedapp/configure/130)Wait over: Front Door Lock lock locked

[app:130](http://hubitat.vargofamily-mi/logs/past#app130)2020-08-22 08:28:01.273 am [info](http://hubitat.vargofamily-mi/installedapp/configure/130)Lock Door if Unlocked: Front Door Lock lock locked

[dev:105](http://hubitat.vargofamily-mi/logs/past#dev105)2020-08-22 08:28:01.189 am [info](http://hubitat.vargofamily-mi/device/edit/105)Front Door Lock was locked via command [digital][6:3]

[app:130](http://hubitat.vargofamily-mi/logs/past#app130)2020-08-22 08:27:58.148 am [info](http://hubitat.vargofamily-mi/installedapp/configure/130)Delay Over: Lock: Front Door Lock --> delayed: 1:00:00 (cancelable)

[dev:105](http://hubitat.vargofamily-mi/logs/past#dev105)2020-08-22 07:27:57.995 am [info](http://hubitat.vargofamily-mi/device/edit/105)Front Door Lock battery is 80%

[app:130](http://hubitat.vargofamily-mi/logs/past#app130)2020-08-22 07:27:57.986 am [info](http://hubitat.vargofamily-mi/installedapp/configure/130)Action: Wait for events: Front Door Lock locked --> timeout: 1:05:00

[app:130](http://hubitat.vargofamily-mi/logs/past#app130)2020-08-22 07:27:57.932 am [info](http://hubitat.vargofamily-mi/installedapp/configure/130)Action: Lock: Front Door Lock --> delayed: 1:00:00 (cancelable)

[app:130](http://hubitat.vargofamily-mi/logs/past#app130)2020-08-22 07:27:57.870 am [info](http://hubitat.vargofamily-mi/installedapp/configure/130)Lock Door if Unlocked: Front Door Lock lock unlocked

[dev:105](http://hubitat.vargofamily-mi/logs/past#dev105)2020-08-22 07:27:57.739 am [info](http://hubitat.vargofamily-mi/device/edit/105)Front Door Lock was manually unlocked [physical][6:2]

[dev:107](http://hubitat.vargofamily-mi/logs/past#dev107)2020-08-22 06:47:13.274 am [info](http://hubitat.vargofamily-mi/device/edit/107)Hub is 1598093233268 ms aka Sat Aug 22 06:47:13 EDT 2020

[dev:107](http://hubitat.vargofamily-mi/logs/past#dev107)2020-08-22 06:47:13.272 am [info](http://hubitat.vargofamily-mi/device/edit/107)NTP is 1598093231973 ms aka Sat Aug 22 06:47:11 EDT 2020

[dev:107](http://hubitat.vargofamily-mi/logs/past#dev107)2020-08-22 06:46:19.498 am [info](http://hubitat.vargofamily-mi/device/edit/107)Hub is 1598093179480 ms aka Sat Aug 22 06:46:19 EDT 2020

[dev:107](http://hubitat.vargofamily-mi/logs/past#dev107)2020-08-22 06:46:19.495 am [info](http://hubitat.vargofamily-mi/device/edit/107)NTP is 1598093178179 ms aka Sat Aug 22 06:46:18 EDT 2020

[dev:107](http://hubitat.vargofamily-mi/logs/past#dev107)2020-08-22 06:46:19.282 am [info](http://hubitat.vargofamily-mi/device/edit/107)Executing 'configure()'

[dev:107](http://hubitat.vargofamily-mi/logs/past#dev107)2020-08-22 12:36:04.262 am [info](http://hubitat.vargofamily-mi/device/edit/107)Hub is 1598070964243 ms aka Sat Aug 22 00:36:04 EDT 2020

[dev:107](http://hubitat.vargofamily-mi/logs/past#dev107)2020-08-22 12:36:04.260 am [info](http://hubitat.vargofamily-mi/device/edit/107)NTP is 1598070963347 ms aka Sat Aug 22 00:36:03 EDT 2020

I just converted the home from a SmartThings to a new C-7 Hub a week and a half ago and now this is happening. The owner isn't very happy and I haven't been able to reproduce it here in location on the C-4.

Poking around I keep seeing these pop up in the forums and fixes such as delete the rule/app reboot the hub and recreate the mode manager or rule. Well lets just say it's not working for me on this hub.

Here is a capture of the details of the rule and looking at the event subscriptions I do see sunrise/sunset subscriptions but the the cron jobs at the end only show the evening and 10:00 pm rules:

Any suggestions?

Is there something you are wanting to do here that you can't do with Mode Manager?

No and mode manager didn't work either at the beginning of my post:

" First I tried mode manager and after a day anything that was related to Sunrise/Sunset wouldn't fire."

Sorry totally missed that.

Are you seeing Sunrise and Sunset events in System Events?

Do you see correct Sunrise and Sunset times at the bottom of Settings, Locations? If not, do you have the correct latitude, longitude, and time zone set?

When you go to Apps, Mode Manager, gear in upper right corner, do you see Mode manager subscriptions to Sunrise and Sunset events? If you click the Events button that page, do you see Mode Manager cycling between the Day and Night modes?

Yes I am seeing sunrise sunset events and I attached the image of the location showing the right long/lat and time of sunrise/sunset. Here are a couple of screen shots of mode changes and you can see today there is a missing event. I had to run Day mode manually and evening mode never fired:

Here is the sunrise/sunset logs:

Your capture of the details of the rule is too small for me to read. Also, you didn’t answer my last paragraph of questions. Your rule seems to be setting Day, Night, Evening modes. The “out of the box” Mode Manager has its own idea of when to set those Modes. Did you delete the setting of those modes in Mode Manager (because you seem to be changing the modes yourself)? Just trying to figure out if your rule and Mode Manager are working at cross purposes.

I just posted the logs of sunrise/sunset and the mode changes. You can see that there is no mode changes for Evening yesterday and Day for today. The strange thing is one of the "Day" events happened in the PM?

Have you rebooted during the past 24 hours? The scheduling of Sunrise happens around midnight when the Hub phones home, and I believe it can take up to 24 hours to resynchronize if a reboot or restore causes confusion. In recent threads there is a discussion of that, I believe.

I think that’s why Mode Manager lets you update the mode, for just that situation.

This was a new hub I was deploying to replace a SmartThings deployment. I did most of the configuration here at my home configuring it like it was on premise. Then two Thursday's ago I deployed the hub and re-paired all the ZigBee/Zwave devices which went absolutely flawlessly, even the modes and other automations worked great. Then this week they confirmed that the lighting scenes I setup failed over the last day and remoted into the network to take a look at the logs and found everything I posted here. When I first setup using mode manager it ran for 2 days before it started to malfunction. That Saturday I removed mode manager and put in the rule machine code instead and that ran fine until Thursday this week.

Ok, now I understand. I will look at the rule again with that background.

All offsets with sunrise or sunset minus an amount of time get scheduled at the the previous day's events. So, if you have an event at Sunrise - 30, tomorrow's event gets scheduled at Sunrise today and today's event got scheduled yesterday. So, if you wrote the rule yesterday afternoon, there was no event to schedule.

So, I would wait at least a day and see if it works correctly on day 2.

Oh it's been more than a week. As stated I set this up two Thursdays ago and the put the rule machine version in last Saturday afternoon. Been running find until Thursday this week.

So, the rule worked on Wednesday and not on Thursday? Okay....what did you change/modify/do between Wednesday and Thursday?

Nothing changed. I put the rule in Saturday August 15 between noon and 1:00 pm because Mode manager failed to trigger properly after running for 2 days. It was running fine since the 15th then started to have issues Thursday Into Friday. On the 21st it did not register a Day event at Sunrise +30 but fired of a day event at 8:54 pm.

I didn't mean changes to this rule. I meant what other changes did you make on the hub at all between Wednesday and Thursday? Since it worked and then didn't, something had to change, right?

Also, you can avoid having multiple actions within your action by using a nested If/Then/Else condition instead of simplified conditions. I would have it set up as follows:

If NOT mode away THEN
     If time is between A and B 
          set to Night
    Else if time is between B and C
           set to day
          set to Evening.

That way you're not playing this -31, -30 game all the time. Makes it a lot easier to set up and avoids having none of the actions fire.

Also, how are you handing coming back from Away mode? You state to not make these changes if you're in away mode, but not how to handle returning. Did you go into away mode at all on Thursday?

No changes to the hub at all. This was a set and forget client hub that I moved off of a SmartThings hub to avoid the use the new app. I have 8 Hubitat installs that I have done at various locations and none of them have had this issue. Even my hub at home uses a like rule for mode changes. This is the first C-7 hub that I have deployed the others are C-4's and C-5's. I would say I am very good with knowing how rules are fired since I have been doing complex automations for home and business automation and orchestration 30 years now. I used to program PLC's at a steel plant :slight_smile:

I’ve gone round and round and get confused. May I suggest a simpler approach? 3 rules.

Rule 1: trigger: when Time is 10:00 pm
Action: Set Mode Night

Rule 2: trigger: Sunrise + 30 minutes
Action: Set Mode Day

Rule 3: trigger: Sunset - 30 minutes
Action: Set Mode Evening

1 Like

I use rules and not mode manager. I think it works more reliably, and I can set modes for different criteria than mode manager allows.

Yep, but is it on the same hardware (C-? vs. C-?) and same firmware version? Right now there are some growing pains with the C-7 and 2.2.3 firmware, which has many changes to support the C-7. With some of the issues, it’s hard to tell whether it’s the new firmware or what. This may be one of those times, which is why I suggested a very different approach. Your rule might work on your hub at home, just not the new one.

1 Like