Hub vs. Local Variable Naming Preemption? [RM5.1] [.105]

While hunting down specifics on this recent Forum question about DateTime variables, I encountered two instances of preemption between same-named Hub Variables and RM Local vars (both named _TestDateTime). For reference:



Now, over in Rule Machine 5.1:

  1. In the Action > Variable > SetVariable > From Variable drop-down, only the Local version is offered …

  2. In the same way, only the Local variable appears in the Action > Variable > SetVariable > Set drop-down …

I'm reminded of a recent change to how Locals and Hubs are listed in RM (which is very helpful, btw), but didn't recall any overt mention about how Locals will "supercede" in this manner.

Is this anomalous or expected? Find another naming schema? Or just one of those pesky "Stop doing that!" moments, LOL?

I would expect that the scope of a local variable would override the scope of a Hub (née global) variable. Any other behavior could produce unexpected results. I believe that’s the way most languages handle this.

1 Like

Fully concur ... normally. However, now that Locals are segregated from Hubs in these contexts, it seems there is possibly room for the two to safely co-exist.

Food for thought, at least.

Don’t you believe that there would be an ambiguity in the displayed variable name in the Rule”s Action?

1 Like

True, true. Good point. Will avoid.

Just constantly surprised by my own internal consistency when it comes to naming things (even across weeks or years), LOL.

1 Like

Download the Hubitat app