Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. Summe aus verschiedenen Datenpunkte

    NEWS

    • Neuer Blog: Fotos und Eindrücke aus Solingen

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

    • ioBroker goes Matter ... Matter Adapter in Stable

    Summe aus verschiedenen Datenpunkte

    This topic has been deleted. Only users with topic management privileges can see it.
    • tigertim08
      tigertim08 @paul53 last edited by

      @paul53 danke, Fehlermeldung compile failed besteht weiter

      
      javascript.0	2020-05-27 19:21:26.987	error	(394) at processTicksAndRejections (internal/process/task_queues.js:97:5)
      javascript.0	2020-05-27 19:21:26.986	error	(394) at runMicrotasks (<anonymous>:null:null)
      javascript.0	2020-05-27 19:21:26.986	error	(394) at /opt/iobroker/node_modules/standard-as-callback/built/index.js:19:49
      javascript.0	2020-05-27 19:21:26.986	error	(394) at tryCatcher (/opt/iobroker/node_modules/standard-as-callback/built/utils.js:11:23)
      javascript.0	2020-05-27 19:21:26.986	error	(394) at /opt/iobroker/node_modules/iobroker.js-controller/lib/states/statesInRedis.js:580:17
      javascript.0	2020-05-27 19:21:26.986	error	(394) at /opt/iobroker/node_modules/iobroker.javascript/main.js:1055:17
      javascript.0	2020-05-27 19:21:26.986	error	(394) at /opt/iobroker/node_modules/iobroker.javascript/main.js:1464:17
      javascript.0	2020-05-27 19:21:26.985	error	(394) at prepareScript (/opt/iobroker/node_modules/iobroker.javascript/main.js:1411:37)
      javascript.0	2020-05-27 19:21:26.985	error	(394) at compile (/opt/iobroker/node_modules/iobroker.javascript/main.js:1188:28)
      javascript.0	2020-05-27 19:21:26.985	error	(394) at Object.createScript (vm.js:263:10)
      javascript.0	2020-05-27 19:21:26.985	error	(394) at new Script (vm.js:88:7)
      javascript.0	2020-05-27 19:21:26.985	error	(394) SyntaxError: Unexpected token 'function'
      javascript.0	2020-05-27 19:21:26.984	error	(394) ^^^^^^^^
      javascript.0	2020-05-27 19:21:26.984	error	(394) function(obj) {
      javascript.0	2020-05-27 19:21:26.984	error	at script.js.common.Test.Stromkosten_Gesamt:13
      javascript.0	2020-05-27 19:21:26.984	error	(394) script.js.common.Test.Stromkosten_Gesamt compile failed:
      javascript.0	2020-05-27 19:21:26.982	info	(394) Start javascript script.js.common.Test.Stromkosten_Gesamt
      javascript.0	2020-05-27 19:21:25.461	info	(394) Stop script script.js.common.Test.Stromkosten_Gesamt
      
      
      paul53 1 Reply Last reply Reply Quote 0
      • paul53
        paul53 @tigertim08 last edited by paul53

        @tigertim08 sagte:

        compile failed besteht weiter

        Es fehlen eine schließende geschweifte Klammer und ein Komma.

        on({id: /\.05_current_year$/, change: 'any'}, function(obj) {
        

        und in Zeile 23 eine schließende runde Klammer.

        });
        
        tigertim08 1 Reply Last reply Reply Quote 0
        • tigertim08
          tigertim08 @paul53 last edited by

          @paul53 said in Summe aus verschiedenen Datenpunkte:

          });

          Super, Danke! Jetzt meckert er nur noch das ich einen string zu einem state assigne. Die Werte werden doch aber auch als State ausgegeben oder habe ich da einen Denkfehler?

          javascript.0	2020-05-28 08:25:30.653	warn	(394) at processImmediate (internal/timers.js:456:21)
          javascript.0	2020-05-28 08:25:30.653	warn	(394) at Immediate._onImmediate (/opt/iobroker/node_modules/iobroker.js-controller/lib/adapter.js:4851:37)
          javascript.0	2020-05-28 08:25:30.653	warn	(394) at Object.stateChange (/opt/iobroker/node_modules/iobroker.javascript/main.js:450:25)
          javascript.0	2020-05-28 08:25:30.652	warn	(394) at Object.callback (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1051:38)
          javascript.0	2020-05-28 08:25:30.652	warn	(394) at Object.<anonymous> (script.js.common.Test.Stromkosten_Gesamt:22:5)
          javascript.0	2020-05-28 08:25:30.652	warn	(394) at setState (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1354:20)
          javascript.0	2020-05-28 08:25:30.651	warn	(394) You are assigning a string to the state "javascript.0.Stromkosten.2020.Summe" which expects a boolean. Please fix your code to use a boolean or change the state type to string. This warning mig
          javascript.0	2020-05-28 08:25:30.651	info	(394) script.js.common.Test.Stromkosten_Gesamt: getState(id=sourceanalytix.0.hm-rpc__0__LEQ0536791__2__ENERGY_COUNTER.cost.05_current_year, timerId=undefined) => {"val":"1.88","ack":true,"ts":1590647
          javascript.0	2020-05-28 08:25:30.651	info	(394) script.js.common.Test.Stromkosten_Gesamt: getState(id=sourceanalytix.0.hm-rpc__0__MEQ0107335__2__ENERGY_COUNTER.cost.05_current_year, timerId=undefined) => {"val":"5.22","ack":true,"ts":1590647
          javascript.0	2020-05-28 08:25:30.650	info	(394) script.js.common.Test.Stromkosten_Gesamt: getState(id=sourceanalytix.0.hm-rpc__0__NEQ0153556__2__ENERGY_COUNTER.cost.05_current_year, timerId=undefined) => {"val":"0.00","ack":true,"ts":1590647
          javascript.0	2020-05-28 08:25:30.650	info	(394) script.js.common.Test.Stromkosten_Gesamt: getState(id=sourceanalytix.0.hm-rpc__0__NEQ0153678__2__ENERGY_COUNTER.cost.05_current_year, timerId=undefined) => {"val":"1.53","ack":true,"ts":1590647
          javascript.0	2020-05-28 08:25:30.650	info	(394) script.js.common.Test.Stromkosten_Gesamt: getState(id=sourceanalytix.0.sonoff__0__Tasmota_TV_Technik__ENERGY_Today.cost.05_current_year, timerId=undefined) => {"val":"0.00","ack":true,"ts":1590
          javascript.0	2020-05-28 08:25:30.649	info	(394) script.js.common.Test.Stromkosten_Gesamt: getState(id=sourceanalytix.0.sonoff__0__PC_Tim__ENERGY_Today.cost.05_current_year, timerId=undefined) => {"val":"0.01","ack":true,"ts":1590647120353,"q
          javascript.0	2020-05-28 08:25:30.649	info	(394) script.js.common.Test.Stromkosten_Gesamt: getState(id=sourceanalytix.0.sonoff__0__Wasserbett__ENERGY_Today.cost.05_current_year, timerId=undefined) => {"val":"0.01","ack":true,"ts":159064712735
          javascript.0	2020-05-28 08:25:29.695	info	(394) script.js.common.Test.Stromkosten_Gesamt: registered 1 subscription and 0 schedules
          javascript.0	2020-05-28 08:25:29.695	info	(394) script.js.common.Test.Stromkosten_Gesamt: subscribe: {"pattern":{"id":{},"change":"any","q":0},"name":"script.js.common.Test.Stromkosten_Gesamt"}
          
          Homoran 1 Reply Last reply Reply Quote 0
          • Homoran
            Homoran Global Moderator Administrators @tigertim08 last edited by Homoran

            @tigertim08 sagte in Summe aus verschiedenen Datenpunkte:

            You are assigning a string to the state "javascript.0.Stromkosten.2020.Summe" which expects a boolean. Please fix your code to use a boolean or change the state type to string. This warning mig

            Dein Datenpunkt ist vom Typ "Logikwert"
            Der muss "Zahl" sein

            1 Reply Last reply Reply Quote 0
            • tigertim08
              tigertim08 last edited by

              laut Datenpunkt ist er das. Habe ihn auch nochmal gelöscht und fom Skript anlegen lassen

              var idSumme = 'javascript.0.Stromkosten.2020.Summe';
              {1}
              createState(idSumme,  { 
                  name: 'Summe aller Verbraucher',
                  unit: '€',
                  type: 'number',
                  def:  0,
                  min: 0
              });
              on({id: /\.05_current_year$/,
                  change: 'any'},
              
              function(obj) {
                  var a = getState('sourceanalytix.0.sonoff__0__Wasserbett__ENERGY_Today.cost.05_current_year').val,
                      b = getState('sourceanalytix.0.sonoff__0__PC_Tim__ENERGY_Today.cost.05_current_year').val,
                      c = getState('sourceanalytix.0.sonoff__0__Tasmota_TV_Technik__ENERGY_Today.cost.05_current_year').val,
                      d = getState('sourceanalytix.0.hm-rpc__0__NEQ0153678__2__ENERGY_COUNTER.cost.05_current_year').val,
                      e = getState('sourceanalytix.0.hm-rpc__0__NEQ0153556__2__ENERGY_COUNTER.cost.05_current_year').val,
                      f = getState('sourceanalytix.0.hm-rpc__0__MEQ0107335__2__ENERGY_COUNTER.cost.05_current_year').val,
                      g = getState('sourceanalytix.0.hm-rpc__0__LEQ0536791__2__ENERGY_COUNTER.cost.05_current_year').val;
                  var summe = a + b + c + d + e + f + g;
                  setState(idSumme, summe);
              });
              
              Homoran 1 Reply Last reply Reply Quote 0
              • Homoran
                Homoran Global Moderator Administrators @tigertim08 last edited by

                @tigertim08 sagte in Summe aus verschiedenen Datenpunkte:

                laut Datenpunkt ist er das.

                dann gilt wohl der erste Tei lder Meldung:

                You are assigning a string to the state "javascript.0.Stromkosten.2020.Summe" which expects a boolean. Please fix your code to use a boolean or change the state type to string. This warning mig

                Also das Ergebnis nach Zahl wandeln

                1 Reply Last reply Reply Quote 0
                • tigertim08
                  tigertim08 last edited by tigertim08

                  Wie ändere ich das denn? Hatte die einzelnen Datenpunkte schon gecheckt, diese sind auch als "number" klassifiziert.

                  2020-05-28_13-29-25.png

                  Kann es an der Unit liegen? Also das die Unit dazu führt das es bei der Folgeverarbeitung ein String und keine Nummer mehr ist?

                  Homoran 1 Reply Last reply Reply Quote 0
                  • Homoran
                    Homoran Global Moderator Administrators @tigertim08 last edited by

                    @tigertim08 sagte in Summe aus verschiedenen Datenpunkte:

                    Hatte die einzelnen Datenpunkte schon gecheckt,

                    nicht die datenpunkte!

                    Die Variable im Skript scheint Typ String zu sein

                    1 Reply Last reply Reply Quote 0
                    • tigertim08
                      tigertim08 last edited by tigertim08

                      (gelöst) DANKE! Für die Unterstützung 🙂

                      okay, also wenn ich den State umwandle sollte es gehen?

                      var idSumme = 'javascript.0.Stromkosten.2020';
                      {1}
                      createState(idSumme,  { 
                          name: 'Summe der Verbraucher',
                          unit: '€',
                          type: 'number',
                          def:  0,
                          min: 0
                      });
                      on({id: /\.05_current_year$/,
                          change: 'any'},
                      
                      function(obj) {
                          var a = parseFloat(getState('sourceanalytix.0.sonoff__0__Wasserbett__ENERGY_Today.cost.05_current_year').val),
                              b = parseFloat(getState('sourceanalytix.0.sonoff__0__PC_Tim__ENERGY_Today.cost.05_current_year').val),
                              c = parseFloat(getState('sourceanalytix.0.sonoff__0__Tasmota_TV_Technik__ENERGY_Today.cost.05_current_year').val),
                              d = parseFloat(getState('sourceanalytix.0.hm-rpc__0__NEQ0153678__2__ENERGY_COUNTER.cost.05_current_year').val),
                              e = parseFloat(getState('sourceanalytix.0.hm-rpc__0__NEQ0153556__2__ENERGY_COUNTER.cost.05_current_year').val),
                              f = parseFloat(getState('sourceanalytix.0.hm-rpc__0__MEQ0107335__2__ENERGY_COUNTER.cost.05_current_year').val),
                              g = parseFloat(getState('sourceanalytix.0.hm-rpc__0__LEQ0536791__2__ENERGY_COUNTER.cost.05_current_year').val);
                          var summe = a + b + c + d + e + f + g;
                          setState(idSumme, summe);
                      });
                      

                      habe es mit parseFloat probiert allerdings bleibt jetzt der Datenpunkt leer. Warnmeldungen werden mir aber nicht mehr angezeit.

                      T 1 Reply Last reply Reply Quote 0
                      • T
                        ticaki Developer @tigertim08 last edited by ticaki

                        @tigertim08

                        Werfe mal das parseFloat() raus und füge:

                        log('a: '+a);
                        log('b: '+b);
                        log('c: '+c);
                        log('d: '+d);
                        log('e: '+e);
                        log('f: '+f);
                        log('g: '+g);
                        

                        nach Zeile 20 ein. Poste die Logeinträge. Denke mal das es ein Problem mit ".," oder Einheitenangaben ist.

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

                        Support us

                        ioBroker
                        Community Adapters
                        Donate

                        543
                        Online

                        31.9k
                        Users

                        80.2k
                        Topics

                        1.3m
                        Posts

                        javascript
                        6
                        20
                        1147
                        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