Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. Blockly
    5. Warning beim Aktualisieren von Datenpunkten

    NEWS

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

    • ioBroker goes Matter ... Matter Adapter in Stable

    • Monatsrückblick - April 2025

    Warning beim Aktualisieren von Datenpunkten

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

      Hallo zusammen,

      ich habe ein Problem beim Aktualisieren eines Datenpunktes aus Blockly.
      Es kommt immer eine Warning Meldung im Log.

      Datenunkt: 0_userdata.0.Shelly.pro4pm_IP-141.Total-0
      18b2d75f-04e1-4d3d-98e1-f5bcdea88c20-grafik.png

      Blockly:
      71533666-97ae-4aaf-8daa-a0c237e3242d-grafik.png

      if (getAttr(json, 'params.switch:0.aenergy.total') != null) {
          console.log(('switch:0.output.aenergy.total: ' + String(getAttr(json, 'params.switch:0.aenergy.total'))));
          total = getAttr(json, 'params.switch:0.aenergy.total');
          console.log(total);
          setStateDelayed('0_userdata.0.Shelly.pro4pm_IP-141.Total-0', total, true, parseInt(((0) || "").toString(), 10), false);
      }
      

      log:
      18:32:00.570 info javascript.0 (28782) script.js.ShellySkripte.Pro4PM_141_auslesen: switch:0.output.aenergy.total: 0
      18:32:00.571 info javascript.0 (28782) script.js.ShellySkripte.Pro4PM_141_auslesen: 0
      18:32:00.575 warn javascript.0 (28782) at Object.<anonymous> (script.js.ShellySkripte.Pro4PM_141_auslesen:16:5)

      Wer kann mir schreiben, warum diese Warnung kommt und wie ich sie weg bekomme?

      TIA
      .h

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

        @half sagte in Warning beim Aktualisieren von Datenpunkten:

        18:32:00.575 warn javascript.0 (28782) at Object.<anonymous> (script.js.ShellySkripte.Pro4PM_141_auslesen:16:5)

        hast du globale Skripte?
        oder kommt da noch was bei Zeile 16???

        H 1 Reply Last reply Reply Quote 0
        • H
          half @Homoran last edited by

          @homoran Zeile 16 ist die setStateDelayed Zeile.

          hier das Ganze Skript:

          var json, total;
          
          
          on({id: "mqtt.0.Shelly.PRO.4PM.141.events.rpc"/*Shelly.PRO.4PM.141/events/rpc*/, change: "ne"}, async function (obj) {
            var value = obj.state.val;
            var oldValue = obj.oldState.val;
            json = (function () { try {return JSON.parse(getState("mqtt.0.Shelly.PRO.4PM.141.events.rpc").val);} catch(e) {return {};}})();
            if (getAttr(json, 'params.switch:0.output') != null) {
              console.log(('switch:0.output: ' + String(getAttr(json, 'params.switch:0.output'))));
              setStateDelayed('0_userdata.0.Shelly.pro4pm_IP-141.Switch-0-State', getAttr(json, 'params.switch:0.output'), false, parseInt(((0) || "").toString(), 10), false);
            }
            if (getAttr(json, 'params.switch:0.aenergy.total') != null) {
              console.log(('switch:0.output.aenergy.total: ' + String(getAttr(json, 'params.switch:0.aenergy.total'))));
              total = getAttr(json, 'params.switch:0.aenergy.total');
              console.log(total);
              setStateDelayed('0_userdata.0.Shelly.pro4pm_IP-141.Total-0', total, true, parseInt(((0) || "").toString(), 10), false);
            }
            if (getAttr(json, 'params.switch:1.output') != null) {
              console.log(('switch:1.output: ' + String(getAttr(json, 'params.switch:1.output'))));
              setStateDelayed('0_userdata.0.Shelly.pro4pm_IP-141.Switch-1-State', getAttr(json, 'params.switch:1.output'), false, parseInt(((0) || "").toString(), 10), false);
            }
            if (getAttr(json, 'params.switch:2.output') != null) {
              console.log(('switch:2.output: ' + String(getAttr(json, 'params.switch:2.output'))));
              setStateDelayed('0_userdata.0.Shelly.pro4pm_IP-141.Switch-2-State', getAttr(json, 'params.switch:2.output'), false, parseInt(((0) || "").toString(), 10), false);
            }
            if (getAttr(json, 'params.switch:3.output') != null) {
              console.log(('switch:3.output: ' + String(getAttr(json, 'params.switch:3.output'))));
              setStateDelayed('0_userdata.0.Shelly.pro4pm_IP-141.Switch-3-State', getAttr(json, 'params.switch:3.output'), false, parseInt(((0) || "").toString(), 10), false);
            }
          });
          
          console.log(json);
          
          Homoran 1 Reply Last reply Reply Quote 0
          • Homoran
            Homoran Global Moderator Administrators @half last edited by Homoran

            @half sagte in Warning beim Aktualisieren von Datenpunkten:

            hier das Ganze Skript:

            was sollte dann eben der Ausschnitt 😡

            @half sagte in Warning beim Aktualisieren von Datenpunkten:

            setStateDelayed('0_userdata.0.Shelly.pro4pm_IP-141.Total-0', total, true, parseInt(((0) || "").toString(), 10), false);

            und wo ist das im Blockly?
            ist das auch nur ein Ausschnitt???

            H paul53 2 Replies Last reply Reply Quote 0
            • H
              half @Homoran last edited by

              @homoran
              Der Blockly Screenshot ist der Auszug.

              Hier auch mal das ganze Blockly Skript:
              45066142-4185-4b3c-9443-9e2020bcfaa8-grafik.png
              cc6d55f5-2092-4cfd-a66a-fdd8c76bce94-grafik.png
              bd314edf-7f19-4dd3-946d-7e305acd5f15-grafik.png

              1 Reply Last reply Reply Quote 0
              • paul53
                paul53 @Homoran last edited by

                @homoran sagte: wo ist das im Blockly?

                Das ist der "schreibe"-Block.

                H Homoran 2 Replies Last reply Reply Quote 0
                • H
                  half @paul53 last edited by

                  @paul53 ich weiss

                  Es ist das Schreiben der Variable: 0_userdata.0.Shelly.pro4pm_IP-141.Total-0

                  Die Variable wird auch geschrieben, aber trotzdem kommt die warnung.

                  Aber warum wird die warning geschmissen?
                  und wie bekomme ich sie weg?

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

                    @paul53 sagte in Warning beim Aktualisieren von Datenpunkten:

                    Das ist der "schreibe"-Block.

                    aber da finde ich den "nach Text" nicht, oder ist das implizit?

                    H paul53 2 Replies Last reply Reply Quote 0
                    • H
                      half @Homoran last edited by

                      @homoran meinst du mit nach text zeile 32?

                      1 Reply Last reply Reply Quote 0
                      • paul53
                        paul53 @Homoran last edited by

                        @homoran sagte: oder ist das implizit?

                        Ja.

                        Homoran H 2 Replies Last reply Reply Quote 1
                        • Homoran
                          Homoran Global Moderator Administrators @paul53 last edited by

                          @paul53 sagte in Warning beim Aktualisieren von Datenpunkten:

                          @homoran sagte: oder ist das implizit?

                          Ja.

                          Danke!
                          dann kann ich ja lange suchen

                          1 Reply Last reply Reply Quote 0
                          • H
                            half @paul53 last edited by

                            @paul53 das ist ein block, den ich rausgezogen hat, der nicht ausgeführt wird.
                            im screeshot oben rechts der einzelne block am anfang des skripts

                            1 Reply Last reply Reply Quote 0
                            • paul53
                              paul53 @half last edited by paul53

                              @half sagte: Aber warum wird die warning geschmissen?

                              Schau mal im Tab "Protokolle" nach. Dort findet man meist mehr Informationen.
                              Enthält "Total-0" wirklich eine Zeichenkette? Wie sieht JSON aus?

                              H 1 Reply Last reply Reply Quote 0
                              • H
                                half @paul53 last edited by

                                @paul53 danke, ich glaub ich habs gefunden.

                                You are assigning a number to the state "0_userdata.0.Shelly.pro4pm_IP-141.Total-0" which expects a string. Please fix your code to use a string or change the state type to number. This warning might become an error in future versions.

                                Dann übergab ich das Ganze mal als String. Mal sehen, ob der Fehler dann weg ist.

                                paul53 1 Reply Last reply Reply Quote 0
                                • paul53
                                  paul53 @half last edited by

                                  @half sagte: Dann übergab ich das Ganze mal als String.

                                  Ich hätte common.type des Datenpunktes von "string" in "number" geändert.

                                  H 1 Reply Last reply Reply Quote 0
                                  • H
                                    half @paul53 last edited by half

                                    @paul53 hat sowohl als auch funktioniert.
                                    habs jetzt den Datenpunkt auf Zahl gesetzt, ist sauberer.

                                    Danke, an Alle für die Denkanstöße

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

                                    Support us

                                    ioBroker
                                    Community Adapters
                                    Donate

                                    790
                                    Online

                                    31.7k
                                    Users

                                    79.8k
                                    Topics

                                    1.3m
                                    Posts

                                    blockly javascript
                                    3
                                    16
                                    844
                                    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