SOLVED Acting on a "No JSON" error?

Is there anyway I can put a switch node after the Routine Speak node; that if I get the “Error: no JSON at Incomin…” error it will repeat back from the template node again?

Whenever I get the error, the debug comes back as msg: string[7].

I tried adding a switch as shown below, but when the error happens, the ‘otherwise’ condition of the switch is not activated.
image

[{"id":"254b5561.22352a","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"662e3eb2.e4b6d","type":"inject","z":"254b5561.22352a","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":290,"y":260,"wires":[["d6b1612b.d1a54"]]},{"id":"d6b1612b.d1a54","type":"template","z":"254b5561.22352a","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<speak>\n    <voice name=\"Giorgio\">test</voice>\n</speak> ","output":"str","x":500,"y":260,"wires":[["c5e94aeb.26b0c8"]]},{"id":"c5e94aeb.26b0c8","type":"alexa-remote-routine","z":"254b5561.22352a","name":"","account":"f0ce5fbc.18734","routineNode":{"type":"speak","payload":{"type":"ssml","text":{"type":"msg","value":"payload"},"devices":["G6G0XG11030205CT"]}},"x":720,"y":260,"wires":[["3bc23a51.f86dd6","c2a0cac6.4db758"]]},{"id":"3bc23a51.f86dd6","type":"debug","z":"254b5561.22352a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":920,"y":140,"wires":[]},{"id":"c2a0cac6.4db758","type":"switch","z":"254b5561.22352a","name":"","property":"payload","propertyType":"msg","rules":[{"t":"null"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":600,"y":360,"wires":[[],["d6b1612b.d1a54"]]},{"id":"f0ce5fbc.18734","type":"alexa-remote-account","name":"","authMethod":"proxy","proxyOwnIp":"192.168.86.215","proxyPort":"3456","cookieFile":"Auth","refreshInterval":"15","alexaServiceHost":"pitangui.amazon.com","amazonPage":"amazon.com","acceptLanguage":"en-US","userAgent":"","useWsMqtt":"on","autoInit":"on"}]

Figured it out. I can do a catch node to just watch the routine speak node!

For future searchers: I’ve adapted your flow above (thanks for the idea) to repeat / re-try x5 times then stop. I will use this on the ‘re-initialise Alexa’ (cookie) nodes for alexaremote2 to reboot HA or NR as I’m fed up with my Routine Speak messages failing!
Nodes you will need - https://flows.nodered.org/node/do-red
flow:

[{"id":"b4b2ec8e.7cd3d","type":"inject","z":"d9faa645.5bfcf8","name":"on","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"on","payloadType":"str","x":390,"y":440,"wires":[["e6ed6a6d.d4be08"]]},{"id":"e6ed6a6d.d4be08","type":"do","z":"d9faa645.5bfcf8","name":"","tasks":["default"],"outputs":2,"x":475,"y":440,"wires":[["18a411bf.64436e"],["598a91e2.aaf43"]],"l":false},{"id":"56fa6528.5c1d2c","type":"do-return","z":"d9faa645.5bfcf8","name":"","mode":"done","x":1190,"y":460,"wires":[]},{"id":"ca07501a.17225","type":"do-return","z":"d9faa645.5bfcf8","name":"","mode":"continue","x":1200,"y":420,"wires":[]},{"id":"e9d329d.a2a1ad8","type":"alexa-remote-routine","z":"d9faa645.5bfcf8","name":"","account":"f21390a6.9c56d","routineNode":{"type":"speak","payload":{"type":"ssml","text":{"type":"msg","value":"payload"},"devices":["G2A1A603045208G8"]}},"x":640,"y":440,"wires":[["f611ce67.cfc6a"]]},{"id":"f611ce67.cfc6a","type":"switch","z":"d9faa645.5bfcf8","name":"Null?","property":"payload","propertyType":"msg","rules":[{"t":"null"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":755,"y":440,"wires":[[],["2a86ec56.c94b54"]],"l":false},{"id":"18a411bf.64436e","type":"template","z":"d9faa645.5bfcf8","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<speak>\n    <voice name=\"Giorgio\">test</voice>\n</speak> ","output":"str","x":535,"y":440,"wires":[["e9d329d.a2a1ad8"]],"l":false},{"id":"88119b67.0fe858","type":"debug","z":"d9faa645.5bfcf8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1170,"y":380,"wires":[]},{"id":"ed5f0896.fcdb08","type":"debug","z":"d9faa645.5bfcf8","name":"reset","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1170,"y":340,"wires":[]},{"id":"2a86ec56.c94b54","type":"trigger","z":"d9faa645.5bfcf8","name":"","op1":"","op2":"on","op1type":"nul","op2type":"str","duration":"5","extend":false,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":815,"y":440,"wires":[["6313c70e.46f2a8"]],"l":false},{"id":"2982414b.9f354e","type":"switch","z":"d9faa645.5bfcf8","name":"","property":"count","propertyType":"msg","rules":[{"t":"lt","v":"6","vt":"num"},{"t":"eq","v":"6","vt":"num"}],"checkall":"false","repair":false,"outputs":2,"x":1095,"y":440,"wires":[["ca07501a.17225","88119b67.0fe858"],["56fa6528.5c1d2c"]],"l":false},{"id":"6313c70e.46f2a8","type":"counter","z":"d9faa645.5bfcf8","name":"5&done","init":"0","step":"1","lower":"0","upper":"5","mode":"increment","outputs":1,"x":940,"y":440,"wires":[["b36506ba.0a7598"]]},{"id":"b36506ba.0a7598","type":"switch","z":"d9faa645.5bfcf8","name":"","property":"reset","propertyType":"msg","rules":[{"t":"eq","v":"true","vt":"str"},{"t":"else"}],"checkall":"false","repair":false,"outputs":2,"x":1035,"y":440,"wires":[[],["2982414b.9f354e"]],"l":false},{"id":"598a91e2.aaf43","type":"change","z":"d9faa645.5bfcf8","name":"reset","rules":[{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"reset","pt":"msg","to":"true","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":730,"y":400,"wires":[["2a86ec56.c94b54","6313c70e.46f2a8","ed5f0896.fcdb08"]]},{"id":"fe26cc6.caa0d3","type":"catch","z":"d9faa645.5bfcf8","name":"Alexa errors","scope":["e9d329d.a2a1ad8"],"uncaught":false,"x":430,"y":400,"wires":[["18a411bf.64436e"]]},{"id":"f21390a6.9c56d","type":"alexa-remote-account","name":"alexa Matty","authMethod":"proxy","proxyOwnIp":"192.168.1.104","proxyPort":"3457","cookieFile":"/config/node-red/data/amazon.txt","refreshInterval":"3","alexaServiceHost":"alexa.amazon.co.uk","amazonPage":"amazon.co.uk","acceptLanguage":"en-UK","userAgent":"","useWsMqtt":"on","autoInit":"on"}]

pic:

1 Like