Rule Machine® Introduction

Is it possible to do a play track at a specific level when doing an action playing a URI track in ‘Control Music Player’ action? This is on Sonos. Ideally also play for specific duration would be perfect. Reason I ask is I’m copying over my good night piston from WebCoRE. In that I play a track with specific URI, set volume and set the piston to stop music after 2 hours

I'm fairly new to Hubitat and am just now setting up some rules in Rule Machine. I have a very basic question. What is the difference between switches to turn on or off after a delay
and switches to turn on or off after a delay, pending cancellation?

The on/off with cancellation means that if the rule truth changes during the delay period, the delayed action will be cancelled.

Suppose you want to turn off a light 2 minutes after motion stops, but not if motion is still active. Motion sensors may report inactive after 15 seconds. By using turn-off-after-a-delay-with-cancel, should the sensor report active again before the 2 minutes is up, it won't turn the light off. The next time the sensor reports inactive, the timer would start again. Only when it remains inactive for the full 2 minutes would the light turn off.

The other type of delay is just a simple delay. It's going to happen when the timer is up, irrespective.

Thanks for the explanation.

This thread has helped get me started. Is there a resource that will help me take a deeper dive into Rule Machine?

1 Like

There are several. A simple search will pull them up.

These really are helping me. I bookmarked them once I found them so I don't have to go searching for them again.

Then

I'm sure there are more, but i'm still figuring everything out and finding my way around my self.

Thanks for the suggestions. They were very helpful.

I finally wrapped my brain around the WC "stays" capability in RM (using the cancel capability). Now, I'm trying to figure out how to implement a WC piston in RM that uses a "changed in the last n minutes" condition. The logic is:

Something Happens
AND
Motion changed in the last 45 minutes
Then do it

Is there a way to do that in one triggered rule?

I think a rule with the Private Boolean of a trigger would work, e.g.

Rule 1
If motion, set Rule 2 PB TRUE
Delay 45 minutes, set FALSE Rule 2 PB [cancel]

Triggered Rule 2
Something happens
AND
Private Boolean TRUE
Then do it

Is there a simpler way?

1 Like

I had to do it with PB. My blinds trip my motion sensors. I actually need a rule and an "action". The trigger fires when the the blinds change setting the PB for the motion rule. It also runs an "action" that has within it a delay of a few seconds and setting the PB back to true. That's the only way that I'be been able to figure out how to do it.

1 Like

I think this would work, but you don't need a condition of PB true in the second rule. If PB is false, the rule will do nothing by default.

You do need to enable the PB restriction in the second rule though.

1 Like

When doing this I find it easier for my brain to just look at RULE1 in RULE2.

Rule 1
If motion
Delay 45 minutes[cancel]

Triggered Rule 2
Something happens
AND
RULE 1 TRUE
Then do it

That really makes no sense because rule 1 is true if motion is active. Your cancel only applies to the action. The rule is still true immediately. So, you don't accomplish anything by breaking it up. Basically, you would get the same functionality if they were in the same rule.

1 Like

Because the rule goes false as soon as motion stops right? It's just the actions that are delayed.

**edit...re-read....you said this already :rofl:

1 Like

Rule Machine allows arbitrarily complex rules to be defined, with parentheses used to group conditions into sub-rules. To use this feature of sub-rules in parentheses, you must first turn on the "Advanced Rule input" option, at the beginning of the Define Rule page........... I for the life of me can not find where I activate Advanced Rule Input. Please help.

Sorry, obsolete documentation. You no longer have to do that. Sub-rules are available on the Which Condition pull down menu:

the built in capabilities in hubitat are limited compared to rule mchine in smartthings.. where is the github for the full version of rule machine for hubitat..

thanks

??

You can only access what is built in. It is not an open source project.

You didn't even ask a question or give examples of what here, so I am not sure how we could even answer it.

I would start a new thread with what you are trying to do, what devices you are using, and see if people have suggestions.

2 Likes

Hubitat's Rule Machine is the Rule Machine that was originally written for ST. The founders got so tired of ST problems that they created their own hub. :slight_smile: However, it has undergone significant changes since then, perhaps the most notable being Rule 4.0, released about a year ago. (Another change is that it is now a closed-source part of the Hubitat platform. If the license for the old code allows, you could probably port it yourself, but I think you'll end up liking the latest Hubitat version better once you figure it out--as with the older versions, there is some learning to do.) If you mean webCoRE, that's an entirely different app, though a port is also maintained for Hubitat (some people used to have problems with it here and I probably wouldn't recommend starting there, but the current version seems to work well for most people).

I would echo the suggestion above to make a thread about a specific automation you are trying to create. Many people in the community, just like ST, are happy to assist. I'd also suggest reading the docs for the latest Rule version, which contain a lot of examples. And don't feel tempted to head straight for RM; Hubitat has lots of built-in apps designed to create common automations without the need to create your own rules (or apps). Best of luck!

3 Likes

RM Feature Request:

Ok, assuming I'm not missing something obvious (very possible), It would be great if there was an additional Trigger Mode called changed from [X] to [Y] in the RM, Simple Rules, and Notifications Apps.

This would be very useful for House Mode changes in particular - 2 scenarios that I would personally use this trigger mode in are as follows:

  1. Mode Changes from [Night] to [Home] - (or Day if you use that Mode) I currently use a fairly crude workaround (a time boundary) to implement actions when this happens, as this Mode change time happens later on the Weekend than it does on weekdays. eg

  1. Mode Changes from [Away] to [Home] - (or Day if you use that Mode) I'd like to be more precise in the way I send Notifications for Mode changes. eg I don't care about [Night] to [Home], but I do like notifications that the [Home] to [Away] and vice versa changes are taking place. This more of a change to the Notifications App than RM, but worth mentioning as I would use this changed from [X] to [Y] trigger a lot in it too.

There are already some things that have a changed to type state (eg XYZ Presence "Arrives") but I think adding the ability to use precise "changed from to" triggers would add even more power to an already powerful rule ecosystem.

It might, (and I could be talking out of my hat here), even make rules, like my Mode change eg above, use less overheads due to a reduction in rule complexity.

I want to say this has been talked about. From what I remember someone suggested setting up a rule that looks like this

Trigger: Mode Changes
Action:
Set Global Variable to Mode -> Delay 5 min

The way the global variable would be whatever the last mode was for 5 min. This is also a bit crude.

What I do is I have a rule for setting the house to HOME from SLEEP and a rule for setting the house to HOME from AWAY. Both of these rules pause themselves when done.

When I enter Sleep or Home I resume the rule that will be needed