Node-red-node-pi-gpiod variable as host

Hi. I have been using node-red-node-pi-gpiod for years to control remote gpio pins. I have always hard coded the IP address of the target host. I want to use a variable (flow context) instead. However, I keep getting an ENOTFOUND error. Is this supported? perhaps I am not properly referencing the flow variable. Thanks.

I don't see anything in the node's readme that suggests that you can vary the ip address at run time.
You could use an environment variable, which would allow it to be configured in the system (or in settings.js) but this still does not allow it to change at run time.

Hi Colin,

Thanks for the reply. I don’t actually need to change it at run time. An environment variable would be OK. I just don’t want to hard code it in each node so if the IP eventually changes, I don’t need to modify each node (there about 20 of them). It would be fine to change it in an environment variable if and when it changes. I’ll give it a try. Don’t know why it wouldn’t resolve the flow variable though. Thanks again.

Ken Kayser

Tobaccoville, NC

kxkayser@gmail.com

Hello again Colin,

I tried an environment variable with the same results. It seems that the node cannot resolve variables regardless of the type. This is unfortunate as I will have to go on hard coding the ip address in all my nodes unless you have another suggestion. Thanks again

Ken Kayser

Tobaccoville, NC

kxkayser@gmail.com

Sometimes, I do a find and replace on the flows.json file when things like IP address change

Obviously not a dynamic solution but works well for things that are only needed once in while

With obvious caveat of making sure your have a backup 1st :slight_smile:

Can you show us an example of how you configured the node with the environment? It certainly should work. Eg ${serverip}.

HI Dceejay,

Using your syntax, it worked. Had tried several others that didn’t. Thanks so much.

Ken Kayser

Tobaccoville, NC

kxkayser@gmail.com

More complete info here
https://nodered.org/docs/user-guide/environment-variables

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