Get Country Wise Covid-19 Data To Your Esp8266 / ESP32 / Notification
Get Covid-19 Data for Selected Country. You can send data to ESP8266 / ESP32 / Any Messaging Platform.
Requirements:
Register on https://rapidapi.com/ to get API
Fill the country name & api on the "ADD API..." function.
See the output of the data for valid information.
Extracts :
country date totalcases newcases recovered deaths tests
You can add more information from the data packets.
This flow uses http request & Cron Alarm nodes to get timed events.
[{"id":"1c89443f.7ea18c","type":"inject","z":"964ca265.ea748","name":"timer","topic":"1","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":160,"wires":[["e186d8ee.f30b98"]]},{"id":"ece085c5.98b2c","type":"debug","z":"964ca265.ea748","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":790,"y":480,"wires":[]},{"id":"4da1ae82.830e1","type":"http request","z":"964ca265.ea748","name":"","method":"GET","ret":"txt","paytoqs":false,"url":"","tls":"","proxy":"","authType":"","x":430,"y":280,"wires":[["c39adbc6.e8bfb8"]]},{"id":"e186d8ee.f30b98","type":"function","z":"964ca265.ea748","name":"ADD API & COUNTRY","func":"//Change your country (First Letter Capital)\nvar country = \"India\";\n\nmsg.url = \"https://covid-193.p.rapidapi.com/statistics?country=\" + country;\nmsg.payload = \"\"\nmsg.headers = {};\nmsg.headers['x-rapidapi-host'] = 'covid-193.p.rapidapi.com';\nmsg.headers['x-rapidapi-key'] = '_YOUR_KEY_HERE_';\nreturn msg;\n\n// Register to rapidapi.com\n//Get key and write here\n//Change country and go.","outputs":1,"noerr":0,"x":340,"y":220,"wires":[["4da1ae82.830e1"]]},{"id":"c39adbc6.e8bfb8","type":"json","z":"964ca265.ea748","name":"","property":"payload","action":"","pretty":false,"x":550,"y":340,"wires":[["810d37e3.82a218"]]},{"id":"810d37e3.82a218","type":"function","z":"964ca265.ea748","name":"Extract Info","func":"var payload = msg.payload;\nvar country = payload.response[0].country;\nvar date = payload.response[0].day;\nvar total=payload.response[0].cases.total;\nvar newcases = payload.response[0].cases.new;\nvar recovered = payload.response[0].cases.recovered;\nvar deaths = payload.response[0].deaths.total;\nvar tests = payload.response[0].tests.total;\n\nmsg.payload = \n\"Covid-19 : \" + total + \" New: \" + newcases + \"\\r\\n\" + \"\\r\\n\" +\n\"Covid Stats for \" + country + \"\\r\\n\" + \n\"Date: \" + date + \"\\r\\n\" + \n\"\\r\\n\" + \n\"Total Cases : \" + total + \"\\r\\n\" +\n\"New Cases : \" + newcases + \"\\r\\n\" + \n\"Recovered : \" + recovered + \"\\r\\n\" + \n\"Deaths : \" + deaths + \"\\r\\n\" + \n\"Tests Done : \" + tests + \"\\r\\n\";\n\nreturn msg;\n\n\n\n","outputs":1,"noerr":0,"x":650,"y":400,"wires":[["ece085c5.98b2c","a390d72d.503af"]]},{"id":"5d33e100.c82c2","type":"cronplus","z":"964ca265.ea748","name":"INDIA 12pm & 10pm, Daily","outputField":"payload","timeZone":"Asia/Kolkata","options":[{"topic":"Start-of-shift","payload":"Start work now ","type":"str","expression":"0 0 12 * * *"},{"topic":"End-of-shift","payload":"Go home","type":"str","expression":"0 0 22 * * *"}],"x":140,"y":60,"wires":[["e186d8ee.f30b98"]]},{"id":"f0bee77b.a34ba8","type":"comment","z":"964ca265.ea748","name":"Get Covid-19 Data (Select Country in function : \"ADD API & COUNTRY\"","info":"","x":590,"y":140,"wires":[]},{"id":"a390d72d.503af","type":"pushbullet","z":"964ca265.ea748","config":"899138b7.30fc48","pushtype":"note","title":"Covid-19 Stats in India","chan":"","name":"Pushbullet","x":790,"y":440,"wires":[]},{"id":"899138b7.30fc48","type":"pushbullet-config","z":"","name":"Pushbullet"}]