Is this a JSON string?

I am being told that this is not a JSON string.

{"topic":"ALARM/A2","payload":{"message":"Node Configuration not set","source":{"id":"493eaac7.a0d6ec","type":"function","name":"Button Colour","count":1}},"qos":0,"retain":false,"_msgid":"15668b8e.75c464","ttl":0,"_queuetimestamp":1598820842167,"_queueCount":74}

by an MQTT IN node.

Is it or not?

It is a JSON object, not a JSON string no.

But can you elaborate on your question ? what does the mqtt in node state and how did you set it up ? (ie. output)

As a clarification - it is a JSON string (or a string containing JSON) if it's not converted to a JSON object first by checking the related option in the MQTT node.

It is impossible to say from the text only if this is a text representation of a JSON object or just a string of text containing a JSON object.

Ok - phew, I still have the message.

I got this message:

{"topic":"ERROR_REPORT/TelePi/Alarm_Display/ALARM/A2","qos":0,"retain":false,"error":{"message":"Failed to parse JSON string","source":{"id":"fc06e466.761568","type":"mqtt in","name":"All alarms","count":1}},"_msgid":"b574722.201349","time":"2020-08-31 06:54:03","payload":{"message":"Failed to parse JSON string","source":{"id":"fc06e466.761568","type":"mqtt in","name":"All alarms","count":1}},"ttl":0,"_queuetimestamp":1598820843868,"_queueCount":73}

The source points to a MQTT IN node. (Yeah, it tells me that)

The node is this:

