No Global Variables? Time to use Node-Red

Lots of users use Node Red. It’s a good system that has good OH integration.

I am an advanced user and I’ve not encountered a situation where I’ve needed a global variable. Honestly, I don’t even have that many dummy Items (I hate that term, there is nothing dummy or fake about these Items, they are just Items not linked to a device). As Russell asked, I too would be interested to understand more about the nature of the problem. Nothing can ever get fixed without more detail.

I find that most users that have this sort of experience with the Rules DSL have some experience with coding before coming to OH. To put it bluntly, you have to be willing to bend to the Rules DSL or you should use something else. Rules DSL will not bend to the way you want to do something. If you bend, I find it a relatively nice language to code Rules in. If you try to make it work like languages you are used to (though I’m not sure global variables are all that well supported in any modern language to be hionest) you will be unhappy.

Luckily there are at least half a dozen other options for you. If you want to stay within the OH ecosystem there’s JSR223 Rules which does support global variables I believe, at least in-so-far as Jython, JavaScript, or Groovy support them. There is NodeRed of course. @Spaceman_Spiff has developed his own Rules engine. I know there are plenty more options.

Depending on what you need the global variables for, you have lots of options in Rules DSL as well.

There are lots of options available. Each one is more or less appropriate based on what you want to use the global variable for.

I’m not trying to convince you or anyone not to use NodeRed. But I don’t want to leave statements like “no global vars” hanging out there for future readers to assume that there is no support for what they might want to do at all.

3 Likes