I'm having issues with the second change node. I can't seem to get the syntax right for it to work.
Its a simple flow, I may be abusing MQTT by embedding data in the topic, but it seems to work quite well except I can't create a message suitable for the file write node, here is the flow:
[{"id":"d4d6d7ff.db9e38","type":"mqtt in","z":"5abbd703.0270a8","name":"AIdetection","topic":"AIdetection/#","qos":"0","broker":"933ca107.c2a6","x":243,"y":739,"wires":[["6606d3f7.33608c","68d7b1fc.212cf","1ee26211.c8944e"]]},{"id":"68d7b1fc.212cf","type":"change","z":"5abbd703.0270a8","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"image","tot":"msg"},{"t":"move","p":"topic","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":472,"y":738,"wires":[["f1b2475e.179118","1ee26211.c8944e"]]},{"id":"f1b2475e.179118","type":"csv","z":"5abbd703.0270a8","name":"","sep":"!","hdrin":"","hdrout":"","multi":"mult","ret":"\\n","temp":"topic,folder,filename,startX,startY,endX,endY","skip":"0","x":677,"y":740,"wires":[["f4a30f0b.33bb4","1ee26211.c8944e"]]},{"id":"f4a30f0b.33bb4","type":"change","z":"5abbd703.0270a8","name":"","rules":[{"t":"set","p":"filename","pt":"msg","to":"payload.filename","tot":"msg"},{"t":"move","p":"image","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":662,"y":854,"wires":[["4eb8acdc.d019c4","1ee26211.c8944e"]]},{"id":"4eb8acdc.d019c4","type":"file","z":"5abbd703.0270a8","name":"","filename":"","appendNewline":false,"createDir":true,"overwriteFile":"true","x":855,"y":846,"wires":[["c77ea48b.8c88d8"]]},{"id":"1ee26211.c8944e","type":"debug","z":"5abbd703.0270a8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":864,"y":797,"wires":[]},{"id":"933ca107.c2a6","type":"mqtt-broker","z":"","name":"localhost","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]
This is the debug output from the MQTT input node, nothing special other than my data embedded in the topic:
MQTT message:
8/18/2019, 4:31:47 PMnode: 1ee26211.c8944e
AIdetection/!2019-08-18!16_31_47.2_Mendel_Cam2.jpg!409!234!492!421 :
msg : Object
object
topic: "AIdetection/!2019-08-18!16_31_47.2_Mendel_Cam2.jpg!409!234!492!421"
payload: buffer[362984]
qos: 0
retain: false
_topic: "AIdetection/!2019-08-18!16_31_47.2_Mendel_Cam2.jpg!409!234!492!421"
_msgid: "816e438e.c1ca"
Debug output from first Change node to move payload to image and topic to payload:
8/18/2019, 4:31:47 PMnode: 1ee26211.c8944e
msg : Object
object
qos: 0
retain: false
_topic: "AIdetection/!2019-08-18!16_31_47.2_Mendel_Cam2.jpg!409!234!492!421"
_msgid: "816e438e.c1ca"
image: buffer[362984]
payload: "AIdetection/!2019-08-18!16_31_47.2_Mendel_Cam2.jpg!409!234!492!421"
So far so good, I though I was home free with the output of csv node to split data embedded in MQTT topic:
8/18/2019, 4:31:47 PMnode: 1ee26211.c8944e
msg : Object
object
qos: 0
retain: false
_topic: "AIdetection/!2019-08-18!16_31_47.2_Mendel_Cam2.jpg!409!234!492!421"
_msgid: "816e438e.c1ca"
image: buffer[362984]
payload: array[1]
0: object
topic: "AIdetection/"
folder: "2019-08-18"
filename: "16_31_47.2_Mendel_Cam2.jpg"
startX: 409
startY: 234
endX: 492
endY: 421
Just use a second change node to move the msg.payload.filename to msg.filename move the msg.image back to msg.payload for input into the file write node.
Fail.
I feel pretty stupid, I've permuted what I could think of but just can't get it to work. Here is the output of the second Change node that I can't get correct:
8/18/2019, 4:31:47 PMnode: 1ee26211.c8944e
msg : Object
object
qos: 0
retain: false
_topic: "AIdetection/!2019-08-18!16_31_47.2_Mendel_Cam2.jpg!409!234!492!421"
_msgid: "816e438e.c1ca"
payload: buffer[362984]
msg.payload looks correct but msg.filename is nowhere to be found