-
Notifications
You must be signed in to change notification settings - Fork 0
/
final.json
1 lines (1 loc) · 18.6 KB
/
final.json
1
[{"id":"d311a3e8.fe2f","type":"tab","label":"Flow 3","disabled":false,"info":""},{"id":"2f187efc.40a5d2","type":"mqtt in","z":"d311a3e8.fe2f","name":"USD or CYN","topic":"outgoingTopic2","qos":"2","datatype":"auto","broker":"bd194014.b3f31","x":106.00018882751465,"y":144.66669845581055,"wires":[["a64828ef.f2de18","245fde06.096ff2"]],"l":false},{"id":"33d56cbb.021684","type":"debug","z":"d311a3e8.fe2f","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":391.00013256073,"y":141.00004196166992,"wires":[],"l":false},{"id":"32011de6.b5a8f2","type":"inject","z":"d311a3e8.fe2f","name":"Currency","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":633.6666946411133,"y":187.66668510437012,"wires":[["642f37ae.a09458"]]},{"id":"642f37ae.a09458","type":"http request","z":"d311a3e8.fe2f","name":"Get cureency values","method":"GET","ret":"txt","paytoqs":"body","url":"https://api.currencyscoop.com/v1/latest?api_key=53e6a9b8f099686afaef8c3057eebdc3","tls":"","persist":false,"proxy":"","authType":"","x":848.6667022705078,"y":186.66668510437012,"wires":[["29901684.191bba"]]},{"id":"29901684.191bba","type":"json","z":"d311a3e8.fe2f","name":"","property":"payload","action":"obj","pretty":false,"x":979.3334140777588,"y":185.00006008148193,"wires":[["bdeb334f.c0ee7"]],"l":false},{"id":"bdeb334f.c0ee7","type":"function","z":"d311a3e8.fe2f","name":"set Rate","func":"let Rate=msg.payload.response.rates.CNY;\nglobal.set(\"UtC\",Rate)\nreturn {\n USDtoCNY:Rate,\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1074.333324432373,"y":187.00003051757812,"wires":[["acbefa06.b61948"]],"l":false},{"id":"9b84470b.2b8238","type":"debug","z":"d311a3e8.fe2f","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1211.9999980926514,"y":185.0000400543213,"wires":[],"l":false},{"id":"ea0b40cb.f4819","type":"mqtt in","z":"d311a3e8.fe2f","name":"Amount","topic":"outgoingTopic3","qos":"2","datatype":"auto","broker":"bd194014.b3f31","x":102.66666889190674,"y":196.66668128967285,"wires":[["34298ddc.639f32"]],"l":false},{"id":"4325c987.43a188","type":"debug","z":"d311a3e8.fe2f","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":387.66661262512207,"y":193.00002479553223,"wires":[],"l":false},{"id":"681cb382.fcbfdc","type":"mqtt in","z":"d311a3e8.fe2f","name":"","topic":"outgoingTopic4","qos":"2","datatype":"auto","broker":"bd194014.b3f31","x":102.66666889190674,"y":237.6666660308838,"wires":[["e807fa5a.003d18"]],"l":false},{"id":"6b1c1480.dfd9ec","type":"debug","z":"d311a3e8.fe2f","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":387.66661262512207,"y":234.00000953674316,"wires":[],"l":false},{"id":"b554d76c.f38f08","type":"mqtt in","z":"d311a3e8.fe2f","name":"","topic":"outgoingTopic5","qos":"2","datatype":"auto","broker":"bd194014.b3f31","x":104.66678619384766,"y":291.66668128967285,"wires":[["9af951a9.d24eb"]],"l":false},{"id":"1d5d8587.0cf53a","type":"debug","z":"d311a3e8.fe2f","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":389.666729927063,"y":288.0000247955322,"wires":[],"l":false},{"id":"34298ddc.639f32","type":"function","z":"d311a3e8.fe2f","name":"","func":"global.set(\"Amount\",msg.payload)\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":220.00005435943604,"y":202.66667652130127,"wires":[["4325c987.43a188","642f37ae.a09458"]],"l":false},{"id":"a64828ef.f2de18","type":"function","z":"d311a3e8.fe2f","name":"","func":"global.set(\"Pref\",msg.payload)\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":224.66666889190674,"y":140.66668128967285,"wires":[["33d56cbb.021684"]],"l":false},{"id":"e807fa5a.003d18","type":"function","z":"d311a3e8.fe2f","name":"","func":"global.set(\"Weather\",msg.payload)\nif (msg.payload==\"yes\"|| \"Yes\"){\n msg.payload=1;\n \n}\nelse{\n msg.payload=0;\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":225.66666889190674,"y":239.6666660308838,"wires":[["6b1c1480.dfd9ec","5743b696.7a0fc8"]],"l":false},{"id":"9af951a9.d24eb","type":"function","z":"d311a3e8.fe2f","name":"","func":"global.set(\"location\",msg.payload)\nreturn msg;","outputs":1,"noerr":0,"initialize":"// Code added here will be run once\n// whenever the node is deployed.\nglobal.set(\"Country\",\"China\");\nflow.set(\"installationId\",\"No\");","finalize":"","x":222.66678619384766,"y":288.66668128967285,"wires":[["1d5d8587.0cf53a","c0d91a21.0da428"]],"l":false},{"id":"26f2a07.2c7ad6","type":"openweathermap","z":"d311a3e8.fe2f","name":"City","wtype":"current","lon":"","lat":"","city":"","country":"","language":"en","x":470.6666679382324,"y":349,"wires":[["b80e7f06.18463","6f915422.abcf4c"]]},{"id":"4014a04e.c6466","type":"inject","z":"d311a3e8.fe2f","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":209.00007152557373,"y":474.333384513855,"wires":[["5c4d5a6.a9953a4"]],"l":false},{"id":"9fe7e98.01ad618","type":"debug","z":"d311a3e8.fe2f","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":673.0001316070557,"y":349.0000066757202,"wires":[],"l":false},{"id":"b80e7f06.18463","type":"function","z":"d311a3e8.fe2f","name":"","func":"let desc= msg.payload.description;\nglobal.set(\"weather\",msg.payload.description);\nvar num = desc.replace(/[^0-9]/g, ''); \n//let numbers= parseInt(num,10); \nlet lat= (parseInt(num.slice(0,6)))/10000;\nlet long=(parseInt(num.slice(6)))/10000;\n\nglobal.set(\"Lat\",lat);\nglobal.set(\"Long\",long);\n\n\nreturn {\n payload:msg.payload.description,\n};","outputs":1,"noerr":0,"initialize":"","finalize":"","x":585.3334522247314,"y":349.3333740234375,"wires":[["9fe7e98.01ad618","ba96c7ff.7dcf38"]],"l":false},{"id":"6f915422.abcf4c","type":"debug","z":"d311a3e8.fe2f","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":554.0001993179321,"y":383,"wires":[],"l":false},{"id":"5c4d5a6.a9953a4","type":"function","z":"d311a3e8.fe2f","name":"","func":"\nreturn {\n location:{country:global.get(\"Country\"),city:global.get(\"location\")}\n}\n \n\n\n","outputs":1,"noerr":0,"initialize":"// Code added here will be run once\n// whenever the node is deployed.\nglobal.set(\"desc\",\"Please Enter City or Coordinates\");","finalize":"","x":327.66666412353516,"y":446.6666793823242,"wires":[["26f2a07.2c7ad6"]]},{"id":"2d663ad3.ad9af6","type":"http request","z":"d311a3e8.fe2f","name":"Get measurements","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://airapi.airly.eu/v2/measurements/installation?installationId={{installationId}}","tls":"","persist":false,"proxy":"","authType":"","x":1281.6666259765625,"y":635,"wires":[["32f3ad73.561c72","8a4d0114.6792d","974dee7.d83ab1"]]},{"id":"e3e3fbac.b55118","type":"http request","z":"d311a3e8.fe2f","name":"Get nearest station","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://airapi.airly.eu/v2/installations/nearest?lat={{lat}}&lng={{lng}}&maxDistanceKM={{maxDistanceKM}}","tls":"","persist":false,"proxy":"","authType":"","x":1001.6666259765625,"y":775,"wires":[["cd63d68.63f1e28","a932a754.196418"]]},{"id":"c71d1078.a891a","type":"function","z":"d311a3e8.fe2f","name":"Set params","func":"msg.lat = flow.get(\"latitude\");\nmsg.lng = flow.get(\"longitude\");\nmsg.maxDistanceKM = flow.get(\"maxDistanceKM\");\nmsg.headers = {};\nmsg.headers['Accept'] = 'application/json';\nmsg.headers['apikey'] = flow.get(\"apikey\");\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":861.6666259765625,"y":715,"wires":[["e3e3fbac.b55118"]]},{"id":"32f3ad73.561c72","type":"function","z":"d311a3e8.fe2f","name":"PM2.5 value","func":"let pm2 = msg.payload.current.values[1].value\nlet AQI=msg.payload.current.indexes[0].value\nlet quality=\"\"\nif(AQI<20){\n quality=\"Very Good\";\n}\nelse if(AQI<50){\n quality=\"Good\";\n}\nelse if(AQI<75){\n quality=\"Moderate\";\n}\nelse if(AQI<100){\n quality=\"Unhealthy for Sensitive Groups\";\n}\nelse{\n quality=\"Unhealthy\";\n}\nreturn { \n payload: \"\\nPM 2.5 value is \" + pm2+\n \"\\nPM AIRLY CAQI value is \" + AQI+\n \"\\n Air Quality is \" + quality\n \n};","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1541.6666259765625,"y":475,"wires":[["d19a5ec7.2470d","e37d9537.d25488","d6845060.58355","1b4dac9a.3f1083"]]},{"id":"a932a754.196418","type":"change","z":"d311a3e8.fe2f","name":"Remember station","rules":[{"t":"set","p":"installationId","pt":"flow","to":"msg.payload[0].id","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1241.6666259765625,"y":775,"wires":[["60d5b91e.fe5528"]]},{"id":"9d19f252.df086","type":"switch","z":"d311a3e8.fe2f","name":"Station selected?","property":"installationId","propertyType":"flow","rules":[{"t":"regex","v":"\\d","vt":"str","case":false},{"t":"else"}],"checkall":"false","repair":false,"outputs":2,"x":881.6666259765625,"y":615,"wires":[["60d5b91e.fe5528"],["c71d1078.a891a"]],"outputLabels":["Yes","No"]},{"id":"c73e27e6.639378","type":"inject","z":"d311a3e8.fe2f","name":"Pool every 20m","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"1200","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":881.6666259765625,"y":495,"wires":[["5c42600d.6eeed","9d19f252.df086","7aa78fad.f848a"]]},{"id":"5c42600d.6eeed","type":"credentials","z":"d311a3e8.fe2f","name":"Airly API key","props":[{"value":"apikey","type":"flow"},{"value":"apikey","type":"flow"}],"x":1163.6667404174805,"y":379,"wires":[[]]},{"id":"e32c66f0.bdacf8","type":"change","z":"d311a3e8.fe2f","name":"Forget station","rules":[{"t":"delete","p":"installationId","pt":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":1231.6666259765625,"y":855,"wires":[[]]},{"id":"cd63d68.63f1e28","type":"delay","z":"d311a3e8.fe2f","name":"After 1h","pauseType":"delay","timeout":"1","timeoutUnits":"hours","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1031.6666259765625,"y":855,"wires":[["e32c66f0.bdacf8"]]},{"id":"60d5b91e.fe5528","type":"function","z":"d311a3e8.fe2f","name":"Set params","func":"msg.installationId = flow.get(\"installationId\");\nmsg.headers = {};\nmsg.headers['Accept'] = 'application/json';\nmsg.headers['apikey'] = flow.get(\"apikey\");\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1141.6666259765625,"y":575,"wires":[["2d663ad3.ad9af6"]]},{"id":"64582c11.52e4b4","type":"comment","z":"d311a3e8.fe2f","name":"<-- Put your GPS location here","info":"","x":1441.6666259765625,"y":335,"wires":[]},{"id":"c8468d99.cdef","type":"comment","z":"d311a3e8.fe2f","name":"<-- Put your Airly API key here (package -contrib-credentials required)","info":"","x":1561.6666259765625,"y":375,"wires":[]},{"id":"7aa78fad.f848a","type":"change","z":"d311a3e8.fe2f","name":"Configuration","rules":[{"t":"set","p":"latitude","pt":"flow","to":"Lat","tot":"global"},{"t":"set","p":"longitude","pt":"flow","to":"Long","tot":"global"},{"t":"set","p":"maxDistanceKM","pt":"flow","to":"25","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":868.6666717529297,"y":398.0001039505005,"wires":[[]],"icon":"node-red/cog.png"},{"id":"d19a5ec7.2470d","type":"debug","z":"d311a3e8.fe2f","name":"PM 2.5","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1676.6666259765625,"y":435,"wires":[],"l":false},{"id":"8a4d0114.6792d","type":"debug","z":"d311a3e8.fe2f","name":"Full message","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1316.6666259765625,"y":475,"wires":[],"l":false},{"id":"e37d9537.d25488","type":"function","z":"d311a3e8.fe2f","name":"","func":"a=flow.get(\"latitude\");\nreturn {\n payload:a,\n \n};","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1851.333251953125,"y":309,"wires":[["9d34f5e8.6b75d8"]],"l":false},{"id":"9d34f5e8.6b75d8","type":"debug","z":"d311a3e8.fe2f","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1943.333251953125,"y":298,"wires":[],"l":false},{"id":"7ba78a0c.620414","type":"inject","z":"d311a3e8.fe2f","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1679.3333415985107,"y":244.33334732055664,"wires":[["e37d9537.d25488"]],"l":false},{"id":"d6845060.58355","type":"function","z":"d311a3e8.fe2f","name":"","func":"a=global.get(\"Lat\");\nreturn {\n payload:a,\n \n};","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1904.333251953125,"y":358,"wires":[["bfec7c25.dff55"]],"l":false},{"id":"bfec7c25.dff55","type":"debug","z":"d311a3e8.fe2f","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1996.333251953125,"y":347,"wires":[],"l":false},{"id":"13980cf6.cc9043","type":"inject","z":"d311a3e8.fe2f","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1863.3333435058594,"y":435.3333339691162,"wires":[["d6845060.58355"]],"l":false},{"id":"c0d91a21.0da428","type":"change","z":"d311a3e8.fe2f","name":"Configuration","rules":[{"t":"set","p":"latitude","pt":"flow","to":"Lat","tot":"global"},{"t":"set","p":"longitude","pt":"flow","to":"Long","tot":"global"},{"t":"set","p":"maxDistanceKM","pt":"flow","to":"25","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":624.3333129882812,"y":569.6666870117188,"wires":[["9d19f252.df086","f1cd01fe.297dd"]],"icon":"node-red/cog.png"},{"id":"acbefa06.b61948","type":"function","z":"d311a3e8.fe2f","name":"","func":"let amount=global.get(\"Amount\");\nlet UtoC=global.get(\"UtC\");\nlet pref=global.get(\"Pref\");\nvar text=\"a\";\nlet conv;\nif (pref==\"Dollars\"){\n conv=(amount*(1/UtoC));\n conv=conv.toFixed(2);\n text=amount+\"Renminbi is =\"+conv+\"United State dollars\";\n} \nelse if (pref==\"Renminbi\"){\n conv=(amount*UtoC); \n conv=conv.toFixed(2);\n text=amount+\" Dollar is = \"+conv+\" Renminbi\";\n}\nelse{}\n\nreturn {\n payload:text,\n};","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1128.6666259765625,"y":185.6666717529297,"wires":[["9b84470b.2b8238","ae6b1fc9.b8c41"]],"l":false},{"id":"974dee7.d83ab1","type":"debug","z":"d311a3e8.fe2f","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1672.0000305175781,"y":562.6666641235352,"wires":[],"l":false},{"id":"1b4dac9a.3f1083","type":"mqtt out","z":"d311a3e8.fe2f","name":"AIr Quality","topic":"incommingAirquality","qos":"","retain":"","broker":"bd194014.b3f31","x":1902.3333759307861,"y":546.9999866485596,"wires":[],"l":false},{"id":"ae6b1fc9.b8c41","type":"mqtt out","z":"d311a3e8.fe2f","name":"Currency","topic":"incommingCurrency","qos":"1","retain":"","broker":"bd194014.b3f31","x":1300.3333740234375,"y":113.66666412353516,"wires":[],"l":false},{"id":"ba96c7ff.7dcf38","type":"mqtt out","z":"d311a3e8.fe2f","name":"","topic":"incommingWeather","qos":"1","retain":"","broker":"bd194014.b3f31","x":701.3333587646484,"y":280.6666793823242,"wires":[],"l":false},{"id":"5743b696.7a0fc8","type":"switch","z":"d311a3e8.fe2f","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":270.9999952316284,"y":370.3333435058594,"wires":[["5c4d5a6.a9953a4"]],"l":false},{"id":"f0fcfafb.c39ae8","type":"debug","z":"d311a3e8.fe2f","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":673.0002040863037,"y":666.9999980926514,"wires":[],"l":false},{"id":"f1cd01fe.297dd","type":"function","z":"d311a3e8.fe2f","name":"","func":"let a=flow.get(\"installationId\");\nreturn {\n paylaod:a,\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","x":602.0000305175781,"y":628.0000152587891,"wires":[["f0fcfafb.c39ae8"]],"l":false},{"id":"fa650121.48c65","type":"function","z":"d311a3e8.fe2f","name":"","func":"var status=msg.covid.CN;\nreturn{\n payload:\"\\nNumber of cases :\"+status.cases+\n \"\\nNumber of deaths :\"+status.deaths+\n \"\\nNumber of recovered :\"+status.recovered+\n \"\\nActive Covid 19 Cases :\"+status.active+\n \"\\nCritical Situations :\"+status.critical+\n \"\\nToday Covid cases :\"+status.todaycases+\n \"\\nToday deaths :\"+status.todaydeaths,\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","x":634.8958129882812,"y":100,"wires":[["ab0cb011.97ec8","8dc59ab4.042708"]]},{"id":"8dc59ab4.042708","type":"mqtt out","z":"d311a3e8.fe2f","name":"","topic":"incommingCovid","qos":"","retain":"","broker":"9b782984.980858","x":887.8957862854004,"y":150.0000114440918,"wires":[]},{"id":"ab0cb011.97ec8","type":"debug","z":"d311a3e8.fe2f","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":864.8958129882812,"y":20,"wires":[]},{"id":"245fde06.096ff2","type":"country statistics","z":"d311a3e8.fe2f","name":"","infected":true,"deaths":true,"recovered":true,"active":true,"critical":true,"todaycases":true,"todaydeaths":true,"casepermilion":false,"regionFilter":true,"deathspermilion":false,"regionList":"[\"CN\"]","regionListType":"json","x":464.89581298828125,"y":100,"wires":[["fa650121.48c65"]]},{"id":"bd194014.b3f31","type":"mqtt-broker","name":"","broker":"Broker.mqttdashboard.com","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"9b782984.980858","type":"mqtt-broker","name":"","broker":"Broker.mqttdashboard.com","port":"1883","clientid":"","usetls":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]