Skip to content
  • Home
  • Recent
  • Tags
  • 0 Unread 0
  • Categories
  • Unreplied
  • Popular
  • GitHub
  • Docu
  • Hilfe
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
ioBroker Logo

Community Forum

donate donate
  1. ioBroker Community Home
  2. Deutsch
  3. Tester
  4. Test Adapter flexcharts - Stapeldiagramme und mehr

NEWS

  • Monatsrückblick Januar/Februar 2026 ist online!
    BluefoxB
    Bluefox
    17
    1
    631

  • Jahresrückblick 2025 – unser neuer Blogbeitrag ist online! ✨
    BluefoxB
    Bluefox
    17
    1
    5.6k

  • Neuer Blogbeitrag: Monatsrückblick - Dezember 2025 🎄
    BluefoxB
    Bluefox
    13
    1
    1.5k

Test Adapter flexcharts - Stapeldiagramme und mehr

Scheduled Pinned Locked Moved Tester
chartchartsdiagrammeechartsvisualisierungvisualization
276 Posts 20 Posters 54.8k Views 22 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Merlin123M Merlin123

    @jrbwh Script funktioniert super! Gefällt mir sehr gut :) Mal schauen, wie ich das in meiner VIS einbauen kann.

    Kleiner Verbesserungsvorschlag:
    Statt die 4 einzelnen DPs im Script eintragen zu müssen könnte man eine Variable mit der HomeID machen und die 4 anderen DPs daraus automatisch erzeugen.

    Und blöde Frage: Werden die Charts automatisch aktualisiert? Ich sehe im Scrips nichts, aber meine JS Fähigkeiten sind "limitiert" ;)

    jrbwhJ Offline
    jrbwhJ Offline
    jrbwh
    wrote on last edited by
    #172

    @merlin123 Das ist eine gute Idee. Die DPs sehen so aus:

    tibberLink.0.Homes.xxx.Consumption.jsonHourly
    tibberLink.0.Homes.xxx.Consumption.jsonDaily
    tibberLink.0.Homes.xxx.Consumption.jsonWeekly
    tibberLink.0.Homes.xxx.Consumption.jsonMonthly
    

    Ist das korrekt? Man könnte also tibberLink.0.Homes.xxx.Consumption also Konstante machen.

    Werden die Charts automatisch aktualisiert?

    Nein. Das gibt das Konzept nicht her. Wie ich auch in der Beschreibung geschrieben habe:
    "Das Chart kann per Hand oder regelmäßig mit der Option refresh (siehe Readme) neu geladen werden. Oder über entsprechende Einstellungen des iFrames."

    Mit &refresh=30 wird automatisch alle 30 Sekunden aktualisiert. Oder Du konfigurierst den iFrame so, dass regelmäßig aktualisiert wird.

    Merlin123M 1 Reply Last reply
    0
    • jrbwhJ jrbwh

      @merlin123 Das ist eine gute Idee. Die DPs sehen so aus:

      tibberLink.0.Homes.xxx.Consumption.jsonHourly
      tibberLink.0.Homes.xxx.Consumption.jsonDaily
      tibberLink.0.Homes.xxx.Consumption.jsonWeekly
      tibberLink.0.Homes.xxx.Consumption.jsonMonthly
      

      Ist das korrekt? Man könnte also tibberLink.0.Homes.xxx.Consumption also Konstante machen.

      Werden die Charts automatisch aktualisiert?

      Nein. Das gibt das Konzept nicht her. Wie ich auch in der Beschreibung geschrieben habe:
      "Das Chart kann per Hand oder regelmäßig mit der Option refresh (siehe Readme) neu geladen werden. Oder über entsprechende Einstellungen des iFrames."

      Mit &refresh=30 wird automatisch alle 30 Sekunden aktualisiert. Oder Du konfigurierst den iFrame so, dass regelmäßig aktualisiert wird.

      Merlin123M Offline
      Merlin123M Offline
      Merlin123
      wrote on last edited by
      #173

      @jrbwh Jup... sehen bei mir auch so aus:

      const IDS = { hourly:  'tibberlink.0.Homes.xxx.Consumption.jsonHourly',  // hourly data
                    daily:   'tibberlink.0.Homes.xxx.Consumption.jsonDaily',  // daily data
                    weekly:  'tibberlink.0.Homes.xxx.Consumption.jsonWeekly',  // weekly data
                    monthly: 'tibberlink.0.Homes.xxx.Consumption.jsonMonthly'   // monthly data
                  };
      

      Aktualisierung:
      Das hab ich überlesen.
      Wenn die aber beim Laden des Frames aktualisiert werden, reicht mir das auch :)

      Beta-Tester

      jrbwhJ M-A HuebM 2 Replies Last reply
      0
      • Merlin123M Merlin123

        @jrbwh Jup... sehen bei mir auch so aus:

        const IDS = { hourly:  'tibberlink.0.Homes.xxx.Consumption.jsonHourly',  // hourly data
                      daily:   'tibberlink.0.Homes.xxx.Consumption.jsonDaily',  // daily data
                      weekly:  'tibberlink.0.Homes.xxx.Consumption.jsonWeekly',  // weekly data
                      monthly: 'tibberlink.0.Homes.xxx.Consumption.jsonMonthly'   // monthly data
                    };
        

        Aktualisierung:
        Das hab ich überlesen.
        Wenn die aber beim Laden des Frames aktualisiert werden, reicht mir das auch :)

        jrbwhJ Offline
        jrbwhJ Offline
        jrbwh
        wrote on last edited by
        #174

        @merlin123 Gut. Hier mal ein Skript zum Testen:

        //
        // Create chart for Tibber data. To be used with flexcharts.
        //
        // Sample http request for hourly data chart:
        // http://localhost:8082/flexcharts/echarts.html?source=script&message=tibber&chart=hourly
        //
        
        // Replace 'MY-TOKEN' with your own token:
        const ID_TIBBER = 'tibberLink.0.Homes.MY-TOKEN.Consumption';
        
        const IDS = { hourly:  '.jsonHourly',  // hourly data
                      daily:   '.jsonDaily',   // daily data
                      weekly:  '.jsonWeekly',  // weekly data
                      monthly: '.jsonMonthly'  // monthly data
                    };
        
        onMessage('tibber', (httpParams, callback) => {
            // Use hourly data in case of invalid chart type
            const id = (httpParams.chart && httpParams.chart in IDS ? ID_TIBBER+IDS[httpParams.chart] : ID_TIBBER+IDS['hourly']);
            if (existsState(id)) { 
                evalTibberData(httpParams.chart, id, result => callback(result));
            } else {
                console.log('Requested state is not available >>'+id+'<<');
                callback({title: { left: "center", textStyle: { color: "#ff0000" }, text: "REQUESTED STATE IS NOT AVAILABLE: >>" + id +"<<" }});
            }
        });
        
        function evalTibberData(myChart, id, callback) {
            const tibber = JSON.parse(getState(id).val);  // Read tibber data
            const chart = {
                            tooltip: { trigger: "axis", axisPointer: { type: "cross" }},
                            legend: { show: true, orient: "horizontal", left: "center", top: 25 },
                            title: { left: "center", text: "Tibber " },
                            grid: { right: "20%" },
                            toolbox: { feature: { dataView: { show: true, readOnly: false }, restore: { show: true }, saveAsImage: { show: true }}},
                            xAxis: [{ type: "category", axisTick: { alignWithLabel: true }, data: []}],
                            yAxis: [{ type: "value", position: "left",  alignTicks: true, axisLine: { show: true, lineStyle: { color: "#5470C6" }}, axisLabel: { formatter: "{value} kWh" }},
                                    { type: "value", position: "right", alignTicks: true, axisLine: { show: true, lineStyle: { color: "#91CC75" }}, axisLabel: { formatter: "{value} €" }}],
                            series: [{ name: "Consumption", type: "bar", yAxisIndex: 0, data: []},
                                     { name: "Cost",        type: "bar", yAxisIndex: 1, data: []}]
                           };
            const xAxis  = [];
            const yAxis0 = [];
            const yAxis1 = [];
            for (const data of Object.values(tibber)) {
                const isHourly = (myChart == 'hourly');  // Hourly data?
                const xValue = (isHourly ? new Date(data.from).toLocaleTimeString() : new Date(data.from).toLocaleDateString());
                xAxis.push(xValue);
                yAxis0.push((data.consumption ? data.consumption.toFixed(2) : 0));  // push 0 on null values
                yAxis1.push((data.cost ? data.cost.toFixed(2) : 0));                // push 0 on null values
            }
            chart.xAxis[0].data  = xAxis;       // Set chart x-axis data
            chart.series[0].data = yAxis0;      // Set chart y-values consumption
            chart.series[1].data = yAxis1;      // Set chart y-values cost
            chart.title.text += myChart;             // Add type of chart to title
            console.log('Evaluation of tibber '+myChart+' data done.');
            callback(chart);
        }
        
        Merlin123M 1 Reply Last reply
        0
        • jrbwhJ jrbwh

          @merlin123 Gut. Hier mal ein Skript zum Testen:

          //
          // Create chart for Tibber data. To be used with flexcharts.
          //
          // Sample http request for hourly data chart:
          // http://localhost:8082/flexcharts/echarts.html?source=script&message=tibber&chart=hourly
          //
          
          // Replace 'MY-TOKEN' with your own token:
          const ID_TIBBER = 'tibberLink.0.Homes.MY-TOKEN.Consumption';
          
          const IDS = { hourly:  '.jsonHourly',  // hourly data
                        daily:   '.jsonDaily',   // daily data
                        weekly:  '.jsonWeekly',  // weekly data
                        monthly: '.jsonMonthly'  // monthly data
                      };
          
          onMessage('tibber', (httpParams, callback) => {
              // Use hourly data in case of invalid chart type
              const id = (httpParams.chart && httpParams.chart in IDS ? ID_TIBBER+IDS[httpParams.chart] : ID_TIBBER+IDS['hourly']);
              if (existsState(id)) { 
                  evalTibberData(httpParams.chart, id, result => callback(result));
              } else {
                  console.log('Requested state is not available >>'+id+'<<');
                  callback({title: { left: "center", textStyle: { color: "#ff0000" }, text: "REQUESTED STATE IS NOT AVAILABLE: >>" + id +"<<" }});
              }
          });
          
          function evalTibberData(myChart, id, callback) {
              const tibber = JSON.parse(getState(id).val);  // Read tibber data
              const chart = {
                              tooltip: { trigger: "axis", axisPointer: { type: "cross" }},
                              legend: { show: true, orient: "horizontal", left: "center", top: 25 },
                              title: { left: "center", text: "Tibber " },
                              grid: { right: "20%" },
                              toolbox: { feature: { dataView: { show: true, readOnly: false }, restore: { show: true }, saveAsImage: { show: true }}},
                              xAxis: [{ type: "category", axisTick: { alignWithLabel: true }, data: []}],
                              yAxis: [{ type: "value", position: "left",  alignTicks: true, axisLine: { show: true, lineStyle: { color: "#5470C6" }}, axisLabel: { formatter: "{value} kWh" }},
                                      { type: "value", position: "right", alignTicks: true, axisLine: { show: true, lineStyle: { color: "#91CC75" }}, axisLabel: { formatter: "{value} €" }}],
                              series: [{ name: "Consumption", type: "bar", yAxisIndex: 0, data: []},
                                       { name: "Cost",        type: "bar", yAxisIndex: 1, data: []}]
                             };
              const xAxis  = [];
              const yAxis0 = [];
              const yAxis1 = [];
              for (const data of Object.values(tibber)) {
                  const isHourly = (myChart == 'hourly');  // Hourly data?
                  const xValue = (isHourly ? new Date(data.from).toLocaleTimeString() : new Date(data.from).toLocaleDateString());
                  xAxis.push(xValue);
                  yAxis0.push((data.consumption ? data.consumption.toFixed(2) : 0));  // push 0 on null values
                  yAxis1.push((data.cost ? data.cost.toFixed(2) : 0));                // push 0 on null values
              }
              chart.xAxis[0].data  = xAxis;       // Set chart x-axis data
              chart.series[0].data = yAxis0;      // Set chart y-values consumption
              chart.series[1].data = yAxis1;      // Set chart y-values cost
              chart.title.text += myChart;             // Add type of chart to title
              console.log('Evaluation of tibber '+myChart+' data done.');
              callback(chart);
          }
          
          Merlin123M Offline
          Merlin123M Offline
          Merlin123
          wrote on last edited by
          #175

          @jrbwh nope...

          Screenshot 2025-02-02 164451.png

          der Name des DPs sieht aber richtig aus....

          Beta-Tester

          jrbwhJ 1 Reply Last reply
          0
          • Merlin123M Merlin123

            @jrbwh nope...

            Screenshot 2025-02-02 164451.png

            der Name des DPs sieht aber richtig aus....

            jrbwhJ Offline
            jrbwhJ Offline
            jrbwh
            wrote on last edited by
            #176

            @merlin123 Ups, es muss tibberlink heißen und nicht tibberLink (mit großem L). Bitte nochmal mit kleinem l probieren.

            Merlin123M 1 Reply Last reply
            0
            • jrbwhJ jrbwh

              @merlin123 Ups, es muss tibberlink heißen und nicht tibberLink (mit großem L). Bitte nochmal mit kleinem l probieren.

              Merlin123M Offline
              Merlin123M Offline
              Merlin123
              wrote on last edited by
              #177

              @jrbwh Geht :) Das hab ich jetzt auch nicht gesehen :P

              Beta-Tester

              jrbwhJ 1 Reply Last reply
              0
              • Merlin123M Merlin123

                @jrbwh Geht :) Das hab ich jetzt auch nicht gesehen :P

                jrbwhJ Offline
                jrbwhJ Offline
                jrbwh
                wrote on last edited by
                #178

                @merlin123 Hab auch eine Weile gebraucht. Aber es musste ein Schreibfehler sein.

                Werde gleich den Beitrag unter "Discussions" entsprechend anpassen.

                Danke!

                Merlin123M 1 Reply Last reply
                0
                • jrbwhJ jrbwh

                  @merlin123 Hab auch eine Weile gebraucht. Aber es musste ein Schreibfehler sein.

                  Werde gleich den Beitrag unter "Discussions" entsprechend anpassen.

                  Danke!

                  Merlin123M Offline
                  Merlin123M Offline
                  Merlin123
                  wrote on last edited by Merlin123
                  #179

                  @jrbwh Gern.... Bei Hourly macht das Format der Zeit keinen Sinn... Minuten und Sekunden braucht man da nicht. Kann man das anpassen?

                  Beta-Tester

                  jrbwhJ 1 Reply Last reply
                  0
                  • Merlin123M Merlin123

                    @jrbwh Gern.... Bei Hourly macht das Format der Zeit keinen Sinn... Minuten und Sekunden braucht man da nicht. Kann man das anpassen?

                    jrbwhJ Offline
                    jrbwhJ Offline
                    jrbwh
                    wrote on last edited by
                    #180

                    @merlin123 sagte in Test Adapter flexcharts - Stapeldiagramme und mehr:

                    Bei Hourly macht das Format der Zeit keinen Sinn

                    Stimmt. Hab ich auch gleich geändert. Minuten finde ich aber schon sinnvoll. Kannst Du leicht entfernen, wenn Du den Eintrag , minute: '2-digit' löscht.

                    Merlin123M 1 Reply Last reply
                    0
                    • jrbwhJ jrbwh

                      @merlin123 sagte in Test Adapter flexcharts - Stapeldiagramme und mehr:

                      Bei Hourly macht das Format der Zeit keinen Sinn

                      Stimmt. Hab ich auch gleich geändert. Minuten finde ich aber schon sinnvoll. Kannst Du leicht entfernen, wenn Du den Eintrag , minute: '2-digit' löscht.

                      Merlin123M Offline
                      Merlin123M Offline
                      Merlin123
                      wrote on last edited by Merlin123
                      #181

                      @jrbwh Funktioniert :) Minuten sind optisch schöner, stimmt

                      Muss jetzt nur die Änderungen in meinem angepassten Script als nachziehen :D Hab die Farben angepasst, da ich keinen weißen Hintergrund habe.

                      Mir ist noch was aufgefallen, keine Ahnung wo man das anpasst:
                      Es wird z,B. "1,234.56 kWh" angezeigt. Im Deutschen müsste das aber "1.234,56" heißen.

                      Idee:
                      Farben für die einzelnen Sachen als Variable am Anfang deklarieren...
                      Aber das ist eher der Goldrand, den man nicht unbedingt braucht ;)

                      Beta-Tester

                      jrbwhJ 1 Reply Last reply
                      0
                      • Merlin123M Merlin123

                        @jrbwh Funktioniert :) Minuten sind optisch schöner, stimmt

                        Muss jetzt nur die Änderungen in meinem angepassten Script als nachziehen :D Hab die Farben angepasst, da ich keinen weißen Hintergrund habe.

                        Mir ist noch was aufgefallen, keine Ahnung wo man das anpasst:
                        Es wird z,B. "1,234.56 kWh" angezeigt. Im Deutschen müsste das aber "1.234,56" heißen.

                        Idee:
                        Farben für die einzelnen Sachen als Variable am Anfang deklarieren...
                        Aber das ist eher der Goldrand, den man nicht unbedingt braucht ;)

                        jrbwhJ Offline
                        jrbwhJ Offline
                        jrbwh
                        wrote on last edited by
                        #182

                        @merlin123 sagte in Test Adapter flexcharts - Stapeldiagramme und mehr:

                        Farben für die einzelnen Sachen als Variable am Anfang deklarieren...

                        Ja, auch eine gute Idee. Man könnte auch in der Konstante IDS für jeden Chart-Typ eigene Farben vorsehen und im Skript passend zuweisen.

                        Es soll ja aber eigentlich eine Vorlage sein und auch zu eigenen Experimenten anregen. Deshalb werde ich es jetzt erstmal so lassen. Du kannst natürlich gerne Weiterentwicklungen in der Diskussion posten.

                        Merlin123M 1 Reply Last reply
                        1
                        • jrbwhJ jrbwh

                          @merlin123 sagte in Test Adapter flexcharts - Stapeldiagramme und mehr:

                          Farben für die einzelnen Sachen als Variable am Anfang deklarieren...

                          Ja, auch eine gute Idee. Man könnte auch in der Konstante IDS für jeden Chart-Typ eigene Farben vorsehen und im Skript passend zuweisen.

                          Es soll ja aber eigentlich eine Vorlage sein und auch zu eigenen Experimenten anregen. Deshalb werde ich es jetzt erstmal so lassen. Du kannst natürlich gerne Weiterentwicklungen in der Diskussion posten.

                          Merlin123M Offline
                          Merlin123M Offline
                          Merlin123
                          wrote on last edited by
                          #183

                          @jrbwh Muss mal schauen, was ich da noch anpasse, aktuell passt es erstmal.
                          Weißt zu zufällig, wie man die Darstellung der Tausender anpassen kann?

                          Beta-Tester

                          jrbwhJ 1 Reply Last reply
                          0
                          • icebearI Online
                            icebearI Online
                            icebear
                            wrote on last edited by
                            #184

                            Was mir noch nicht so ganz klar ist, wie bekomme ich den die Daten aus den DP's z.B. Heizung (VLT, AT, RLT) in ein Array so das ich es dann als Datenreihe im Fexchart verarbeiten kann?

                            Also ich hab die drei DP's in denen die Werte stehen und die auch in InfluxDB gespeichert werden. So wie ich es Vertsanden hab müssen die ja irgendwie in ein Daten Array kommen z.B. Tägliche, Wöchentlich oder Monatliche Werte. Wie stell ich das an.

                            jrbwhJ L 2 Replies Last reply
                            0
                            • Merlin123M Merlin123

                              @jrbwh Muss mal schauen, was ich da noch anpasse, aktuell passt es erstmal.
                              Weißt zu zufällig, wie man die Darstellung der Tausender anpassen kann?

                              jrbwhJ Offline
                              jrbwhJ Offline
                              jrbwh
                              wrote on last edited by
                              #185

                              @merlin123 Meinst Du die Darstellung im Tooltip? Das geht, ist aber nicht ganz einfach. Schau Dir mal dieses Issue an und den Abschnitt zu "Functions" im Readme an.

                              Merlin123M 1 Reply Last reply
                              0
                              • icebearI icebear

                                Was mir noch nicht so ganz klar ist, wie bekomme ich den die Daten aus den DP's z.B. Heizung (VLT, AT, RLT) in ein Array so das ich es dann als Datenreihe im Fexchart verarbeiten kann?

                                Also ich hab die drei DP's in denen die Werte stehen und die auch in InfluxDB gespeichert werden. So wie ich es Vertsanden hab müssen die ja irgendwie in ein Daten Array kommen z.B. Tägliche, Wöchentlich oder Monatliche Werte. Wie stell ich das an.

                                jrbwhJ Offline
                                jrbwhJ Offline
                                jrbwh
                                wrote on last edited by
                                #186

                                @icebear Das geht nur über ein Skript (Blockly oder Javascript). Schau Dir mal die Templates (siehe im Readme) an, oder z.B. diesen oder diesen Beitrag in Discussions.

                                1 Reply Last reply
                                0
                                • jrbwhJ jrbwh

                                  @merlin123 Meinst Du die Darstellung im Tooltip? Das geht, ist aber nicht ganz einfach. Schau Dir mal dieses Issue an und den Abschnitt zu "Functions" im Readme an.

                                  Merlin123M Offline
                                  Merlin123M Offline
                                  Merlin123
                                  wrote on last edited by Merlin123
                                  #187

                                  @jrbwh Danke für den Link. Muss ich mir heute Mittag mal anschauen.
                                  Hab hier noch was gefunden. Muss ich mal testen. Da hatte jemand das gleiche Problem

                                  Beta-Tester

                                  1 Reply Last reply
                                  0
                                  • icebearI icebear

                                    Was mir noch nicht so ganz klar ist, wie bekomme ich den die Daten aus den DP's z.B. Heizung (VLT, AT, RLT) in ein Array so das ich es dann als Datenreihe im Fexchart verarbeiten kann?

                                    Also ich hab die drei DP's in denen die Werte stehen und die auch in InfluxDB gespeichert werden. So wie ich es Vertsanden hab müssen die ja irgendwie in ein Daten Array kommen z.B. Tägliche, Wöchentlich oder Monatliche Werte. Wie stell ich das an.

                                    L Online
                                    L Online
                                    legro
                                    wrote on last edited by
                                    #188

                                    @icebear sagte in Test Adapter flexcharts - Stapeldiagramme und mehr:

                                    Was mir noch nicht so ganz klar ist, wie bekomme ich den die Daten aus den DP's z.B. Heizung (VLT, AT, RLT) in ein Array so das ich es dann als Datenreihe im Fexchart verarbeiten kann?

                                    Schau mal hier vorbei! Dort findest du alle Techniken, die du benötigst und wie man sie handhabt.

                                    Raspberry Pi 5 mit 8GB + 120GB SSD + Coordinator COD-m + ioBroker ..

                                    1 Reply Last reply
                                    0
                                    • Merlin123M Merlin123

                                      @jrbwh Jup... sehen bei mir auch so aus:

                                      const IDS = { hourly:  'tibberlink.0.Homes.xxx.Consumption.jsonHourly',  // hourly data
                                                    daily:   'tibberlink.0.Homes.xxx.Consumption.jsonDaily',  // daily data
                                                    weekly:  'tibberlink.0.Homes.xxx.Consumption.jsonWeekly',  // weekly data
                                                    monthly: 'tibberlink.0.Homes.xxx.Consumption.jsonMonthly'   // monthly data
                                                  };
                                      

                                      Aktualisierung:
                                      Das hab ich überlesen.
                                      Wenn die aber beim Laden des Frames aktualisiert werden, reicht mir das auch :)

                                      M-A HuebM Offline
                                      M-A HuebM Offline
                                      M-A Hueb
                                      wrote on last edited by
                                      #189

                                      @merlin123 wenn ich das Richtig gesehn hab bei deinem TestSkript wird unter dem DP flexcharts.0.info kein Punkt angelegt.
                                      könnte man das noch mit rein machen?
                                      Woher bekomme ich die URL die bei dir im Kommentar steht?

                                      iobroker unter Win10. NPM 10.9.3 Node.js v22.18.0 js-controller 7.0.7

                                      Merlin123M 1 Reply Last reply
                                      0
                                      • M-A HuebM M-A Hueb

                                        @merlin123 wenn ich das Richtig gesehn hab bei deinem TestSkript wird unter dem DP flexcharts.0.info kein Punkt angelegt.
                                        könnte man das noch mit rein machen?
                                        Woher bekomme ich die URL die bei dir im Kommentar steht?

                                        Merlin123M Offline
                                        Merlin123M Offline
                                        Merlin123
                                        wrote on last edited by
                                        #190

                                        @m-a-hueb Welches Script von mir meinst Du?

                                        Beta-Tester

                                        M-A HuebM 1 Reply Last reply
                                        0
                                        • Merlin123M Merlin123

                                          @m-a-hueb Welches Script von mir meinst Du?

                                          M-A HuebM Offline
                                          M-A HuebM Offline
                                          M-A Hueb
                                          wrote on last edited by
                                          #191

                                          @merlin123 von dem hier:

                                          
                                          //
                                          // Create chart for Tibber data. To be used with flexcharts.
                                          //
                                          // Sample http request for hourly data chart:
                                          // http://localhost:8082/flexcharts/echarts.html?source=script&message=tibber&chart=hourly
                                          //
                                           
                                          // Replace 'MY-TOKEN' with your own token:
                                          const ID_TIBBER = 'tibberLink.0.Homes.MY-TOKEN.Consumption';
                                           
                                          const IDS = { hourly:  '.jsonHourly',  // hourly data
                                                        daily:   '.jsonDaily',   // daily data
                                                        weekly:  '.jsonWeekly',  // weekly data
                                                        monthly: '.jsonMonthly'  // monthly data
                                                      };
                                           
                                          onMessage('tibber', (httpParams, callback) => {
                                              // Use hourly data in case of invalid chart type
                                              const id = (httpParams.chart && httpParams.chart in IDS ? ID_TIBBER+IDS[httpParams.chart] : ID_TIBBER+IDS['hourly']);
                                              if (existsState(id)) { 
                                                  evalTibberData(httpParams.chart, id, result => callback(result));
                                              } else {
                                                  console.log('Requested state is not available >>'+id+'<<');
                                                  callback({title: { left: "center", textStyle: { color: "#ff0000" }, text: "REQUESTED STATE IS NOT AVAILABLE: >>" + id +"<<" }});
                                              }
                                          });
                                           
                                          function evalTibberData(myChart, id, callback) {
                                              const tibber = JSON.parse(getState(id).val);  // Read tibber data
                                              const chart = {
                                                              tooltip: { trigger: "axis", axisPointer: { type: "cross" }},
                                                              legend: { show: true, orient: "horizontal", left: "center", top: 25 },
                                                              title: { left: "center", text: "Tibber " },
                                                              grid: { right: "20%" },
                                                              toolbox: { feature: { dataView: { show: true, readOnly: false }, restore: { show: true }, saveAsImage: { show: true }}},
                                                              xAxis: [{ type: "category", axisTick: { alignWithLabel: true }, data: []}],
                                                              yAxis: [{ type: "value", position: "left",  alignTicks: true, axisLine: { show: true, lineStyle: { color: "#5470C6" }}, axisLabel: { formatter: "{value} kWh" }},
                                                                      { type: "value", position: "right", alignTicks: true, axisLine: { show: true, lineStyle: { color: "#91CC75" }}, axisLabel: { formatter: "{value} €" }}],
                                                              series: [{ name: "Consumption", type: "bar", yAxisIndex: 0, data: []},
                                                                       { name: "Cost",        type: "bar", yAxisIndex: 1, data: []}]
                                                             };
                                              const xAxis  = [];
                                              const yAxis0 = [];
                                              const yAxis1 = [];
                                              for (const data of Object.values(tibber)) {
                                                  const isHourly = (myChart == 'hourly');  // Hourly data?
                                                  const xValue = (isHourly ? new Date(data.from).toLocaleTimeString() : new Date(data.from).toLocaleDateString());
                                                  xAxis.push(xValue);
                                                  yAxis0.push((data.consumption ? data.consumption.toFixed(2) : 0));  // push 0 on null values
                                                  yAxis1.push((data.cost ? data.cost.toFixed(2) : 0));                // push 0 on null values
                                              }
                                              chart.xAxis[0].data  = xAxis;       // Set chart x-axis data
                                              chart.series[0].data = yAxis0;      // Set chart y-values consumption
                                              chart.series[1].data = yAxis1;      // Set chart y-values cost
                                              chart.title.text += myChart;             // Add type of chart to title
                                              console.log('Evaluation of tibber '+myChart+' data done.');
                                              callback(chart);
                                          }
                                          
                                          

                                          iobroker unter Win10. NPM 10.9.3 Node.js v22.18.0 js-controller 7.0.7

                                          Merlin123M 1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          Support us

                                          ioBroker
                                          Community Adapters
                                          Donate

                                          679

                                          Online

                                          32.7k

                                          Users

                                          82.6k

                                          Topics

                                          1.3m

                                          Posts
                                          Community
                                          Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen | Einwilligungseinstellungen
                                          ioBroker Community 2014-2025
                                          logo
                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Home
                                          • Recent
                                          • Tags
                                          • Unread 0
                                          • Categories
                                          • Unreplied
                                          • Popular
                                          • GitHub
                                          • Docu
                                          • Hilfe