ioBroker / ioBroker.node-red

Instantiate the server with node-red
Apache License 2.0
52 stars 27 forks source link

Defining Environment Variables for NodeRed Process #323

Closed mickym2 closed 9 months ago

mickym2 commented 2 years ago

I need a variable in the adapter configuration to define environment variables for the whole NodeRed process in settings.js.

See here: https://nodered.org/docs/user-guide/environment-variables

For example: process.env.FOO='World';

A concrete need was necessary since the last update of the kernel update of the raspberry. So I tested it - and it works with defining environment variables in settings. js. The example was described in detail in German in this thread: https://forum.iobroker.net/topic/57283/ersatz-f%C3%BCr-vcgencmd-nach-raspberry-kernel-update

Apollon77 commented 2 years ago

The question is how to edit that ... needs some lists in the config

mickym2 commented 2 years ago

Why not just a string which is replaced by the variable - the user is self responsible to use the correct syntax - as the name of the variable and the value must be free.

Apollon77 commented 2 years ago

And then the next one comes and needs 3 env variables ;-))

mickym2 commented 2 years ago

But in a string you can put more than one in a line if separated by semicolon

Apollon77 commented 2 years ago

I think we can do that better in the ioBroker UI :-)

mickym2 commented 2 years ago

It must be just outside the module.exports section.

This works perfect - here my need:

image

mickym2 commented 2 years ago

I think we can do that better in the ioBroker UI :-)

I am not sure if this is working - I need this environment variable available when I execute a command in the exec Node. However I do not know if this is working or not when specified in the iobroker UI - it needs to be in the same process running that it can be accessed when I am running the exec node. So may be it needs to be tested - I can only say that in this way it is working.