-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathha-nr-mycovidstats.json
1 lines (1 loc) · 54.3 KB
/
ha-nr-mycovidstats.json
1
[{"id":"70d8432d3fe90b8b","type":"csv","z":"c8694ea1.9678f","name":"","sep":",","hdrin":true,"hdrout":"none","multi":"mult","ret":"\\n","temp":"","skip":"0","strings":true,"include_empty_strings":false,"include_null_values":false,"x":735,"y":2520,"wires":[["040b7d0b46092d60"]],"l":false},{"id":"040b7d0b46092d60","type":"function","z":"c8694ea1.9678f","name":"cases_malaysia","func":"newmsg = {};\nnewmsg.cases_malaysia = {};\n\n\nlet latestdata = msg.payload.pop()\n\nnewmsg.cases_malaysia[\"date\"] = latestdata.date;\nnewmsg.cases_malaysia[\"new_cases\"] = latestdata.cases_new;\nflow.set(\"cases_malaysia\", newmsg.cases_malaysia);\n\n\nreturn newmsg;\n\n\n//anasothman-myy, 6/6/2021 1000","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":860,"y":2520,"wires":[["7b95515e8c38725d"]]},{"id":"9acfbcc72c62b529","type":"http request","z":"c8694ea1.9678f","name":"cases_malaysia.csv","method":"GET","ret":"txt","paytoqs":"ignore","url":"https://raw.githubusercontent.com/MoH-Malaysia/covid19-public/main/epidemic/cases_malaysia.csv","tls":"","persist":false,"proxy":"","authType":"","x":560,"y":2520,"wires":[["70d8432d3fe90b8b"]]},{"id":"059089cddb283272","type":"comment","z":"c8694ea1.9678f","name":"COVID Stats","info":"","x":190,"y":2240,"wires":[]},{"id":"7b95515e8c38725d","type":"debug","z":"c8694ea1.9678f","name":"cases_malaysia","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1100,"y":2520,"wires":[]},{"id":"2d3da4806050804e","type":"debug","z":"c8694ea1.9678f","name":"cases_death","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1090,"y":2640,"wires":[]},{"id":"cfeb52067f163cca","type":"http request","z":"c8694ea1.9678f","name":"tests_malaysia.csv","method":"GET","ret":"txt","paytoqs":"ignore","url":"https://raw.githubusercontent.com/MoH-Malaysia/covid19-public/main/epidemic/tests_malaysia.csv","tls":"","persist":false,"proxy":"","authType":"","x":550,"y":2880,"wires":[["3a921e59f91839dc"]]},{"id":"68727e8c152fc631","type":"comment","z":"c8694ea1.9678f","name":"At least twice weekly","info":"","x":550,"y":2820,"wires":[]},{"id":"e24a5167b6727c1c","type":"comment","z":"c8694ea1.9678f","name":"Daily","info":"","x":510,"y":2460,"wires":[]},{"id":"2549b4016376e524","type":"inject","z":"c8694ea1.9678f","name":"","props":[{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","x":210,"y":3300,"wires":[["b0bdad2325c636b8"]]},{"id":"b0bdad2325c636b8","type":"http request","z":"c8694ea1.9678f","name":"citf_population","method":"GET","ret":"txt","paytoqs":"ignore","url":"https://raw.githubusercontent.com/CITF-Malaysia/citf-public/main/static/population.csv","tls":"","persist":false,"proxy":"","authType":"","x":520,"y":3300,"wires":[["86ffcb6ee44a6f7b"]]},{"id":"86ffcb6ee44a6f7b","type":"file","z":"c8694ea1.9678f","name":"Save to File","filename":"/share/covid_stats/citf_populations.csv","appendNewline":false,"createDir":true,"overwriteFile":"true","encoding":"none","x":710,"y":3300,"wires":[[]]},{"id":"a9691de3fe5b3e2f","type":"file in","z":"c8694ea1.9678f","name":"Retreive from File","filename":"/share/covid_stats/citf_populations.csv","format":"utf8","chunk":false,"sendError":false,"encoding":"none","allProps":false,"x":550,"y":3120,"wires":[["521cdb7f8b3a0011"]]},{"id":"521cdb7f8b3a0011","type":"csv","z":"c8694ea1.9678f","name":"","sep":",","hdrin":true,"hdrout":"none","multi":"mult","ret":"\\n","temp":"","skip":"0","strings":true,"include_empty_strings":false,"include_null_values":false,"x":695,"y":3120,"wires":[["79086502d0920389"]],"l":false},{"id":"b96694073105d3f1","type":"inject","z":"c8694ea1.9678f","name":"","props":[{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":270,"y":3120,"wires":[["a9691de3fe5b3e2f"]]},{"id":"01c19508c1393bc6","type":"debug","z":"c8694ea1.9678f","name":"File Retrieved","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1140,"y":3120,"wires":[]},{"id":"795e4c0575640d88","type":"http request","z":"c8694ea1.9678f","name":"cases_state.csv","method":"GET","ret":"txt","paytoqs":"ignore","url":"https://raw.githubusercontent.com/MoH-Malaysia/covid19-public/main/epidemic/cases_state.csv","tls":"","persist":false,"proxy":"","authType":"","x":540,"y":2580,"wires":[["3a6f93b9408e56a5"]]},{"id":"03dde84db64f3e75","type":"function","z":"c8694ea1.9678f","name":"cases_state","func":"\nlet newmsg = {};\nnewmsg.latest = [];\nnewmsg.cases_state = {};\n//newmsg.cases_malaysia = msg.cases_malaysia\n\nvar today = new Date();\nvar dd = String(today.getDate()-1).padStart(2, '0');\nvar mm = String(today.getMonth() + 1).padStart(2, '0'); //January is 0!\nvar yyyy = today.getFullYear();\nvar current_time = today.getHours();\ntoday = yyyy + '-' + mm + '-' + dd ;\nvar cumulative_state_cases = 0;\n\nnewmsg.today = today;\n// get first element - capture date as reference for rest to stay the same\nlet cases_state = msg.payload.pop();\nnewmsg.latest[0] = cases_state;\nnewmsg.cases_state.date = cases_state.date;\nnewmsg.cases_state[cases_state.state] = cases_state.cases_new;\ncumulative_state_cases += cases_state.cases_new;\n\n// pop remaining in list - expected 15+1 = 16 total\nfor (let i = 1; i < 16; i++) {\n let cases_state = msg.payload.pop();\n newmsg.latest[i] = cases_state;\n // only if the date is the same - reference to first latest[0]\n if (cases_state.date === newmsg.cases_state.date){\n \n newmsg.cases_state[cases_state.state] = cases_state.cases_new;\n cumulative_state_cases += cases_state.cases_new;\n\n }\n\n}\n\nnewmsg.cases_state.cumulative_state_cases = cumulative_state_cases;\nflow.set(\"cases_state\", newmsg.cases_state);\nnewmsg.latest = [];\n\nreturn newmsg;\n\n//anasothman-myy, 6/6/2021 1000","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":850,"y":2580,"wires":[["6d9c70ba70c75423"]]},{"id":"3a6f93b9408e56a5","type":"csv","z":"c8694ea1.9678f","name":"","sep":",","hdrin":true,"hdrout":"none","multi":"mult","ret":"\\n","temp":"","skip":"0","strings":true,"include_empty_strings":false,"include_null_values":false,"x":735,"y":2580,"wires":[["03dde84db64f3e75"]],"l":false},{"id":"6d9c70ba70c75423","type":"debug","z":"c8694ea1.9678f","name":"cases state","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1090,"y":2580,"wires":[]},{"id":"ea80ecae9df42d19","type":"function","z":"c8694ea1.9678f","name":"cases_death","func":"newmsg = {};\nnewmsg.cases_death = {};\n\nlet latestdata = msg.payload.pop()\n\nnewmsg.cases_death[\"date\"] = latestdata.date;\nnewmsg.cases_death[\"new_death\"] = latestdata.deaths_new;\nflow.set(\"cases_death\", newmsg.cases_death);\n\n\nreturn newmsg;\n\n\n//anasothman-myy, 6/6/2021 1000","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":850,"y":2640,"wires":[["2d3da4806050804e"]]},{"id":"f5e558105901a4ad","type":"csv","z":"c8694ea1.9678f","name":"","sep":",","hdrin":true,"hdrout":"none","multi":"mult","ret":"\\n","temp":"","skip":"0","strings":true,"include_empty_strings":false,"include_null_values":false,"x":735,"y":2640,"wires":[["ea80ecae9df42d19"]],"l":false},{"id":"1764adf069a9194b","type":"http request","z":"c8694ea1.9678f","name":"deaths_malaysia.csv","method":"GET","ret":"txt","paytoqs":"ignore","url":"https://raw.githubusercontent.com/MoH-Malaysia/covid19-public/main/epidemic/deaths_malaysia.csv","tls":"","persist":false,"proxy":"","authType":"","x":560,"y":2640,"wires":[["f5e558105901a4ad"]]},{"id":"178cb79beb7ebdf8","type":"inject","z":"c8694ea1.9678f","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":540,"y":2280,"wires":[["b8194249a2c6dd8e"]]},{"id":"059930c7d4dd9ff6","type":"debug","z":"c8694ea1.9678f","name":"clear flow context","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":990,"y":2280,"wires":[]},{"id":"b8194249a2c6dd8e","type":"change","z":"c8694ea1.9678f","name":"Clear Flow Context","rules":[{"t":"delete","p":"cases_death","pt":"flow"},{"t":"delete","p":"cases_malaysia","pt":"flow"},{"t":"delete","p":"cases_state","pt":"flow"},{"t":"delete","p":"test_samples","pt":"flow"},{"t":"delete","p":"cases_death_state","pt":"flow"},{"t":"delete","p":"hosp_stats","pt":"flow"},{"t":"delete","p":"vaksin_malaysia","pt":"flow"},{"t":"delete","p":"icu_stats","pt":"flow"},{"t":"delete","p":"citf_my_population","pt":"flow"},{"t":"delete","p":"vax_registration","pt":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":730,"y":2280,"wires":[["059930c7d4dd9ff6"]]},{"id":"57dd012367d79789","type":"function","z":"c8694ea1.9678f","name":"test_samples","func":"newmsg = {};\nnewmsg.test_samples = {};\n\nlet latestdata = msg.payload.pop()\n\nnewmsg.test_samples[\"date\"] = latestdata.date;\nnewmsg.test_samples[\"rtk_ag\"] = latestdata[\"rtk-ag\"];\nnewmsg.test_samples[\"pcr\"] = latestdata[\"pcr\"];\nnewmsg.test_samples[\"total_samples\"] = latestdata[\"pcr\"] + latestdata[\"rtk-ag\"];\nflow.set(\"test_samples\", newmsg.test_samples);\n\nreturn newmsg;\n\n\n//anasothman-myy, 6/6/2021 1000","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":850,"y":2880,"wires":[["f9a6b993d08c53de"]]},{"id":"3a921e59f91839dc","type":"csv","z":"c8694ea1.9678f","name":"","sep":",","hdrin":true,"hdrout":"none","multi":"mult","ret":"\\n","temp":"","skip":"0","strings":true,"include_empty_strings":false,"include_null_values":false,"x":735,"y":2880,"wires":[["57dd012367d79789"]],"l":false},{"id":"f9a6b993d08c53de","type":"debug","z":"c8694ea1.9678f","name":"test_samples","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1130,"y":2880,"wires":[]},{"id":"ef32c1dd01b04338","type":"debug","z":"c8694ea1.9678f","name":"cases_death_state","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1110,"y":2700,"wires":[]},{"id":"50777c7b9fd94ae5","type":"function","z":"c8694ea1.9678f","name":"cases_death_state","func":"\nlet newmsg = {};\nnewmsg.latest = [];\nnewmsg.cases_death_state = {};\n//newmsg.cases_malaysia = msg.cases_malaysia\n\nvar today = new Date();\nvar dd = String(today.getDate()-1).padStart(2, '0');\nvar mm = String(today.getMonth() + 1).padStart(2, '0'); //January is 0!\nvar yyyy = today.getFullYear();\nvar current_time = today.getHours();\ntoday = yyyy + '-' + mm + '-' + dd ;\n\nvar cumulative_new_death = 0;\n\nnewmsg.today = today;\n\n// get first element - capture date as reference for rest to stay the same\nlet statecase_today = msg.payload.pop();\nnewmsg.latest[0] = statecase_today;\nnewmsg.cases_death_state.date = statecase_today.date;\nnewmsg.cases_death_state[statecase_today.state] = statecase_today.deaths_new;\ncumulative_new_death += statecase_today.deaths_new;\n\n// pop remaining in list - expected 15+1 = 16 total\nfor (let i = 1; i < 16; i++) {\n let statecase_today = msg.payload.pop();\n newmsg.latest[i] = statecase_today;\n // only if the date is the same - reference to first latest[0]\n if (statecase_today.date === newmsg.cases_death_state.date){\n \n newmsg.cases_death_state[statecase_today.state] = statecase_today.deaths_new;\n cumulative_new_death += statecase_today.deaths_new;//\n\n }\n\n}\n \n \nnewmsg.cases_death_state.cumulative_new_death = cumulative_new_death;\nflow.set(\"cases_death_state\", newmsg.cases_death_state);\n \n \n//newmsg.latest = [];\n\nreturn newmsg;\n\n//anasothman-myy, 6/6/2021 1000","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":870,"y":2700,"wires":[["ef32c1dd01b04338"]]},{"id":"1e06e6849b0704ed","type":"csv","z":"c8694ea1.9678f","name":"","sep":",","hdrin":true,"hdrout":"none","multi":"mult","ret":"\\n","temp":"","skip":"0","strings":true,"include_empty_strings":false,"include_null_values":false,"x":735,"y":2700,"wires":[["50777c7b9fd94ae5"]],"l":false},{"id":"69aed142e0c73083","type":"http request","z":"c8694ea1.9678f","name":"deaths_statecsv","method":"GET","ret":"txt","paytoqs":"ignore","url":"https://raw.githubusercontent.com/MoH-Malaysia/covid19-public/main/epidemic/deaths_state.csv","tls":"","persist":false,"proxy":"","authType":"","x":540,"y":2700,"wires":[["1e06e6849b0704ed"]]},{"id":"b3acb6b476c095c8","type":"function","z":"c8694ea1.9678f","name":"Get flow data","func":"msg = {};\n\nlet cases_death = flow.get(\"cases_death\");\nlet cases_death_state = flow.get(\"cases_death_state\");\nlet cases_malaysia = flow.get(\"cases_malaysia\");\nlet cases_state = flow.get(\"cases_state\");\nlet test_samples = flow.get(\"test_samples\");\nlet hosp_stats = flow.get(\"hosp_stats\");\nlet vaksin_my = flow.get(\"vaksin_malaysia\");\nlet icu_stats = flow.get(\"icu_stats\");\nlet pkrc_stats = flow.get(\"pkrc_stats\");\nlet citf_my_population = flow.get(\"citf_my_population\");\nlet vax_registration = flow.get(\"vax_registration\");\n\n\nmsg.cases_death = cases_death;\nmsg.cases_death_stats = cases_death_state;\nmsg.cases_malaysia = cases_malaysia;\nmsg.cases_state = cases_state;\nmsg.test_samples = test_samples;\nmsg.hosp_stats = hosp_stats;\nmsg.vaksin_my = vaksin_my;\nmsg.icu_stats = icu_stats;\nmsg.pkrc_stats = pkrc_stats;\nmsg.citf_my_population = citf_my_population;\nmsg.vax_registration = vax_registration;\n\n// find vax %\n// registered - full vax\n\n//cumulative 2nd dose / (population malaysia above 18 : total - minus18 below)\nlet vax_my_complete_vax = ( vaksin_my.dose2_cumul / (citf_my_population.Malaysia.pop_60 + citf_my_population.Malaysia.pop_18 ))*100\nmsg.vax_my = vax_my_complete_vax;\n\n\n\n// registered - 1st dose\n// registered but not yet vax\n// not yet registered\n\n\nreturn msg;\n\n\n//anasothman-myy, 6/6/2021 1000","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1470,"y":2940,"wires":[["2d3cbefa24373f05","5e431dc27810ac6c","1310a8a8cfafb558","165ca7cc8c7267a8","13f27b59d45bd7c7","a523ca99db90b5b8","f5350b9929f386a6","c32d9602edd23329","3f34a9f18e87c026"]]},{"id":"2d3cbefa24373f05","type":"debug","z":"c8694ea1.9678f","name":"Debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1730,"y":2660,"wires":[]},{"id":"5e431dc27810ac6c","type":"ha-entity","z":"c8694ea1.9678f","name":"COVID19 Malaysia Daily Stats","server":"71b7c783.42e358","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"covid19_my_daily_stats"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:virus"},{"property":"unit_of_measurement","value":""}],"state":"cases_state.date","stateType":"msg","attributes":[{"property":"Date","value":"cases_state.date","valueType":"msg"},{"property":"Putrajaya","value":"cases_state[\"W.P. Putrajaya\"]","valueType":"msg"},{"property":"Labuan","value":"cases_state[\"W.P. Labuan\"]","valueType":"msg"},{"property":"KL","value":"cases_state[\"W.P. Kuala Lumpur\"]","valueType":"msg"},{"property":"Terrenganu","value":"cases_state.Terengganu","valueType":"msg"},{"property":"Selangor","value":"cases_state.Selangor","valueType":"msg"},{"property":"Sarawak","value":"cases_state.Sarawak","valueType":"msg"},{"property":"Sabah","value":"cases_state.Sabah","valueType":"msg"},{"property":"Pulau Pinang","value":"cases_state[\"Pulau Pinang\"]","valueType":"msg"},{"property":"Perlis","value":"cases_state.Perlis","valueType":"msg"},{"property":"Perak","value":"cases_state.Perak","valueType":"msg"},{"property":"Pahang","value":"cases_state.Pahang","valueType":"msg"},{"property":"Negeri Sembilan","value":"cases_state[\"Negeri Sembilan\"]","valueType":"msg"},{"property":"Melaka","value":"cases_state.Melaka","valueType":"msg"},{"property":"Kelantan","value":"cases_state.Kelantan","valueType":"msg"},{"property":"Kedah","value":"cases_state.Kedah","valueType":"msg"},{"property":"Johor","value":"cases_state.Johor","valueType":"msg"},{"property":"Total Kes","value":"cases_state.cumulative_state_cases","valueType":"msg"}],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1810,"y":2800,"wires":[[]]},{"id":"1310a8a8cfafb558","type":"ha-entity","z":"c8694ea1.9678f","name":"COVID19 Malaysia Daily Stats - Kes Kematian","server":"71b7c783.42e358","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"covid19_my_kes_kematian"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:emoticon-dead"},{"property":"unit_of_measurement","value":""}],"state":"cases_death_stats.cumulative_new_death","stateType":"msg","attributes":[{"property":"Date","value":"cases_death_stats.date","valueType":"msg"},{"property":"Putrajaya","value":"cases_death_stats[\"W.P. Putrajaya\"]","valueType":"msg"},{"property":"Labuan","value":"cases_death_stats[\"W.P. Labuan\"]","valueType":"msg"},{"property":"KL","value":"cases_death_stats[\"W.P. Kuala Lumpur\"]","valueType":"msg"},{"property":"Terrenganu","value":"cases_death_stats.Terengganu","valueType":"msg"},{"property":"Selangor","value":"cases_death_stats.Selangor","valueType":"msg"},{"property":"Sarawak","value":"cases_death_stats.Sarawak","valueType":"msg"},{"property":"Sabah","value":"cases_death_stats.Sabah","valueType":"msg"},{"property":"Pulau Pinang","value":"cases_death_stats[\"Pulau Pinang\"]","valueType":"msg"},{"property":"Perlis","value":"cases_death_stats.Perlis","valueType":"msg"},{"property":"Perak","value":"cases_death_stats.Perak","valueType":"msg"},{"property":"Pahang","value":"cases_death_stats.Pahang","valueType":"msg"},{"property":"Negeri Sembilan","value":"cases_death_stats[\"Negeri Sembilan\"]","valueType":"msg"},{"property":"Melaka","value":"cases_death_stats.Melaka","valueType":"msg"},{"property":"Kelantan","value":"cases_death_stats.Kelantan","valueType":"msg"},{"property":"Kedah","value":"cases_death_stats.Kedah","valueType":"msg"},{"property":"Johor","value":"cases_death_stats.Johor","valueType":"msg"}],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1860,"y":2920,"wires":[[]]},{"id":"165ca7cc8c7267a8","type":"ha-entity","z":"c8694ea1.9678f","name":"COVID19 Malaysia Daily Stats - Test Samples","server":"71b7c783.42e358","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"covid19_my_test_samples"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:test-tube"},{"property":"unit_of_measurement","value":""}],"state":"test_samples.total_samples","stateType":"msg","attributes":[{"property":"Date","value":"test_samples.date","valueType":"msg"},{"property":"PCR","value":"test_samples.pcr","valueType":"msg"},{"property":"RTK-AG","value":"test_samples.rtk_ag","valueType":"msg"}],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1860,"y":2980,"wires":[[]]},{"id":"5daa39c15e34dd8c","type":"http request","z":"c8694ea1.9678f","name":"hospital.csv","method":"GET","ret":"txt","paytoqs":"ignore","url":"https://raw.githubusercontent.com/MoH-Malaysia/covid19-public/main/epidemic/hospital.csv","tls":"","persist":false,"proxy":"","authType":"","x":530,"y":2940,"wires":[["b3baab9e8b3a5770"]]},{"id":"e75bf75f958b7166","type":"function","z":"c8694ea1.9678f","name":"Hospital Stats","func":"// let latestdate = msg.payload.pop()\n// msg.payload = latestdate;\n// return msg;\n\nlet newmsg = {};\nnewmsg.hosp_stats = {};\nnewmsg.latest = {};\n\nvar total_hosp_beds = 0;\nvar total_hosp_beds_covid19 = 0;\nvar total_hosp_beds_noncritical = 0;\nvar total_hosp_admitted_pui = 0;\nvar total_hosp_admitted_covid = 0;\nvar total_hosp_admitted_total = 0;\nvar total_discharged_pui = 0;\nvar total_discharged_covid = 0;\nvar total_discharged_total = 0;\nvar total_hosp_covid = 0;\nvar total_hosp_pui = 0;\nvar total_hosp_noncovid = 0;\n\n// get first element - capture date as reference for rest to stay the same\nlet hosp_stats = msg.payload.pop();\nnewmsg.latest[0] = hosp_stats;\nnewmsg.hosp_stats.date = hosp_stats.date;\nnewmsg.hosp_stats[hosp_stats.state] = hosp_stats;\ntotal_hosp_beds += hosp_stats.beds;\ntotal_hosp_beds_covid19 += hosp_stats.beds_covid19;\ntotal_hosp_beds_noncritical += hosp_stats.beds_noncrit;\ntotal_hosp_admitted_pui += hosp_stats.admitted_pui;\ntotal_hosp_admitted_covid += hosp_stats.admitted_covid;\ntotal_hosp_admitted_total += hosp_stats.admitted_total;\ntotal_discharged_pui += hosp_stats.discharged_pui;\ntotal_discharged_covid += hosp_stats.discharged_covid;\ntotal_discharged_total += hosp_stats.discharged_total;\ntotal_hosp_covid += hosp_stats.hosp_covid;\ntotal_hosp_pui += hosp_stats.hosp_pui;\ntotal_hosp_noncovid += hosp_stats.hosp_noncovid;\n\n//pop remaining in list - expected 15+1 = 16 total\nfor (let i = 1; i < 16; i++) {\n let hosp_stats = msg.payload.pop();\n newmsg.latest[i] = hosp_stats;\n \n // only if the date is the same - reference to first latest[0]\n if (hosp_stats.date === newmsg.hosp_stats.date){\n \n newmsg.hosp_stats[hosp_stats.state] = hosp_stats;\n total_hosp_beds += hosp_stats.beds;\n total_hosp_beds_covid19 += hosp_stats.beds_covid19;\n total_hosp_beds_noncritical += hosp_stats.beds_noncrit;\n total_hosp_admitted_pui += hosp_stats.admitted_pui;\n total_hosp_admitted_covid += hosp_stats.admitted_covid;\n total_hosp_admitted_total += hosp_stats.admitted_total;\n total_discharged_pui += hosp_stats.discharged_pui;\n total_discharged_covid += hosp_stats.discharged_covid;\n total_discharged_total += hosp_stats.discharged_total;\n total_hosp_covid += hosp_stats.hosp_covid;\n total_hosp_pui += hosp_stats.hosp_pui;\n total_hosp_noncovid += hosp_stats.hosp_noncovid;\n\n }\n\n }\n\nnewmsg.hosp_stats.my_hosp_beds = total_hosp_beds;\nnewmsg.hosp_stats.my_hosp_beds_covid19 = total_hosp_beds_covid19;\nnewmsg.hosp_stats.my_hosp_beds_noncritical = total_hosp_beds_noncritical;\nnewmsg.hosp_stats.my_hosp_admitted_pui = total_hosp_admitted_pui ;\nnewmsg.hosp_stats.my_hosp_admitted_covid = total_hosp_admitted_covid;\nnewmsg.hosp_stats.my_hosp_admitted_total = total_hosp_admitted_total;\nnewmsg.hosp_stats.my_discharged_pui = total_discharged_pui ;\nnewmsg.hosp_stats.my_discharged_covid = total_discharged_covid;\nnewmsg.hosp_stats.my_discharged_total = total_discharged_total ;\nnewmsg.hosp_stats.my_hosp_covid = total_hosp_covid ;\nnewmsg.hosp_stats.my_hosp_pui = total_hosp_pui ;\nnewmsg.hosp_stats.my_hosp_noncovid = total_hosp_noncovid ;\n\nflow.set(\"hosp_stats\", newmsg.hosp_stats);\n \n \n \nreturn newmsg;\n//anasothman-myy, 6/6/2021 1000","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":860,"y":2940,"wires":[["4138a03275015263"]]},{"id":"4138a03275015263","type":"debug","z":"c8694ea1.9678f","name":"Hospital Stats","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1140,"y":2940,"wires":[]},{"id":"b349cee3107dc9d0","type":"inject","z":"c8694ea1.9678f","name":"","props":[{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":190,"y":2940,"wires":[["5daa39c15e34dd8c"]]},{"id":"b3baab9e8b3a5770","type":"csv","z":"c8694ea1.9678f","name":"","sep":",","hdrin":true,"hdrout":"none","multi":"mult","ret":"\\n","temp":"","skip":"0","strings":true,"include_empty_strings":false,"include_null_values":false,"x":735,"y":2940,"wires":[["e75bf75f958b7166"]],"l":false},{"id":"13f27b59d45bd7c7","type":"ha-entity","z":"c8694ea1.9678f","name":"COVID19 Malaysia Daily Stats - Kes Baharu","server":"71b7c783.42e358","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"covid19_my_kes_baharu"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:virus"},{"property":"unit_of_measurement","value":""}],"state":"cases_state.cumulative_state_cases","stateType":"msg","attributes":[{"property":"Date","value":"cases_state.date","valueType":"msg"},{"property":"Putrajaya","value":"cases_state[\"W.P. Putrajaya\"]","valueType":"msg"},{"property":"Labuan","value":"cases_state[\"W.P. Labuan\"]","valueType":"msg"},{"property":"KL","value":"cases_state[\"W.P. Kuala Lumpur\"]","valueType":"msg"},{"property":"Terrenganu","value":"cases_state.Terengganu","valueType":"msg"},{"property":"Selangor","value":"cases_state.Selangor","valueType":"msg"},{"property":"Sarawak","value":"cases_state.Sarawak","valueType":"msg"},{"property":"Sabah","value":"cases_state.Sabah","valueType":"msg"},{"property":"Pulau Pinang","value":"cases_state[\"Pulau Pinang\"]","valueType":"msg"},{"property":"Perlis","value":"cases_state.Perlis","valueType":"msg"},{"property":"Perak","value":"cases_state.Perak","valueType":"msg"},{"property":"Pahang","value":"cases_state.Pahang","valueType":"msg"},{"property":"Negeri Sembilan","value":"cases_state[\"Negeri Sembilan\"]","valueType":"msg"},{"property":"Melaka","value":"cases_state.Melaka","valueType":"msg"},{"property":"Kelantan","value":"cases_state.Kelantan","valueType":"msg"},{"property":"Kedah","value":"cases_state.Kedah","valueType":"msg"},{"property":"Johor","value":"cases_state.Johor","valueType":"msg"}],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1850,"y":2860,"wires":[[]]},{"id":"a523ca99db90b5b8","type":"ha-entity","z":"c8694ea1.9678f","name":"COVID19 Malaysia Daily Stats - Hospital Stats","server":"71b7c783.42e358","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"covid19_my_hosp_stats"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:hospital-building"},{"property":"unit_of_measurement","value":""}],"state":"hosp_stats.my_hosp_covid","stateType":"msg","attributes":[{"property":"Date","value":"hosp_stats.date","valueType":"msg"},{"property":"Total Beds ","value":"hosp_stats.my_hosp_beds","valueType":"msg"},{"property":"Beds for Covid19","value":"hosp_stats.my_hosp_beds_covid19","valueType":"msg"},{"property":"Beds Non Critical","value":"hosp_stats.my_hosp_beds_noncritical","valueType":"msg"},{"property":"COVID Patients","value":"hosp_stats.my_hosp_covid","valueType":"msg"},{"property":"PUI Patients","value":"hosp_stats.my_hosp_pui","valueType":"msg"},{"property":"Non-COVID","value":"hosp_stats.my_hosp_noncovid","valueType":"msg"},{"property":"Admitted COVID","value":"hosp_stats.my_hosp_admitted_covid","valueType":"msg"},{"property":"Discharged COVID","value":"hosp_stats.my_discharged_covid","valueType":"msg"}],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1860,"y":3040,"wires":[[]]},{"id":"b9a1270637e18828","type":"function","z":"c8694ea1.9678f","name":"vaksin","func":"newmsg = {};\nnewmsg.vaksin_malaysia = {};\n\nlet latestdata = msg.payload.pop()\n\nnewmsg.vaksin_malaysia[\"date\"] = latestdata.date;\nnewmsg.vaksin_malaysia[\"dose1_daily\"] = latestdata.daily_partial;\nnewmsg.vaksin_malaysia[\"dose2_daily\"] = latestdata.daily_full;\nnewmsg.vaksin_malaysia[\"total_daily\"] = latestdata.daily;\nnewmsg.vaksin_malaysia[\"dose1_cumul\"] = latestdata.cumul_partial;\nnewmsg.vaksin_malaysia[\"dose2_cumul\"] = latestdata.cumul_full;\nnewmsg.vaksin_malaysia[\"total_cumul\"] = latestdata.cumul;\nnewmsg.vaksin_malaysia[\"pfizer1\"] = latestdata.pfizer1;\nnewmsg.vaksin_malaysia[\"pfizer2\"] = latestdata.pfizer2;\nnewmsg.vaksin_malaysia[\"sinovac1\"] = latestdata.sinovac1;\nnewmsg.vaksin_malaysia[\"sinovac2\"] = latestdata.sinovac2;\nnewmsg.vaksin_malaysia[\"astra1\"] = latestdata.astra1;\nnewmsg.vaksin_malaysia[\"astra2\"] = latestdata.astra2;\nnewmsg.vaksin_malaysia[\"pending\"] = latestdata.pending;\n\nflow.set(\"vaksin_malaysia\", newmsg.vaksin_malaysia);\n\n\nreturn newmsg;\n\n\n//anasothman-myy, 6/6/2021 1000","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":830,"y":2400,"wires":[["17b942c56d866a2f"]]},{"id":"53c0fc516ea3556a","type":"http request","z":"c8694ea1.9678f","name":"vaksin.csv","method":"GET","ret":"txt","paytoqs":"ignore","url":"https://raw.githubusercontent.com/CITF-Malaysia/citf-public/main/vaccination/vax_malaysia.csv","tls":"","persist":false,"proxy":"","authType":"","x":530,"y":2400,"wires":[["a3c930c8cb4eba9c"]]},{"id":"a3c930c8cb4eba9c","type":"csv","z":"c8694ea1.9678f","name":"","sep":",","hdrin":true,"hdrout":"none","multi":"mult","ret":"\\n","temp":"","skip":"0","strings":true,"include_empty_strings":false,"include_null_values":false,"x":715,"y":2400,"wires":[["b9a1270637e18828"]],"l":false},{"id":"aac7b4a007231df4","type":"comment","z":"c8694ea1.9678f","name":"Daily 0200","info":"","x":520,"y":2340,"wires":[]},{"id":"17b942c56d866a2f","type":"debug","z":"c8694ea1.9678f","name":"vaksin_malaysia","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1100,"y":2400,"wires":[]},{"id":"533d2f732b22968b","type":"function","z":"c8694ea1.9678f","name":"ICU stats","func":"// let latestdate = msg.payload.pop()\n// msg.payload = latestdate;\n// return msg;\n\nlet newmsg = {};\nnewmsg.icu_stats = {};\nnewmsg.latest = {};\n\nvar total_icu_pui = 0;\nvar total_icu_covid = 0;\nvar total_icu_noncovid = 0;\nvar total_vent_pui = 0;\nvar total_vent_covid = 0;\nvar total_vent_noncovid = 0;\nvar total_vent_port = 0;\nvar total_vent = 0;\nvar total_beds_icu_covid = 0;\nvar total_beds_icu = 0;\nvar total_beds_icu_rep = 0;\nvar total_beds_icu_total = 0;\n\n// get first element - capture date as reference for rest to stay the same\nlet icu_stats = msg.payload.pop();\nnewmsg.latest[0] = icu_stats;\nnewmsg.icu_stats.date = icu_stats.date;\nnewmsg.icu_stats[icu_stats.state] = icu_stats;\ntotal_icu_pui += icu_stats.icu_pui;\ntotal_icu_covid += icu_stats.icu_covid;\ntotal_icu_noncovid += icu_stats.icu_noncovid;\ntotal_vent_pui += icu_stats.vent_pui;\ntotal_vent_covid += icu_stats.vent_covid;\ntotal_vent_noncovid += icu_stats.vent_noncovid;\ntotal_vent_port += icu_stats.vent_port;\ntotal_vent += icu_stats.vent;\ntotal_beds_icu_covid += icu_stats.beds_icu_covid;\ntotal_beds_icu += icu_stats.beds_icu;\ntotal_beds_icu_rep += icu_stats.beds_icu_rep;\ntotal_beds_icu_total += icu_stats.beds_icu_total;\n\n//pop remaining in list - expected 15+1 = 16 total\nfor (let i = 1; i < 16; i++) {\n let icu_stats = msg.payload.pop();\n newmsg.latest[i] = icu_stats;\n \n // only if the date is the same - reference to first latest[0]\n if (icu_stats.date === newmsg.icu_stats.date){\n \n newmsg.icu_stats[icu_stats.state] = icu_stats;\n total_icu_pui += icu_stats.icu_pui;\n total_icu_covid += icu_stats.icu_covid;\n total_icu_noncovid += icu_stats.icu_noncovid;\n total_vent_pui += icu_stats.vent_pui;\n total_vent_covid += icu_stats.vent_covid;\n total_vent_noncovid += icu_stats.vent_noncovid;\n total_vent_port += icu_stats.vent_port;\n total_vent += icu_stats.vent;\n total_beds_icu_covid += icu_stats.beds_icu_covid;\n total_beds_icu += icu_stats.beds_icu;\n total_beds_icu_rep += icu_stats.beds_icu_rep;\n total_beds_icu_total += icu_stats.beds_icu_total;\n\n\n }\n\n }\n\nnewmsg.icu_stats.total_icu_pui = total_icu_pui;\nnewmsg.icu_stats.total_icu_covid = total_icu_covid;\nnewmsg.icu_stats.total_icu_noncovid = total_icu_noncovid;\nnewmsg.icu_stats.total_vent_pui = total_vent_pui;\nnewmsg.icu_stats.total_vent_covid = total_vent_covid;\nnewmsg.icu_stats.total_vent_noncovid = total_vent_noncovid;\nnewmsg.icu_stats.total_vent_port = total_vent_port;\nnewmsg.icu_stats.total_vent = total_vent;\nnewmsg.icu_stats.total_beds_icu_covid = total_beds_icu_covid;\nnewmsg.icu_stats.total_beds_icu = total_beds_icu;\nnewmsg.icu_stats.total_beds_icu_rep = total_beds_icu_rep;\nnewmsg.icu_stats.total_beds_icu_total = total_beds_icu_total;\n\n\nflow.set(\"icu_stats\", newmsg.icu_stats);\n \n \n \nreturn newmsg;\n//anasothman-myy, 6/6/2021 1000","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":840,"y":3000,"wires":[["4ed3ced65deb7d73"]]},{"id":"ccf4cf5230cf61d2","type":"csv","z":"c8694ea1.9678f","name":"","sep":",","hdrin":true,"hdrout":"none","multi":"mult","ret":"\\n","temp":"","skip":"0","strings":true,"include_empty_strings":false,"include_null_values":false,"x":735,"y":3000,"wires":[["533d2f732b22968b"]],"l":false},{"id":"a5bba3dbb13e5dea","type":"http request","z":"c8694ea1.9678f","name":"icu.csv","method":"GET","ret":"txt","paytoqs":"ignore","url":"https://raw.githubusercontent.com/MoH-Malaysia/covid19-public/main/epidemic/icu.csv","tls":"","persist":false,"proxy":"","authType":"","x":510,"y":3000,"wires":[["ccf4cf5230cf61d2"]]},{"id":"4ed3ced65deb7d73","type":"debug","z":"c8694ea1.9678f","name":"ICU Stats","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1120,"y":3000,"wires":[]},{"id":"b1f8571dc3c39885","type":"inject","z":"c8694ea1.9678f","name":"","props":[{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":190,"y":3000,"wires":[["a5bba3dbb13e5dea"]]},{"id":"f5350b9929f386a6","type":"ha-entity","z":"c8694ea1.9678f","name":"COVID19 Malaysia Daily Stats - ICU Stats","server":"71b7c783.42e358","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"covid19_my_icu_stats"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:hospital-box"},{"property":"unit_of_measurement","value":""}],"state":"icu_stats.total_icu_covid","stateType":"msg","attributes":[{"property":"Date","value":"icu_stats.date","valueType":"msg"},{"property":"Total ICU PUI","value":"icu_stats.total_icu_pui","valueType":"msg"},{"property":"Total ICU Covid","value":"icu_stats.total_icu_covid","valueType":"msg"},{"property":"Total ICU NonCovid","value":"icu_stats.total_icu_noncovid","valueType":"msg"},{"property":"Total Ventilator PUI","value":"icu_stats.total_vent_pui","valueType":"msg"},{"property":"Total Ventilator Covid","value":"icu_stats.total_vent_covid","valueType":"msg"},{"property":"Total Ventilator NonCovid","value":"icu_stats.total_vent_noncovid","valueType":"msg"},{"property":"Total Portable Ventilators","value":"icu_stats.total_vent_port","valueType":"msg"},{"property":"Total Ventilators","value":"icu_stats.total_vent","valueType":"msg"},{"property":"Total Beds for Covid","value":"icu_stats.total_beds_icu_covid","valueType":"msg"},{"property":"Total Gazetted ICU Beds","value":"icu_stats.total_beds_icu","valueType":"msg"},{"property":"Total Beds reserved for Others","value":"icu_stats.total_beds_icu_rep","valueType":"msg"},{"property":"Total ICU Beds medical infrastructure","value":"icu_stats.total_beds_icu_total","valueType":"msg"}],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1840,"y":3120,"wires":[[]]},{"id":"9fd92b8dafe61347","type":"http request","z":"c8694ea1.9678f","name":"pkrc.csv","method":"GET","ret":"txt","paytoqs":"ignore","url":"https://raw.githubusercontent.com/MoH-Malaysia/covid19-public/main/epidemic/pkrc.csv","tls":"","persist":false,"proxy":"","authType":"","x":520,"y":3060,"wires":[["2e06132f62e2c760"]]},{"id":"c896dfb51bd3b421","type":"function","z":"c8694ea1.9678f","name":"pkrc stats","func":"// let latestdate = msg.payload.pop()\n// msg.payload = latestdate;\n// return msg;\n\nlet newmsg = {};\nnewmsg.pkrc_stats = {};\nnewmsg.latest = {};\n\nvar total_beds = 0;\nvar total_admitted_pui = 0;\nvar total_admitted_covid = 0;\nvar total_admitted_total = 0;\nvar total_discharge_pui = 0;\nvar total_discharge_covid = 0;\nvar total_discharge_total = 0;\nvar total_pkrc_covid = 0;\nvar total_pkrc_pui = 0;\nvar total_pkrc_noncovid = 0;\n\n\n// get first element - capture date as reference for rest to stay the same\nlet pkrc_stats = msg.payload.pop();\nnewmsg.latest[0] = pkrc_stats;\nnewmsg.pkrc_stats.date = pkrc_stats.date;\nnewmsg.pkrc_stats[pkrc_stats.state] = pkrc_stats;\n\ntotal_beds += pkrc_stats.beds;\ntotal_admitted_pui += pkrc_stats.admitted_pui;\ntotal_admitted_covid += pkrc_stats.admitted_covid;\ntotal_admitted_total += pkrc_stats.admitted_total;\ntotal_discharge_pui += pkrc_stats.discharge_pui;\ntotal_discharge_covid += pkrc_stats.discharge_covid;\ntotal_discharge_total += pkrc_stats.discharge_total;\ntotal_pkrc_covid += pkrc_stats.pkrc_covid;\ntotal_pkrc_pui += pkrc_stats.pkrc_pui;\ntotal_pkrc_noncovid += pkrc_stats.pkrc_noncovid;\n\n//pop remaining in list - expected 15+1 = 16 total\nfor (let i = 1; i < 16; i++) {\n let pkrc_stats = msg.payload.pop();\n newmsg.latest[i] = pkrc_stats;\n \n // only if the date is the same - reference to first latest[0]\n if (pkrc_stats.date === newmsg.pkrc_stats.date){\n \n newmsg.pkrc_stats[pkrc_stats.state] = pkrc_stats;\n total_beds += pkrc_stats.beds;\n total_admitted_pui += pkrc_stats.admitted_pui;\n total_admitted_covid += pkrc_stats.admitted_covid;\n total_admitted_total += pkrc_stats.admitted_total;\n total_discharge_pui += pkrc_stats.discharge_pui;\n total_discharge_covid += pkrc_stats.discharge_covid;\n total_discharge_total += pkrc_stats.discharge_total;\n total_pkrc_covid += pkrc_stats.pkrc_covid;\n total_pkrc_pui += pkrc_stats.pkrc_pui;\n total_pkrc_noncovid += pkrc_stats.pkrc_noncovid;\n\n }\n\n }\n \nnewmsg.pkrc_stats.totalbeds = total_beds;\nnewmsg.pkrc_stats.totaladmitted_pui = total_admitted_pui;\nnewmsg.pkrc_stats.totaladmitted_covid = total_admitted_covid;\nnewmsg.pkrc_stats.totaladmitted_total = total_admitted_total;\nnewmsg.pkrc_stats.totaldischarge_pui = total_discharge_pui;\nnewmsg.pkrc_stats.totaldischarge_covid = total_discharge_covid;\nnewmsg.pkrc_stats.totaldischarge_total = total_discharge_total;\nnewmsg.pkrc_stats.totalpkrc_covid = total_pkrc_covid;\nnewmsg.pkrc_stats.totalpkrc_pui = total_pkrc_pui;\nnewmsg.pkrc_stats.totalpkrc_noncovid = total_pkrc_noncovid;\n\n\nflow.set(\"pkrc_stats\", newmsg.pkrc_stats);\n \n \n \nreturn newmsg;\n//anasothman-myy, 6/6/2021 1000","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":840,"y":3060,"wires":[["37ec500072ef549d"]]},{"id":"2e06132f62e2c760","type":"csv","z":"c8694ea1.9678f","name":"","sep":",","hdrin":true,"hdrout":"none","multi":"mult","ret":"\\n","temp":"","skip":"0","strings":true,"include_empty_strings":false,"include_null_values":false,"x":735,"y":3060,"wires":[["c896dfb51bd3b421"]],"l":false},{"id":"37ec500072ef549d","type":"debug","z":"c8694ea1.9678f","name":"PKRC Stats","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1130,"y":3060,"wires":[]},{"id":"d486287dd0dd608f","type":"inject","z":"c8694ea1.9678f","name":"","props":[{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":190,"y":3060,"wires":[["9fd92b8dafe61347"]]},{"id":"9e077e57cde0cffe","type":"inject","z":"c8694ea1.9678f","name":"","props":[{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":190,"y":2880,"wires":[["cfeb52067f163cca"]]},{"id":"e05d249efc195e71","type":"inject","z":"c8694ea1.9678f","name":"","props":[{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":210,"y":2580,"wires":[["795e4c0575640d88"]]},{"id":"6d8807f11bc9b528","type":"inject","z":"c8694ea1.9678f","name":"","props":[{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":210,"y":2640,"wires":[["1764adf069a9194b"]]},{"id":"2b2470fc38aa1c67","type":"inject","z":"c8694ea1.9678f","name":"","props":[{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":210,"y":2700,"wires":[["69aed142e0c73083"]]},{"id":"9c22c3f7db240d8c","type":"inject","z":"c8694ea1.9678f","name":"","props":[{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":210,"y":2520,"wires":[["9acfbcc72c62b529"]]},{"id":"10b8e74d2115a049","type":"inject","z":"c8694ea1.9678f","name":"","props":[{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":210,"y":2400,"wires":[["53c0fc516ea3556a"]]},{"id":"d531ee28c19492c1","type":"inject","z":"c8694ea1.9678f","name":"0200 Update","props":[],"repeat":"14400","crontab":"","once":false,"onceDelay":"0.1","topic":"","x":180,"y":2320,"wires":[["25de1927f89cbb46"]]},{"id":"25de1927f89cbb46","type":"change","z":"c8694ea1.9678f","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":315,"y":2300,"wires":[["53c0fc516ea3556a","9acfbcc72c62b529","795e4c0575640d88","1764adf069a9194b","69aed142e0c73083","cfeb52067f163cca","5daa39c15e34dd8c","a5bba3dbb13e5dea","9fd92b8dafe61347","a9691de3fe5b3e2f","62e6e9d07780c025"]],"l":false},{"id":"672c048d1f2ebadf","type":"inject","z":"c8694ea1.9678f","name":"Initial Get","props":[],"repeat":"","crontab":"","once":true,"onceDelay":"0.1","topic":"","x":200,"y":2280,"wires":[["25de1927f89cbb46"]]},{"id":"aa1b9f3a4914dc52","type":"inject","z":"c8694ea1.9678f","name":"0200 Update","props":[],"repeat":"14400","crontab":"","once":false,"onceDelay":"0.1","topic":"","x":1360,"y":2760,"wires":[["5bc35404160dcd14"]]},{"id":"5bc35404160dcd14","type":"change","z":"c8694ea1.9678f","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1495,"y":2720,"wires":[["b3acb6b476c095c8"]],"l":false},{"id":"329cdd51095ef93c","type":"inject","z":"c8694ea1.9678f","name":"Initial Get","props":[],"repeat":"","crontab":"","once":true,"onceDelay":"0.1","topic":"","payloadType":"str","x":1380,"y":2720,"wires":[["5bc35404160dcd14"]]},{"id":"79086502d0920389","type":"function","z":"c8694ea1.9678f","name":"CITF STats","func":"\n\nlet newmsg = {};\nnewmsg.citf_my_population = {};\nnewmsg.latest = {};\n\n//pop one by one\nfor (let i = 0; i < 17; i++) {\n let citf_my_population = msg.payload.pop();\n newmsg.citf_my_population[citf_my_population.state] = citf_my_population;\n\n }\n\n\n\n\n\nflow.set(\"citf_my_population\", newmsg.citf_my_population);\n \n \n \nreturn newmsg;\n//anasothman-myy, 6/6/2021 1000","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":850,"y":3120,"wires":[["01c19508c1393bc6"]]},{"id":"2ddb7813387207a0","type":"comment","z":"c8694ea1.9678f","name":"Only once off","info":"","x":530,"y":3240,"wires":[]},{"id":"62e6e9d07780c025","type":"http request","z":"c8694ea1.9678f","name":"vaxreg_malaysia.csv","method":"GET","ret":"txt","paytoqs":"ignore","url":"https://raw.githubusercontent.com/CITF-Malaysia/citf-public/main/registration/vaxreg_malaysia.csv","tls":"","persist":false,"proxy":"","authType":"","x":560,"y":2760,"wires":[["f8445c8f0c27d89b"]]},{"id":"f8445c8f0c27d89b","type":"csv","z":"c8694ea1.9678f","name":"","sep":",","hdrin":true,"hdrout":"none","multi":"mult","ret":"\\n","temp":"","skip":"0","strings":true,"include_empty_strings":false,"include_null_values":false,"x":735,"y":2760,"wires":[["8c86a9beba0cd665"]],"l":false},{"id":"8c86a9beba0cd665","type":"function","z":"c8694ea1.9678f","name":"Get Last Row","func":"let latestdate = msg.payload.pop()\nmsg.payload = latestdate;\n\nflow.set(\"vax_registration\", latestdate);\n\nreturn msg;\n\n//anasothman-myy, 6/6/2021 1000","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":860,"y":2760,"wires":[["11f0e4f0c54864f6"]]},{"id":"d0842dd06423834c","type":"inject","z":"c8694ea1.9678f","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":220,"y":2760,"wires":[["62e6e9d07780c025"]]},{"id":"11f0e4f0c54864f6","type":"debug","z":"c8694ea1.9678f","name":"Debug","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1130,"y":2760,"wires":[]},{"id":"c32d9602edd23329","type":"ha-entity","z":"c8694ea1.9678f","name":"COVID19 Malaysia Daily Stats - PKRC Stats","server":"71b7c783.42e358","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"covid19_my_pkrc_stats"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:hospital-marker"},{"property":"unit_of_measurement","value":""}],"state":"pkrc_stats.totalpkrc_covid","stateType":"msg","attributes":[{"property":"Date","value":"pkrc_stats.date","valueType":"msg"},{"property":"Total Admitted PUI","value":"pkrc_stats.totaladmitted_pui","valueType":"msg"},{"property":"Total Admitted Covid","value":"pkrc_stats.totaladmitted_covid","valueType":"msg"},{"property":"Total Admitted","value":"pkrc_stats.totaladmitted_total","valueType":"msg"},{"property":"Total Discharged PUI","value":"pkrc_stats.totaldischarge_pui","valueType":"msg"},{"property":"Total Discharged Covid","value":"pkrc_stats.totaldischarge_covid","valueType":"msg"},{"property":"Total Discharged ","value":"pkrc_stats.totaldischarge_total","valueType":"msg"},{"property":"Total PKRC Covid","value":"pkrc_stats.totalpkrc_covid","valueType":"msg"},{"property":"Total PKRC PUI","value":"pkrc_stats.totalpkrc_pui","valueType":"msg"},{"property":"Total PKRC NonCovid","value":"pkrc_stats.totalpkrc_noncovid","valueType":"msg"}],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1850,"y":2740,"wires":[[]]},{"id":"b9103a96315119cc","type":"ha-entity","z":"c8694ea1.9678f","name":"Vaksin Stats - Dose 1 Daily","server":"71b7c783.42e358","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"vaksin_dose1_daily"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:needle"},{"property":"unit_of_measurement","value":""}],"state":"vaksin_my.dose1_daily","stateType":"msg","attributes":[{"property":"Data Date","value":"vaksin_my.dose1_daily","valueType":"msg"}],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":2500,"y":3000,"wires":[[]]},{"id":"a4c095096ba04dec","type":"ha-entity","z":"c8694ea1.9678f","name":"Vaksin Stats - Dose 2 Daily","server":"71b7c783.42e358","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"vaksin_dose2_daily"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:needle"},{"property":"unit_of_measurement","value":""}],"state":"vaksin_my.dose2_daily","stateType":"msg","attributes":[{"property":"Data Date","value":"vaksin_my.date","valueType":"msg"}],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":2500,"y":3060,"wires":[[]]},{"id":"a27560240e2fc887","type":"ha-entity","z":"c8694ea1.9678f","name":"Vaksin Stats - Total Dose Daily","server":"71b7c783.42e358","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"vaksin_total_dose_daily"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:needle"},{"property":"unit_of_measurement","value":""}],"state":"vaksin_my.total_daily","stateType":"msg","attributes":[{"property":"Data Date","value":"vaksin_my.date","valueType":"msg"}],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":2510,"y":3120,"wires":[[]]},{"id":"e8e971fb1157d7f7","type":"ha-entity","z":"c8694ea1.9678f","name":"Vaksin Stats - Dose 1 Cumulative","server":"71b7c783.42e358","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"vaksin_dose1_cumul"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:needle"},{"property":"unit_of_measurement","value":""}],"state":"vaksin_my.dose1_cumul","stateType":"msg","attributes":[{"property":"Data Date","value":"vaksin_my.dose1_daily","valueType":"msg"}],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":2520,"y":2820,"wires":[[]]},{"id":"3507154ce20be64e","type":"ha-entity","z":"c8694ea1.9678f","name":"Vaksin Stats - Dose 2 Cumulative","server":"71b7c783.42e358","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"vaksin_dose2_cumul"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:needle"},{"property":"unit_of_measurement","value":""}],"state":"vaksin_my.dose2_cumul","stateType":"msg","attributes":[{"property":"Data Date","value":"vaksin_my.date","valueType":"msg"}],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":2520,"y":2880,"wires":[[]]},{"id":"b987050ba809d0da","type":"ha-entity","z":"c8694ea1.9678f","name":"Vaksin Stats - Total Dose Cumulative","server":"71b7c783.42e358","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"vaksin_total_dose_cumulative"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:needle"},{"property":"unit_of_measurement","value":""}],"state":"vaksin_my.total_cumul","stateType":"msg","attributes":[{"property":"Data Date","value":"vaksin_my.date","valueType":"msg"}],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":2530,"y":2940,"wires":[[]]},{"id":"3f34a9f18e87c026","type":"link out","z":"c8694ea1.9678f","name":"in-vaksin","links":["f99b387313c5c75d"],"x":1705,"y":2620,"wires":[]},{"id":"5be80b275cfd0397","type":"ha-entity","z":"c8694ea1.9678f","name":"COVID19 Malaysia Daily Stats - Vaccine Stats","server":"71b7c783.42e358","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"covid19_my_vax"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:needle"},{"property":"unit_of_measurement","value":""}],"state":"vaksin_my.total_daily","stateType":"msg","attributes":[{"property":"Date","value":"vaksin_my.date","valueType":"msg"},{"property":"Daily 1st Dose","value":"vaksin_my.dose1_daily","valueType":"msg"},{"property":"Daily 2nd Dose","value":"vaksin_my.dose2_daily","valueType":"msg"},{"property":"Total 1st Dose","value":"vaksin_my.dose1_cumul","valueType":"msg"},{"property":"Total 2nd Dose","value":"vaksin_my.dose2_cumul","valueType":"msg"},{"property":"Total Vaccinated","value":"vaksin_my.total_cumul","valueType":"msg"},{"property":"Pfizer 1st Dose","value":"vaksin_my.pfizer1","valueType":"msg"},{"property":"Pfizer 2nd Dose","value":"vaksin_my.pfizer2","valueType":"msg"},{"property":"Sinovac 1st Dose","value":"vaksin_my.sinovac1","valueType":"msg"},{"property":"Sinovac 2nd Dose","value":"vaksin_my.sinovac2","valueType":"msg"},{"property":"Astra 1st Dose","value":"vaksin_my.astra1","valueType":"msg"},{"property":"Astra 2nd Dose","value":"vaksin_my.astra2","valueType":"msg"},{"property":"Pending","value":"vaksin_my.pending","valueType":"msg"},{"property":"Daily Dose","value":"vaksin_my.total_daily","valueType":"msg"}],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":2560,"y":2760,"wires":[[]]},{"id":"f99b387313c5c75d","type":"link in","z":"c8694ea1.9678f","name":"out-vaksin","links":["3f34a9f18e87c026"],"x":2105,"y":2940,"wires":[["5be80b275cfd0397","e8e971fb1157d7f7","3507154ce20be64e","b987050ba809d0da","b9103a96315119cc","a4c095096ba04dec","a27560240e2fc887"]]},{"id":"71b7c783.42e358","type":"server","name":"Home Assistant","version":1,"legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]