Order of commands in rule machine

I have set up a "Bedtime" rule that turns some lights on, some lights off, changes to night mode, and then after a 5 minute delay turns some lights off. I trigger It my pressing a button on a Remotec remote in the Lounge. It works but there always seems to be quite a lag before any of the lights that I can see operate (several seconds). Having come from Vera, this always makes me question if the routine has run at all.

This has given me a few questions about rule machine in general.

What order do the actions in a rule take place? IE if I've picked 5 lights to switch on at the same time, are the commands sent simultaneously, or one at a time, and if so in what order?

Does rule machine wait for confirmation that an action has been performed before processing the next action?

Finally, I would really like to only change to Night mode after the 5 minute delay rather than instantly , but could not find a way to do that in a single rule. Any tips?

Thanks in advance

Yes, use two rules :smiley:

Rule Machine LOVES multiple Rules.

So, in my example, you would have a rule for the instant on/offs and another for the delayed offs and the mode change to Night, but both triggered by the same button press? I can see how that would work, but it doesn't seem very "elegant". Also if you wanted to change which button operated the rules, you've got to change it in 2 places. There seems to have been a lot of thought put into Hubitat, there must be a neater way of achieving what I want.

There is an order in which actions in RM take place, however generally speaking (with an exception*) it should not matter to the functioning of the rule. If you've selected 5 lights to turn on at the same time, RM will send 5 on commands in quick succession, one to each device. The order of those commands will be arbitrary.

RM does not wait for any confirmation that an action has taken place. For that matter, no app does, as there is no such mechanism in the platform at the app level. An app issues an On command, and moves on to whatever is next. That On command may not be the very next thing that actually occurs, depending on latency of the various technologies (i.e., Zigbee mesh, Z-Wave mesh, LAN, Cloud, etc.).

  • The exception is that setting of Private Boolean will always precede other rule-to-rule actions.
2 Likes

No, just put the second set of actions in a stand-alone Action, that has the delay in it. The first rule runs that Action as one of its actions. So some things happen right away (in the rule), and some stuff happens after a delay (in the separate Action).

That way, if you change the button that fires the whole thing, it works for both sets of actions.

Delays are sort of inherently not elegant in RM.

3 Likes

Thanks for the replies, I think I have a better understanding of this now.

I've re-written my rule and actually decided to split it into 3 new rules. The first rule just turns off the light I can see, so I get instant visual feedback. Then a 2 second delayed rule has all the other light actions, and the third is delayed 5 mins with the final commands and the change to Night mode. All these are then called by the original rule. This worked perfectly last night.

1 Like

If you had a moment, could you expand on this? I'm trying to decide whether to use RM, WebCore, or just hand-write apps. I'm finding RM fairly unexpressive, and I am trying to understand what I'm missing.

Not sure what you mean by this. What are you trying to accomplish? If you could describe a specific use case, I could describe how it would be accomplished in RM.

That'd be great! I have an example I will share tomorrow. But as a brief example, you mention delays being 'inherently inelegant' in RM. But delays are a really common part of a sophisticated set of behaviors in a controlled system, aren't they?

I don't remember what I meant by that comment. Delays work fine in RM. Complex multi-delay automations are possible, but entail multiple Actions to accomplish. WebCore is more like an interpreted high level programming language (sitting on top of an interpreted high level programming language), while RM is more a basic set of automation building blocks.

Perhaps I am failing to understand it in some crucial way. . . . thanks for your help. I'm down to try anything.

A number of other things make it very hard to use - here are a couple:

  • Deleting an associated object deletes the rule (what to do when I need to re-pair a device?)
  • Rule editing doesn't work (have to control-click, copy URL, open manually)

Contrast with a text editor or even WebCore's clunky web editor, where editing and saving are very clear.
Perhaps I'm missing something - I'd love for that to be the case!

It may be that my biggest failing is just thinking in RM's terms. You graciously offered to parse some examples. That's a huge way to make things make sense, and I'd love that!

Let's say I have a fairly simple case:

