How to set a node input in the subflow?

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

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

Unfortunately no...

  • Sent from my mobile phone. Sorry for typos -

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

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.

1 Like

Great!
Thank you Nick!

Fabio

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

@knolleary
This is the not-working subflow:

[{"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"}]

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

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.

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.

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

This is an example of subflow's use:

[{"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:

[{"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"}]

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..

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