How to Trigger a Rule when a Hub Variable Changes

Trying to migrate from Legacy Rules to R5

I have a Global Variable - when it changes it pushes the content of the Global Variable out to a list of Alert screens and devices and after 5 minutes clears the message.

How do you replicate this in R5?

Because it appears that you cannot Trigger of a Variable Change .

This will stop me migrating most of my Legacy Rules to R5 as I use changes in Variables a lot to manage heating demand in every room.

So I will not be able to upgrade HE once Legacy Rules and Global Variables not longer supported. :frowning:

Define a connector tied to the variable, trigger on the connector. Connectors are devices and generate events, which are needed for triggers.


Going to try that now, I had thought that Devices (virtual) / Connectors could not store text, will know in a minute

Ok Hub Variable created Connector is a Device called Alert-Message and is a Type of Connector Variable.

What type of Device do I trigger off against?

There is no 'Connector Variable' type I can find.

Not a Switch, or Custom Attrib, Digital Switch, Water Sensor, or Temp Sensor,

Kinda running out of Trigger Devices to try.

Use custom attribute. The attribute is then variable. I think that is what you are wanting.



The Only attribute of a Variable Connector Device is a Custom Attribute Variable...


This is an improvement to Rules 4.....?

I can see some obvious enhancements for Rules 6 :slight_smile:

@terminal3 Thank you.

I may hold off migrating from 'Legacy Rules' to Rules 5 until Rules 6 is out or I will end up have to re-do them twice

Perhaps you should read through the link below by @bravenel it explains why Hub variables and the reasoning behind how they work. I personally don't see how using a connector makes it any less useful, just different.


I am always amused by questions that demand an answer that only have one answer.

In this case you have to select Custom Attribute then make another selection of the only attribute selectable, Variable.

Why not just have the Type Variable Connectors? Allow people to go straight to it.

If the ONLY attribute is the variable, it is not a Custom Attribute it is the default.

Not an obstacle but suspect the way this works will mature and become more standardised going forward, if you migrate to it now, you will have to do it again later.

Not a problem, I like the idea of Hub Variables and can see the benefits of just will wait until it is fully implemented and stable.

You also realize when you create a connector, use can make them a switch, lock, many different types of devices, or a variable. You obviously used variable which is a custom attribute, but for a decimal, number or boolean there are many other choices you could have used.

We just haven't gotten to it yet, because hadn't realized the need for it. It's not like you can't get to it. I will put it on the list of features to look at for the next release.


Add me to the list of a person that lives by the global variables in RM 4.0 being identified as changed to take actions, most are based on value changes vs. true/false or on/off thus virtual switches will not work. This is a breaking change for RM 5.0 and hub variables for me.

You can use them for triggers by using their Connectors. Is there some reason you don't want to have Connectors?

Oh I can use connectors. Just started to convert my old RM rooms/scenes management code over to RM 5.0 and hit it this yesterday. Spent about 30 minutes of free time and ran into this. Didn't have much downtime to think about using the connectors, just an additional steps.

I converted mine slowly over the course of 2-3 days a few weeks back.

Paused the old rule, created the new one and then once I actually confirmed it was working I later went back and officially deleted the paused original.

The variable connector is 2-3 extra clicks but overall I prefer the changes.

If anything my only real gripe is having to dig all the way into bowls of the hubitat settings menu every time I want to add or edit a hub variable but after having to do it 2-3 times I just made myself a bookmark to jump right to it.

I wasn’t really planning on re-writing all my rules for 5.0 originally but it did give me a chance to re-think and optimize some of my older rules that otherwise would have continued to go untouched.

After noticing how much cleaner I had rewritten the first 2-3 rules I kind of got excited and ended up just updating all of them whenever I had free time.

Any suggestions? It's got to be somewhere.

BTW, the approach I take to using the hub is to have a window open with many tabs to different things I'm working on. Hub Variables is one of them, Logs is another.

It just occurred to me recently because of this discussion, but one nice feature I have discovered about setting up a Global as a connector rather than just the variable is with cloning rules. Could have done this in earlier version, but it didn't occur to me.

For instance I have Rules setup to control my shades, each shade has a separate rule, but each rule is basically the same. The only difference being the shade and it's global that tracks it's currant position. So I would update one and when I got it working I would clone it for each shade. In cloning a rule, variables can't be replaced but connectors can, so after realizing this, once the rule was cloned I was done. No need to open up each rule and edit the variable to switch it to that shade's corresponding global.

Haha no, not really sorry!

I assumed you tucked it so far in there to keep it away from novice users accidentally messing with them or something but if I had to answer on the spot I’d say I would have expected it to just live on the bottom of the main menu near the apps/drivers code options.

One random thought that just came to me (probably a horrible idea) is I’d be curious to think through flipping the entire variables and connectors concept on its head altogether and think through what would happen if it was built into the existing “add virtual devices” flow.

I’ve been up working for over 31 hours straight so I doubt it even makes sense but if you created a variable as a new virtual device, gave it a name and selected some kind of “variable switch” driver… then you have everything you need right there similar to an existing ux flow people are used to… maybe?

haha I need sleep so just ignore me! :crazy_face: