How does one set a "parameter" via a global variable

Good day learned ones!

I have a need to be able to set a serial port address from an defined variable that I can input via a dashboard....

Particularly these bits (particularly the Port Address, More if possible....)


I am not sure whether it is possible, but any help would be awesome!


You might be able to set the port using an env variable but I dont think the other values can be set dynamically.

To use an env var in a config var, see Using environment variables : Node-RED

Thanks Steve,

I will go through it and give it a go!

Much appreciated!!


Where I am curious about is, what is the case between it? Maybe you can change your approach and instead of port select the serial device by ID. See /dev/serial/by-id in your linux machine.

Hi @EmilWesselink

I was previously using by-path, so it should work to use by-id - I just need to wrap my head around selecting this setting from a dashboard and seeing if it can be done...


No but if you want to change the input make a flow with a switch that looks to a global variable. And connect all devices on a seperate input node, but let the switch only pass the ones that are selected based on the value of the global variable.


Ah, got you! - in my "simple terms" - set up a bunch of "default" configuration serial nodes referring to usb0/usb1/usb2 etc and just limit/enable the comms to those nodes via "switch control" ..... that might just work for me!!


Edit: I would rather go the "port" route than by name/id - If I can remember, the name/id changes according to the hardware type installed - would make the maintenance a bit easier for me in the long run, especially with my "lightning strike" track history ATM...

1 Like

That is exactly why I asked you to give some more information about what en why you to achieve something. It can give people more insight to have a alternative solution. For me the id was the best solution because the device in was always the same, only the port changed sometimes.


Here's the "alternative solution" I have settled on, thanks for the pointer into this direction!


Depending on a global variable written to disk in the parameters, the switch nodes only allow writing to a particular usb port and reading from that same usb port....


If you only ever have one serial usb device plugged in the you could use a udev rule to map any serial device plugged in to a fixed virtual device to, for example, /dev/serial. Configure node red to use that device and it should work with any device. you might even be able to hot plug them, I am not sure.

Wont work for me.... Multiple devices, but might help someone else indeed!

But interestingly, regarding the hotplugging, I don't think it will... It seems that while an i/o can be pointed to the correct usb while "live", Node Red doesn't seem to pick it up until it is restarted with the device in place, or indeed, if node red is redeployed with a change to the usb config made to forcibly redeploy the port...

There probably is a setting/method that can be employed to rescan the ports without redeploying NR, but I will need to look around to see if I can find anything...


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.