i'm learning nodered and mqtt.
i use also homeassistant , and when i create an esp32node with mqtt enabled , then i got a very nice tree-structure in mqtt-explorer
now i want to create some data to send to my mqtt broker , but as test i want to inject some hardcoded values to my broker.
but it need to have a nice tree-strucure like in this image above.
my first test is complete differtent result in mqtt-explorer :
how can i create a kind of directory and subdirectorries ?
It is very easy to create a topic in a msg with various levels for example setting msg.topic to:
home/firstFloor/livingroom/northwall/switch
but really you should go read the tutorial, it examines a lot and has a complete section on topics and hoe to subscribe to them. It will be worth your time to learn the terminology and get an understanding of how the pub/sub process works.
I like to reproduce internal JSON structures to equivalent trees in MQTT. The best way is to create a function node that walks through the JSON input and outputs the topic/value pairs. Done right, you only need to do it once and then you should be able to reuse it.
I guess I should probably write a node for that at some point unless someone has beaten me to it.