# How to set a node input in the subflow?

**URL:** https://discourse.nodered.org/t/how-to-set-a-node-input-in-the-subflow/40833
**Category:** General
**Created:** [11 February 2021 17:50 UTC](https://discourse.nodered.org/t/how-to-set-a-node-input-in-the-subflow/40833 "2021-02-11T17:50:43Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![fmarzocca](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fmarzocca/32/35901_2.png) [@fmarzocca](https://discourse.nodered.org/u/fmarzocca)
#### Post date: [11 February 2021 17:50 UTC](https://discourse.nodered.org/t/how-to-set-a-node-input-in-the-subflow/40833/1 "2021-02-11T17:50:43Z")

</div>

I am willing to include in my subflow a node which requires to set a value in its configuration (node HUE in). Am I allowed to do that? How can I set programmatically the Light ID required by the node (see screenshot) or at least repositioning the input variable on the subflow input?  
 ![Schermata 2021-02-11 alle 18.46.57](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/f/3f141dc341803df2bbcb87d008bb03f7e7caca61.png)

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [11 February 2021 18:36 UTC](https://discourse.nodered.org/t/how-to-set-a-node-input-in-the-subflow/40833/2 "2021-02-11T18:36:20Z")

</div>

Does the built in help say you can send the light id in a msg parameter?

---

<div class="post-metadata">

### Author: ![fmarzocca](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fmarzocca/32/35901_2.png) [@fmarzocca](https://discourse.nodered.org/u/fmarzocca)
#### Post date: [11 February 2021 18:55 UTC](https://discourse.nodered.org/t/how-to-set-a-node-input-in-the-subflow/40833/3 "2021-02-11T18:55:50Z")

</div>

Unfortunately no...

- Sent from my mobile phone. Sorry for typos -

---

<div class="post-metadata">

### Author: ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)
#### Post date: [11 February 2021 19:43 UTC](https://discourse.nodered.org/t/how-to-set-a-node-input-in-the-subflow/40833/4 "2021-02-11T19:43:15Z")

</div>

Hi @fmarzocca

do you mean you'd like the light id property to be exposed as a property of the subflow node? So you can customise the light id of individual instances of the subflow?

If so, you can use subflow properties to do that.

1. set the light id field to `${LIGHT_ID}`
2. edit your subflow properties and under the Environment Variables section, add a new property called `LIGHT_ID`

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/7/a7c3a24946f520688c3c4eb3b90453d04b332a41.png)

When you edit an instance of your subflow you should now have a LIGHT\_ID field you can enter a value into. That will get passed to the hue node inside the subflow when it is started.

If you click the `>` arrow next to the property in the screenshot above, you can customise the label and icon of the field as it will get displayed when editing instances of the subflow.

---

<div class="post-metadata">

### Author: ![fmarzocca](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fmarzocca/32/35901_2.png) [@fmarzocca](https://discourse.nodered.org/u/fmarzocca)
#### Post date: [11 February 2021 20:42 UTC](https://discourse.nodered.org/t/how-to-set-a-node-input-in-the-subflow/40833/5 "2021-02-11T20:42:26Z")

</div>

Great!  
Thank you Nick!

Fabio

---

<div class="post-metadata">

### Author: ![fmarzocca](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fmarzocca/32/35901_2.png) [@fmarzocca](https://discourse.nodered.org/u/fmarzocca)
#### Post date: [11 February 2021 21:10 UTC](https://discourse.nodered.org/t/how-to-set-a-node-input-in-the-subflow/40833/6 "2021-02-11T21:10:10Z")

</div>

Nope, it doesn't work. It seems that the hue node dosen't inherit the field...

---

<div class="post-metadata">

### Author: ![fmarzocca](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fmarzocca/32/35901_2.png) [@fmarzocca](https://discourse.nodered.org/u/fmarzocca)
#### Post date: [11 February 2021 21:18 UTC](https://discourse.nodered.org/t/how-to-set-a-node-input-in-the-subflow/40833/7 "2021-02-11T21:18:57Z")

</div>

@knolleary  
This is the not-working subflow:

```auto
[{"id":"2fd3c0ca.54355","type":"subflow","name":"Toggle Hue","info":"","category":"LilioHome","in":[{"x":50,"y":30,"wires":[{"id":"b3c3be6a.468a8"}]}],"out":[],"env":[{"name":"LIGHT_ID","type":"num","value":"","ui":{"icon":"font-awesome/fa-lightbulb-o","label":{"en-US":"LIGHT ID"}}},{"name":"HEX_COLOR","type":"str","value":""},{"name":"BRIGHTNESS","type":"num","value":""}],"color":"#C7E9C0","icon":"node-red/light.svg","status":{"x":740,"y":180,"wires":[{"id":"80d4b0b0.3d56d","port":0}]}},{"id":"b3c3be6a.468a8","type":"function","z":"2fd3c0ca.54355","name":"toggle HUE","func":"var hue_state = !flow.get(\"hue\");\n\nmsg.payload = {\n \"on\": hue_state,\n \"bri\": 100\n}\n\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":190,"y":60,"wires":[["1ed97502.c5858b"]]},{"id":"1ed97502.c5858b","type":"node-hue-in","z":"2fd3c0ca.54355","server":"ef95c758.c60bb8","lightID":"${LIGHT_ID}","name":"","x":390,"y":60,"wires":[]},{"id":"80d4b0b0.3d56d","type":"status","z":"2fd3c0ca.54355","name":"","scope":null,"x":610,"y":180,"wires":[[]]},{"id":"2c5a631.7deee9c","type":"node-hue-out","z":"2fd3c0ca.54355","server":"ef95c758.c60bb8","lightID":"${LIGHT_ID}","name":"","x":170,"y":240,"wires":[["6d4caa58.4d5014"]]},{"id":"6d4caa58.4d5014","type":"function","z":"2fd3c0ca.54355","name":"state hue","func":"\nflow.set(\"hue\", msg.payload.on);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":320,"y":240,"wires":[[]]},{"id":"ef95c758.c60bb8","type":"node-hue-bridge","name":"Hue Bridge","address":"10.0.0.240","key":"nyDsJfhHnQVvgC9OKuDxZCedGfGAMvBNDFIHIMSA","interval":"1000"}]

```

---

<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: [11 February 2021 21:27 UTC](https://discourse.nodered.org/t/how-to-set-a-node-input-in-the-subflow/40833/8 "2021-02-11T21:27:41Z")

</div>

Can you post the actual use of it that isn't working?

---

<div class="post-metadata">

### Author: ![fmarzocca](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fmarzocca/32/35901_2.png) [@fmarzocca](https://discourse.nodered.org/u/fmarzocca)
#### Post date: [11 February 2021 21:38 UTC](https://discourse.nodered.org/t/how-to-set-a-node-input-in-the-subflow/40833/9 "2021-02-11T21:38:02Z")

</div>

Just deploy a subflow instance, set the hue light ID and inject a timestamp. The light should switch on and off toggling) at each message. But the hue-node does not light up the light.  
I tested the hue-node separately, bu entering the Light ID, and it works.  
It seems to me that the LIGHT ID is not inheriting into the subflow's hue node.

---

<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: [11 February 2021 21:40 UTC](https://discourse.nodered.org/t/how-to-set-a-node-input-in-the-subflow/40833/10 "2021-02-11T21:40:52Z")

</div>

I can't test it, as I haven't got the hardware. Could you export an example of its use please, I can examine the flow to make sure it looks ok.

Also please export an example of the hue node with the id filled in.

> [@fmarzocca](#):
>
> It seems to me that the LIGHT ID is not inheriting into the subflow's hue node.

That shouldn't be possible as node-red fills it in when it deploys.

Edit: Also which exact node type are you using, there seem to be several contrib hue nodes. [Library - Node-RED](https://flows.nodered.org/search?term=hue&type=node&page=1)

---

<div class="post-metadata">

### Author: ![fmarzocca](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fmarzocca/32/35901_2.png) [@fmarzocca](https://discourse.nodered.org/u/fmarzocca)
#### Post date: [11 February 2021 21:49 UTC](https://discourse.nodered.org/t/how-to-set-a-node-input-in-the-subflow/40833/11 "2021-02-11T21:49:27Z")

</div>

This is an example of subflow's use:

```auto
[{"id":"2fd3c0ca.54355","type":"subflow","name":"Toggle Hue","info":"","category":"","in":[{"x":50,"y":30,"wires":[{"id":"b3c3be6a.468a8"}]}],"out":[],"env":[{"name":"LIGHT_ID","type":"num","value":"","ui":{"icon":"font-awesome/fa-lightbulb-o","label":{"en-US":"LIGHT ID"}}},{"name":"HEX_COLOR","type":"str","value":""},{"name":"BRIGHTNESS","type":"num","value":""}],"color":"#C7E9C0","icon":"node-red/light.svg","status":{"x":740,"y":180,"wires":[{"id":"80d4b0b0.3d56d","port":0}]}},{"id":"b3c3be6a.468a8","type":"function","z":"2fd3c0ca.54355","name":"toggle HUE","func":"var hue_state = !flow.get(\"hue\");\n\nmsg.payload = {\n \"on\": hue_state,\n \"bri\": 100\n}\n\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":190,"y":60,"wires":[["1ed97502.c5858b"]]},{"id":"1ed97502.c5858b","type":"node-hue-in","z":"2fd3c0ca.54355","server":"ef95c758.c60bb8","lightID":"${LIGHT_ID}","name":"","x":390,"y":60,"wires":[]},{"id":"80d4b0b0.3d56d","type":"status","z":"2fd3c0ca.54355","name":"","scope":null,"x":610,"y":180,"wires":[[]]},{"id":"2c5a631.7deee9c","type":"node-hue-out","z":"2fd3c0ca.54355","server":"ef95c758.c60bb8","lightID":"${LIGHT_ID}","name":"","x":170,"y":240,"wires":[["6d4caa58.4d5014"]]},{"id":"6d4caa58.4d5014","type":"function","z":"2fd3c0ca.54355","name":"state hue","func":"\nflow.set(\"hue\", msg.payload.on);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":320,"y":240,"wires":[[]]},{"id":"ef95c758.c60bb8","type":"node-hue-bridge","name":"Hue Bridge","address":"10.0.0.240","key":"nyDsJfhHnQVvgC9OKuDxZCedGfGAMvBNDFIHIMSA","interval":"1000"},{"id":"3d899cb1.9a46b4","type":"subflow:2fd3c0ca.54355","z":"63eeeb61.93efd4","name":"","env":[{"name":"LIGHT_ID","value":"14","type":"str"}],"x":840,"y":380,"wires":[]},{"id":"ba5ca479.2753c8","type":"inject","z":"63eeeb61.93efd4","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":800,"y":260,"wires":[["3d899cb1.9a46b4"]]}]

```

and this is the hue-node with the LIGHT\_ID filled in:

```auto
[{"id":"fae17cbb.c7758","type":"node-hue-in","z":"63eeeb61.93efd4","server":"ef95c758.c60bb8","lightID":"light14","name":"","x":820,"y":520,"wires":[]},{"id":"ef95c758.c60bb8","type":"node-hue-bridge","name":"Hue Bridge","address":"10.0.0.240","key":"nyDsJfhHnQVvgC9OKuDxZCedGfGAMvBNDFIHIMSA","interval":"1000"}]

```

---

<div class="post-metadata">

### Author: ![fmarzocca](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fmarzocca/32/35901_2.png) [@fmarzocca](https://discourse.nodered.org/u/fmarzocca)
#### Post date: [11 February 2021 21:50 UTC](https://discourse.nodered.org/t/how-to-set-a-node-input-in-the-subflow/40833/12 "2021-02-11T21:50:46Z")

</div>

my bad!  
I was typing in the wrong code. In fact hue node wants "light14", but I was entering only 14.  
Sorry and thanks for assistance..

---

<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: [25 February 2021 21:51 UTC](https://discourse.nodered.org/t/how-to-set-a-node-input-in-the-subflow/40833/13 "2021-02-25T21:51:07Z")

</div>

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