Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. Blockly
    5. Blockly für Wert aus JSON zu extrahieren

    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

    Blockly für Wert aus JSON zu extrahieren

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

      Hallo.
      Ich habe im IoBroker einen Datenpunkt wo die Daten als JSON ankommen. Ich bekomme es aber leider nicht hin, den Wert den ich benötige zu extrahieren, evtl. kann mir hier einer helfen.
      Ich brauche ein Blockly, das mir den rot markierten Wert in einen Datenpunkt schreibt.
      Schonmal vielen Dank für die Hilfe .)

      
      {
        "body": {
          "header": {
            "access_no": 35,
            "identification": "0x80, 0x74, 0x12, 0x39",
            "manufacturer": "SEN",
            "medium": "0x4",
            "sign": "0x0, 0x0",
            "status": "0x0",
            "type": "0x72",
            "version": "0x19"
          },
          "records": [
            {
              "function": "FunctionType.INSTANTANEOUS_VALUE",
              "type": "VIFUnit.ENERGY_WH",
              "unit": "MeasureUnit.WH",
              "value": 6720000
            },
            {
              "function": "FunctionType.INSTANTANEOUS_VALUE",
              "type": "VIFUnit.VOLUME",
              "unit": "MeasureUnit.M3",
              "value": 1083.3120000000001
            },
            {
              "function": "FunctionType.INSTANTANEOUS_VALUE",
              "type": "VIFUnit.VOLUME_FLOW",
              "unit": "MeasureUnit.M3_H",
              "value": 0
            },
            {
              "function": "FunctionType.INSTANTANEOUS_VALUE",
              "type": "VIFUnit.POWER_W",
              "unit": "MeasureUnit.W",
              "value": 0
            },
            {
              "function": "FunctionType.INSTANTANEOUS_VALUE",
              "type": "VIFUnit.FLOW_TEMPERATURE",
              "unit": "MeasureUnit.C",
              "value": 34.2
            },
            {
              "function": "FunctionType.INSTANTANEOUS_VALUE",
              "type": "VIFUnit.RETURN_TEMPERATURE",
              "unit": "MeasureUnit.C",
              "value": 22.900000000000002
            },
            {
              "function": "FunctionType.INSTANTANEOUS_VALUE",
              "type": "VIFUnit.TEMPERATURE_DIFFERENCE",
              "unit": "MeasureUnit.K",
              "value": 11.397
            },
            {
              "function": "FunctionType.INSTANTANEOUS_VALUE",
              "type": "VIFUnit.FABRICATION_NO",
              "unit": "MeasureUnit.NONE",
              "value": 80741239
            },
            {
              "function": "FunctionType.INSTANTANEOUS_VALUE",
              "type": "VIFUnitExt.CUSTOMER_LOCATION",
              "unit": "MeasureUnit.NONE",
              "value": 80741239
            },
            {
              "function": "FunctionType.MORE_RECORDS_FOLLOW",
              "type": "None",
              "unit": "None",
              "value": null
            }
          ]
        },
        "head": {
          "a": "0x0",
          "c": "0x8",
          "crc": "0xbd",
          "length": "0x42",
          "start": "0x68",
          "stop": "0x16"
        }
      }
      

      MOD-EDIT: Code in code-tags gesetzt!

      gesucht wird das valeue in

      "records": [
      {
      "function": "FunctionType.INSTANTANEOUS_VALUE",
      "type": "VIFUnit.ENERGY_WH",
      "unit": "MeasureUnit.WH",
      "value": 6720000
      },
      
      paul53 Homoran 2 Replies Last reply Reply Quote 0
      • paul53
        paul53 @Atifan last edited by

        @atifan Versuche mal:

        Bild_2021-07-15_200051.png

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

          @atifan versuch es mal so:
          json02.png

          ich habe die Variable JSON_Import benutzt um dein JSON "einzulesen"

          EDIT:
          Paul war mal wieder schneller 😞

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

            Thx euch beiden, funktioniert wunderbar. Hab das von @paul53 genommen, weil das für mich etwas verständlicher ist^^.

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

              @atifan sagte in Blockly für Wert aus JSON zu extrahieren:

              weil das für mich etwas verständlicher ist

              Paul extrahiert erst alle records und nimmt dann aus diesem Array das erste Element.
              Mein Beispiel macht direkt alles in einem Schub.
              Das erste Element des Arrays hat die Zahl 0

              Ich hatte erst gar nicht erkannt dass records ein Array ist. ;-(

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

                @homoran Jo Danke für die gute Erklärung 🙂 Ich bin froh dass ich kein Programmierer geworden bin, das wär nix für mich 😄

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

                  @homoran sagte: nimmt dann aus diesem Array das erste Element.

                  Aus dem Array lassen sich leicht weitere Messwerte erfassen:

                  Bild_2021-07-15_205121.png

                  Atifan 1 Reply Last reply Reply Quote 1
                  • Atifan
                    Atifan @paul53 last edited by

                    Ah cool, dann muss ich das Sciptchen noch bisschen erweitern 😄 Thx!

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

                      @atifan sagte in Blockly für Wert aus JSON zu extrahieren:

                      dann muss ich das Sciptchen noch bisschen erweitern

                      sieh dir mal die Seite http://jsonviewer.stack.hu/ an.
                      da kannst du das JSON unter text reinkopieren und dann im Reiter JSON die Struktur ansehen:
                      json_viewer02.png

                      Da siehst du dann mit welchem Parameter du welchen Wert/Einheit/Datum usw. nach dem gleichen Schema auslesen kannst

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

                        @homoran Ah super, vielen Dank!
                        Ja das ist sehr hilfreich 🙂

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

                          @atifan sagte in Blockly für Wert aus JSON zu extrahieren:

                          Ja das ist sehr hilfreich

                          wir werden dir noch deine Grundeinstellung von wegen:

                          @atifan sagte in Blockly für Wert aus JSON zu extrahieren:

                          das wär nix für mich

                          gewaltig umkrempeln 😂

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

                          Support us

                          ioBroker
                          Community Adapters
                          Donate

                          594
                          Online

                          31.9k
                          Users

                          80.2k
                          Topics

                          1.3m
                          Posts

                          3
                          11
                          1012
                          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