Rules not triggering with Sunrise/Sunset

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
    Else
          set to Evening.
     End-If
End-If

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

I think I found the issue over the weekend on this. I use the NTP device from @dan.t

And there was a version update that I never applied to my test device here at home which changed some of the parameters for how often the query to the time server was done and the drift before updating time. I my test device at home has a 1 minute drift and the one that I deployed had a 1 second interval.

Seeing that I decided to change the drift to a 1 minute interval and see what happens and so far Saturday night, Sunday, and now the A.M Monday everything from my original rule is firing just fine. It may be a coincidence but I going to let these setting sit for the week and see what happens. The NTP server that is running at that location is built into the Asus router and has been reliable for a couple of years now. Keeping fingers crossed.

1 Like

The NTP Client app fixed it for me a few months ago.

Looks like they uncovered some Sunrise/Sunset issues and updated in 2.2.3.132:

Added new calculated times for apps.

  • todaysSunrise
  • todaysSunset
  • tomorrowsSunrise
  • tomorrowsSunset
1 Like

I'm running into the exact same issue here, in that Time Between Sunrise and Sunset isn't resolving the way I expect it to. Are these calculated values that YOU created, or...?

Nope I am just using the internal time components in rule machine for sunrise/set. Since I updated and let the hub settle down for a day after I reported this issue the sunrise/sunset calculations have been working fine.

When you've got a moment, would you be willing to post a screenshot of how you reference these? The only reference I can find to those items all bring me back to your post here. I'm just seeing "Sunrise/Sunset" as my RM time options, unless I need to do something different.

Thanks!

The internal variables that I posted previously aren't directly exposed in rule machine but used when the condition's are evaluated from what I understand. Here is my rules. For the trigger events I used just sunrise/sunset with offsets.

That makes sense. For whatever reason, my HE seems to be updating the sunrise/sunset times immediately when the sunrise/sunset event occurs, then always referencing the new times in the rules.

My workaround was to create two new global variables in RM: todaysSunrise & todaysSunset. I have a rule that updates them each day, then use them in my rules. Works so far.

Have you looked at Mode Manager?

Yes but back last year with the C7 there were all sorts of time/sunrise/sunset issues that were finally resolved. I just never moved back to Mode manager because that Rule Machine rule was working. If it works why change :slight_smile:

2 Likes

Oddly I have only had a C7 and never had issues with Mode Manager but it's one of the great things with Hubitat is to have options.

Yes. But I can't get the "Earlier of two times/later of two times" time rules to work, The rule I finally implemented was:

IF (Time between 21:00 and 23:59) THEN
    Mode: Night
ELSE-IF (Time between 18:00 and 21:00 OR Time between sunsetToday and 21:00) THEN
    Mode: Evening
ELSE-IF (Time between 07:00 and 18:00 AND Time between sunriseToday and 18:00) THEN
    Mode: Day
ELSE-IF (Time between 05:00 and 07:00) THEN
    Mode: Early Morning
ELSE
    Mode: Late Night
END-IF