I want a switch (#1) to run 1 hour every 12 hours. Once it's been running for 5 minutes, if a thermometer shows a temperature below 80, turn on another switch (#2). If #2 is off, turn it off 5 minutes before the hour is complete, then turn off #1.

Then I want another:

If Button #B is pushed, regardless of the above, set the desired temperature (above) to 100, and run Switch #1 and Switch #2 until temperature is 100, or for 1 hour. Shut it down in the same way - #2, then five minutes later, #1.

This implements a pretty simple hot tub control. Constructing it in Rule Machine would require, as far as I can tell, a number of Actions and Rules, all separate and acting on each other. Sharing data between rules/actions/etc isn't easy, so this is quite hard.

These are odd. Are you saying that when you delete a device, the rule deletes? Doesn't happen on my hub. Never has under the previous RM or RM 2.5. Removing the device simply removes it from the rule.

Rule editing should definately work. Have you tried removing rule machine and reinstalling it. Perhaps your RM app is corrupt.

Yeah; deleting a device was the only way I had to delete a rule until I realized that control-clicking and copying the URL would allow editing (that hasn't worked, either).

I've deleted, and reinstalled, Rule Machine -

Version 2.5.1/2.5.7

Click the i in the blue circle to the right of the rule and then click "Remove app". That will delete the rule regardless of which device is configured in the rule already.

What are you talking about? How does deleting a device delete a rule? (It doesn't.)

You delete a rule by one of two methods: opening the rule (from the Apps page) and clicking Remove at the bottom, or opening the app detail page and clicking Remove at the bottom of that page.

Why are you control-clicking a url? There is no need to do that. It is not possible to copy rules or duplicate rules.

I'd love if it there were no need to do that, @bravenel . However, clicking without control-clicking simply opens the main Rule Machine installation. I'd be happy to send you a video if you'd like. I am not attempting to duplicate a rule by control clicking, but only to get at the URL associated with the link. This was great, because it let me actually edit and delete rules. Before that, it was fire-and-forget. This persists through deleting and reinstalling Rule Machine.

I'm sorry if hearing about this bothered you -- perhaps you are involved in building it. I'm a developer as well - in a dozen or so languages for a couple decades - and it's still hard to hear about bugs! I didn't mean to hurt your feelings. I'd love to find a way to make it work, and I look forward to learning more.

What you have to do is breakdown a complex scenario into pieces, and link the pieces together. I think the below does what you described above, if I understood it correctly.

The first part is a trigger:

Trigger event: Periodic, at hour 4 and hour 16 (or whatever)

Action: Turn on switch 1, delayed-off switch 1 in 60 minutes, Run action 2 in 5 minutes, set PB for rule 3 to false.

Action 2:

Set PB of rule 3 to true, delay off switch 2 in 50 minutes (5 minutes before switch 1 turns off). If switch 2 is off then, turning it off won't hurt.

This action enables checking the temperature (in Rule 3), and turns off switch-2 5 minutes before switch 1 turns off.

Rule 3:

Condition: Temp > virt temp-A
Rule: Temp > virt temp-A
Action for True: Turn on switch-2
Restriction: Disable with PB

This rule turns on switch-2 when the temp exceeds that of a virtual temp sensor. We use a virtual temp sensor so we can set it to 80 or to 100.

Trigger 4:

Trigger event: Button b pushed
Action: Set virt temp to 100, turn on switch 1 and 2, set PB for rule-5 to true, run action 6 in 55 minutes.

Pushing Button B changes the target temp to 100, turns on both switches and schedule the shutdown action in 55 minutes (which may run sooner if temp reaches 100)

Rule 5:
condition: temp >= 100
rule: temp >= 100
action for true: run action 6, set PB to false (resetting this rule so that it is activated only by Button B)
restriction: disable with PB

Action 6: (the shutdown action)

Turn off switch 2, delayed off switch 1 in 5 minutes.

There are no doubt other ways to accomplish the same steps. This is just what came to mind working through the steps you described in a linear way.

Another way to solve this problem is to write a simple app in Groovy. Call it the Hot Tub Manager. It would allow you to select Switch-1, Switch-2 and Button-B, the temperature settings of 80 and 100, and the times you want it to run.

Look at this:

You can open any rule by simply clicking on it. This is the Apps page. You don't open Rule Machine unless you want to install a new rule. If I click on AC Track, that will open that rule.

I am completely misunderstanding what you are describing. Perhaps you should post some screenshots of what you are talking about!

I am the developer of Rule Machine, and you couldn't possibly hurt my feelings by criticizing it or complaining about it, nor am I bothered by your comments. It's been kicked around quite a bit by lots of people. While it still may have a latent bug here or there lurking in corners, it is largely robust -- for what it is. I make no apologies for what it is, as it is the grand-daddy of rule engines in this space. CoRE and then webCoRE were implemented in its wake after I withdrew it from SmartThings in 2016.

Alas, @SmartHomePrimer, clicking the 'info' circle also just loaded the main Rule Machine panel. It did not allow removing individual rules, actions, or triggers.

Screenshot please!! What you are describing is not the functionality at all.

Please provide screenshot of Apps page.