Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. Blockly
    5. [gelöst] assigning an object to state which expects a number

    NEWS

    • Wir empfehlen: Node.js 22.x

    • Neuer Blog: Fotos und Eindrücke aus Solingen

    • ioBroker goes Matter ... Matter Adapter in Stable

    [gelöst] assigning an object to state which expects a number

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

      Hi Zusammen,

      nach meinem Update auf 6.2 bekomme ich folgende Fehlermeldung:

      You are assigning a object to the state "0_userdata.0.Verbrauchswerte.HWR.Lüftungsanlage" which expects a number. Please fix your code to use a number or change the state type to object. This warning might become an error in future versions.
      

      Ich kann mir das allerdings nicht erklären, da ich im Blockly eine Zahl zuordne:

      c89b8662-6588-459e-a4a0-fcab01ee19c9-image.png

      Vorher hat das funktioniert mit JSON nach Objekt, nach dem Update kam oben stehende Fehlermeldung daher habe ich nach Objekt in nach Zahl getauscht. Habt Ihr eine Idee was ich falsch mache?

      Danke und Gruß,

      Claus

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

        @claus1985-0
        Man kann ein JSON (Wert) nicht nach Zahl konvertieren, sondern nur das Attribut "ENERGY.Total", falls es überhaupt erforderlich sein sollte.

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

          @paul53 wie kann ich es dann am sinnvollsten in einen Userwert Zahl schreiben?
          Ich dachte ich beziehe mich in diesem Fall auf das Attribut ENERGY.Total

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

            @claus1985-0 sagt: beziehe mich in diesem Fall auf das Attribut ENERGY.Total

            Das machst Du beim Konvertieren nach Zahl eben nicht.

            Blockly_temp.JPG

            Wie sieht das JSON aus? Ist überhaupt eine Konvertierung nach Zahl erforderlich?

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

              @paul53 hast Recht, war ein Denkfehler, danke für den Tipp! Fehlermeldung ist weg.

              Allerdings bleiben die beiden Werte die er aktualisiert (alle paar Sekunden) bei (null):
              212a538f-ebb5-4823-805c-f6d4a4294966-image.png

              JSON sieht übrigens aus wie folgt:

              {"Time":"2023-03-11T20:49:59","ENERGY":{"TotalStartTime":"2019-06-29T22:31:34","Total":1614.568,"Yesterday":0.937,"Today":0.799,"Period":4,"Power":58,"ApparentPower":83,"ReactivePower":59,"Factor":0.70,"Voltage":227,"Current":0.365}}
              

              Hast Du ne Idee wo mein Denkfehler liegt?

              Danke Dir und Gruß,

              Claus

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

                @claus1985-0 sagte: JSON sieht übrigens aus wie folgt:

                Dann ist eine Wandlung nach Zahl nicht erforderlich.

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

                  @paul53 ohne Wandlung kommt die Fehlermeldung assigning object to state which expects a number. Mit Wandlung zu Zahl gehts zwar ohne Meldung aber die Werte bleiben (null) obwohl im JSON eine Zahl drinsteht.

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

                    @claus1985-0 sagte: die Werte bleiben (null) obwohl im JSON eine Zahl drinsteht.

                    Hast Du es so gemacht?

                    Blockly_temp.JPG

                    So muss es funktionieren, wenn das gezeigte JSON im Datenpunktwert enthalten ist.

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

                      @paul53 danke für den Tipp funktioniert einwandfrei! Danke Dir!

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

                        @claus1985-0 sagte in assigning an object to state which expects a number:

                        danke für den Tipp

                        war schon was "älter"

                        @paul53 sagte in assigning an object to state which expects a number:

                        @claus1985-0 sagt: beziehe mich in diesem Fall auf das Attribut ENERGY.Total

                        Das machst Du beim Konvertieren nach Zahl eben nicht.

                        Blockly_temp.JPG

                        Wie sieht das JSON aus? Ist überhaupt eine Konvertierung nach Zahl erforderlich?

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

                        Support us

                        ioBroker
                        Community Adapters
                        Donate

                        799
                        Online

                        32.0k
                        Users

                        80.5k
                        Topics

                        1.3m
                        Posts

                        3
                        10
                        384
                        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