Hub Variables / Global Variables Changing

I have a question about Hub variables (I imagine the answer to the question would be the same for Global Variables). To start let us say that I have created a Hub variable of the type string that is named "Color" it has three possible string values: Red, Yellow, Green. Every 30 minutes a rule triggers that updates the variable to one of these three values, it may or may not change the existing value. For example, if the existing value is Red, when the rule fires it may update the value to Red, Yellow, or Green.

Let us imagine the rule fires every 30 minutes as follows:
1:00 pm. set variable to Red
1:30 pm set variable to Yellow
2:00 pm set variable to Yellow
2:30 pm set variable to Yellow
3:00 pm set variable to Green
3:30 pm set variable to Yellow
4:00 pm set variable to Red

Now that I described all that, I will try to ask my question, lol. If I have a second rule that triggers to a change in the above variable that I called "Color", at what times would that rule trigger?

It is obvious that the rule would trigger when the initial variable gets updated to a different color, but would it also trigger if the variable gets updated from "Yellow" to "Yellow"

There is probably a way to force the change event from yellow to yellow, but Iā€™m thinking that the default behavior would be to not generate a change event for it.

1 Like

I agree.

The first time I have seen mention of forcing an event when something gets updated to the same value is with this switch driver. It has an option in the settings. Kinda cool.

Not for Hub Variables, or for their connectors. First of all, as the platform exists in release 2.2.8 there are no Hub Variable events. (There are pseudo events for Global Variables within the domain of Rule Machine Legacy.) So it is a moot point about state change. Nevertheless, for pretty much all devices including connectors, if they send an event that does not represent a state change, that event is discarded by the system, and won't trigger anything. The only exception to this is that a driver can force an event to be sent even when it is not a state change, but this is rare, and none of the standard drivers do this.

3 Likes

Yeah I got caught out by this when sending switch on commands to a virtual switch that I had forgotten to have switched off in between. The turning on of the switch was meant to trigger something and of course it didn't as the switch was already on.

Yeah, you can put an auto-off into a virtual switch you want to use this way.

1 Like