NEWS
Test Coronavirus Statistics for ioBroker
Test Coronavirus Statistics for ioBroker
-
@Uli977 sagte in Test Coronavirus Statistics for ioBroker:
@sigi234 Danke!
Aber was habe ich vergessen?
vis-materialdesign.0 ist installiert
Das Skript von @Scrounger ?
Soweit ich weis baut das @Dutchman aber ein.
-
@Uli977 sagte in Test Coronavirus Statistics for ioBroker:
Wo finde ich diese lIste?
Das musst du im JS Adapter eintragen und Adapter neu starten!

-
@Uli977 sagte in Test Coronavirus Statistics for ioBroker:
@sigi234 Danke!
Aber was habe ich vergessen?
vis-materialdesign.0 ist installiert
Das Skript von @Scrounger ?
Soweit ich weis baut das @Dutchman aber ein.
@sigi234 sagte in Test Coronavirus Statistics for ioBroker:
Soweit ich weis baut das @Dutchman aber ein.
das design, nope die sache mit den Kontinenten kommt noch
-
@Uli977 sagte in Test Coronavirus Statistics for ioBroker:
Wo finde ich diese lIste?
Das musst du im JS Adapter eintragen und Adapter neu starten!

-
-
-
-
-
-
@Uli977 sagte in Test Coronavirus Statistics for ioBroker:
@sigi234 nä... nicht da
Welche Version hast du?
-
@Uli977 sagte in Test Coronavirus Statistics for ioBroker:
@sigi234 nä... nicht da
Welche Version hast du?
-
-
-
@sigi234 geht! Danke! Habe immer auf stable stehen.... hab aber jetzt mal auf latest gesetzt...

-
-
@Uli977 sagte in Test Coronavirus Statistics for ioBroker:
@sigi234 wieso habe ich keine Icons?
Musst du @stimezo fragen, vielleicht stellt er sie Online.
-
Da mich schon immer die Werte pro Kontinent intressiert haben, aber ich dazu nix brauchbares im Netz finden kann, hab ich mal ein kleines Skript geschrieben, dass die Daten dieses Adapters verwendet.
Voraussetzung:
- Javascript NPM-Module:
country-list-js
Unter der Javascript instanz wird folgende Struktur automatisch angelegt:

Skript:
const countryJs = require("country-list-js"); let selector = `[id=coronavirus-statistics.0.*.cases]` let allCountries = $(selector); // Fehlermeldung ausgeben, wenn selector kein result liefert if (allCountries.length === 0) { console.error(`no result for selector '${selector}'`) } on({ id: 'coronavirus-statistics.0.global_totals.updated', change: 'any' }, statsForContinents); function statsForContinents() { setTimeout(function () { console.log('Corona Statistik für Kontinente wird erstellt'); let countryTranslator = { // https://github.com/i-rocky/country-list-js/blob/master/data/names.json "Vatican_City": "Vatican", "USA": "United States", "UK": "United Kingdom", "UAE": "United Arab Emirates", "US_Virgin_Islands": "U.S. Virgin Islands", "St_Vincent_Grenadines": "Saint Vincent and the Grenadines", "St_Barth": "Saint Barthelemy", "S_Korea": "South Korea", "Palestine": "Palestinian Territory", "North_Macedonia": "Macedonia", "Faeroe_Islands": "Faroe Islands", "Eswatini": "Swaziland", "Czechia": "Czech Republic", "Congo": "Republic of the Congo", "CAR": "Central African Republic", "DRC": "Democratic Republic of the Congo", "Channel_Islands": "France" // gehört zu Europa, deshalb Frankreich einfach vergeben } var continentsStats = {}; countryJs.continents().forEach(function (continent, index) { continentsStats[continent] = { cases: 0, critical: 0, deaths: 0, recovered: 0, todayCases: 0, todayDeaths: 0, } }); for (var i = 0; i <= allCountries.length - 1; i++) { let idCases = allCountries[i]; let idCritical = idCases.replace('.cases', '.critical'); let idDeaths = idCases.replace('.cases', '.deaths'); let idRecovered = idCases.replace('.cases', '.recovered'); let idTodayCases = idCases.replace('.cases', '.todayCases'); let idTodayDeaths = idCases.replace('.cases', '.todayDeaths'); let countryName = idCases.split('.')[2]; let country = countryJs.findByName(countryName.replace(/_/g, ' ').replace('é', 'e').replace('ç', 'c')); if (country) { calcStats(country); } else { country = countryJs.findByName(countryTranslator[countryName]); if (country) { calcStats(country); } else { if (countryName !== 'global_totals' && countryName !== 'Diamond_Princess') { console.warn(`${countryName} nicht in gefunden. Korrekter Name muss im skript manuell hinzugefügt werden!`); } } } function calcStats(country) { if (country.continent) { continentsStats[country.continent].cases = continentsStats[country.continent].cases + getState(idCases).val; continentsStats[country.continent].critical = continentsStats[country.continent].critical + getState(idCritical).val; continentsStats[country.continent].deaths = continentsStats[country.continent].deaths + getState(idDeaths).val; continentsStats[country.continent].recovered = continentsStats[country.continent].recovered + getState(idRecovered).val; continentsStats[country.continent].todayCases = continentsStats[country.continent].todayCases + getState(idTodayCases).val; continentsStats[country.continent].todayDeaths = continentsStats[country.continent].todayDeaths + getState(idTodayDeaths).val; } else { console.warn(`Für ${countryName} existiert kein Kontinent!`); } } } for (var continent in continentsStats) { for (var prop in continentsStats[continent]) { let dpId = `corona.continents.${continent}.${prop}` if (existsState(dpId)) { setState(dpId, continentsStats[continent][prop], true); } else { createState(dpId, continentsStats[continent][prop], { name: `${continent} ${prop}`, read: true, write: false, desc: `${continent} ${prop}`, type: "number", def: 0, }); } } } }, 30000); } // Bei JS Start ausführen statsForContinents();@Scrounger Wäre ja noch toll, wenn man ein Land seiner Wahl noch etwas detaillieren könnte.... Meinst du das geht?
- Javascript NPM-Module:
-
Hier noch mein IconList Widget mit Material Design Icons:

Widget:
benötigte CSS Klassen:
.my-corona-title { display: flex; align-items: center; justify-content: center; height: 24px; } .my-corona-value { margin-top: 4px; }@Scrounger sagte in Test Coronavirus Statistics for ioBroker:
Hier noch mein IconList Widget mit Material Design Icons:
nice, haste lust das als widget setzt hinzuzufügen im adapter ?
hier ein beispiel wie wir die anderen gemacht haben :







