Rule Machine Global Variables


#42

@bravenel
Thank you for the response!


#43

@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.


#44

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


#45

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.


#46

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...


#47

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.


#48

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


#49

@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.


#50

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}'
 		}
 		main(["Value1"])
 		details(["Value1","Value2","Value3","Value4","Value5"])
 	}
 }
 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 mind...you 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.


#51

@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.


#52

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


#53

Seems to be testing the variable in the rule.


#54

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


#55

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


#56

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.


#57

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.


#58

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


#59

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


#60

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.