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

**URL:** <https://discourse.nodered.org/t/node-red-node-pi-gpiod-variable-as-host/83107>\
**Category:** General\
**Created:** [22 November 2023 19:01 UTC](https://discourse.nodered.org/t/node-red-node-pi-gpiod-variable-as-host/83107 "2023-11-22T19:01:15Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![kxkayser](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kxkayser/32/6301_2.png) [@kxkayser](https://discourse.nodered.org/u/kxkayser)\
**Post date:** [22 November 2023 19:01 UTC](https://discourse.nodered.org/t/node-red-node-pi-gpiod-variable-as-host/83107/1 "2023-11-22T19:01:15Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [22 November 2023 20:52 UTC](https://discourse.nodered.org/t/node-red-node-pi-gpiod-variable-as-host/83107/2 "2023-11-22T20:52:16Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![kxkayser](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kxkayser/32/6301_2.png) [@kxkayser](https://discourse.nodered.org/u/kxkayser)\
**Post date:** [22 November 2023 22:58 UTC](https://discourse.nodered.org/t/node-red-node-pi-gpiod-variable-as-host/83107/3 "2023-11-22T22:58:36Z")

</div>

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](mailto:kxkayser@gmail.com)

---

<div class="post-metadata">

**Author:** ![kxkayser](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kxkayser/32/6301_2.png) [@kxkayser](https://discourse.nodered.org/u/kxkayser)\
**Post date:** [23 November 2023 00:28 UTC](https://discourse.nodered.org/t/node-red-node-pi-gpiod-variable-as-host/83107/4 "2023-11-23T00:28:14Z")

</div>

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](mailto:kxkayser@gmail.com)

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [23 November 2023 07:04 UTC](https://discourse.nodered.org/t/node-red-node-pi-gpiod-variable-as-host/83107/5 "2023-11-23T07:04:25Z")

</div>

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 🙂

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [23 November 2023 09:10 UTC](https://discourse.nodered.org/t/node-red-node-pi-gpiod-variable-as-host/83107/6 "2023-11-23T09:10:12Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![kxkayser](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kxkayser/32/6301_2.png) [@kxkayser](https://discourse.nodered.org/u/kxkayser)\
**Post date:** [23 November 2023 16:10 UTC](https://discourse.nodered.org/t/node-red-node-pi-gpiod-variable-as-host/83107/7 "2023-11-23T16:10:32Z")

</div>

HI Dceejay,

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

Ken Kayser

Tobaccoville, NC

[kxkayser@gmail.com](mailto:kxkayser@gmail.com)

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [23 November 2023 18:19 UTC](https://discourse.nodered.org/t/node-red-node-pi-gpiod-variable-as-host/83107/8 "2023-11-23T18:19:41Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [7 December 2023 18:20 UTC](https://discourse.nodered.org/t/node-red-node-pi-gpiod-variable-as-host/83107/9 "2023-12-07T18:20:06Z")

</div>

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