Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Tester
    4. Test Coronavirus Statistics for ioBroker

    NEWS

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    • Monatsrückblick - April 2025

    Test Coronavirus Statistics for ioBroker

    This topic has been deleted. Only users with topic management privileges can see it.
    • Scrounger
      Scrounger Developer last edited by Scrounger

      Sorry hab leider in dem Skript echt nen Schnitzer drin gehabt - bei North / South America ist ein Leerzeichen drin, was bei Ids nicht empfohlen ist.
      Bitte nehmt das folgende Skript und löscht alle DPs von North / South America.

      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.replace(" ", "_")] = {
                      cases: 0,
                      critical: 0,
                      deaths: 0,
                      recovered: 0,
                      todayCases: 0,
                      todayDeaths: 0,
                  }
              });
      
              continentsStats['America'] = {
                  cases: 0,
                  critical: 0,
                  deaths: 0,
                  recovered: 0,
                  todayCases: 0,
                  todayDeaths: 0,
              };
      
              continentsStats['World'] = {
                  critical: 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) {
                          let continent = country.continent.replace(" ", "_");
                          continentsStats[continent].cases = continentsStats[continent].cases + getState(idCases).val;
                          continentsStats[continent].critical = continentsStats[continent].critical + getState(idCritical).val;
                          continentsStats[continent].deaths = continentsStats[continent].deaths + getState(idDeaths).val;
                          continentsStats[continent].recovered = continentsStats[continent].recovered + getState(idRecovered).val;
                          continentsStats[continent].todayCases = continentsStats[continent].todayCases + getState(idTodayCases).val;
                          continentsStats[continent].todayDeaths = continentsStats[continent].todayDeaths + getState(idTodayDeaths).val;
      
                          if (country.continent === 'South America' || country.continent === 'North America') {
                              continentsStats['America'].cases = continentsStats['America'].cases + getState(idCases).val;
                              continentsStats['America'].critical = continentsStats['America'].critical + getState(idCritical).val;
                              continentsStats['America'].deaths = continentsStats['America'].deaths + getState(idDeaths).val;
                              continentsStats['America'].recovered = continentsStats['America'].recovered + getState(idRecovered).val;
                              continentsStats['America'].todayCases = continentsStats['America'].todayCases + getState(idTodayCases).val;
                              continentsStats['America'].todayDeaths = continentsStats['America'].todayDeaths + getState(idTodayDeaths).val;
                          }
      
                          continentsStats['World'].critical = continentsStats['World'].critical + getState(idCritical).val;
                          continentsStats['World'].todayCases = continentsStats['World'].todayCases + getState(idTodayCases).val;
                          continentsStats['World'].todayDeaths = continentsStats['World'].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();
      
      1 Reply Last reply Reply Quote 1
      • Uli977
        Uli977 @sigi234 last edited by Uli977

        @sigi234

        was ist mir hier passiert...
        be7f8c9b-566a-49cf-a516-364b0fa8ac95-image.png
        warum fehlen die daten der länder

        Habe das View auch nochmal neu importiert... trotzdem so....

        Scrounger 1 Reply Last reply Reply Quote 0
        • Scrounger
          Scrounger Developer @Uli977 last edited by

          @Uli977
          API liefert aktuell keine Daten https://coronavirus-19-api.herokuapp.com/countries

          Uli977 2 Replies Last reply Reply Quote 0
          • Uli977
            Uli977 @Scrounger last edited by

            @Scrounger Ah ok... also nicht mein Fehler..

            1 Reply Last reply Reply Quote 0
            • Uli977
              Uli977 @sigi234 last edited by

              @stimezo gibst du deine icons raus?

              1 Reply Last reply Reply Quote 0
              • Uli977
                Uli977 @Scrounger last edited by

                @Scrounger Jetzt haben sich gerade die Anzahl der Fälle in Deutschland halbiert.... sehr merkwürdig alles

                1 Reply Last reply Reply Quote 0
                • D
                  dos1973 last edited by

                  ist mir auch aufgefallen - und jetzt wieder auf knapp 12000?!

                  1 Reply Last reply Reply Quote 0
                  • crunchip
                    crunchip Forum Testing Most Active last edited by

                    Laut Livestream sind die 14.000 schon erreicht

                    1 Reply Last reply Reply Quote 0
                    • N
                      norman1991 last edited by

                      @Scrounger kannst du mir (uns allen) die Icons zur Verfügung stellen?

                      Scrounger sigi234 2 Replies Last reply Reply Quote 0
                      • Scrounger
                        Scrounger Developer @norman1991 last edited by

                        @norman1991

                        Das geht leider nicht ganz so einfach, weil das eine Schriftart ist, die im Material Design Widgets Adapter implementiert ist. Am einfachsten ist es die Widgets von meinem Adapter zu nutzen.

                        Alterntiv könnt ihr Euch die icons auf https://materialdesignicons.com/ heraussuchen und herunterladen.

                        50c14e97-b238-4d0c-b829-630d5e9ece87-grafik.png

                        Namen der verwendeten icons von links nach rechts:

                        • biohazard
                        • heart-pulse
                        • seat-flat
                        • grave-stone
                        • hospital-box
                        • skull-crossbones
                        Uli977 1 Reply Last reply Reply Quote 0
                        • sigi234
                          sigi234 Forum Testing Most Active @norman1991 last edited by

                          @norman1991 sagte in Test Coronavirus Statistics for ioBroker:

                          @Scrounger kannst du mir (uns allen) die Icons zur Verfügung stellen?

                          seat-flat.png hospital-box.png skull-crossbones.png biohazard.png heart-pulse.png grave-stone.png

                          1 Reply Last reply Reply Quote 0
                          • S
                            SaiBot1981 last edited by

                            Moin, ich hab leider das Problem das ich mit dem ipad2 leider keine Schrift oder Symbole angezeigt bekomme.

                            Auf meinem MediaTab T3 klappt es ohne Probleme. Ich lasse mir die Vis via iqontrol per Safari anzeigen.

                            Gibts da evtl noch jemanden der n ipad2 nutzt und es gegen testen könnte?

                            Oder evtl eine kleine Anpassung damit auch ein altes ipad es anzeigen kann?

                            1 Reply Last reply Reply Quote 0
                            • Chaot
                              Chaot @Dutchman last edited by

                              @Dutchman
                              Seit heute morgen diese Warnung:

                              coronavirus-statistics.0	2020-03-19 07:30:47.800	warn	(31245) State attribute definition missing for + casesPerOneMillion
                              coronavirus-statistics.0	2020-03-19 07:30:47.677	warn	(31245) State attribute definition missing for + casesPerOneMillion
                              coronavirus-statistics.0	2020-03-19 07:30:47.543	warn	(31245) State attribute definition missing for + casesPerOneMillion
                              coronavirus-statistics.0	2020-03-19 07:30:47.362	warn	(31245) State attribute definition missing for + casesPerOneMillion
                              coronavirus-statistics.0	2020-03-19 07:30:47.102	warn	(31245) State attribute definition missing for + casesPerOneMillion
                              coronavirus-statistics.0	2020-03-19 07:30:46.955	warn	(31245) State attribute definition missing for + casesPerOneMillion
                              
                              cvidal Knallochse Dutchman 3 Replies Last reply Reply Quote 0
                              • D
                                dos1973 last edited by

                                Wie formatiere ich denn denn DP, wann das letzte mal die Daten aktualisiert wurden. Da kommt bei mir ein Linux Zahlenwert. Also der unter „Global“

                                sigi234 1 Reply Last reply Reply Quote 0
                                • Uli977
                                  Uli977 @Scrounger last edited by

                                  @Scrounger Danke!
                                  @sigi234 Danke!

                                  1 Reply Last reply Reply Quote 0
                                  • sigi234
                                    sigi234 Forum Testing Most Active @dos1973 last edited by

                                    @dos1973 sagte in Test Coronavirus Statistics for ioBroker:

                                    Wie formatiere ich denn denn DP, wann das letzte mal die Daten aktualisiert wurden. Da kommt bei mir ein Linux Zahlenwert. Also der unter „Global“

                                    Nimm das Widget Timestamp

                                    D 1 Reply Last reply Reply Quote 0
                                    • D
                                      dos1973 @sigi234 last edited by

                                      @sigi234 Danke, funktioniert!

                                      1 Reply Last reply Reply Quote 0
                                      • cvidal
                                        cvidal Forum Testing @Chaot last edited by

                                        @Chaot sagte in Test Coronavirus Statistics for ioBroker:

                                        @Dutchman
                                        Seit heute morgen diese Warnung:

                                        coronavirus-statistics.0	2020-03-19 07:30:47.800	warn	(31245) State attribute definition missing for + casesPerOneMillion
                                        coronavirus-statistics.0	2020-03-19 07:30:47.677	warn	(31245) State attribute definition missing for + casesPerOneMillion
                                        coronavirus-statistics.0	2020-03-19 07:30:47.543	warn	(31245) State attribute definition missing for + casesPerOneMillion
                                        coronavirus-statistics.0	2020-03-19 07:30:47.362	warn	(31245) State attribute definition missing for + casesPerOneMillion
                                        coronavirus-statistics.0	2020-03-19 07:30:47.102	warn	(31245) State attribute definition missing for + casesPerOneMillion
                                        coronavirus-statistics.0	2020-03-19 07:30:46.955	warn	(31245) State attribute definition missing for + casesPerOneMillion
                                        

                                        Kann ich bestätigen, ist bei mir seit heute auch so.

                                        1 Reply Last reply Reply Quote 0
                                        • Knallochse
                                          Knallochse @Chaot last edited by

                                          @Chaot sagte in Test Coronavirus Statistics for ioBroker:

                                          @Dutchman
                                          Seit heute morgen diese Warnung:

                                          coronavirus-statistics.0	2020-03-19 07:30:47.800	warn	(31245) State attribute definition missing for + casesPerOneMillion
                                          

                                          Bei mir auch

                                          1 Reply Last reply Reply Quote 0
                                          • Dutchman
                                            Dutchman Developer Most Active Administrators @Chaot last edited by Dutchman

                                            @Chaot sagte in Test Coronavirus Statistics for ioBroker:

                                            Seit heute morgen diese Warnung:

                                            @cvidal sagte in Test Coronavirus Statistics for ioBroker:

                                            Kann ich bestätigen, ist bei mir seit heute auch so.

                                            Cool neue daten, kleine sorgen ich mach mal n update 🙂

                                            Dutchman 1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post

                                            Support us

                                            ioBroker
                                            Community Adapters
                                            Donate

                                            984
                                            Online

                                            31.6k
                                            Users

                                            79.6k
                                            Topics

                                            1.3m
                                            Posts

                                            adapter installation adapterentwicklung testen
                                            120
                                            1177
                                            244647
                                            Loading More Posts
                                            • Oldest to Newest
                                            • Newest to Oldest
                                            • Most Votes
                                            Reply
                                            • Reply as topic
                                            Log in to reply
                                            Community
                                            Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
                                            The ioBroker Community 2014-2023
                                            logo