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] Blockly json wert

    NEWS

    • Wir empfehlen: Node.js 22.x

    • Neuer Blog: Fotos und Eindrücke aus Solingen

    • ioBroker goes Matter ... Matter Adapter in Stable

    [gelöst] Blockly json wert

    This topic has been deleted. Only users with topic management privileges can see it.
    • padrino
      padrino Most Active @bishop last edited by

      @bishop
      In welchen Datenpunkt willst Du denn schreiben?
      Dann solltest Du "schreibe Objekt" verwenden.
      Objekte sind ja die Datenpunkte.

      1 Reply Last reply Reply Quote 0
      • B
        bishop last edited by

        @padrino danke ja das weis ich schon, ich bekomme ja im debug die Ausgabe "undefined" als test.

        Wenn der Wert die Nummer wäre würde ich den dann natürlich in ein DP schreiben.

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

          @bishop sagte:

          callee in einen DP schreiben, wie bekomme ich das hin?

          Es handelt sich nicht um eine Liste (array), sondern um ein Objekt.

          Blockly_temp.JPG

          1 Reply Last reply Reply Quote 1
          • B
            bishop last edited by

            @paul53 Vielen Dank, genau das was ich gesucht habe.

            1 Reply Last reply Reply Quote 0
            • padrino
              padrino Most Active last edited by padrino

              Hm, ist das Umwandeln nötig?
              Das hier scheint auch zu klappen:
              json_obj.PNG

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

                @padrino sagte:

                Das hier scheint auch zu klappen:

                Ja, aber mit Error-Log. Welche weiteren Informationen liefert der Tab "Log" ?

                padrino 1 Reply Last reply Reply Quote 0
                • padrino
                  padrino Most Active @paul53 last edited by

                  @paul53
                  Nix. 😉
                  Gibt doch keinen Error, ist doch nur, weil ich den Debug Output auf level "error" stehen habe, das Log ist sonst "sauber". 🙂

                  E paul53 2 Replies Last reply Reply Quote 0
                  • E
                    e-s @padrino last edited by

                    @padrino
                    Blöde Frage, aber das sieht mir arg nach Fritz Adapter aus, da gibt es doch unter inbound direkt diese datenpunkte, warum holst du diese aus der json?

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

                      @padrino
                      Du hast recht, ich habe es gerade getestet: Man kann kann die Attribute direkt dem JSON entnehmen.

                      var json = {"a":10,"b":[22,"xx"]};
                      log(json.b[0]); // Log: 22
                      
                      1 Reply Last reply Reply Quote 0
                      • B
                        bishop last edited by

                        @e-s
                        das mache ich weil die DP nicht immer geschrieben werden.
                        So funktioniert mein vorhaben deutlich zuverlässiger.

                        E 1 Reply Last reply Reply Quote 0
                        • padrino
                          padrino Most Active @e-s last edited by

                          @e-s
                          Also, ich mache gar nix. 😉
                          Ich versuche nur das zu verstehen. 🙂
                          Übrigens, hole ich zu Testzwecken die Info aus dem JSON Objekt des Alexa2 Adapters.

                          @paul53
                          Habe keine Ahung, worum es genau geht, aber cool, dass es geht. 😎 😉

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

                            @padrino sagte:

                            Habe keine Ahung, worum es genau geht,

                            Doku zu getAttr():

                            If the first attribute is string, the function will try to parse the string as JSON string.

                            padrino 1 Reply Last reply Reply Quote 1
                            • E
                              e-s @bishop last edited by

                              @bishop
                              Ups, mal wieder den falschen beim antworten erwischt. Kenne dein Problem und wollte dieses eigentlich dahingehend beseitigen indem ich auf das Klingeln selber triggern wollte, um somit auch bei 2 mal infolge den selben Namen bzw Nummer keine Probleme bekomme.

                              1 Reply Last reply Reply Quote 0
                              • padrino
                                padrino Most Active @paul53 last edited by padrino

                                @paul53
                                Ok. 😳

                                Übrigens, wenn man nicht wirklich weiß, was man tut, dann kann man auch 'n "error" erzeugen, denn sowas geht wohl nicht:
                                json_error.PNG

                                ☝ Beweis, padrino hat's noch nicht ganz geschnallt. 😌 😉

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

                                  @padrino sagte:

                                  sowas geht wohl nicht:

                                  Bezeichner dürfen nicht mit einer Ziffer beginnen, was hier der Fall wäre, falls es sich nicht um ein Array handelt. Wie sieht das JSON aus ?

                                  padrino 1 Reply Last reply Reply Quote 0
                                  • padrino
                                    padrino Most Active @paul53 last edited by

                                    @paul53

                                    {
                                      "_id": "0_userdata.0.Garagentor",
                                      "type": "state",
                                      "common": {
                                        "name": "Garagentor",
                                        "role": "",
                                        "type": "number",
                                        "read": true,
                                        "write": true,
                                        "desc": "Manuell erzeugt",
                                        "min": -1,
                                        "max": 1,
                                        "def": 0,
                                        "states": {
                                          "0": "in_Bewegung",
                                          "1": "offen",
                                          "-1": "geschlossen"
                                        }
                                      },
                                      "native": {},
                                      "from": "system.adapter.admin.0",
                                      "ts": 1579877911665,
                                      "acl": {
                                        "object": 1636,
                                        "state": 1636,
                                        "owner": "system.user.admin",
                                        "ownerGroup": "system.group.administrator"
                                      }
                                    }
                                    
                                    paul53 1 Reply Last reply Reply Quote 0
                                    • paul53
                                      paul53 @padrino last edited by

                                      @padrino sagte:

                                      "0_userdata.0.Garagentor"

                                      "0_userdata.0.Garagentor" ist kein Objekt, sondern ein String. Du hast die Datenpunkt-ID übergeben.

                                      padrino 1 Reply Last reply Reply Quote 1
                                      • padrino
                                        padrino Most Active @paul53 last edited by

                                        @paul53
                                        🤦‍♂️
                                        Jo, hast Recht, ist natürlich nur die ID, die man mit Blockly Übergibt.
                                        Das Objekt selbst geht damit gar nicht...

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

                                        Support us

                                        ioBroker
                                        Community Adapters
                                        Donate

                                        850
                                        Online

                                        32.0k
                                        Users

                                        80.4k
                                        Topics

                                        1.3m
                                        Posts

                                        4
                                        19
                                        1491
                                        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