Are variables 'static'?

Question,
Are variables statically defined, meaning if two rules are running at the same time and one rule modifies a variable – will the other rule see the change in value?

Thanks!

Internally we refer to variables as Global Variables as they are shared across the system including rules and dashboards. So yes, changes from rule A will be visible in rule B.

Can you share more details about what you’re trying to accomplish?

One ‘gotcha’ with this is when using a variable as both a trigger and top-level condition within the same rule. In that case, make sure to use Context Variables ($context.event.value), as it’s possible for the event to trigger the rule before the variable is completely updated in the database.

I have rules that trigger scenes at sunset (on) and at a certain time at night (off) and I also have other rules that once it detects those lights on does other actions (such as rotating colors). But I am running into a race condition where the rule to turn off the lights has run but the color rotating rule turns the lights back on. Trying to figure out how best to attack this. Could simply take the rotating lights out of the sunset rule and trigger on their own but pondering approaches.

Thanks!

So since these are global variables? Is there any plans on local variables, meaning variables that are only used inside the rule, much like how tasker handles variables?

It means it was something we thought about during the design of the current Variable implementation! :wink:

It was something I thought there would be interest in, but I hadn’t seen any feature requests for it, so we’ve focused on other highly requested features in the meantime.

1 Like