-
Notifications
You must be signed in to change notification settings - Fork 0
/
flow-file.json
1 lines (1 loc) · 3.43 KB
/
flow-file.json
1
[{"id":"8981a3df.74d82","type":"tab","label":"When can I see the ISS","disabled":false,"info":""},{"id":"91bf0ac4.22ea9","type":"http request","z":"8981a3df.74d82","name":"Convert UK postcode","method":"GET","ret":"obj","paytoqs":false,"url":"api.postcodes.io/postcodes/{{{postcode}}}","tls":"","persist":false,"proxy":"","authType":"","x":260,"y":280,"wires":[["b62a5e8e.1f70b8","f61b5d3a.9bda1"]]},{"id":"3ca18412.522c14","type":"change","z":"8981a3df.74d82","name":"","rules":[{"t":"set","p":"postcode","pt":"msg","to":"req.query.postcode","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":190,"y":200,"wires":[["91bf0ac4.22ea9"]]},{"id":"abd1f71.68be908","type":"change","z":"8981a3df.74d82","name":"","rules":[{"t":"set","p":"longitude","pt":"msg","to":"payload.result.longitude","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":550,"y":100,"wires":[["d5acbf94.5b1ac8"]]},{"id":"d5acbf94.5b1ac8","type":"change","z":"8981a3df.74d82","name":"","rules":[{"t":"set","p":"latitude","pt":"msg","to":"payload.result.latitude","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":160,"wires":[["842507d0.1e9bc8"]]},{"id":"842507d0.1e9bc8","type":"http request","z":"8981a3df.74d82","name":"Request next ISS pass","method":"GET","ret":"obj","paytoqs":false,"url":"http://api.open-notify.org/iss-pass.json?lat={{latitude}}&lon={{longitude}}","tls":"","persist":false,"proxy":"","authType":"","x":640,"y":220,"wires":[["6fda684.f4e7398"]]},{"id":"f7adf79f.56fc18","type":"http in","z":"8981a3df.74d82","name":"When will the ISS be visible next?","url":"iss","method":"get","upload":false,"swaggerDoc":"","x":150,"y":120,"wires":[["3ca18412.522c14"]]},{"id":"dc8d5e10.f8a678","type":"http response","z":"8981a3df.74d82","name":"Respond to request","statusCode":"","headers":{},"x":720,"y":340,"wires":[]},{"id":"b62a5e8e.1f70b8","type":"switch","z":"8981a3df.74d82","name":"Good postcode found","property":"statusCode","propertyType":"msg","rules":[{"t":"eq","v":"200","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":520,"y":40,"wires":[["abd1f71.68be908"]]},{"id":"f61b5d3a.9bda1","type":"switch","z":"8981a3df.74d82","name":"Bad postcode or failure","property":"statusCode","propertyType":"msg","rules":[{"t":"neq","v":"200","vt":"num"}],"checkall":"false","repair":false,"outputs":1,"x":530,"y":460,"wires":[["992d0deb.d3f55"]]},{"id":"992d0deb.d3f55","type":"http response","z":"8981a3df.74d82","name":"Failed to find postcode","statusCode":"404","headers":{},"x":550,"y":520,"wires":[]},{"id":"6fda684.f4e7398","type":"function","z":"8981a3df.74d82","name":"Prepare output","func":"// Gather details from the next ISS pass\n// over user-specified location.\nduration = msg.payload.response[0].duration;\nrisetime = msg.payload.response[0].risetime;\nstrTime = new Date(risetime*1000).toLocaleString('en-GB', { timeZone: 'UTC', timeZoneName: 'short' });\ndateDuration = new Date(duration*1000);\nstrDuration = dateDuration.getMinutes()\n + \" minutes \"\n + dateDuration.getSeconds()\n + \" seconds\";\n\n// Delete previous request details\ndelete msg.payload.request;\ndelete msg.payload.response;\n\n// Create output details\nmsg.payload.time = risetime;\nmsg.payload.strtime = strTime;\nmsg.payload.duration = duration; \nmsg.payload.strduration = strDuration;\nreturn msg;","outputs":1,"noerr":0,"x":660,"y":280,"wires":[["dc8d5e10.f8a678"]]}]