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.
def rules = RMUtils.getRuleList()
Is there an update to this to pickup up the new RM 5.0 rules?
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.
Thank you!
Thanks,
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.
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.
I don't know. That would take a lot of digging to find out.
minimum HE firmware version
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).
Thanks...I'll put 2.2.9 as the minimum.
Can we do this as save rules?
The "appLabel" parameter is passed and will appear in the log entry that the rule makes when it performs the action commanded. Typically, simply pass
app.label
, for the name of the app that is causing the action. This has no other function than logging.Example:
def rules = RMUtils.getRuleList() input "theseRules", "enum", title: "Select which rules to stop", options: rules RMUtils.sendAction(theseRules, "stopRuleAct", app.label)
Set Hub Variable
A Hub Variable can be set by an endpoint trigger. The format for the parameter is this:
/setHubVariable=varName:varString
The
varString
portion is assumed to be URL encoded, and is URL decoded before being stored into thevarName
Hub Variable.Set Global Variable
A Global Variable can be set by an endpoint trigger. The format for the parameter is this:
/setGlobalVariable=varName:varString
@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:
This is a brief introduction to how to use Hub Variables in user apps. Please note: expect for Variable Connectors to be phased out in favor of direct access to Hub Variables. Existing connectors will, of course, continue to work. But, the ability to create new ones will be deprecated at some point. Hub Variables Methods GlobalVariable (Object) getGlobalVar(String name) GlobalVariable: [name: xx, type: xx, value: xx, deviceId: xx, attribute: xx] Note: value is already cast to created dataā¦
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.
Would you kindly add this to the original post? Iāve been spinning my wheels on this for hours. 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