Rule Machine Global Variables


Thank you for the response!


@bravenel, Are GV like rules - the more the merrier? Or are GV as per webcore, keep them limited?

I want to know if I can remove my virtual switches and convert them to GV's. Not dozens, but maybe 10.


There are no significant performance issues with RM global variables. You can create as many as you need.


Can you only use GV in conditions and triggers? I was going to use a number GV that was set depending on the mode. Then I was going to use this as the dimmer level or kelvin level of my lights. The idea being I could have a value and implement this in all the rules rather than repeating the same values. So if you want to change the kelvin you currently have for all your lights in a mode you only need to change one rule.


This is not possible at present. There has been another request to be able to use GVs for any numeric input. This idea, while it has some merit, is somewhat challenging in the implementation. I'm considering it...


Theoretically you could send the variable value in a web request that's pointed at the Maker API cloud endpoint of your device. It's not local but I think it is doable.


I figure I'd pass this along. At least with sharptools, ran into a work around to display a GV. I currently don't use the built in dashboard, so am not 100% sure if can display a chosen attribute for it to work here

then josh came up with a "cleaner" device to use here:

This solution also gave me a means of passing a GV from RM to ST


@bravenel could the global be made with a default value? IE bool already be true? Or a way to set them to value.

I have a trigger rule that have them as a condition of "true" and for true set it to false and false set to true.

So i then needed to do a temp rule to set them to a value.


There was a DTH for WebCoRE that Robin developed for a Value tile. Basically, all it did was stored data for display other places. You should be able to use an attribute tile and an HTTP request to the Maker API to set the attributes in the device. Haven't tried it yet but it should work, unless I'm missing something.

metadata {
 	definition (name: "webCoRE Value Ties", namespace: "SmartThings", author: "Robin Winbourne") {
 	capability "Actuator"
 	capability "Switch"
    attribute "Value1","string"
    attribute "Value2","string"
    attribute "Value3","string"
    attribute "Value4","string"
    attribute "Value5","string"
    command "changeValue1"
    command "changeValue2"
    command "changeValue3"
    command "changeValue4"
    command "changeValue5"
 	tiles {
 		valueTile("Value1", "device.Value1", width: 3, height: 1, canChangeBackground: true) {
 			state "default", label:'${currentValue}'
 		valueTile("Value2", "device.Value2", width: 3, height: 1) {
 			state "default", label:'${currentValue}'
 		valueTile("Value3", "device.Value3", width: 3, height: 1) {
 			state "default", label:'${currentValue}'
 		valueTile("Value4", "device.Value4", width: 3, height: 1) {
 			state "default", label:'${currentValue}'
 		valueTile("Value5", "device.Value5", width: 3, height: 1) {
 			state "default", label:'${currentValue}'
 def changeValue1 (param1) {
    sendEvent("name":"Value1", "value":param1)
 def changeValue2 (param2) {
    sendEvent("name":"Value2", "value":param2)
 def changeValue3 (param3) {
    sendEvent("name":"Value3", "value":param3)
 def changeValue4 (param4) {
    sendEvent("name":"Value4", "value":param4)
 def changeValue5 (param5) {
    sendEvent("name":"Value5", "value":param5)

EDIT: Never can't send an HTTP request to yourself. DUH! Sorry.
If we had the ability to set parameters for custom commands within the rule itself instead of just when defining the command, that might solve a lot of problems too. Just a thought.


@bravene i think there is a bug in global as conditions.

this seems to work fine and i can see the bool changing correctly

but it doesn't seem to actually update this rule.

so then only true happens to fire this

if i use switches instead it works so must be the globals not passing state.


Sorry, I'm not following what is wrong. Which is failing, setting the variable, or testing the variable in the rule?


Seems to be testing the variable in the rule.


Is the TRUE or FALSE displayed in the rule correct? It uses the same mechanism to make that display as when the rule runs.


No, but I just thought that was always wrong/ delayed, has that been fixed?


I can't find any problem with Boolean global variables being tested in a rule. Or with them being set by a rule.

I'm not sure what you are talking about. Starting with defining a condition, and later defining a rule, it will always show you the current truth of a condition or a rule. And when you open a rule it will show you the current truth. So yes, all of that has been fixed.


I thought I remembered that at some point there was stale data on it.

I'll try and do some more testing but it was working with a virtual switch but isn't when a Boolean global variable is used. I triggered the toggle rule and refreshed the global variable page and it was swapping from true to false correctly. But on the raise and lower rule is was sticking at true which was only lowering the lamp.


I have platform rev c-4. Is there a place for me to create and manipulate variables or is this not released yet?


It was released in 2.0.5. You need to update your hub platform software. Go to Settings/Check for Updates.


I have a similar problem with hue lights and swiches under control of the Hue hub. Hubitat does not see the change in status, if I turn the Hue lights on or off, using a Hue dimmer or Alexa. It only updates if directly controlled thru HE. Hue bulbs paired directly to HE (no Hue hub), update properly.


Hello @WBergmans, the closest I have gotten to getting around the HUE updating issues is by using the HUE Dimmers with Advanced Button Controller App and Groups and Scenes App. If you use the ABC app with the Hue Dimmer combines with scenes it will update hubitat as expected. Using groups will also update Hubitat as expected. This will also work using Alexa but need to control the group rather than the individual device. I can send you an example of how I have a room configured if you'd like. There are gaps / restrictions in functionality but it is working for my needs. The ABC app is fantastic, in my opinion, and drastically increases the Hue Dimmer functionality. The groups and scenes app has also helped with alexa and keeping devices states accurate. There are gaps in functionality but for the most part i've been able to meet the requirements i need. You can get around most issues with virtual switches / bulbs and rule / triggers just depends on how much a function is needed and how far down the rabbit hole you want to go with additional virtual devices and rules.