Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workaround for "no json", "no body" etc. #18

Open
bwims opened this issue Apr 2, 2021 · 7 comments
Open

Workaround for "no json", "no body" etc. #18

bwims opened this issue Apr 2, 2021 · 7 comments

Comments

@bwims
Copy link

bwims commented Apr 2, 2021

What I find works for me is the following workaround:

  1. In every flow with Alexa Remote routines, I use a catch node specifying all of them, sending them to debug in the first place.
  2. I then use a switch node to check for the errors, e.g.no Json, Authentication failed: "no body", etc and execute an "initialise"
  3. if it's an error I haven't checked for, it goes to the debug line. If re-initalising cures it, it goes in the check list.
@bwims
Copy link
Author

bwims commented Apr 3, 2021 via email

@ghost
Copy link

ghost commented Apr 3, 2021

Thank you very much ....

@maddingamer
Copy link

@bwims could you provide your exported flow? :)

@bwims
Copy link
Author

bwims commented Apr 11, 2021

It's very difficult, which is why I used screenshots. The alexa routines won't point to any meaningful devices, so will immediately be unconfigured.

Still, here you go

First flow is where the account is initialised periodically after authentication the link comes in from any tab which has an alexa node that may throw an error.

[{"id":"b9eb3ad5.40c0b8","type":"alexa-remote-init","z":"87fa7c5d.a1e39","name":"","account":"77f08fbc.87385","option":"initialise","x":550,"y":300,"wires":[["5b221ebc.7f747"]]},{"id":"343315b2.cc471a","type":"inject","z":"87fa7c5d.a1e39","name":"","topic":"","payload":"","payloadType":"date","repeat":"10800","crontab":"","once":true,"onceDelay":"5","x":340,"y":300,"wires":[["b9eb3ad5.40c0b8"]]},{"id":"9fd88224.61fec","type":"catch","z":"87fa7c5d.a1e39","name":"","scope":["b9eb3ad5.40c0b8"],"uncaught":false,"x":760,"y":300,"wires":[["d80b17e5.463358"]]},{"id":"776955b9.8dc69c","type":"debug","z":"87fa7c5d.a1e39","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1080,"y":500,"wires":[]},{"id":"71a60332.bd9bcc","type":"delay","z":"87fa7c5d.a1e39","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"5","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":810,"y":200,"wires":[["b9eb3ad5.40c0b8"]]},{"id":"5b221ebc.7f747","type":"change","z":"87fa7c5d.a1e39","name":"","rules":[{"t":"set","p":"loginCookie","pt":"flow","to":"payload.loginCookie","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":860,"y":400,"wires":[[]]},{"id":"d80b17e5.463358","type":"switch","z":"87fa7c5d.a1e39","name":"","property":"error.message","propertyType":"msg","rules":[{"t":"eq","v":"Authentication failed: "no JSON"","vt":"str"},{"t":"eq","v":"Error while checking Authentication: Error: no JSON","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":3,"x":960,"y":320,"wires":[["71a60332.bd9bcc"],["71a60332.bd9bcc"],["71a60332.bd9bcc","776955b9.8dc69c"]]},{"id":"3681816c.1b119e","type":"link in","z":"87fa7c5d.a1e39","name":"Init Alexa In","links":["e0401e43.1fce7","828f912b.28846","9daaf98d.1228c8"],"x":265,"y":360,"wires":[["b9eb3ad5.40c0b8"]]}]

Here is an example of a tab catching an alexa error and linking back. Of course, I'm only using it for remote button presses, so can just retry. Other needs may include sending some kind of message of failure.

[{"id":"5a40b572.06952c","type":"catch","z":"5beb7bc7.3bcfb4","name":"alexa bug","scope":["87f2843a.ae13f8","74405399.be3b6c","c60f46aa.c20ad8","2853b155.0f3ebe","50f53085.2ca5f","e3b44ec5.cc5aa","efaade47.56557","14bbed52.8d8b63","475f358.31958cc","184f5464.828c8c"],"uncaught":false,"x":340,"y":660,"wires":[["edb18d3d.abc9d"]]},{"id":"293dbc4e.8747d4","type":"debug","z":"5beb7bc7.3bcfb4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":870,"y":700,"wires":[]},{"id":"edb18d3d.abc9d","type":"switch","z":"5beb7bc7.3bcfb4","name":"","property":"error","propertyType":"msg","rules":[{"t":"eq","v":"no body","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":530,"y":660,"wires":[["81eb5e8b.4c2fa"],["b2ad0cf.d5400f"]]},{"id":"81eb5e8b.4c2fa","type":"link out","z":"5beb7bc7.3bcfb4","name":"Init Alexa out","links":["722a72b1.e268ac","d53cd4b0.0a6b68","ff4d4dd1.31634"],"x":665,"y":620,"wires":[]},{"id":"b2ad0cf.d5400f","type":"switch","z":"5beb7bc7.3bcfb4","name":"","property":"error.message","propertyType":"msg","rules":[{"t":"eq","v":"no JSON","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":610,"y":740,"wires":[["81eb5e8b.4c2fa"],["81eb5e8b.4c2fa","293dbc4e.8747d4"]]}]

@cvlaray
Copy link

cvlaray commented May 31, 2021

It seems that the "no json" error is triggered when I try to run several commands in a short time. At least in my case, the problem was solved by introducing a delay of 3 seconds before executing another command in the same device. I am not sure if it also occurs when different devices are used simultaneously.

@Toxo666
Copy link

Toxo666 commented May 31, 2021

Hi.

Here mine auth checking flow with catch & status node. Status Node monitors "Check Authentication" node.
It shows a led on dashboard green/red, logs errors and input cookie file at intialise.
Maybe it will help someone...

You need node-red-contrib-moment and node-red-contrib-ui-led.

msedge_JuO2zxZ4iY

[{"id":"f5b2703d.3f79d","type":"file","z":"4d9e927f.d52e2c","name":"","filename":"/home/pi/alexa","appendNewline":true,"createDir":false,"overwriteFile":"true","encoding":"none","x":1420,"y":180,"wires":[[]]},{"id":"bd1729dc.9d8758","type":"change","z":"4d9e927f.d52e2c","name":"","rules":[{"t":"set","p":"alexa","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1420,"y":140,"wires":[[]]},{"id":"ee77b0e8.1b91c","type":"ui_button","z":"4d9e927f.d52e2c","name":"Alexa Reset","group":"eb78ed9c.20848","order":16,"width":1,"height":1,"passthru":false,"label":"","tooltip":"Alexa Reset","color":"","bgcolor":"grey","icon":"fa-retweet","payload":"","payloadType":"date","topic":"","x":630,"y":100,"wires":[["d220208c.40d3b"]]},{"id":"484f5986.021418","type":"file in","z":"4d9e927f.d52e2c","name":"alexa","filename":"/home/pi/alexa","format":"utf8","chunk":false,"sendError":false,"encoding":"none","x":1010,"y":160,"wires":[["7bf02bbc.104ae4"]]},{"id":"7bf02bbc.104ae4","type":"json","z":"4d9e927f.d52e2c","name":"","property":"payload","action":"","pretty":false,"x":1130,"y":160,"wires":[["3e0d0c9.943eef4"]]},{"id":"639378d4.ad4978","type":"file","z":"4d9e927f.d52e2c","name":"","filename":"/home/pi/log/alexa.txt","appendNewline":true,"createDir":false,"overwriteFile":"false","encoding":"none","x":440,"y":100,"wires":[[]]},{"id":"cfb27548.6d2dc8","type":"moment","z":"4d9e927f.d52e2c","name":"","topic":"","input":"payload.time","inputType":"msg","inTz":"Europe/Berlin","adjAmount":0,"adjType":"days","adjDir":"add","format":"dddd, D. MMM YYYY HH:mm:ss","locale":"de_DE","output":"payload.time","outputType":"msg","outTz":"Europe/Berlin","x":440,"y":160,"wires":[["639378d4.ad4978","4b03afdd.df7cb"]]},{"id":"efa3155.0c0b6e8","type":"catch","z":"4d9e927f.d52e2c","name":"","scope":null,"uncaught":false,"x":100,"y":160,"wires":[["e2775d07.9aa82"]]},{"id":"4b03afdd.df7cb","type":"switch","z":"4d9e927f.d52e2c","name":"","property":"payload.message","propertyType":"msg","rules":[{"t":"eq","v":"account not initialised","vt":"str"},{"t":"eq","v":"Timeout","vt":"str"},{"t":"eq","v":"no body","vt":"str"},{"t":"eq","v":"no JSON","vt":"str"}],"checkall":"true","repair":false,"outputs":4,"x":650,"y":160,"wires":[["42980c02.ccd8d4","d220208c.40d3b"],["42980c02.ccd8d4","d220208c.40d3b"],["42980c02.ccd8d4","d220208c.40d3b"],["42980c02.ccd8d4","d220208c.40d3b"]]},{"id":"e2775d07.9aa82","type":"change","z":"4d9e927f.d52e2c","name":"move error","rules":[{"t":"move","p":"payload","pt":"msg","to":"temp","tot":"msg"},{"t":"move","p":"error","pt":"msg","to":"payload","tot":"msg"},{"t":"set","p":"time","pt":"msg","to":"","tot":"date"},{"t":"move","p":"time","pt":"msg","to":"payload.time","tot":"msg"},{"t":"move","p":"temp","pt":"msg","to":"payload.temp","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":250,"y":160,"wires":[["cfb27548.6d2dc8"]]},{"id":"d220208c.40d3b","type":"delay","z":"4d9e927f.d52e2c","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"minute","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":840,"y":160,"wires":[["484f5986.021418"]]},{"id":"11328392.ed3a6c","type":"inject","z":"4d9e927f.d52e2c","name":"","props":[{"p":"payload"}],"repeat":"3600","crontab":"","once":true,"onceDelay":"15","topic":"","payload":"","payloadType":"str","x":110,"y":240,"wires":[["d6d707c4.fb75f8"]]},{"id":"978da742.b217c8","type":"ui_button","z":"4d9e927f.d52e2c","name":"","group":"eb78ed9c.20848","order":19,"width":"2","height":"1","passthru":false,"label":"Check Auth","tooltip":"Check Authentication on amazon.de","color":"","bgcolor":"grey","icon":"","payload":"","payloadType":"str","topic":"topic","topicType":"msg","x":110,"y":200,"wires":[["d6d707c4.fb75f8"]]},{"id":"2e13dc69.5ac1c4","type":"ui_led","z":"4d9e927f.d52e2c","order":21,"group":"eb78ed9c.20848","width":"1","height":"1","label":"","labelPlacement":"left","labelAlignment":"left","colorForValue":[{"color":"#ff0000","value":"false","valueType":"bool"},{"color":"#008000","value":"true","valueType":"bool"}],"allowColorForValueInMessage":false,"shape":"circle","showGlow":true,"name":"","x":1010,"y":240,"wires":[]},{"id":"3120f481.683a3c","type":"status","z":"4d9e927f.d52e2c","name":"","scope":["d6d707c4.fb75f8"],"x":400,"y":260,"wires":[["502e94c8.2ea78c"]]},{"id":"42980c02.ccd8d4","type":"change","z":"4d9e927f.d52e2c","name":"false","rules":[{"t":"set","p":"payload","pt":"msg","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":890,"y":220,"wires":[["2e13dc69.5ac1c4"]]},{"id":"502e94c8.2ea78c","type":"switch","z":"4d9e927f.d52e2c","name":"","property":"status.text","propertyType":"msg","rules":[{"t":"eq","v":"success","vt":"str"},{"t":"eq","v":"sending","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":530,"y":260,"wires":[["b7abc05f.e0b84","a9bb6b71.050a18"],["cc244418.2b8898"]]},{"id":"b7abc05f.e0b84","type":"change","z":"4d9e927f.d52e2c","name":"reset","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":650,"y":220,"wires":[["d43096ed.0c0178"]]},{"id":"a9bb6b71.050a18","type":"delay","z":"4d9e927f.d52e2c","name":"1s","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":650,"y":260,"wires":[["6e649ae1.7a1934"]]},{"id":"6e649ae1.7a1934","type":"change","z":"4d9e927f.d52e2c","name":"true","rules":[{"t":"set","p":"payload","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":770,"y":260,"wires":[["d43096ed.0c0178"]]},{"id":"cc244418.2b8898","type":"change","z":"4d9e927f.d52e2c","name":"false","rules":[{"t":"set","p":"delay","pt":"msg","to":"10000","tot":"num"},{"t":"set","p":"payload","pt":"msg","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":650,"y":300,"wires":[["d43096ed.0c0178"]]},{"id":"d43096ed.0c0178","type":"delay","z":"4d9e927f.d52e2c","name":"var","pauseType":"delayv","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":890,"y":260,"wires":[["2e13dc69.5ac1c4"]]},{"id":"ab45eb51.a27048","type":"inject","z":"4d9e927f.d52e2c","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":true,"onceDelay":"20","topic":"","payload":"","payloadType":"date","x":630,"y":60,"wires":[["d220208c.40d3b"]]},{"id":"d6d707c4.fb75f8","type":"alexa-remote-other","z":"4d9e927f.d52e2c","name":"","account":"e602d30e.6d251","config":{"option":"checkAuthentication"},"x":300,"y":220,"wires":[[]]},{"id":"3e0d0c9.943eef4","type":"alexa-remote-init","z":"4d9e927f.d52e2c","name":"","account":"e602d30e.6d251","option":"initialise","x":1260,"y":160,"wires":[["bd1729dc.9d8758","f5b2703d.3f79d"]]},{"id":"eb78ed9c.20848","type":"ui_group","name":"Test","tab":"57d20ffc.0aff7","order":1,"disp":false,"width":10,"collapse":false},{"id":"e602d30e.6d251","type":"alexa-remote-account","name":"","authMethod":"proxy","proxyOwnIp":"localhost","proxyPort":"3456","cookieFile":"/home/pi/alexa","refreshInterval":"3","alexaServiceHost":"pitangui.amazon.com","amazonPage":"amazon.com","acceptLanguage":"en-US","userAgent":"","useWsMqtt":"on","autoInit":"on"},{"id":"57d20ffc.0aff7","type":"ui_tab","name":"Bad","icon":"hot_tub","order":3,"disabled":false,"hidden":false}]

Greetings Toxo

@gaussey
Copy link

gaussey commented Jun 3, 2021

Solution : #22 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants