# Is there a dynamic way to set a nodes configuration node?

**URL:** <https://discourse.nodered.org/t/is-there-a-dynamic-way-to-set-a-nodes-configuration-node/53715>\
**Category:** General\
**Created:** [14 November 2021 12:52 UTC](https://discourse.nodered.org/t/is-there-a-dynamic-way-to-set-a-nodes-configuration-node/53715 "2021-11-14T12:52:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![erktrek](https://avatars.discourse-cdn.com/v4/letter/e/db5fbb/32.png) [@erktrek](https://discourse.nodered.org/u/erktrek)\
**Post date:** [14 November 2021 12:52 UTC](https://discourse.nodered.org/t/is-there-a-dynamic-way-to-set-a-nodes-configuration-node/53715/1 "2021-11-14T12:52:35Z")

</div>

I am using the excellent "node-red-contrib-hubitat" nodes for communicating with my home automation hubs. Each hub connection requires a config node which is to be expected. I would like to be able to dynamically change a certain node instance's config to different one before sending a message to it - is this possible?

Currently my workaround is having a bunch of subflows with big switch statements - while not ideal because things are hard-coded it works. My other thought would be forking the existing nodes to build in that capability but wanted to check with the community to see if there were an easier way. Do not really want to bear the burden of maintaining a whole separate bunch nodes when the existing ones work great.

Hope I am making sense here!

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [14 November 2021 20:04 UTC](https://discourse.nodered.org/t/is-there-a-dynamic-way-to-set-a-nodes-configuration-node/53715/2 "2021-11-14T20:04:12Z")

</div>

I may not be understanding fully what you mean, but here goes:

These _hubitat_ nodes want a configuration _node_ to set them up.

Why not get/use a `change` node that reads `flow.context` variables to set the desired values?

Something like this:

```auto
[{"id":"eb15546eb5e6683f","type":"inject","z":"65c9b63cb09879a0","name":"Signal to update/change variables in hubitat node","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"date","x":1410,"y":2430,"wires":[["2bb68fee1ebe7217"]]},{"id":"2bb68fee1ebe7217","type":"change","z":"65c9b63cb09879a0","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"something","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":1490,"y":2500,"wires":[["0d96704ecddcde1f"]]},{"id":"0d96704ecddcde1f","type":"debug","z":"65c9b63cb09879a0","name":"To hubitat node","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1690,"y":2500,"wires":[]}]

```

The `inject` node would be replaced with a signal indicating you want to update things.  
And the `debug` node is there only to look nice. 😉 But it goes to the `hubitat` node and sets what is to be changed.

---

<div class="post-metadata">

**Author:** ![erktrek](https://avatars.discourse-cdn.com/v4/letter/e/db5fbb/32.png) [@erktrek](https://discourse.nodered.org/u/erktrek)\
**Post date:** [15 November 2021 12:34 UTC](https://discourse.nodered.org/t/is-there-a-dynamic-way-to-set-a-nodes-configuration-node/53715/3 "2021-11-15T12:34:48Z")

</div>

> [@Trying\_to\_learn](#):
>
> ```auto
> [{"id":"eb15546eb5e6683f","type":"inject","z":"65c9b63cb09879a0","name":"Signal to update/change variables in hubitat node","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"date","x":1410,"y":2430,"wires":[["2bb68fee1ebe7217"]]},{"id":"2bb68fee1ebe7217","type":"change","z":"65c9b63cb09879a0","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"something","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":1490,"y":2500,"wires":[["0d96704ecddcde1f"]]},{"id":"0d96704ecddcde1f","type":"debug","z":"65c9b63cb09879a0","name":"To hubitat node","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1690,"y":2500,"wires":[]}]
> 
> ```

Thanks for your response! Yeah I might not have been clear about this.. The Hubitat "command" node for example requires me to set a certain config at deployment which points to a specific "hub" instance. This is locked in as far as I know. I can either select a device after selecting a config at deployment or pass a "msg.deviceId" to get a device that is tied to that hub/config. I cannot send a "msg.hubconfig" to select a hub which is a problem if you have multiple hubs like I do. I was looking for a run-time way of changing the particular node instance's config property..

edit: I may have to see about tweaking the nodes and submitting a pull request but am a little leery about jumping off the deep end of the pool in that regard.

---

<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:** [14 January 2022 12:34 UTC](https://discourse.nodered.org/t/is-there-a-dynamic-way-to-set-a-nodes-configuration-node/53715/4 "2022-01-14T12:34:58Z")

</div>

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