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 ] JSON aufteilen in DP

    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

    [ gelöst ] JSON aufteilen in DP

    This topic has been deleted. Only users with topic management privileges can see it.
    • Homoran
      Homoran Global Moderator Administrators @ioBrokerMike last edited by

      @iobrokermike starte mal die Instsnz neu und mach rinen Browserrefresh (Strg-f5)

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

        @homoran sagte in JSON aufteilen in DP:

        war das große log nach mqtt gefiltert?

        Ja, das war nach mqtt gefiltert

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

          @iobrokermike sagte in JSON aufteilen in DP:

          @homoran sagte in JSON aufteilen in DP:

          war das große log nach mqtt gefiltert?

          Ja, das war nach matt gefiltert

          dann kann man da natürlich auch keine Meldungen von javascript sehen!

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

            @paul53 sagte in JSON aufteilen in DP:

            @mickym sagte: früher ging das glaub nicht.

            Das ging mit getAttr() schon immer. Siehe Doku. Die Funktion wurde speziell für Blockly geschaffen.

            Irgendwie ist das aber anscheinend doch kein Objekt - zumindest, wenn ich es in JSONATA weiter verwenden will. Gibt es da eine Erklärung?

            51cae8de-09dd-4ffa-9335-2766aa379d39-image.png

            Im 1. Fall ohne Konvertierung - kann ich über JSONATA nicht auf die Objekteigenschaft zugreifen. Im 2. Fall gehts.

            <xml xmlns="https://developers.google.com/blockly/xml">
             <variables>
               <variable id="NWR;`_N@3a:sTiBKQkne">Objekt</variable>
             </variables>
             <block type="variables_set" id="M@F*zUMa;{#yJo2.2goG" x="-1137" y="-337">
               <field name="VAR" id="NWR;`_N@3a:sTiBKQkne">Objekt</field>
               <value name="VALUE">
                 <block type="text" id="fWZa-MC8^[YM-V-;#R}:">
                   <field name="TEXT">{"meterId":"1KFM00000754396","deviceId":"EBSD14250567526","msgType":"EMETER_OBIS_V2","measurements":[{"timestamp":"2022-12-03T13:25:53Z","values":{"1-0:96.90.21":"7E2005D2","1-0:0.2.00":"312E3033","1-0:14.7.0255":50,"1-0:81.7.26255":359,"1-0:81.7.15255":330,"1-0:81.7.4255":337,"1-0:81.7.2255":238,"1-0:81.7.1255":118,"1-0:71.7.0255":10.119999885559082,"1-0:51.7.0255":1.7100000381469727,"1-0:31.7.0255":0.89999997615814209,"1-0:72.7.0255":235.89999389648438,"1-0:52.7.0255":234.69999694824219,"1-0:32.7.0255":237,"1-0:16.7.0255":2818,"1-0:2.8.0255":0,"1-0:1.8.0255":9071.03125,"1-0:96.1.0255":"0A014B464D0000006E24","1-0:96.50.1*1":"4B464D"}}]}</field>
                 </block>
               </value>
               <next>
                 <block type="debug" id="^5#in-UU}%!K~KPOKHz_">
                   <field name="Severity">info</field>
                   <value name="TEXT">
                     <shadow type="text" id="-,TGC$b5|aHgxT-/9J]`">
                       <field name="TEXT">test</field>
                     </shadow>
                     <block type="variables_get" id="nRXii?=4yGGy,y7%2jY(">
                       <field name="VAR" id="NWR;`_N@3a:sTiBKQkne">Objekt</field>
                     </block>
                   </value>
                   <next>
                     <block type="debug" id="C*BY:f~|[e)Xvn8W1*s{">
                       <field name="Severity">info</field>
                       <value name="TEXT">
                         <shadow type="text" id="michMudNxqrBOIIp?ntJ">
                           <field name="TEXT">test</field>
                         </shadow>
                         <block type="convert_jsonata" id="AS%.5T)U4NQRb~6pE|^y">
                           <value name="EXPRESSION">
                             <shadow type="text" id="]-J?Hivq,p/e0?KwDjKv">
                               <field name="TEXT">$.measurements[0].values.'1-0:96.50.1*1'</field>
                             </shadow>
                           </value>
                           <value name="TARGET">
                             <block type="variables_get" id="$:M+P`jmlylnj6q[{yF,">
                               <field name="VAR" id="NWR;`_N@3a:sTiBKQkne">Objekt</field>
                             </block>
                           </value>
                         </block>
                       </value>
                       <next>
                         <block type="variables_set" id="QRu@$s3*df8mR7r@=iO#">
                           <field name="VAR" id="NWR;`_N@3a:sTiBKQkne">Objekt</field>
                           <value name="VALUE">
                             <block type="convert_json2object" id="R.c9ffe%vYu70tFC4Wg0">
                               <value name="VALUE">
                                 <block type="variables_get" id="Z^;~j8`)]MoA[fRfSluS">
                                   <field name="VAR" id="NWR;`_N@3a:sTiBKQkne">Objekt</field>
                                 </block>
                               </value>
                             </block>
                           </value>
                           <next>
                             <block type="debug" id="yQlY]j3k2iPYr$s%:Z=c">
                               <field name="Severity">info</field>
                               <value name="TEXT">
                                 <shadow type="text" id="michMudNxqrBOIIp?ntJ">
                                   <field name="TEXT">test</field>
                                 </shadow>
                                 <block type="convert_jsonata" id="*P_(9@j7YL};L(Uz5~ZN">
                                   <value name="EXPRESSION">
                                     <shadow type="text" id="7abV56Ncd4Eb9CA7Gy|N">
                                       <field name="TEXT">$.measurements[0].values.'1-0:96.50.1*1'</field>
                                     </shadow>
                                   </value>
                                   <value name="TARGET">
                                     <block type="variables_get" id="^3+giB~)?btQR6/;R1~a">
                                       <field name="VAR" id="NWR;`_N@3a:sTiBKQkne">Objekt</field>
                                     </block>
                                   </value>
                                 </block>
                               </value>
                             </block>
                           </next>
                         </block>
                       </next>
                     </block>
                   </next>
                 </block>
               </next>
             </block>
            </xml>
            

            Oder heißt das, dass zum Extrahieren wird es temporär in ein Objekt gewandelt, wenn ich es aber weiterverwenden will, dann muss ich es konveritieren.

            Ja ich hab es mir selbst beantwortet. Vergiss diesen Post.

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

              @homoran

              So jetzt die Filterung von Javascript:

                 2024-11-29 20:59:14.006	warn	(COMPACT) at Job.job (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1876:34)
              
              javascript.0
              2024-11-29 20:59:14.006	warn	(COMPACT) at Object.<anonymous> (script.js.00_Anwesend.AnzahlAnwesend:17:3)
              
              javascript.0
              2024-11-29 20:59:14.005	warn	(COMPACT) at setState (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:2090:20)
              
              javascript.0
              2024-11-29 20:59:14.003	warn	(COMPACT) You are assigning a number to the state "0_userdata.0.Anwesend.Anzahl" 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.
              
              javascript.0
              2024-11-29 20:59:12.010	info	(COMPACT) State value to set for "0_userdata.0.Anwesend.Anzahl" has to be type "string" but received type "number"
              
              javascript.0
              2024-11-29 20:59:12.005	warn	(COMPACT) at processTimers (node:internal/timers:519:7)
              
              javascript.0
              2024-11-29 20:59:12.005	warn	(COMPACT) at listOnTimeout (node:internal/timers:581:17)
              
              javascript.0
              2024-11-29 20:59:12.004	warn	(COMPACT) at Timeout._onTimeout (/opt/iobroker/node_modules/node-schedule/lib/Invocation.js:228:7)
              
              javascript.0
              2024-11-29 20:59:12.004	warn	(COMPACT) at /opt/iobroker/node_modules/node-schedule/lib/Invocation.js:268:28
              
              javascript.0
              2024-11-29 20:59:12.004	warn	(COMPACT) at Job.invoke (/opt/iobroker/node_modules/node-schedule/lib/Job.js:171:15)
              
              javascript.0
              2024-11-29 20:59:12.004	warn	(COMPACT) at Job.job (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1876:34)
              
              javascript.0
              2024-11-29 20:59:12.003	warn	(COMPACT) at Object.<anonymous> (script.js.00_Anwesend.AnzahlAnwesend:17:3)
              
              javascript.0
              2024-11-29 20:59:12.003	warn	(COMPACT) at setState (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:2090:20)
              
              javascript.0
              2024-11-29 20:59:12.002	warn	(COMPACT) You are assigning a number to the state "0_userdata.0.Anwesend.Anzahl" 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.
              
              javascript.0
              2024-11-29 20:59:10.011	info	(COMPACT) State value to set for "0_userdata.0.Anwesend.Anzahl" has to be type "string" but received type "number"
              
              javascript.0
              2024-11-29 20:59:10.005	warn	(COMPACT) at processTimers (node:internal/timers:519:7)
              
              

              starte mal die Instsnz neu und mach rinen Browserrefresh (Strg-f5)

              Javascript und mqtt neugestartet sowie F5

              mickym Homoran 2 Replies Last reply Reply Quote 0
              • Homoran
                Homoran Global Moderator Administrators @mickym last edited by

                @mickym Ist sehr interessant (vielleicht werd ich deswegen mit jsonata nicht warm), aber könnten wir das bitte aus diesem Thread erst mal herauslassen.

                ich fürchte wir verlieren @ioBrokerMike sonst.

                mickym 1 Reply Last reply Reply Quote 0
                • mickym
                  mickym Most Active @ioBrokerMike last edited by

                  @iobrokermike Ja entweder konvertierst Du die Anzahl in eine Zahl oder den Datenpunkt in String/Zeichenkette.

                  I 1 Reply Last reply Reply Quote 0
                  • mickym
                    mickym Most Active @Homoran last edited by

                    @homoran Ja ist OK - ich habs selbst gecheckt - Du kannst den Post auch löschen.

                    1 Reply Last reply Reply Quote 1
                    • I
                      ioBrokerMike @mickym last edited by

                      @mickym sagte in JSON aufteilen in DP:

                      die Anzahl in eine Zahl oder den Datenpunkt in String/Zeichenkette.

                      Schon gemacht

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

                        @iobrokermike sagte in JSON aufteilen in DP:

                        So jetzt die Filterung von Javascript:

                        und in dem Zeitbereich (4 Sekunden!) hast du das Testskript refreshed?

                        @iobrokermike sagte in JSON aufteilen in DP:

                                                2024-11-29 20:59:12.004	warn	(COMPACT)
                        

                        läuft der Adapter bei dir im compact mode?
                        warum?

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

                          @homoran sagte in JSON aufteilen in DP:

                          nd in dem Zeitbereich (4 Sekunden!) hast du das Testskript refres

                          Nein das hatte ich nicht getan.

                          läuft der Adapter bei dir im compact mode?
                          warum?

                          Das kann ich nicht sagen.
                          Habe den harken im Host raus gemacht.

                          Was mir eben auffiel ist :
                          Wenn ich den Javascript Adapter auf debug stelle läuft das Testscript warum auch immer.
                          Blockly 7.png

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

                            @iobrokermike sagte in JSON aufteilen in DP:

                            läuft das Testscript warum auch immer.

                            dann jetzt zum echten Skript!

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

                              @homoran sagte in JSON aufteilen in DP:

                              t zum echten Skript!

                              Blockly 8.png

                              Vielen Dank an euch und eure Geduld . 👍

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

                                @iobrokermike sagte in [ gelöst ] JSON aufteilen in DP:

                                Vielen Dank an euch und eure Geduld .

                                heisst das, dass es jetzt läuft?

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

                                  @homoran

                                  Richtig !!!
                                  Es läuft.

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

                                    @iobrokermike sagte in [ gelöst ] JSON aufteilen in DP:

                                    @homoran

                                    Richtig !!!
                                    Es läuft.

                                    Super!
                                    so muss es sein!

                                    dann kann @mickym jetzt mit @paul53 weiter über die Wandlung des json zum Objekt philosophieren

                                    mickym 1 Reply Last reply Reply Quote 0
                                    • mickym
                                      mickym Most Active @Homoran last edited by

                                      @homoran Nicht mehr nötig - ich konnte es mir ja selbst erklären.

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

                                        @mickym sagte in [ gelöst ] JSON aufteilen in DP:

                                        @homoran Nicht mehr nötig - ich konnte es mir ja selbst erklären.

                                        ok, du hast wieder heimlich editiert 😉
                                        ist aber nur eine Arbeitshypothese, oder?

                                        mickym 1 Reply Last reply Reply Quote 0
                                        • mickym
                                          mickym Most Active @Homoran last edited by

                                          @homoran Nein ich habe nichts editiert. Ich habe nur folgendes verstanden:

                                          1. Wenn Du über einen JSON String ein Attribut extrahierst, wird temporär in ein Objekt gewandelt, um das Attribut zu extrahieren. Es bleibt aber ein JSON, also Text und wird nicht in ein Objekt gewandelt.
                                          2. Um also den JSON als Objekt weiter zu verarbeiten musst du den JSON permanent in ein Objekt wandeln.

                                          Das ganze hat also nichts mit JSONATA zu tun.

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

                                          Support us

                                          ioBroker
                                          Community Adapters
                                          Donate

                                          754
                                          Online

                                          31.7k
                                          Users

                                          79.9k
                                          Topics

                                          1.3m
                                          Posts

                                          5
                                          48
                                          2001
                                          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