This may just be me misunderstanding how rules work, but I’m several of my condition-based rules aren’t firing.
I have several time-of-day based rules: “It’s morning”, “It’s day”, etc. These are rules with time conditions and no actions, they just indicate a state. (Basically like modes.)
I have rules that should fire when these are true. Like, I want to turn on my back porch light when “It’s evening” is true.
My understanding is that this should work. When the time is right, “It’s evening” becomes true, and my back porch rule that has it as a condition should fire. Unfortunately, that’s not happening. If I open the “back porch light” rule, I can see that the “It’s evening” rule has become true. If I click “Done” in the “back porch light rule”, it sees that “It’s evening” is true and turns on the back porch light.
So, from the manual it sounds like rules that are based on conditions should be evaluated, and potentially fire actions, when those conditions change. Is that not the case? Should I be using the “It’s evening” rule as a trigger rather than just as a condition for the “back porch light” rule?
I had an issue like this back when I first installed and started using RM. The next update broke it. I uninstalled RM, reinstalled it and resetup my rules. After that, everything worked perfectly. Not sure where the problem was. But that did fix my issues.
I have one rule that is setup similar, its called Night from 10pm to 4am and this set the Mode for Night when True and Back to Home/Day when False.
I only use that rule to setup Night and back to Home
I have another rule that says when its in Night mode allow the doors to beep once when opened when only in that mode.
So tonight, some time after it was “evening” I noticed that the “Good evening” rule hadn’t fired. I opened up the “It’s evening” rule and could see that its state was TRUE, and I opened the “Good evening” rule and noted that it was also showing “It’s evening” as being TRUE. I clicked the “Done” button in “Good evening”, at which point the rule immediately fired and lights came on. I’ve noted this multiple other times over the last couple of days (where a rule doesn’t fire, but if I open it and click the “Done” button it does).
In your evening rule you define the times but when true is there a reason your action is not set for when True go to Evening mode?
Select Actions for True - Evening
I specifically tell mine to go to the mode I want it to be in when change to Night mode. Maybe that is what is causing it not to change over
I did mine with a rule to change to the mode I want
Then I did a trigger so when that mode is met it changes. Possibly this could be the issue as well.
I’m sure there are several ways to make this work
My understanding is that I shouldn't need to set anything with the rule; "rule truth" is a condition that can be used in other rules. I could see setting the rule's private boolean, but from the manual it's not clear that doing so is necessary.
The other reason I don't (currently) use mode for time based things is that there's only one mode variable, and presence seems to have priority there. (That always seemed like a weird deficiency in ST, and I was surprised that it carried over into Hubitat.)
I could use a virtual switch to hold state. That would be fine, and I use that model on ST for some things. It just seemed like it might not be necessary with RM. Basically, the “rule truth” condition seems like a way to use a rule as a dynamically computed global variable.
@jason0x43 not familiar with truth rules, but I have three modes setup like ST did home, away and night and use the rules to set them and then have triggers that run only in those modes.
That would work, and having a global "time of day" variable does seem like the logical way to go. The issue is that I also want to have "home" and "away" modes, and I don't want those to be exclusive. Like, I want lights to come on at night even when I'm not at home.
That's certainly also a valid way to go, and I do that for some of my lights. I have groups of lights, though, like a bunch of them on the ground floor, that I want to do things at the same time (like, all come on in the morning at a certain color temp, all turn off when its "day", and all turn back on in the evening at a warmer shade). I could program them all individually to do things at different times, but that would be kind of a pain.
I any case, I’m not really saying the way I’m doing things is the best way, or that other ways aren’t as good. I’m just trying to explore whats possible and understand the constraints of the system. (Because apparently I don’t understand how some parts of it work, or something’s broken.)
@jason0x43 yeah i understand, as mentioned more than one way to do things so I’m sure someone else might have the magic. I have a pretty simple setup so going into it just configued as my ST was as it worked. Hopefully it’s something simple.
I’ve been using CoRE and webCoRE for a while now on ST, and thought it’d be fun to re-implement things in RM when I was setting up my Hubitat. I was using some webCoRE features that RM doesn’t directly support, like “global” variables, so my setup there doesn’t port directly over.
It’s been interesting coming up with equivalent ways of doing things. I like RM’s comparative simplicity; it gives you some basic building blocks that you can do most anything with (at least it seems that way so far), while keeping the overall system pretty easy to reason about (barring my apparent inability to reason about what’s going on with my breaking rules).
OK, a couple of things: You are right that it should work the way you have it. The reason something happens when you click Done in the rule is that forces an evaluation of the rule. Since the rule is true, clicking done will cause the Actions for True to happen.
I'm going to try something similar, and see if I can reproduce what you're seeing.
Remember this key point, rule truth must change for a rule to do anything. Based on what you showed above, that should be happening in both rules. First, the time hits sunset - 60 and first rule becomes true. Assuming second rule was false prior to that, it should change to true and do it's true action. Then when it's 11:00 pm, the opposite should occur. The first rule will become false, and that should cause the second rule to become false. Nothing will happen at 11 pm as there are no Actions for False in either rule. But the rule truth of both should now be false, so the next day at sunset-60 it should all work.
Like I said, I will check it out and see if something is messed up in RM or not.
That's what I was thinking. When "It's evening" becomes true, the state change should cause any rules that depend on it to be evaluated.
Hmmm... the only condition for "Good evening" is the rule truth of "It's evening" -- is there a way "Good evening" could be true when "It's evening" is false?
I can confirm that there is a bug somewhere. Now to dig it out. It appears that the second rule is firing it’s true action when the first rule goes false, which is obviously wrong.
This bug has been identified and fixed, should be in the next release.
This one was very interesting. Turns out that the code worked fine in ST, but not in Hubitat. In Hubitat there was a race condition caused due to our multi-threaded architecture. Solution was quite simple.