It would seem my thinking I understand MQTT and messages is wrong.
Or I am missing something - again.
This is my test flow.
[{"id":"b87b117d64f2fc0a","type":"mqtt out","z":"65c9b63cb09879a0","name":"","topic":"test","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"8941f4c3.0f151","x":340,"y":1870,"wires":[]},{"id":"8cccb4dff9644103","type":"mqtt in","z":"65c9b63cb09879a0","name":"","topic":"test","qos":"2","datatype":"auto","broker":"8941f4c3.0f151","nl":false,"rap":true,"rh":0,"x":470,"y":1870,"wires":[["1401dff22e7b167b"]]},{"id":"1401dff22e7b167b","type":"json","z":"65c9b63cb09879a0","name":"","property":"payload","action":"","pretty":false,"x":590,"y":1870,"wires":[["639e04cb31c14b7d","2adf3a80409bc323"]]},{"id":"639e04cb31c14b7d","type":"debug","z":"65c9b63cb09879a0","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":730,"y":1870,"wires":[]},{"id":"523ce62d14a37f87","type":"inject","z":"65c9b63cb09879a0","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"payload\":\"text\"}","payloadType":"json","x":190,"y":1870,"wires":[["b87b117d64f2fc0a"]]},{"id":"2adf3a80409bc323","type":"switch","z":"65c9b63cb09879a0","name":"","property":"payload.payload","propertyType":"msg","rules":[{"t":"eq","v":"text","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":590,"y":1940,"wires":[["bbc460a221fd8fd6"]]},{"id":"bbc460a221fd8fd6","type":"debug","z":"65c9b63cb09879a0","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":740,"y":1940,"wires":[]},{"id":"8941f4c3.0f151","type":"mqtt-broker","name":"Local","broker":"127.0.0.1","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]
Local MQTT broker.
I create a JSON
message - I hope - in the inject
node.
Send that into the MQTT
node then it is received.
I send it through a JSON
node and look at the output in a debug
node.
I need the JSON
node to de-construct the message from the MQTT
wrapping.
Ideally I should get text
in the debug
node.
Then the switch
node will pass the message is the msg.payload
(don't get ahead of me) is text
.
Or so it should.
But it only works if I make the switch
node compare the msg.payload.payload
.
Shouldn't the JSON
node strip all that stuff off?
SORRY!
I know I've been through this before and I remember way back in the early days NicOleary helped me when I was going around in circles with the JSON
(or more so: message structure) problem.
But for reasons unknown: I can't seem to get it working to simply send a message through.