I NEARLY posted a question earlier but sat down, and sort of nutted it out.
But..... I'm ba-ack with a problem I am seeming to be missing.
Going on from the msg.(what ever) is modified via MQTT to basically msg.payload, I am (again) stuck.
I send a message over MQTT and it is received. For now it is just for testing so it isn't entirely "correct".
Here's the story: (See attached)
To get the msg.payload re-readable I stuck it through a JSON{} node. You can see the log on the right.
payload.DEVICE is "TelePi" and payload.COMMAND is "MAIN" Well, that is what the program is telling me when I use the icon to get the path.
So.... (Middle of the screen) (Ok I didn't quite circle all the nodes) the "set variables" node too.
The message is received and I want to look for the payload.DEVICE to be equal to TelePi. (See line 2 in node).
YET! If you look at the other marked box above the exploded message.payload you see that message.DEVICE is set to MAIN.
Errr.... How does that happen?
This is the very cut down part of the flow.
All on one "page".
I am trying to get my head around flow variables. Though I think I could "cheat" and just swap message.(thingies) to get the same result, I want to learn.
[{"id":"dcb81563.07c1e","type":"inject","z":"bfe818d4.1a76b8","name":"TelePi Main","topic":"","payload":"{\"DEVICE\":\"TelePi\", \"COMMAND\":\"MAIN\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":230,"y":160,"wires":[["30291269.0d6376","71fc0f3.97ac4f"]]},{"id":"30291269.0d6376","type":"switch","z":"bfe818d4.1a76b8","name":"","property":"payload.COMMAND","propertyType":"msg","rules":[{"t":"cont","v":"MAIN","vt":"str"},{"t":"cont","v":"TIMEPI","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":3,"x":390,"y":190,"wires":[["c3ef346f.415c1"],["c429ce80.1563f"],[]]},{"id":"71fc0f3.97ac4f","type":"function","z":"bfe818d4.1a76b8","name":"Set variables","func":"if (msg.payload.DEVICE == \"TelePi\")\n{\n //\n node.warn(\"Setting TelePiS variable to\");\n node.warn(msg.payload.COMMAND);\n flow.set('TelePiS',msg.payload.COMMAND);\n} else\nif (msg.payload.DEVICE == \"CameraPi\")\n{\n //\n node.warn(\"Setting CameaPiS variable to\");\n node.warn(msg.payload.COMMAND);\n flow.set('CameraPiS',msg.COMMAND);\n}\nreturn msg;","outputs":1,"noerr":0,"x":390,"y":260,"wires":[["b607250.00141d8","4cc9139c.bdbf54"]]},{"id":"b607250.00141d8","type":"mqtt out","z":"bfe818d4.1a76b8","name":"Send command","topic":"COMMAND22","qos":"2","retain":"","broker":"a05708b5.c2fea8","x":560,"y":260,"wires":[]},{"id":"bae52a2.db211d8","type":"mqtt in","z":"bfe818d4.1a76b8","name":"","topic":"COMMAND22","qos":"2","broker":"6cb3b554.d0c6ec","x":160,"y":520,"wires":[["f060d436.8bd728","efc82972.fa93a"]]},{"id":"efc82972.fa93a","type":"json","z":"bfe818d4.1a76b8","name":"","property":"payload","action":"","pretty":false,"x":150,"y":560,"wires":[["8c25d6bb.b2fef","b8d49e4e.67c288"]]},{"id":"8c25d6bb.b2fef","type":"function","z":"bfe818d4.1a76b8","name":"Set variables","func":"node.warn(msg.payload.DEVICE);\nif (msg.payload.DEVICE == \"TelePi\")\n{\n //\n node.warn(\"Setting TelePiS variable to\");\n node.warn(msg.payload.COMMAND);\n flow.set('TelePiA',msg.COMMAND);\n} else\nif (msg.payload.DEVICE == \"CameraPi\")\n{\n //\n node.warn(\"Setting CameaPiS variable to\");\n node.warn(msg.payload.COMMAND);\n flow.set('CameraPiA',msg.COMMAND);\n}\nreturn msg;","outputs":1,"noerr":0,"x":150,"y":610,"wires":[["1b11d2d8.74a875","19ad15e0.56dbd2"]]},{"id":"1b11d2d8.74a875","type":"delay","z":"bfe818d4.1a76b8","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":150,"y":650,"wires":[["b3eb3fcf.f7b448"]]},{"id":"b3eb3fcf.f7b448","type":"switch","z":"bfe818d4.1a76b8","name":"Device select","property":"payload.DEVICE","propertyType":"msg","rules":[{"t":"cont","v":"TelePi","vt":"str"},{"t":"cont","v":"CameraPi","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":3,"x":190,"y":700,"wires":[["db9d998f.f361d8"],["4157dc9a.70c35c"],[]]},{"id":"a05708b5.c2fea8","type":"mqtt-broker","z":"","broker":"192.168.0.99","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"20","cleansession":true,"willTopic":"EOM","willQos":"2","willRetain":"true","willPayload":"'Tele Pi telemetry failure'","birthTopic":"SOM","birthQos":"2","birthPayload":""},{"id":"6cb3b554.d0c6ec","type":"mqtt-broker","z":"","broker":"192.168.0.99","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"20","cleansession":true,"willTopic":"EOM","willQos":"2","willRetain":"true","willPayload":"'Tele Pi telemetry failure'","birthTopic":"SOM","birthQos":"2","birthPayload":""}]
After smashing my head (repeatedly) into the wall, things seem to have worked them selves out.
I ADMIT, I goofed with the injection of the data having it set as STRING and not JSON{}.
(That probably didn't help).
But the "names" are/were/still are not exactly clear to what was going on with them.