Parameters page and how to store them

Hi All
I need to setup a parameters page, that will hold information about room names and alarm text. These will be used as settings for tags in an influxdb database, and also for text on buttons.

I need some advise as the best approach to this, as the setting will have to be retained or reloaded during a power failure or restart. They will also have to be available across all flows.

The two ways I can think of are in a database or using global variables.

The parameters page will just allow the above to be changed when required.

Please could some of you with far more experience than myself, point me in the most efficient way to do this.

Thanks Laurie

It depends. You could do either. I see no reason to favour one other the other - unless, the database is only for parameters. If the database would exist only for parameters then I consider that unnecessary overhead and an unnecessary failure point.

There is a file backed key store node in the palette you can install. That would permit you to input & update parameters via dashboard and they will persist. Alternatively, you can enable file backed flow/global context.

Personally, unless you know that you will be needing to get either really complex or really fast, maybe multi-user, I would keep it simple and use the persistent global variables. By chosing an object definition that lets you key off a suitable ID in each case. For example, for your devices:

    "DEVICE001": {
        "name": "DEVICE001".
        "location": "Lounge"

And similar for locations. Those are much easier to use than an array for example since you can always do varName[myid] to get the exact entry you want. It is still easy to walk the whole object with Object.keys(vaName) which returns an array.

The only real downside of this approach in my view - at least for fairly small setups such as I'd expect in most homes - if the lack of event handling. It would be great if we could get events attached to global variables so that you could trigger a flow when one changes for example. However, this is easily simulated in Node-RED. For example, set up a receiving link node that triggers a flow and use sending link nodes wherever you might update the variable.

I have a number of these types of flow and variable in my own setup.

Thanks guys for the advise. I did not think the global variables were persistent ?

Do you have any example flows that you guys use that I can see to get started with.


There is also the option of storing in retained topics in MQTT, then you automatically get notification on change and on startup and even the ability to access from multiple node-red instances if that is required.

1 Like