Rule Machine Global Variables


#62

Bruce,

In RM 2.5, I'm finding that Global variables as trigger (in a triggered rule) do not work.
Rule:

This rule is not firing when the applicable GV changes to Home.


#63

You have to also set a global variable to activate the global variable package within the rules. So, put a placeholder variable in and set it to anything and the trigger will work. This is supposedly fixed in rule 3.0.


#64

Thanks. Not really sure what you mean here, but I might wait for RM3.0, as it will drop tomorrow (??).


#65

What I mean is that in order for a global variable to work as a trigger, you have to set a global variable somewhere in the action of the rule. I know it seems counterintuitive but that's what you've gotta do. It doesn't matter what variable you set. I created one called "placeholder" that I use for this purpose.


#66

It sounds as though there is a bug in 2.5. However, I'm not going to dig into it. Will confirm though that this works as expected in 3.0.


#67

I believe you already did @bravenel.


#68

@bravenel I'm going to +1 on being able to use GV for delays. LOVE RM 3.0 and everything you've already accomplished.

I was hoping to create some GV for delay times for raising shades seasonally (i.e. Spring, Summer, Winter, Fall -- longer and shorter days so time between sunrise and real-noon, for instance, changes. Rather than code a number of If-Then statements for each rule/device, I was hoping to set these delays once in a global variable that could easily be tweaked to update all my automations in one place.

The way I see this happening is validating for only a numeric GV to be entered in any of the three current delay input fields (either hour, minute, or seconds). A non-numeric GV could return ** bad value ** as you are currently doing for, let's say, when a GV text string or numeric value over 100 is attempted to be used as a dimmer set value.


#69

Understood. I will look at it as a possible enhancement.


#70

This isn't going to work for a number of reasons. The only way to do this would be to introduce something specific to delay based on a variable. I will look at that possibility.


#71

Thanks, Bruce! Appreciate your work and such a great product.


#72

@bravenel

Can a GV value be accessed from within an app or a driver? Or must we send the value through a custom action?


#73

They are only available within Rule Machine.


#74

Ahh Ok I was hoping something similar to this might be possible. No biggie though itll work the sending the custom action as well I think..


#75

Is there anyway to set a global variable to open weather attributes not listed as sensors such as cloudiness? have no issues with setting variables from temperature or humidity, however, attributes which are not common too many devices are not available in the select for sensor type when setting values in rules machine.


#76

as long as that attribute is exposed in the driver correctly you can use it as a action or a condition (depending on what it is obviously cloudiness can't be a action), so i suspect you need to reach out to the developer to ask the driver to be corrected. IE below


#77

thank you borris, it is for the Open Weather Map driver which I believe is a hubitat created / supported driver. haven't been able to find any way to set a global variable to the cloudiness value or implement as needed in a rule. you can select the virtual device created for the OpenWeatherMap driver along then with custom attributes to use in a rule conditions as you captured in your response, however, are limited to comparison operators of =,!=,contains, and changed. same goes for if attempting to use in action conditional actions. Possibly assigned as a string rather than numeric based on those operators and no ability to assign its value to a variable. will look for support of OpenWeatherMap driver.


#78

Not sure if i'm understanding you correctly but if i am you want want when a the driver "changes" its cloudiness value you want this to represent in a GV?

So what about a trigger for when custom attribute "changes" set GV X to ?


assuming this is where you got too?

If so it looks like your need to request it as a feature as it does not currently seem possible


#79

that's right where i'm at. have a trigger built already looking for changes in value. stuck here trying to extract value.


#80

tried to go a different route using a rule to assign a variable value based on ranges and can't make that happen either unless i get in the mood to create a boat load of conditional statements


#81

grabbed an api for apxi and added csteele's wx-ApiXU-Driver.groovy driver in. run into same issues. can't pull those custom attributes out when looking to assign their values.

Will be able to make a work around with the APXI driver cloud attribute as it's comparison operator selection contains the full list of operators. If statement with use of >,<,>=, and <= comparisons operators to create ranges.

Looks like the cloudiness attribute in the OpenWeatherMap driver may need a type reassignment and possible new functionality request to extract the custom attributes for assignment to global variables...unless i'm missing something yet