Is there any way to use variables instead of strings in edit fields of a node?
To make it concrete:
In case of e.g. MQTT I have some devices of the same type. All devices have a couple of properties.
In order to access the same property of different devices I have to use the same 'Topic' with one difference, the address of the device. So I wonder if it is possible to replace the cryptic address (e.g. 0001204302303 ) by a more intuitive name like 'tempOffice'.
In general: is it possible to use variables for fields in nodes, for example the 'Name' field. No matter if it is wise here or not.
The name of a node however, CAN NOT be taken from a variable. in all my time using Node RED, the name of a node in your flow, is always a static value.
Other properties, again... Node Dependant, does support variables.
Regarding the MQTT in node, it does offer dynamic subscriptions, which let you unsubscribe from one topic and subscribe to another.
But in your case of multiple devices of the same type, do they let you change the mqtt topic?
If so use a topic such as peskysensor/<sensor id> and subscribe to peskysensor/#.
Edit - changed "#" to "+" in the hope of reducing unnecessary message delivery.
If they don't, I guess a workaround might be to subscribe to +, use a switch node to check if msg.topic matches the regex for 13 digits and republish to peskysensor/<inbound topic>
Of course your downstream flow has to handle messages from different devices.
Thank's a lot. @jbudd: Not really what I was looking for, but very interesting for this use case.
I think it will make my life (the 'node-red-life') a little easier.
Most mqtt devices i have used (shelly, tasmota etc) it is possible to edit the device name/id (0001204302303 ) to a more human readable one. Have you looked at editing the topic device name in the mqqt devices own config?
@E1cid: It is not possible in my MQTT device. This makes it very uncomfortable to handle it and to track devices e.g. with MQTT explorers. Human readable information is available on the subscriber side, but it is not forwarded.
@markus-j-davis: The MQTT node has no input, so I don't know how to connect them.
ALL: The wildcard of MQTT is at the end a fairly nice solution. Together with a function node to filter the device coming out of the 'topic' it will be a really good solution. 'good' because it can end up in a structured piece of code and all links between intransparent numbers and transparent names are at one place.
... Yes. Really a lot. And these data come in if any value changes.
So I changed my mind: marcus' hint works fine. And in combination with a subflow and drop down menus it's perfect. There is still only one location to map devices an functions and a very good usability.