[{"id":"98a12d23.4caf","type":"subflow","name":"Time Stamp","info":"","category":"","in":[{"x":80,"y":100,"wires":[{"id":"b51453d8.f777"}]}],"out":[{"x":640,"y":180,"wires":[{"id":"537f67d0.440958","port":0},{"id":"b51453d8.f777","port":0}]},{"x":640,"y":230,"wires":[{"id":"b51453d8.f777","port":0},{"id":"436ec434.1175cc","port":0}]},{"x":640,"y":280,"wires":[{"id":"c77ad598.3b98e8","port":0},{"id":"b51453d8.f777","port":0}]}],"env":[],"color":"#FF8888","outputLabels":["For logging use","msg.time","For filename use"],"icon":"node-red/timer.svg"},{"id":"537f67d0.440958","type":"moment","z":"98a12d23.4caf","name":"","topic":"","input":"payload","inputType":"msg","inTz":"Australia/Sydney","adjAmount":0,"adjType":"days","adjDir":"add","format":"YYYY-MM-DD HH:mm:ss","locale":"en_AU","output":"payload","outputType":"msg","outTz":"Australia/Sydney","x":390,"y":180,"wires":[["c77ad598.3b98e8","9a6e708b.c8249"]]},{"id":"c77ad598.3b98e8","type":"string","z":"98a12d23.4caf","name":"","methods":[{"name":"replaceAll","params":[{"type":"str","value":":"},{"type":"str","value":""}]}],"prop":"payload","propout":"payload","object":"msg","objectout":"msg","x":440,"y":280,"wires":[[]]},{"id":"9a6e708b.c8249","type":"change","z":"98a12d23.4caf","name":"TOPIC","rules":[{"t":"move","p":"payload","pt":"msg","to":"time","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":220,"y":230,"wires":[["436ec434.1175cc"]]},{"id":"204888d7.8b194","type":"change","z":"98a12d23.4caf","name":"Save","rules":[{"t":"set","p":"payload","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":220,"y":140,"wires":[["93239165.b7976"]]},{"id":"436ec434.1175cc","type":"change","z":"98a12d23.4caf","name":"Get","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":440,"y":230,"wires":[[]]},{"id":"b51453d8.f777","type":"switch","z":"98a12d23.4caf","name":"check topic","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"TIMESTAMP","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":200,"y":100,"wires":[[],["204888d7.8b194"]]},{"id":"93239165.b7976","type":"change","z":"98a12d23.4caf","name":"TimeStamp","rules":[{"t":"set","p":"payload","pt":"msg","to":"","tot":"date"}],"action":"","property":"","from":"","to":"","reg":false,"x":200,"y":180,"wires":[["537f67d0.440958"]]},{"id":"df12de57.5f0de8","type":"tab","label":"Alarm display","disabled":false,"info":"This flow is to receive messages via MQTT on\nEVENT/EVENT\nWork in progress.\n"},{"id":"fc06e466.761568","type":"mqtt in","z":"df12de57.5f0de8","name":"All alarms","topic":"ALARM/#","qos":"2","datatype":"auto","broker":"1ecd3a9e.dc5bfd","x":150,"y":270,"wires":[["dcf93904.c4f75","e19ab931.4054","418ba4ad.aecb94"]]},{"id":"dcf93904.c4f75","type":"debug","z":"df12de57.5f0de8","name":"RAW","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":160,"y":220,"wires":[]},{"id":"e4e27985.7e8bc8","type":"comment","z":"df12de57.5f0de8","name":"Error catcher","info":"","x":4400,"y":120,"wires":[]},{"id":"9120c098.72a8d","type":"inject","z":"df12de57.5f0de8","name":"Stop","topic":"CONTROL","payload":"STOP","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":4220,"y":150,"wires":[["7018404b.f96d9","a2460395.61625"]]},{"id":"32cd9951.2823ee","type":"inject","z":"df12de57.5f0de8","name":"Go","topic":"CONTROL","payload":"GO","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":"1","x":4220,"y":190,"wires":[["7018404b.f96d9","a2460395.61625"]]},{"id":"7018404b.f96d9","type":"gate","z":"df12de57.5f0de8","name":"","controlTopic":"CONTROL","defaultState":"open","openCmd":"GO","closeCmd":"STOP","toggleCmd":"toggle","defaultCmd":"default","persist":false,"x":4394,"y":240,"wires":[["f6b6fb7e.24f27"]]},{"id":"f6b6fb7e.24f27","type":"function","z":"df12de57.5f0de8","name":"Set topic","func":"var device_name =global.get('myDeviceName');\nmsg.topic =\"ERROR_REPORT/\" + device_name + \"/\" + msg.topic;\nreturn msg;","outputs":1,"noerr":0,"x":4530,"y":240,"wires":[["66a1ead7.4c42a4"]]},{"id":"a2460395.61625","type":"function","z":"df12de57.5f0de8","name":"","func":"var name = flow.get('name');\nvar ok = global.get('Error_Flow_Pass');\nvar stop = global.get('Error_Flow_Stop');\nvar caught = global.get('Error_Detected');\n\n//node.warn(\"Name of the flow \" + name);\n//  --  check if this is a CONTROL message.\nif (msg.topic == 'CONTROL')\n{\n    //node.warn(\"Control signal received \" + msg.payload);\n    if (msg.payload == 'STOP')\n    {\n        context.set('notify',1);\n        msg.topic = name;\n        msg.colour = stop;\n    } else\n    {\n        context.set('notify',0);\n        msg.topic = name;\n        msg.colour = ok;\n    }\n    return msg;\n}\n\n//  --  Send YELLOW as the message if error detected.\n//\tThis is only if the error reporting is blocked.\nvar pass = context.get('notify') ||0;\nif (pass == 1)\n{\n    // set msg.payload to indicate\n    node.warn(\"Error detected check indication\");\n    msg.topic = name;\n    msg.colour = caught;\nreturn msg;\n}\n","outputs":1,"noerr":0,"x":4390,"y":190,"wires":[["cae09ec8.24fbd8"]]},{"id":"cae09ec8.24fbd8","type":"link out","z":"df12de57.5f0de8","name":"","links":["432257a4.443a48","bb335d19.a8936"],"x":4485,"y":190,"wires":[]},{"id":"ec1ab6c7.33a56","type":"inject","z":"df12de57.5f0de8","name":"","topic":"","payload":"Alarm_Display","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":4590,"y":120,"wires":[["579fe43.6a1609c"]]},{"id":"579fe43.6a1609c","type":"change","z":"df12de57.5f0de8","name":"","rules":[{"t":"set","p":"name","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":4820,"y":120,"wires":[[]]},{"id":"b76ee921.233498","type":"link in","z":"df12de57.5f0de8","name":"Health_Error_CTL","links":["28336f9f.11cc68"],"x":4180,"y":110,"wires":[["a2460395.61625","7018404b.f96d9"]],"l":true},{"id":"66a1ead7.4c42a4","type":"link out","z":"df12de57.5f0de8","name":"Display error TX","links":["ee9ad7ef.4664e"],"x":4710,"y":240,"wires":[],"l":true},{"id":"d8d7d681.092dd8","type":"debug","z":"df12de57.5f0de8","name":"alarm After JSON","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1090,"y":230,"wires":[]},{"id":"4e0441ac.ef44d8","type":"change","z":"df12de57.5f0de8","name":"","rules":[{"t":"set","p":"device","pt":"msg","to":"payload.device","tot":"msg"},{"t":"set","p":"error","pt":"msg","to":"payload.err","tot":"msg"},{"t":"set","p":"payload","pt":"msg","to":"payload.payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1080,"y":270,"wires":[["c806c715.a74be8"]]},{"id":"c806c715.a74be8","type":"string","z":"df12de57.5f0de8","name":"","methods":[{"name":"delLeftMost","params":[{"type":"str","value":"/"}]}],"prop":"device","propout":"device","object":"msg","objectout":"msg","x":1110,"y":310,"wires":[["9303f3f0.24ad08","6b8e3318.76082c"]]},{"id":"41288c74.f19de4","type":"link in","z":"df12de57.5f0de8","name":"","links":["5066ae76.fcd418","8db457e5.950918"],"x":825,"y":450,"wires":[["35c54b6e.32f3a4"]]},{"id":"788d210f.ac4fd","type":"link in","z":"df12de57.5f0de8","name":"","links":["61ef0d8e.10c974","2ecc0896.84004"],"x":825,"y":600,"wires":[["50248f17.866398","7e393288.44121c"]]},{"id":"fe2d91ab.06b3d8","type":"link in","z":"df12de57.5f0de8","name":"","links":["52c55fa4.0fec3","aaf36071.9db6e"],"x":825,"y":750,"wires":[["69f8ba0f.8c729c","bcfecf06.78fe78"]]},{"id":"9303f3f0.24ad08","type":"debug","z":"df12de57.5f0de8","name":"A1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1280,"y":270,"wires":[]},{"id":"8efd2068.840818","type":"debug","z":"df12de57.5f0de8","name":"A2 after JSON","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1310,"y":400,"wires":[]},{"id":"50248f17.866398","type":"debug","z":"df12de57.5f0de8","name":"A3","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1280,"y":560,"wires":[]},{"id":"69f8ba0f.8c729c","type":"debug","z":"df12de57.5f0de8","name":"O1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1280,"y":710,"wires":[]},{"id":"475a5865.ce9ed","type":"switch","z":"df12de57.5f0de8","name":"Alarm type","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"ALARM/A1","vt":"str"},{"t":"eq","v":"ALARM/A2","vt":"str"},{"t":"eq","v":"ALARM/A3","vt":"str"},{"t":"eq","v":"ALARM/O1","vt":"str"},{"t":"eq","v":"ALARM/O2","vt":"str"}],"checkall":"true","repair":false,"outputs":5,"x":540,"y":350,"wires":[["aa395696.df5dc8"],["8db457e5.950918"],["2ecc0896.84004"],["aaf36071.9db6e"],["8634317d.5dbd7"]]},{"id":"8db457e5.950918","type":"link out","z":"df12de57.5f0de8","name":"A2 alarm","links":["41288c74.f19de4"],"x":685,"y":310,"wires":[]},{"id":"2ecc0896.84004","type":"link out","z":"df12de57.5f0de8","name":"A3 alarm","links":["788d210f.ac4fd"],"x":685,"y":350,"wires":[]},{"id":"aaf36071.9db6e","type":"link out","z":"df12de57.5f0de8","name":"O1 alarm","links":["fe2d91ab.06b3d8"],"x":685,"y":390,"wires":[]},{"id":"6681bd46.d31f9c","type":"link in","z":"df12de57.5f0de8","name":"","links":["aa395696.df5dc8","e9478748.104e68"],"x":825,"y":270,"wires":[["4e0441ac.ef44d8"]]},{"id":"aa395696.df5dc8","type":"link out","z":"df12de57.5f0de8","name":"A1 alarm","links":["6681bd46.d31f9c"],"x":685,"y":270,"wires":[]},{"id":"f5d11f3f.60b7f","type":"comment","z":"df12de57.5f0de8","name":"A1","info":"","x":1050,"y":190,"wires":[]},{"id":"1ac1aca7.63849b","type":"json","z":"df12de57.5f0de8","name":"","property":"payload","action":"","pretty":false,"x":1070,"y":490,"wires":[["8efd2068.840818"]]},{"id":"960b6432.2ce34","type":"comment","z":"df12de57.5f0de8","name":"A2","info":"","x":1070,"y":400,"wires":[]},{"id":"76a38a3b.f31f6c","type":"comment","z":"df12de57.5f0de8","name":"A3","info":"","x":1080,"y":540,"wires":[]},{"id":"cdda7a52.c5d888","type":"comment","z":"df12de57.5f0de8","name":"O1","info":"","x":1080,"y":710,"wires":[]},{"id":"5d5a83ce.d60d8c","type":"change","z":"df12de57.5f0de8","name":"Wipe","rules":[{"t":"set","p":"reset","pt":"msg","to":"1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1910,"y":400,"wires":[["6b8e3318.76082c"]]},{"id":"6b8e3318.76082c","type":"simple-queue","z":"df12de57.5f0de8","name":"queue1","firstMessageBypass":false,"bypassInterval":"0","x":1920,"y":310,"wires":[["446e403a.32395"]]},{"id":"447c1acb.a9e3a4","type":"inject","z":"df12de57.5f0de8","name":"Wipe","topic":"","payload":" ","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":"","x":1780,"y":400,"wires":[["5d5a83ce.d60d8c"]]},{"id":"446e403a.32395","type":"debug","z":"df12de57.5f0de8","name":"A1 errors","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":2070,"y":310,"wires":[]},{"id":"a6456881.25c85","type":"change","z":"df12de57.5f0de8","name":"Read","rules":[{"t":"set","p":"trigger","pt":"msg","to":"1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1910,"y":360,"wires":[["6b8e3318.76082c"]]},{"id":"fe901700.5d8768","type":"inject","z":"df12de57.5f0de8","name":"Read","topic":"","payload":" ","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":"","x":1780,"y":360,"wires":[["a6456881.25c85"]]},{"id":"7f767ba7.69f1d4","type":"debug","z":"df12de57.5f0de8","name":"A2 errors","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":2070,"y":450,"wires":[]},{"id":"35c54b6e.32f3a4","type":"simple-queue","z":"df12de57.5f0de8","name":"queue1","firstMessageBypass":false,"bypassInterval":"0","x":1920,"y":450,"wires":[["7f767ba7.69f1d4"]]},{"id":"78f49b78.bcefbc","type":"change","z":"df12de57.5f0de8","name":"Wipe","rules":[{"t":"set","p":"reset","pt":"msg","to":"1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1910,"y":540,"wires":[["35c54b6e.32f3a4"]]},{"id":"9bfa1d96.f6ee4","type":"change","z":"df12de57.5f0de8","name":"Read","rules":[{"t":"set","p":"trigger","pt":"msg","to":"1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1910,"y":500,"wires":[["35c54b6e.32f3a4"]]},{"id":"f0daa0c9.51b65","type":"inject","z":"df12de57.5f0de8","name":"Wipe","topic":"","payload":" ","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":"","x":1780,"y":540,"wires":[["78f49b78.bcefbc"]]},{"id":"87c3cabd.f62b7","type":"inject","z":"df12de57.5f0de8","name":"Read","topic":"","payload":" ","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":"","x":1780,"y":500,"wires":[["9bfa1d96.f6ee4"]]},{"id":"c8da4f7b.b0099","type":"debug","z":"df12de57.5f0de8","name":"A3 errors","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":2070,"y":600,"wires":[]},{"id":"8bfb9585.8198c8","type":"simple-queue","z":"df12de57.5f0de8","name":"queue1","firstMessageBypass":false,"bypassInterval":"0","x":1920,"y":600,"wires":[["c8da4f7b.b0099"]]},{"id":"83639b7e.aa2118","type":"change","z":"df12de57.5f0de8","name":"Wipe","rules":[{"t":"set","p":"reset","pt":"msg","to":"1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1910,"y":690,"wires":[["8bfb9585.8198c8"]]},{"id":"3c24a4fb.2b8134","type":"change","z":"df12de57.5f0de8","name":"Read","rules":[{"t":"set","p":"trigger","pt":"msg","to":"1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1910,"y":650,"wires":[["8bfb9585.8198c8"]]},{"id":"f92ca84c.210cf8","type":"inject","z":"df12de57.5f0de8","name":"Wipe","topic":"","payload":" ","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":"","x":1780,"y":690,"wires":[["83639b7e.aa2118"]]},{"id":"3f88056c.33e282","type":"inject","z":"df12de57.5f0de8","name":"Read","topic":"","payload":" ","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":"","x":1780,"y":650,"wires":[["3c24a4fb.2b8134"]]},{"id":"a2aae92b.39af9","type":"debug","z":"df12de57.5f0de8","name":"O1 errors","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":2070,"y":750,"wires":[]},{"id":"27c9a2fb.c08246","type":"simple-queue","z":"df12de57.5f0de8","name":"queue1","firstMessageBypass":false,"bypassInterval":"0","x":1920,"y":750,"wires":[["a2aae92b.39af9"]]},{"id":"20d29184.61331e","type":"change","z":"df12de57.5f0de8","name":"Wipe","rules":[{"t":"set","p":"reset","pt":"msg","to":"1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1910,"y":840,"wires":[["27c9a2fb.c08246"]]},{"id":"7c7ac241.e2215c","type":"change","z":"df12de57.5f0de8","name":"Read","rules":[{"t":"set","p":"trigger","pt":"msg","to":"1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1910,"y":800,"wires":[["27c9a2fb.c08246"]]},{"id":"99e633da.1b354","type":"inject","z":"df12de57.5f0de8","name":"Wipe","topic":"","payload":" ","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":"","x":1780,"y":840,"wires":[["20d29184.61331e"]]},{"id":"be983580.2763a","type":"inject","z":"df12de57.5f0de8","name":"Read","topic":"","payload":" ","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":"","x":1780,"y":800,"wires":[["7c7ac241.e2215c"]]},{"id":"7e393288.44121c","type":"fan","z":"df12de57.5f0de8","x":1160,"y":600,"wires":[["8bfb9585.8198c8"]]},{"id":"bcfecf06.78fe78","type":"fan","z":"df12de57.5f0de8","x":1170,"y":750,"wires":[["27c9a2fb.c08246"]]},{"id":"8634317d.5dbd7","type":"link out","z":"df12de57.5f0de8","name":"O2 Alarm","links":["3be6d353.24e5f4"],"x":685,"y":430,"wires":[]},{"id":"3be6d353.24e5f4","type":"link in","z":"df12de57.5f0de8","name":"","links":["8634317d.5dbd7"],"x":815,"y":890,"wires":[["59e1bc6a.8f49bc","e3c0fc8.dd0168"]]},{"id":"59e1bc6a.8f49bc","type":"debug","z":"df12de57.5f0de8","name":"O2","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1280,"y":850,"wires":[]},{"id":"8a295052.1d3ff8","type":"comment","z":"df12de57.5f0de8","name":"O2","info":"","x":1080,"y":850,"wires":[]},{"id":"e3c0fc8.dd0168","type":"fan","z":"df12de57.5f0de8","x":1170,"y":890,"wires":[[]]},{"id":"7e592efc.5c50f","type":"debug","z":"df12de57.5f0de8","name":"O2 After JSON","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1480,"y":850,"wires":[]},{"id":"b9999c05.62437","type":"fan","z":"df12de57.5f0de8","x":4220,"y":240,"wires":[["a2460395.61625","7018404b.f96d9"]]},{"id":"31509fc1.1bacb8","type":"catch","z":"df12de57.5f0de8","name":"","scope":null,"x":3290,"y":240,"wires":[["d514fd4e.1760f","c931deb2.1eb0d8"]]},{"id":"a51977b6.ec4d","type":"inject","z":"df12de57.5f0de8","name":"","topic":"","payload":"Test","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":3300,"y":280,"wires":[["c931deb2.1eb0d8"]]},{"id":"d307a93d.1cb888","type":"comment","z":"df12de57.5f0de8","name":"Error catching","info":"","x":3850,"y":60,"wires":[]},{"id":"1052fc4f.7af0d4","type":"function","z":"df12de57.5f0de8","name":"Name flow","func":"var device_name =global.get('myDeviceName') || \"Artificial Device Name\";\nvar flow_name = flow.get('name') || \"Artificial Flow Name\";\nmsg.topic =\"ERROR_REPORT/\" + device_name + \"/\" + flow_name + \"/\" + msg.topic;\nreturn msg;","outputs":1,"noerr":0,"x":3660,"y":240,"wires":[["d6da28ac.68d528","57a1422e.4a21f4"]]},{"id":"dda0bf46.8734a8","type":"change","z":"df12de57.5f0de8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"error","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":4055,"y":240,"wires":[["b9999c05.62437","27e4bafe.7e477e"]]},{"id":"e54cd4b0.3f74d","type":"inject","z":"df12de57.5f0de8","name":"Read","topic":"","payload":" ","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":"","x":3495,"y":291,"wires":[["56bf456.5235d3c"]]},{"id":"b20b83cb.261338","type":"inject","z":"df12de57.5f0de8","name":"Wipe","topic":"","payload":" ","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":"","x":3495,"y":331,"wires":[["93003a95.234268"]]},{"id":"93003a95.234268","type":"change","z":"df12de57.5f0de8","name":"Wipe","rules":[{"t":"set","p":"reset","pt":"msg","to":"1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":3675,"y":331,"wires":[["27e4bafe.7e477e"]]},{"id":"56bf456.5235d3c","type":"change","z":"df12de57.5f0de8","name":"Read","rules":[{"t":"set","p":"trigger","pt":"msg","to":"1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":3675,"y":291,"wires":[["27e4bafe.7e477e"]]},{"id":"27e4bafe.7e477e","type":"simple-queue","z":"df12de57.5f0de8","name":"queue1","firstMessageBypass":false,"bypassInterval":"0","x":3861,"y":291,"wires":[["e993f476.73b1f"]]},{"id":"e993f476.73b1f","type":"debug","z":"df12de57.5f0de8","name":"Local Readings error list","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":4055,"y":291,"wires":[]},{"id":"4daf2ef0.abfdb","type":"inject","z":"df12de57.5f0de8","name":"Stop","topic":"control","payload":"stop","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":3680,"y":160,"wires":[["57a1422e.4a21f4"]],"icon":"node-red/alert.png"},{"id":"ac230f5b.64b228","type":"inject","z":"df12de57.5f0de8","name":"Go","topic":"control","payload":"go","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":"1","x":3680,"y":200,"wires":[["57a1422e.4a21f4"]]},{"id":"d6da28ac.68d528","type":"debug","z":"df12de57.5f0de8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":3850,"y":200,"wires":[]},{"id":"57a1422e.4a21f4","type":"gate","z":"df12de57.5f0de8","name":"","controlTopic":"control","defaultState":"open","openCmd":"go","closeCmd":"stop","toggleCmd":"toggle","defaultCmd":"default","persist":false,"x":3850,"y":240,"wires":[["dda0bf46.8734a8"]]},{"id":"c931deb2.1eb0d8","type":"subflow:98a12d23.4caf","z":"df12de57.5f0de8","name":"","x":3500,"y":240,"wires":[[],["1052fc4f.7af0d4"],[]]},{"id":"3dd7f1a6.2f5406","type":"function","z":"df12de57.5f0de8","name":"This will throw an error","func":"var n = 23 + 56 / a;\n//var n = 23 + 56 ;\nmsg.payload = n;\nreturn msg;","outputs":1,"noerr":0,"x":3910,"y":580,"wires":[["e77adc91.b479d8"]]},{"id":"c860799a.1dfe08","type":"inject","z":"df12de57.5f0de8","name":"","topic":"","payload":"Cause an error","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":3890,"y":540,"wires":[["3dd7f1a6.2f5406"]]},{"id":"e77adc91.b479d8","type":"debug","z":"df12de57.5f0de8","name":"Fake error message","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":3910,"y":620,"wires":[]},{"id":"33709acc.7e5c3e","type":"comment","z":"df12de57.5f0de8","name":"Test error generation","info":"","x":3890,"y":500,"wires":[]},{"id":"fdd06ad6.58f648","type":"subflow:98a12d23.4caf","z":"df12de57.5f0de8","name":"","x":360,"y":350,"wires":[[],["475a5865.ce9ed"],[]]},{"id":"debb7d4f.24dc98","type":"link out","z":"df12de57.5f0de8","name":"Runaway","links":["8da8c919.68c64","3462a866.13a728","22b06b49.92507c","fdc3ca8f.7a24b8"],"x":3860,"y":120,"wires":[],"l":true},{"id":"550e83e8.cea0bc","type":"change","z":"df12de57.5f0de8","name":"Stop","rules":[{"t":"set","p":"payload","pt":"msg","to":"stop","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"CONTROL","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":3680,"y":120,"wires":[["debb7d4f.24dc98","57a1422e.4a21f4"]]},{"id":"1f09d605.a0d692","type":"switch","z":"df12de57.5f0de8","name":"> 30","property":"payload","propertyType":"msg","rules":[{"t":"gt","v":"30","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":3520,"y":120,"wires":[["550e83e8.cea0bc"]]},{"id":"d514fd4e.1760f","type":"msg-speed","z":"df12de57.5f0de8","name":"Speed check","frequency":"sec","estimation":false,"ignore":false,"x":3500,"y":200,"wires":[["1f09d605.a0d692"],[]]},{"id":"e19ab931.4054","type":"function","z":"df12de57.5f0de8","name":"MQTT Decoder","func":"var newMsg = msg.payload; \nreturn newMsg;","outputs":1,"noerr":0,"x":170,"y":350,"wires":[["fdd06ad6.58f648"]],"info":"This node takes the *modified* message and puts it back to what it was on the other machine before it was sent via MQTT.\nSimple.\n2 lines of code."},{"id":"c7a35c66.615b08","type":"switch","z":"df12de57.5f0de8","name":"","property":"payload","propertyType":"msg","rules":[{"t":"istype","v":"json","vt":"json"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":930,"y":490,"wires":[["1ac1aca7.63849b"],[]]},{"id":"14bca9f3.42be86","type":"debug","z":"df12de57.5f0de8","name":"Raw alarm messages","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":630,"y":210,"wires":[]},{"id":"418ba4ad.aecb94","type":"simple-queue","z":"df12de57.5f0de8","name":"queue1","firstMessageBypass":false,"bypassInterval":"0","x":440,"y":210,"wires":[["14bca9f3.42be86"]]},{"id":"309cbd1b.871c72","type":"change","z":"df12de57.5f0de8","name":"Wipe","rules":[{"t":"set","p":"reset","pt":"msg","to":"1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":430,"y":160,"wires":[["418ba4ad.aecb94"]]},{"id":"36b4dfe0.14a7a8","type":"change","z":"df12de57.5f0de8","name":"Read","rules":[{"t":"set","p":"trigger","pt":"msg","to":"1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":430,"y":120,"wires":[["418ba4ad.aecb94"]]},{"id":"7a0da546.b3aea4","type":"inject","z":"df12de57.5f0de8","name":"Wipe","topic":"","payload":" ","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":"","x":300,"y":160,"wires":[["309cbd1b.871c72"]]},{"id":"53e388a0.89a718","type":"inject","z":"df12de57.5f0de8","name":"Read","topic":"","payload":" ","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":"","x":300,"y":120,"wires":[["36b4dfe0.14a7a8"]]},{"id":"1ecd3a9e.dc5bfd","type":"mqtt-broker","z":"","name":"MQTT host","broker":"192.168.0.99","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"SOM","birthQos":"0","birthPayload":"TelePi comms up","closeTopic":"EOM","closePayload":"TelePi shutting down","willTopic":"EOM","willQos":"0","willPayload":"TelePi Comms Failure"}]

Are the settings correct in that node to parse that message?

I got a (somewhat large) crash this morning and about 75 of those errors.
I didn't check all of them, but the ones at which I looked were all the same.

It was a bit of a run away that didn't quite run away.

If ever in doubt, paste your string into one of the many online JSON validators.

Hmmmm, no, JSON (aka JavaScript Object Notation) by definition IS a string (a string notation that represents a JavaScript Object)

(PS: forgive me @bakman2, sorry to pull you up on that - i respect your abilities & I know very well you know the difference but this statement is somewhat inaccurate and misleading)

EDIT: I may have misread your post @bakman2 - i'm not sure now :thinking:

Agreed.

Well, thanks all.

I've book marked it and shall use it in future.

(Ok, silly me. Got the message I posted and the site says it IS a JSON message.)

So why is/was the MQTT IN node complaining?

(PS: forgive me @bakman2, sorry to pull you up on that - i respect your abilities & I know very well you know the difference but this statement is somewhat inaccurate and misleading)

EDIT: I may have misread your post @bakman2 - i'm not sure now :thinking:

I might have written too quickly :robot: long story short: I agree that it is valid (json)

@Trying_to_learn The actual input/output information is missing because the mqtt node failed to parse it.

is it possible that you are sending messages that contain double quotes or slashes for example, it could fail to parse it because those characters need to be escaped.

I'll have to keep looking at that then.

But thanks.

I am sure I am sending messages with / in them.

How are you generating the string in the first place? If you are using, for example, the MQTT out node to convert a string or object to JSON then it should handle the escaping. Similarly if you are generating the string using one of the javascript JSON functions then there should not be a problem. If, however, you are generating by hand then you may need to escape it yourself. Forward slashes are not a problem, just backslashes. See https://www.freeformatter.com/json-escape.html

Forward slashes do not need escaping, only backslash.

Oh poo.

I think I may have opened a lot of worm cans without knowing it.

Not wanting to sound argumentative, but I am wanting to understand this.
And ok, that could be taken the wrong way.
No, I am being honest. The reason I took so long to post (and edit) the reply is I was chasing a few more of those Gremlins. They are tenasious critters.

I am sure I am going to be caught out by other Gremlins but there is something I am missing.

If what is written above is true, and I understand it, this flow should NOT work.

It does.

What am I missing?

[{"id":"8c4deec3.12daa","type":"inject","z":"68e3655f.b606b4","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":730,"wires":[["82ab03f6.cb8f4"]]},{"id":"82ab03f6.cb8f4","type":"function","z":"68e3655f.b606b4","name":"Dummy message","func":"msg = {\n    \"RTC\":6456005,\n    \"local\":6462011,\n    \"time\":\"2020-08-31 17:57:15\",\n    \"payload\":6006,\n    \"foo\":[1,2,3],\n    \"text_test\":\"This/is/a/test\"\n};\n\nreturn msg;","outputs":1,"noerr":0,"x":310,"y":730,"wires":[["6b2d8513.aaeb8c","2e016dfd.4cde9a"]]},{"id":"6b2d8513.aaeb8c","type":"function","z":"68e3655f.b606b4","name":"*CHEAT NODE 1*","func":"//node.warn(msg);\n\nvar newMsg = {payload:msg}\n\nreturn newMsg;\n\n","outputs":1,"noerr":0,"x":540,"y":730,"wires":[["b129cbe6.38b008","3e18b789.00d998"]],"info":"This node has 2 lines and accepts dynamic message structures.\nSo you don't have to remmeber to add extra / new lines if/when you change the `message` structure.\n"},{"id":"93638132.e5b57","type":"function","z":"68e3655f.b606b4","name":"*CHEAT NODE 2*","func":"var newMsg = msg.payload; \nreturn newMsg;","outputs":1,"noerr":0,"x":340,"y":850,"wires":[["35d89213.20a016"]],"info":"This node takes the *modified* message and puts it back to what it was on the other machine before it was sent via MQTT.\nSimple.\n2 lines of code."},{"id":"2e016dfd.4cde9a","type":"debug","z":"68e3655f.b606b4","name":"OUT RAW 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":290,"y":690,"wires":[]},{"id":"b129cbe6.38b008","type":"debug","z":"68e3655f.b606b4","name":"OUT RAW 2","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":520,"y":690,"wires":[]},{"id":"3e18b789.00d998","type":"mqtt out","z":"68e3655f.b606b4","name":"","topic":"test","qos":"","retain":"","broker":"378c0403.8cda04","x":740,"y":730,"wires":[]},{"id":"83b3519a.944a4","type":"mqtt in","z":"68e3655f.b606b4","name":"","topic":"test","qos":"2","datatype":"json","broker":"378c0403.8cda04","x":130,"y":850,"wires":[["93638132.e5b57","fab49f16.15d5f"]]},{"id":"fab49f16.15d5f","type":"debug","z":"68e3655f.b606b4","name":"IN RAW 2","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":140,"y":810,"wires":[]},{"id":"35d89213.20a016","type":"debug","z":"68e3655f.b606b4","name":"IN RAW 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":530,"y":850,"wires":[]},{"id":"378c0403.8cda04","type":"mqtt-broker","z":"","name":"MQTT HOST","broker":"192.168.0.99","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthRetain":"true","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

It breaks the rules with the contents of the message.
There are / in the message.
There is an array - foo?

They all get through.

So please help me learn.

Why would you think it wont work?

You send a payload of ...

{
    "RTC":6456005,
    "local":6462011,
    "time":"2020-08-31 17:57:15",
    "payload":6006,
    "foo":[1,2,3],
    "text_test":"This/is/a/test"
}

... to an MQTT Out node - then receive it via an MQTT In node set to convert the JSON back to an object.

There is nothing in that payload that cannot be converted to a JSON string.

Proof...

Please...

Where are these "bad" MQTT messages being created though? outside of node-red?

If (for example) a library (say on an ESP32 or a python app) is not taking care of escaping payloads then it is possible to send (from elsewhere) bad data that cannot be parsed back into an object.

Your example was pointless as node-red converts the object (and escapes strings as necessary) for you.

Try this...

[{"id":"6f3eedcf.0ccdf4","type":"inject","z":"d0c7a908.ca3ac8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":260,"y":220,"wires":[["7448c565.963f9c"]]},{"id":"82b02fb0.99526","type":"mqtt out","z":"d0c7a908.ca3ac8","name":"","topic":"test","qos":"","retain":"","broker":"74e3858f.d1884c","x":590,"y":220,"wires":[]},{"id":"7559a98e.7d4b78","type":"mqtt in","z":"d0c7a908.ca3ac8","name":"","topic":"test","qos":"2","datatype":"json","broker":"74e3858f.d1884c","x":260,"y":340,"wires":[["286a72d.0ccf38e"]]},{"id":"286a72d.0ccf38e","type":"debug","z":"d0c7a908.ca3ac8","name":"IN RAW 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":420,"y":340,"wires":[]},{"id":"7448c565.963f9c","type":"function","z":"d0c7a908.ca3ac8","name":"","func":"msg.payload = '{\"RTC\":6456005,\"local\":6462011,\"time\":\"2020-08-31 17:57:15\",\"payload\":6006,\"foo\":[1,2,3],\"text_test\":This\\\\is/a/test\"}'\nreturn msg;","outputs":1,"noerr":0,"x":400,"y":220,"wires":[["82b02fb0.99526"]]},{"id":"74e3858f.d1884c","type":"mqtt-broker","z":"","name":"","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

to see how you can make it fail

I am not sure. Probably. As they don't come up often it is difficult to know.

Though I am now trying to capture them better so I can learn.

But if I want to send what is visible at point 1 in that flow, I can't just send it to MQTT and expect it to get through.

So I had a lot of pain building the messages with a change node. Then at the other end had to go through a similar deconstruction with another change node.

That just became painful, especially if/when I add another part to the message.

Oh, and something I also just discovered in the "sending" node and the code should really be:

var t = msg.topic;

var newMsg = {payload:msg}
newMsg.topic = t;

return newMsg;

Though that requires me to also include a topic in the message.
But as that is/can be dynamic, it is probably good.

I see what you are doing. It probably will work fine.
But that is a constructed message which I think isn't as easy to construct as the way I did it.

The problem I have (or think I have) is that I am on a remote machine and something happens.

To convey more than an absolutely basic message, and try to include a bit more, there are dynamic stuff which needs to be included.
Granted there needs to be a structure to that.

So when it goes into that part of the flow on the remote machine I set those variables as parts of the message. Like machine name, flow, and the entire error message.
So the way I got it done in those ..... 3 lines. It really makes life easier.

Then, I can expand / change or remove what is being sent and not have to worry about editing a change node modifying things in the msg structure.

Same at the other end.

Ok, here is an error I have now.

{"topic":"ERROR_REPORT/TelePi/ERROR_REPORT/TelePi/Alarm_Display/ALARM/A2","qos":2,"retain":false,"error":{"message":"Failed to parse JSON string","source":{"id":"fc06e466.761568","type":"mqtt in","name":"All alarms","count":1}},"_msgid":"1bea5b8b.4cec24","time":"2020-08-31 20:04:10","payload":{"message":"Failed to parse JSON string","source":{"id":"fc06e466.761568","type":"mqtt in","name":"All alarms","count":1}},"_event":"node:66a1ead7.4c42a4"}

Forget the format and look at the message.

It is a MQTT IN node and it Failed to parse JSON string

Ok, so I'll de-construct that.

This is what was sent to it:

{"payload":{"_msgid":"31d8d3a0.f40a9c","topic":"ALARM/A1","payload":"rgb,6,120,0,90","name":"NTP sync slip","event":"(not set)","priority":1,"device":"TimePi"},"topic":"ALARM/A1","_msgid":"31d8d3a0.f40a9c"}

I went to that site which validates JSON messages. Guess what. It is happy with it.
So what is happening to cause this to happen?

How is the mqtt in node configured for the ouput ? is it set to autodetect or to "a parsed JSON object" ?

That payload is not valid JSON