Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. Blockly
    5. States aus DP auslesen

    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

    States aus DP auslesen

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

      Hallo,

      ist es möglich states aus einem DP auszulesen?
      Vermutlich benötigt es dafür eine Funktion?

      "states": "localhost:localhost;proxmox:proxmox;MariaDB:MariaDB;Docker:Docker;Adguard:Adguard;Jellyfin:Jellyfin;AgentDVR:AgentDVR;TrueNAS:TrueNAS;Wireguard:Wireguard;",
      

      Hier hätte ich gerne jeden Rechner ist einer Liste für ich verarbeiten kann.

      M 1 Reply Last reply Reply Quote 0
      • M
        MCU @David G. last edited by

        @david-g
        60fcdee5-9f3f-43e3-b7a3-b6b5de1fec37-image.png

        let obj = getObject(id)
        if(obj && obj.common && obj.common.states){
            return getObject(id).common.states
        }else{
            return 'States nicht vorhanden'
        }
        
        David G. 1 Reply Last reply Reply Quote 1
        • David G.
          David G. @MCU last edited by

          @mcu

          Danke, das klappt.
          Da kann ich jetzt ja eine Liste draus generieren und dann alles bis zum : nehmen.

          M 1 Reply Last reply Reply Quote 0
          • M
            MCU @David G. last edited by MCU

            @david-g

            18fddd72-f9ba-4917-b44e-36ac8f5b1fd0-image.png

            <xml xmlns="https://developers.google.com/blockly/xml">
             <variables>
               <variable id="JARviY49cV(`iqn9GHt9">id</variable>
               <variable id="u)zSo.N+(973pr$O]bnV">Arr</variable>
               <variable id="IWNI}6dn^T7LpBgUMAbn">Liste</variable>
               <variable id="vV:HepyF#+Fq2nC+7Fhe">i</variable>
             </variables>
             <block type="procedures_defcustomreturn" id="Y[`8(q2%P.Y7l$}%)I6m" x="188" y="88">
               <mutation statements="false">
                 <arg name="id" varid="JARviY49cV(`iqn9GHt9"></arg>
               </mutation>
               <field name="NAME">getStates</field>
               <field name="SCRIPT">bGV0IG9iaiA9IGdldE9iamVjdChpZCkNCmlmKG9iaiAmJiBvYmouY29tbW9uICYmIG9iai5jb21tb24uc3RhdGVzKXsNCiAgICByZXR1cm4gZ2V0T2JqZWN0KGlkKS5jb21tb24uc3RhdGVzDQp9ZWxzZXsNCiAgICByZXR1cm4gJ1N0YXRlcyBuaWNodCB2b3JoYW5kZW4nDQp9</field>
               <comment pinned="false" h="80" w="160">Beschreibe diese Funktion …</comment>
             </block>
             <block type="variables_set" id="V||ha4xrlmxv^sSvE4TV" x="224" y="197">
               <field name="VAR" id="u)zSo.N+(973pr$O]bnV">Arr</field>
               <value name="VALUE">
                 <block type="lists_create_with" id="ORj6DR-zvmO!Y@E)6_CZ">
                   <mutation items="0"></mutation>
                 </block>
               </value>
               <next>
                 <block type="variables_set" id="MjunNC/[O[++tA2?;*2U">
                   <field name="VAR" id="IWNI}6dn^T7LpBgUMAbn">Liste</field>
                   <value name="VALUE">
                     <block type="object_new" id="OvL,{,mH/kW+PwIyft}@"></block>
                   </value>
                   <next>
                     <block type="variables_set" id="f~$n_fBJ^x`;`3pV!bEU">
                       <field name="VAR" id="IWNI}6dn^T7LpBgUMAbn">Liste</field>
                       <value name="VALUE">
                         <block type="procedures_callcustomreturn" id="^%t`if[Um5BZH[Dbf,Fz">
                           <mutation name="getStates">
                             <arg name="id"></arg>
                           </mutation>
                           <value name="ARG0">
                             <block type="text" id="X|F.E:P%M5nI?bWWQ^Pg">
                               <field name="TEXT">0_userdata.0.jarvis.bdl.team</field>
                             </block>
                           </value>
                         </block>
                       </value>
                       <next>
                         <block type="controls_forEach" id="~L^`|eEY;I/zGzdm=#uz">
                           <field name="VAR" id="vV:HepyF#+Fq2nC+7Fhe">i</field>
                           <value name="LIST">
                             <block type="convert_json2object" id=",Qy0L-J+jtYBXD.!NDSs">
                               <value name="VALUE">
                                 <block type="variables_get" id="UH28g:iQv]p_JnODaNA(">
                                   <field name="VAR" id="IWNI}6dn^T7LpBgUMAbn">Liste</field>
                                 </block>
                               </value>
                             </block>
                           </value>
                           <statement name="DO">
                             <block type="lists_setIndex" id="cE-^?n3$@wAk28!FAO1o">
                               <mutation at="false"></mutation>
                               <field name="MODE">INSERT</field>
                               <field name="WHERE">LAST</field>
                               <value name="LIST">
                                 <block type="variables_get" id="|%r_kSR|9Lex5pMMTzoA">
                                   <field name="VAR" id="u)zSo.N+(973pr$O]bnV">Arr</field>
                                 </block>
                               </value>
                               <value name="TO">
                                 <block type="variables_get" id="cyRH.`Ag`e.G!?i[AvBN">
                                   <field name="VAR" id="vV:HepyF#+Fq2nC+7Fhe">i</field>
                                 </block>
                               </value>
                               <next>
                                 <block type="debug" id="Hac;:Jhgp693%:Mz`T+|">
                                   <field name="Severity">info</field>
                                   <value name="TEXT">
                                     <shadow type="text" id="oIAS25/qy$!JC@|7rPli">
                                       <field name="TEXT">test</field>
                                     </shadow>
                                     <block type="variables_get" id="3/#-Pq%w^oucFjF]I1lF">
                                       <field name="VAR" id="vV:HepyF#+Fq2nC+7Fhe">i</field>
                                     </block>
                                   </value>
                                 </block>
                               </next>
                             </block>
                           </statement>
                           <next>
                             <block type="debug" id="7;CENs~s+XpOy}h:y@X1">
                               <field name="Severity">info</field>
                               <value name="TEXT">
                                 <shadow type="text" id="L/+X$!IM/T~S#UV3VV3E">
                                   <field name="TEXT">test</field>
                                 </shadow>
                                 <block type="variables_get" id="A!VQ7+@-|#b|fl9%Dvl8">
                                   <field name="VAR" id="u)zSo.N+(973pr$O]bnV">Arr</field>
                                 </block>
                               </value>
                             </block>
                           </next>
                         </block>
                       </next>
                     </block>
                   </next>
                 </block>
               </next>
             </block>
            </xml>
            

            Arr hat dann alle Elemente im Array

            David G. 1 Reply Last reply Reply Quote 0
            • David G.
              David G. @MCU last edited by

              @mcu

              Das möchte bei mir nicht
              Screenshot_20250125_222615_Chrome.jpg

              Hab es aber parallel so gelöst (brauche alle states untereinander als Text)
              Screenshot_20250125_222723_Chrome.jpg
              (Die Prüfung ob größer 1 hab ich gemacht weil immer noch ein leerer State am Ende der Liste war.)

              mickym 1 Reply Last reply Reply Quote 0
              • mickym
                mickym Most Active @David G. last edited by mickym

                @david-g Ist das die Quelle - und Du möchtest die Werte als Liste?

                {"states": "localhost:localhost;proxmox:proxmox;MariaDB:MariaDB;Docker:Docker;Adguard:Adguard;Jellyfin:Jellyfin;AgentDVR:AgentDVR;TrueNAS:TrueNAS;Wireguard:Wireguard;"}
                
                David G. 1 Reply Last reply Reply Quote 0
                • David G.
                  David G. @mickym last edited by

                  @mickym

                  Ja, aus einem DP
                  Screenshot_20250125_232329_Chrome.jpg

                  Aber klappt jetzt ja so weit.

                  mickym 1 Reply Last reply Reply Quote 0
                  • mickym
                    mickym Most Active @David G. last edited by mickym

                    @david-g Ja dann hier nur nochmal eine einfach JSONATA Lösung mit regulärem Ausdruck mit dem common Objekt.

                    6a5b6615-9c16-4cb5-8db2-35c0eba08bb5-image.png

                    Ansonsten halt weglassen.

                    $match(common.states,/\w+/).match~>$distinct()
                    

                    also nur

                    $match(states,/\w+/).match~>$distinct()
                    

                    <xml xmlns="https://developers.google.com/blockly/xml">
                     <variables>
                       <variable id="f{SPWMDeJ!t?Tt{oHa-w">Liste</variable>
                     </variables>
                     <block type="variables_set" id="jKN8F;HD7[UKq45_:Vw{" x="-287" y="-237">
                       <field name="VAR" id="f{SPWMDeJ!t?Tt{oHa-w">Liste</field>
                       <value name="VALUE">
                         <block type="convert_json2object" id="gY[U%GBa-TB2;qcL^=87">
                           <value name="VALUE">
                             <block type="text" id="HdUSNbWPE)HiUPN4!yw[">
                               <field name="TEXT">{   "common": {     "states": "localhost:localhost;proxmox:proxmox;MariaDB:MariaDB;Docker:Docker;Adguard:Adguard;Jellyfin:Jellyfin;AgentDVR:AgentDVR;TrueNAS:TrueNAS;Wireguard:Wireguard;"   } }</field>
                             </block>
                           </value>
                         </block>
                       </value>
                       <next>
                         <block type="debug" id="CN/v16=5#s1D|=8)yk[}">
                           <field name="Severity">info</field>
                           <value name="TEXT">
                             <shadow type="text" id="-n5X=}DS{1k*jws-P:%,">
                               <field name="TEXT">test</field>
                             </shadow>
                             <block type="variables_get" id="^o;H~=_0K^WR1PF,+5R:">
                               <field name="VAR" id="f{SPWMDeJ!t?Tt{oHa-w">Liste</field>
                             </block>
                           </value>
                           <next>
                             <block type="variables_set" id=";CqShE#z4I$MLA3-2e;m">
                               <field name="VAR" id="f{SPWMDeJ!t?Tt{oHa-w">Liste</field>
                               <value name="VALUE">
                                 <block type="convert_jsonata" id=":%m?7,V!o=^RxLW@VkF9">
                                   <value name="EXPRESSION">
                                     <shadow type="text" id="U0x!nDlO!=6Wl|+I`4P~">
                                       <field name="TEXT">$match(common.states,/\w+/).match~&gt;$distinct()</field>
                                     </shadow>
                                   </value>
                                   <value name="TARGET">
                                     <block type="variables_get" id="t-{z1,$a7wl~_lusrXW4">
                                       <field name="VAR" id="f{SPWMDeJ!t?Tt{oHa-w">Liste</field>
                                     </block>
                                   </value>
                                 </block>
                               </value>
                               <next>
                                 <block type="debug" id="-F}Nw`irgr)0w_],AYKV">
                                   <field name="Severity">info</field>
                                   <value name="TEXT">
                                     <shadow type="text" id="*fR:|[obP+4|R)-AOCP^">
                                       <field name="TEXT">test</field>
                                     </shadow>
                                     <block type="lists_getSublist" id="}/zTsh*p-V6mK,z!qD$l">
                                       <mutation at1="false" at2="false"></mutation>
                                       <field name="WHERE1">FIRST</field>
                                       <field name="WHERE2">LAST</field>
                                       <value name="LIST">
                                         <block type="variables_get" id="jdxs=WV==C.]F`0XK5VK">
                                           <field name="VAR" id="f{SPWMDeJ!t?Tt{oHa-w">Liste</field>
                                         </block>
                                       </value>
                                     </block>
                                   </value>
                                 </block>
                               </next>
                             </block>
                           </next>
                         </block>
                       </next>
                     </block>
                    </xml>
                    

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

                    Support us

                    ioBroker
                    Community Adapters
                    Donate

                    497
                    Online

                    31.8k
                    Users

                    80.0k
                    Topics

                    1.3m
                    Posts

                    3
                    8
                    240
                    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