Da sich die REST-API geändert hat (Danke Timo), (Deutschland ist nun auf Platz 4 oder jetzt auf 3) hier das Update:
Hier nun die Version, die nach dem Namen und nicht mehr nach einem fixen Index der Reihenfolge sucht.
1 2 3 4 5 6 7 8 9 10 |
// Hier das gewünschte Land angeben var land = "Germany" // Suche den Index des Land for (var i = 0; i < msg.payload.length; i++){ if (msg.payload[i].countryRegion == land ){ land = i break } } |
Hier der ganze Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 |
[ { "id": "884ebfce.72d028", "type": "tab", "label": "Coronavirus", "disabled": false, "info": "" }, { "id": "e602c35.d1770c", "type": "inject", "z": "884ebfce.72d028", "name": "Täglich um 9:15 Uhr", "topic": "", "payload": "", "payloadType": "date", "repeat": "", "crontab": "15 09 * * *", "once": false, "onceDelay": 0.1, "x": 140, "y": 100, "wires": [ [ "35fdb980.106f26" ] ] }, { "id": "35fdb980.106f26", "type": "http request", "z": "884ebfce.72d028", "name": "Covid-19 abfragen", "method": "GET", "ret": "obj", "paytoqs": false, "url": "https://covid19.mathdro.id/api", "tls": "", "persist": false, "proxy": "", "authType": "basic", "x": 210, "y": 160, "wires": [ [ "9e353355.0a94e" ] ] }, { "id": "9e353355.0a94e", "type": "function", "z": "884ebfce.72d028", "name": "Covid-19 weltweit Meldung", "func": "\nvar nachricht = \"Bestätigte Personen mit covid-19 weltweit: \" + msg.payload.confirmed.value + \n\" und wiederhergestellt: \" + msg.payload.recovered.value + \n\" und gestorben: \" + msg.payload.deaths.value;\n\nmsg.payload = nachricht;\nmsg.topic = nachricht;\n\nreturn msg;\n", "outputs": 1, "noerr": 0, "x": 300, "y": 220, "wires": [ [ "3a1f746c.f0c0fc", "4a020e21.78c558" ] ] }, { "id": "3a1f746c.f0c0fc", "type": "rbe", "z": "884ebfce.72d028", "name": "Nur bei Änderung des Wert weiter", "func": "rbe", "gap": "", "start": "", "inout": "out", "property": "payload", "x": 380, "y": 280, "wires": [ [ "4a020e21.78c558", "6fd8c4e6.8553e4", "330efe00.b45a22" ] ] }, { "id": "4a020e21.78c558", "type": "debug", "z": "884ebfce.72d028", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "x": 670, "y": 280, "wires": [] }, { "id": "6fd8c4e6.8553e4", "type": "pushover", "z": "884ebfce.72d028", "name": "Sende Pushover Nachricht", "device": "", "title": "Covid-19 Statistik Weltweit", "priority": 0, "sound": "", "url": "http://www.wenzlaff.info", "url_title": "covid-19", "html": false, "x": 480, "y": 340, "wires": [] }, { "id": "622e582b.b2261", "type": "comment", "z": "884ebfce.72d028", "name": "www.wenzlaff.info", "info": "", "x": 630, "y": 500, "wires": [] }, { "id": "e0ebb947.21967", "type": "comment", "z": "884ebfce.72d028", "name": "Erzeuge Meldung über covid-19 weltweit", "info": "", "x": 180, "y": 40, "wires": [] }, { "id": "330efe00.b45a22", "type": "twitter out", "z": "884ebfce.72d028", "twitter": "", "name": "Tweet", "x": 410, "y": 400, "wires": [] }, { "id": "9851a5e0.9e28d", "type": "comment", "z": "884ebfce.72d028", "name": "via Service von https://covid19.mathdro.id/api", "info": "", "x": 530, "y": 160, "wires": [] }, { "id": "8c6d68f.1965618", "type": "inject", "z": "884ebfce.72d028", "name": "Jede Stunde", "topic": "", "payload": "", "payloadType": "date", "repeat": "3600", "crontab": "", "once": false, "onceDelay": 0.1, "x": 140, "y": 540, "wires": [ [ "3198308f.b1d0b" ] ] }, { "id": "3198308f.b1d0b", "type": "http request", "z": "884ebfce.72d028", "name": "Covid-19 abfragen für Deutschland", "method": "GET", "ret": "obj", "paytoqs": false, "url": "https://covid19.mathdro.id/api/confirmed", "tls": "", "persist": false, "proxy": "", "authType": "basic", "x": 280, "y": 600, "wires": [ [ "85336713.7e3e5" ] ] }, { "id": "85336713.7e3e5", "type": "function", "z": "884ebfce.72d028", "name": "Covid-19 Deutschland Fallzahlen Meldung", "func": "\n// Hier das gewünschte Land angeben\nvar land = \"Germany\"\n\n// Suche den Index des Land\nfor (var i = 0; i < msg.payload.length; i++){\n if (msg.payload[i].countryRegion == land ){\n land = i\n break\n }\n} \n\nvar nachricht = \"Bestätigte Personen mit covid-19 in \" \n+ msg.payload[land].countryRegion\n+ \": \" + msg.payload[land].confirmed \n+ \" Genesen: \" + + msg.payload[land].recovered \n+ \" Gestorben: \" + + msg.payload[land].deaths \n+ \" - #covid19 #coronavirus #corona #coronavirusdeutschland #covid #virus #deutschland #rki #SARS-CoV-2\";\n\nmsg.payload = nachricht;\nmsg.topic = \"COVID-19 Fallzahlen Deutschland\";\n\nreturn msg;\n", "outputs": 1, "noerr": 0, "x": 350, "y": 660, "wires": [ [ "a29a5d6.a71512", "edf4f959.998a88" ] ] }, { "id": "a29a5d6.a71512", "type": "rbe", "z": "884ebfce.72d028", "name": "Nur bei Änderung des Wert weiter", "func": "rbe", "gap": "", "start": "", "inout": "out", "property": "payload", "x": 400, "y": 720, "wires": [ [ "edf4f959.998a88", "c7aea8a5.ed7d38" ] ] }, { "id": "edf4f959.998a88", "type": "debug", "z": "884ebfce.72d028", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "x": 690, "y": 680, "wires": [] }, { "id": "c7aea8a5.ed7d38", "type": "twitter out", "z": "884ebfce.72d028", "twitter": "", "name": "Tweet", "x": 670, "y": 780, "wires": [] }, { "id": "71ae5876.b57de8", "type": "comment", "z": "884ebfce.72d028", "name": "via Service von https://covid19.mathdro.id/api/confirmed", "info": "", "x": 750, "y": 600, "wires": [] }, { "id": "8e007bf2.5451c8", "type": "comment", "z": "884ebfce.72d028", "name": "covid-19 Live-Ticker für Deutschland", "info": "", "x": 180, "y": 500, "wires": [] } ] |