I have just moved about 200 devices over from Smartthings and the Rule Machine is frustrating me to no end. I just need to set up a few rules that were very intuitive in Smartthings. Here is what I want to do. I have Hubitat set to go into away mode and lock all doors upon departure based on presence. I am trying to build a simple rule that Unlocks a certain door when the system goes from Away mode to Day mode. It seems like it should be easy but nothing that I have tried works. What I am looking for are rules that look like this:
If in Away mode and changes to Day mode Unlock Mudroom door.
I also want a rule that looks like this
If in Night mode and changes to Day mode turn off Hue Bloom and Hue LED Strip.
Please help, I am extremely frustrated over my inability to generate such simple rules.
I do something similar — do something if the mode changes only if it was a particular mode before — using virtual switches. You'd maybe need two switches: one for away and one for night. Something like this might get you started.
IF Mode is Away THEN
On: Away Switch
ELSE-IF Mode is Night THEN
On: Night Switch
ELSE-IF Mode is Day THEN
If Away Switch is On THEN
Unlock Mudroom door
Off: Away Switch
ELSE-IF Night Switch is On THEN
Off: Hue Bloom, Hue LED Strip
Off: Night Switch
Thanks Carl. I am changing the mode with presence. All of that is working. Honestly, I just can't figure out how to write the rule in rules machine. I have read the documentation but it still isn't clear how to get the rule. I am about ready to try Sharptools but would prefer to stay away from a cloud solution.
Okay, I tried the switch route and here is what I have so far. It still doesn't work. When I said that I can't figure it out, I meant that using Rule Machine to write rules is not intuitive. I will catch on but I come from Smartthings and Iris before that. Those systems are/were pretty intuitive.
In order for the rule to work this way the ELSE-IF would need to be ELSE-IF (Mode is Day AND Switch Away is ON). You wouldn't need the IF (Switch Away is off) in this case.
I think it would be easier with a local variable but that is just personal preference. Either way will work. There are multiple ways to do almost everything. You just need to find out what makes sense to you and run with it.
It definitely takes some getting used to the RM interface especially when your trying to add a section in the middle of a complex rule and have to keep finding where the next line needs to go since it won't keep inserting in the middle.
The reason I think it's easier to use a variable here is twofold.
You don't need to create/manage the virtual switch
You will need to manipulate the virtual switch whenever the mode changes from Away. If you fail/forget to do that in another rule this rule will not work properly. If Mode goes from Away to Night for example and you don't have a rule to catch that.
If you were to capture the previous Mode in a Global variable, I used a Local variable in my example, you could use that in other rules as well.
Here is what I have so far. Still doesn't work and it is not turning the switch on and off or unlocking the door. At least I am learning. I have to run out for a while so any more attempts at this will be later tonight.
One problem you might find with your rule is that you turn Switch Away off, and then have an IF statement to check to see if it's off. That IF will always be true. You probably want ti check to see if it's ON rather than OFF, and then set it off after the IF. I think you want something more like this. You should also get in the habit of always closing your IFs with END-IFs. If there are no statements following, the END-IFs aren't strictly needed. But they keep things neat and tidy and make the rule easier to read. If anything outside of the condition follows an IF, then you absolutely need the END-IF for the rule to execute correctly.
Mode becomes *changed*
IF Mode is Away THEN
On: Switch Away
ELSE-IF Mode is Day THEN
If Switch Away is On THEN
Unlock Deadbolt Mudroom Door
Off: Switch Away
On the virtual switch vs variable debate... I use virtual switches because I've found that they're handy to use in other rules or apps. For example, I can use a routine in Alexa to trigger a mode (i.e. "Alexa good night"), I can use an Away switch in Mode Manager to trigger a mode, or in Motion Lighting to keep a light on/off even if there's motion. I can also refer to them in other rules. You can use local variables only in the rule they are a part of, and that works fine if you don't need the information that switch carries anywhere else. There are global variables in RM also that can be used in multiple rules. Global variables cannot be used outside of RM. And, they may slow your rule down because, as I understand it, they have to call the parent RM app rather than staying local within the rule.
Of course, this is just my preference. There are many ways to skin this cat, and any of them will work fine. It just depends on what your use case is.
I used to have one gigantic rule that did absolutely everything anytime a mode changed. It was very complex and long, and editing it was not only a real hassle, it was really slow. I broke it up into one rule for each mode, and that's worked great. But for a relatively simple rule like this one, you should be fine including more than one mode, like I did in the first example I posted above.