Rule Machine API

Hmmm, it does seem to be broken. Will investigate...

I assume then that what you mean by the above is "Create an endpoint URL in ANY rule, it doesn't matter which one, and that will have an access token you can use for getRuleList and setGlobalVariable". Is that correct?

Since getRuleList and setGlobalVariable have nothing to do with a specific rule, do you use the appid of the rule you got the token from, or the app id of Rule Manager itself for these two commands?

The rule with the endpoint has to exist. The API access is via that rule.

I just confirmed that setting a GV with this works.

Yes it does, but it also runs the rule. Is that intentional?

Is there a complimentary /getGlobalVariable? If not, can it be added?

If I try /getGlobalVariable I don't get an error but the rule runs.

Is there an update to this to pickup up the new RM 5.0 rules?

2 Likes

Yes, sorry that I haven't caught up with the documentation yet.

def rules50 = RMUtils.getRuleList('5.0')

and for actions:

RMUtils.sendAction(rule50abc, 'pauseRule', app.label, '5.0')

Defaults to Rule-4.1 when omitted.

4 Likes

Thank you!

Thanks,

Happy New Year Bruce. I'm adding RM5 support to my ABC app. Can you tell me what the minimum HE firmware version is needed for RMUtils to support version 5? I want to include this info in my changelog.

3 Likes

I don't know. That would take a lot of digging to find out.

If you want to play it safe, it was probably somewhere in 2.2.8, so maybe the latest in that series, 2.2.8.156, would be something to specify (it was definitely there before 2.2.9, given that the post was made on August 21 and 2.2.9 was released on October 7). :smiley:

3 Likes

Thanks...I'll put 2.2.9 as the minimum.

Can we do this as save rules?

@bravenel does the RMUtils API allow the setting of hub or global variables? I see you can set them via endpoint trigger but hoping the RMUtils API allows this as well. If so what is the syntax to pass the variable name and variable value?

If I take your example above would expect something like the following:

def rules = RMUtils.getRuleList()
input "theseRules", "enum", title: "Select which rules to stop", options: rules
RMUtils.sendAction(theseRules, "setHubVariable", "varName:varString")
RMUtils.sendAction(theseRules, "setGlobalVariable", "varName:varString")

I'm not sure about "legacy" global variables, but hub variables have their own API (this is no longer an RM-specific feature), and documentation on them can be found here for the time being:

3 Likes

Would you kindly add this to the original post? Iā€™ve been spinning my wheels on this for hours. :cry: It might help somebody else in the future.

Thank you.

I'd suggest just looking at the documentation (which has, indeed, since been updated) instead:

https://docs2.hubitat.com/apps/rule-machine#rule-machine-api

2 Likes