Hi.
I´m pretty new in Node-Red, but I´m trying to understand it better every day.
Actually I want to transfer MQTT of my heat pump to my PLC with ADS.
But I don´t want to use 100´s of MQTT nodes, just only one with /# and then use only the ones I need.
But how can I do that, to filter for subtopics ?
Thanks.
That would depend on your topic structure, any answer would be a guess as you do not provide examples of your topics.
you could use a look up object and see if your incoming topic is in the look up object.
Or
you could split your topic on "/" and only pass if a certain array value is something you want to pass.
Hi.
The structure is for example "panasonic_heat_pump/main/Heatpump_Status" or "panasonic_heat_pump/main/Main_Inlet_Temp".
Behind main/ is one of my suptopics and every subtopic has a value.
So I´m using "panasonic_heat_pump/main/# for calling every subtopic.
so spliting your topic on "/" and selecting an array index would produce a string msg.topic = msg.topic.split("/")[2];
outputs "Heatpump_Status"
you could then compare in function or switch node for that value.
How can I do this in the other way ?
Signals are coming from PLC, for example "1", and must be sent to panasonic_heat_pump/main/SetOperationMode.
But I´m also using /# for the MQTT-Out.
With the change node it´s not working.
As described in the help text for the node, leave the topic blank in the Out node and put the topic in msg.topic. In fact I believe that is the original reason that msg.topic is called msg.topic.
against missunderstanding:
"ADS Notification" -> "CHANGE" with 2 rules: bolean to number & msg.topic with the full path -> "MQTT-Out" with blank topic ?