How to pass a message through the MQTT IN node configured in dynamic subscription mode

Works fine - just not how you think.

Here is a fully working demo...

Here is another using your values...
chrome_6Z6vYYtxra

[{"id":"90c6b92a167ccfd0","type":"function","z":"ec9cf53f5ff54f3b","name":"connect action","func":"msg.broker = {\"broker\":\"broker.hivemq.com\",\"port\":1883};\nmsg.action = \"connect\";\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1140,"y":60,"wires":[["66b1ad13cb265281"]]},{"id":"66b1ad13cb265281","type":"mqtt in","z":"ec9cf53f5ff54f3b","name":"","topic":"","qos":"2","datatype":"auto-detect","broker":"87ae16f44f4c9289","nl":false,"rap":true,"rh":0,"inputs":1,"x":1370,"y":80,"wires":[["11fbaa32576de64f"]]},{"id":"3ae59f4eb19407ae","type":"inject","z":"ec9cf53f5ff54f3b","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":960,"y":60,"wires":[["90c6b92a167ccfd0"]]},{"id":"11fbaa32576de64f","type":"debug","z":"ec9cf53f5ff54f3b","name":"debug 54","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1400,"y":140,"wires":[]},{"id":"7d4e46fa8e71c57a","type":"mqtt out","z":"ec9cf53f5ff54f3b","name":"","topic":"","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"87ae16f44f4c9289","x":1190,"y":260,"wires":[]},{"id":"72b84df48b0acf5a","type":"inject","z":"ec9cf53f5ff54f3b","name":"{\"key\":\"32wf43eg\"}","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"joshworld","payload":"{\"key\":\"32wf43eg\"}","payloadType":"json","x":1010,"y":260,"wires":[["7d4e46fa8e71c57a"]]},{"id":"dd2ae0d3db44925e","type":"function","z":"ec9cf53f5ff54f3b","name":"subscribe action","func":"msg.action = \"subscribe\";\nmsg.topic = \"joshworld\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1140,"y":140,"wires":[["66b1ad13cb265281"]]},{"id":"41db7b3deaae2651","type":"inject","z":"ec9cf53f5ff54f3b","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":960,"y":140,"wires":[["dd2ae0d3db44925e"]]},{"id":"4329193ee5bd637b","type":"inject","z":"ec9cf53f5ff54f3b","name":"{\"key\":\"32wf43eg\"}","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"joshworld","payload":"{\"key\":\"abcdef\"}","payloadType":"json","x":1010,"y":300,"wires":[["7d4e46fa8e71c57a"]]},{"id":"dea0d19eb4e1a97a","type":"inject","z":"ec9cf53f5ff54f3b","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":960,"y":180,"wires":[["2a1712b5f6c429c5"]]},{"id":"2a1712b5f6c429c5","type":"function","z":"ec9cf53f5ff54f3b","name":"unsubscribe action","func":"msg.action = \"unsubscribe\";\nmsg.topic = \"joshworld\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1150,"y":180,"wires":[["66b1ad13cb265281"]]},{"id":"18c55b5aa26ca697","type":"function","z":"ec9cf53f5ff54f3b","name":"disconnect action","func":"msg.action = \"disconnect\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1150,"y":100,"wires":[["66b1ad13cb265281"]]},{"id":"3f476107531ea14f","type":"inject","z":"ec9cf53f5ff54f3b","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":960,"y":100,"wires":[["18c55b5aa26ca697"]]},{"id":"87ae16f44f4c9289","type":"mqtt-broker","name":"dynamic","broker":"0.0.0.0","port":"1883","clientid":"","autoConnect":false,"usetls":false,"protocolVersion":"5","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"userProps":"","sessionExpiry":""}]
1 Like