Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. Blockly
    5. JSON über Blockly zerlegen

    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

    JSON über Blockly zerlegen

    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      MCU @aski71 last edited by MCU

      @aski71 Läuft bei mir:
      503dfc8b-3da9-411c-af80-cb985c7b5c72-image.png

      <xml xmlns="https://developers.google.com/blockly/xml">
       <variables>
         <variable id="vC~s+KSv55[ns)`NZd^V">Liste</variable>
         <variable id="Sd(Azq!#PX`0:3Mw}V{n">obj</variable>
       </variables>
       <block type="variables_set" id=":z)TGf~|{]2p(uSE],4z" x="138" y="88">
         <field name="VAR" id="vC~s+KSv55[ns)`NZd^V">Liste</field>
         <value name="VALUE">
           <block type="convert_json2object" id="XZ)I?D4IHyDL@+Kp0waa">
             <value name="VALUE">
               <block type="get_value" id="T(,s,(LcwfL;ERDtx_%h">
                 <field name="ATTR">val</field>
                 <field name="OID">0_userdata.0.jarvis.test.text</field>
               </block>
             </value>
           </block>
         </value>
         <next>
           <block type="controls_forEach" id="$V[_btjKL*tF5GCx1JzR">
             <field name="VAR" id="Sd(Azq!#PX`0:3Mw}V{n">obj</field>
             <value name="LIST">
               <block type="variables_get" id="aoE=x6B=7=4q6U5?_6A|">
                 <field name="VAR" id="vC~s+KSv55[ns)`NZd^V">Liste</field>
               </block>
             </value>
             <statement name="DO">
               <block type="controls_if" id="dstB@fFd(smWhy(ooUa#">
                 <value name="IF0">
                   <block type="logic_compare" id="{XA:vd).Kd3$4R$zRr?i">
                     <field name="OP">EQ</field>
                     <value name="A">
                       <block type="get_attr" id="UXM]jNg_3I(+mMK*kfXA">
                         <value name="PATH">
                           <shadow type="text" id=";e[OJ-s@bfM3_F@Khj@|">
                             <field name="TEXT">event</field>
                           </shadow>
                         </value>
                         <value name="OBJECT">
                           <block type="variables_get" id="I)n0R+=j__6;G~$WuLb[">
                             <field name="VAR" id="Sd(Azq!#PX`0:3Mw}V{n">obj</field>
                           </block>
                         </value>
                       </block>
                     </value>
                     <value name="B">
                       <block type="text" id="dw](D=SXZ0~XDt#:`7N6">
                         <field name="TEXT">Charge</field>
                       </block>
                     </value>
                   </block>
                 </value>
                 <statement name="DO0">
                   <block type="debug" id="CHhC?IQqC^Fj`ICssf_=">
                     <field name="Severity">log</field>
                     <value name="TEXT">
                       <shadow type="text" id="q($Z?V`5.!i[Qg@J747[">
                         <field name="TEXT">test</field>
                       </shadow>
                       <block type="get_attr" id="-7s3ggu$oXXS^?N$hdi+">
                         <value name="PATH">
                           <shadow type="text" id="cq81G*t.|)uOD$#`-qBG">
                             <field name="TEXT">location</field>
                           </shadow>
                         </value>
                         <value name="OBJECT">
                           <block type="variables_get" id="R3M7:9]u;mQRv(sL6DMr">
                             <field name="VAR" id="Sd(Azq!#PX`0:3Mw}V{n">obj</field>
                           </block>
                         </value>
                       </block>
                     </value>
                   </block>
                 </statement>
               </block>
             </statement>
           </block>
         </next>
       </block>
      </xml>
      

      A 1 Reply Last reply Reply Quote 0
      • A
        aski71 @MCU last edited by

        @mcu Hm. Bei mir nicht. Er geht nicht in den "falls" Zweig. Hab das genauso runter gedengelt, wie in Deinem Screenshot. Unterschied ist nur die tatsächliche ObjektID, in dem das steht und ich habe geringfügig andere Variablennamen.

        M 1 Reply Last reply Reply Quote 0
        • M
          MCU @aski71 last edited by

          @aski71 Zeig doch mal Deine Version als Bild.

          A 1 Reply Last reply Reply Quote 0
          • A
            aski71 @MCU last edited by

            @mcu Screenshot 2022-06-02 at 18.49.39.png

            M paul53 2 Replies Last reply Reply Quote 0
            • M
              MCU @aski71 last edited by

              @aski71 Und das Log dazu? Welcher Fehler oder gar nichts kommt?

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

                @aski71
                Dann logge mal die Liste.

                Bild_2022-06-02_185720972.png

                A 1 Reply Last reply Reply Quote 0
                • A
                  aski71 @MCU last edited by

                  @mcu said in JSON über Blockly zerlegen:

                  @aski71 Und das Log dazu? Welcher Fehler oder gar nichts kommt?

                  Der erste debug output kommt. danach nur noch "ermittelter wert = undefined".
                  Ich mache gleich mal einen log auf die Liste @paul53

                  M 1 Reply Last reply Reply Quote 0
                  • A
                    aski71 @paul53 last edited by

                    @paul53 said in JSON über Blockly zerlegen:

                    @aski71
                    Dann logge mal die Liste.

                    Bild_2022-06-02_185720972.png

                    Hm....

                    javascript.0 (1722) script.js.common.calTest: {}

                    1 Reply Last reply Reply Quote 0
                    • M
                      MCU @aski71 last edited by

                      @aski71 Wie schon eben gesagt, es ist kein JSON-DP. Kontrollier nochmal den DP.

                      A 1 Reply Last reply Reply Quote 0
                      • A
                        aski71 @MCU last edited by

                        @mcu said in JSON über Blockly zerlegen:

                        @aski71 Wie schon eben gesagt, es ist kein JSON-DP. Kontrollier nochmal den DP.

                        So ist es!
                        Es ist bereits eine Liste!

                        Ergo:

                        Screenshot 2022-06-02 at 19.11.05.png

                        Jetzt funktioniert es.

                        Vielen Dank für Eure Hilfe!

                        1 Reply Last reply Reply Quote 0
                        • sten-tor
                          sten-tor @aski71 last edited by sten-tor

                          @aski71 Hi Alex, JSONata ist ziemlich mächtig. Du kannst damit direkt ohne Schleife den gewünschten location-Wert extrahieren:

                          $[event='Charge'].location
                          

                          Falls mehrere Charge-Events vorkommen und du willst nur das erste haben:

                          $[event='Charge'][0].location
                          

                          Hier kannst du die JSONata Befehle testen:
                          https://try.jsonata.org/

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

                          Support us

                          ioBroker
                          Community Adapters
                          Donate

                          728
                          Online

                          31.9k
                          Users

                          80.1k
                          Topics

                          1.3m
                          Posts

                          blockly
                          4
                          17
                          769
                          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