Environment variable in dropdown fields

Hello,

I'm brand new to Node Red and have used fhem and iobroker before. But I'm really excited about the flexibility and possibilities that Node Red has to offer me.

I've already tried around a bit and quickly reached my limits, as I'm still lacking an overview.

I'm currently trying to create my devices and would like to delegate the setting options for this from top to bottom. (It should also be fixed settings)

But I also have components in the subflow that have a dropdown field as a setting option, and I would also like to transfer my environment variables in these settings.

E.g. Google smarthome with the device type or dashboard UI with the tabs and sliders.

Does anyone know of a way to transfer the data from an environment variable into this fields?

Possibly through an extension or are there already integrated commands that allow me to do this?

In case of doubt, probably I could work with the nodes file-read and file-write or with exec and sed, for example. But that wouldn't be the most elegant solution for me.

Welcome to the forum @plopp79

This page in the docs describes the many ways to use env variables in node red. Start by reading through that, then come back if you need further help. Using environment variables : Node-RED

I already know this site. I didn't find a solution to my problem there.

You can specify your env var in the properties of the subflow, then use that inside the subflow when you build the dropdown list.

[Edit] Perhaps I misunderstand. What do you mean by

Hello Colin,

Thank you very much for your help, It's nice to be helped like this here.
I'll try to explain it with an example. This example has the add-on Dashboard-ui

[{"id":"8a8858a059602f06","type":"subflow","name":"example (2)","info":"","category":"Shelly http","in":[],"out":[],"env":[{"name":"room or tab","type":"str","value":"Livingroom"},{"name":"slider","type":"str","value":"Buttons"}],"meta":{"module":"shelly_http","license":"Apache-2.0"},"color":"#ff7f24","icon":"node-red-dashboard/ui_switch.png"},{"id":"2e061d1f7e33a836","type":"ui_switch","z":"8a8858a059602f06","name":"","label":"switch","tooltip":"","group":"b861a8386c93496d","order":1,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"topic","topicType":"msg","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","animate":false,"className":"","x":530,"y":200,"wires":[[]]},{"id":"b861a8386c93496d","type":"ui_group","name":"Schalter","tab":"3616a722.b89bc8","order":1,"disp":true,"width":"6","collapse":false,"className":""},{"id":"3616a722.b89bc8","type":"ui_tab","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]

There's a switch that i want to use the variables to tell which tab to end up in.

And could I give a "Link in" field a name via a variable or maybe also a msg?

Enter the env var in the subflow properties and use that in the switch.

Yes, I have already entered the var in the subflow properties, but were and how could I enter the env in the switch? There is only a dropdown menu :slight_smile:

I have just realised fully what you are trying to do. I think you have the bigger problem that you cannot put dashboard nodes in subflows. Not reliably at least.

1 Like

Hello Colin,

thank you for your support. I've now thought of a different structure. But could you explain your last statement to me why that is?

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