Navigation

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

    NEWS

    • Wir empfehlen: Node.js 22.x

    • Neuer Blog: Fotos und Eindrücke aus Solingen

    • ioBroker goes Matter ... Matter Adapter in Stable

    Datenquelle ermitteln

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

      @paul53 dann muss die manuelle gefüllte Liste idsRoom nur die gleiche Reihenfolge haben wie die Sensoren

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

        @homoran sagte: dann muss die manuelle gefüllte Liste Rooms nur die gleiche Reihenfolge haben wie die Sensoren

        Das meinte ich mit "korrespondierend".

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

          @linedancer sagte in Datenquelle ermitteln:

          Ich würde auch Node Red nehmen 😉 wenn’s mit Blockly nicht machbar ist

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

            @paul53 sagte in Datenquelle ermitteln:

            Ist es mit zwei korrespondierenden Listen und einer Schleife.

            Ich denke ich hab das Blockly verstanden, auch wenn ich bis jetzt nix mit Schleifen gemacht hab.
            Das Bau ich morgen nach melde mich. Heut wird das nix mehr.

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

              Ok hier nun meine NodeRed Lösung.

              Ich habe mal folgende Testdatenpunkte angelegt, damit das in etwa Deiner Struktur gleich kommt.

              3d7ed08a-af99-436b-a58c-7527601005d1-image.png

              Ich habe also die Enums genommen, die im System verankert sind. 😉
              Du siehst einmal ist der Raum Wohnzimmer, dann Bad.

              a10c5e01-8819-409f-8429-8f4fb251eb34-image.png

              [
                 {
                     "id": "2df53e5d19a0cb01",
                     "type": "ioBroker list",
                     "z": "7e6af0015415146d",
                     "name": "",
                     "topic": "",
                     "objType": "",
                     "regex": "",
                     "asArray": "false",
                     "onlyIDs": "false",
                     "withValues": "false",
                     "x": 810,
                     "y": 3180,
                     "wires": [
                         [
                             "f8e6aad5dbd578ac"
                         ]
                     ]
                 },
                 {
                     "id": "87bcd684e308ef6e",
                     "type": "debug",
                     "z": "7e6af0015415146d",
                     "name": "Raum",
                     "active": true,
                     "tosidebar": true,
                     "console": false,
                     "tostatus": false,
                     "complete": "payload",
                     "targetType": "msg",
                     "statusVal": "",
                     "statusType": "auto",
                     "x": 1170,
                     "y": 3180,
                     "wires": []
                 },
                 {
                     "id": "f8e6aad5dbd578ac",
                     "type": "change",
                     "z": "7e6af0015415146d",
                     "name": "",
                     "rules": [
                         {
                             "t": "set",
                             "p": "payload",
                             "pt": "msg",
                             "to": "$each(payload.enums,function($v, $k) {$contains($k,\"rooms\") ? $v})",
                             "tot": "jsonata"
                         }
                     ],
                     "action": "",
                     "property": "",
                     "from": "",
                     "to": "",
                     "reg": false,
                     "x": 990,
                     "y": 3180,
                     "wires": [
                         [
                             "87bcd684e308ef6e"
                         ]
                     ]
                 },
                 {
                     "id": "ca329680d55789a4",
                     "type": "ioBroker in",
                     "z": "7e6af0015415146d",
                     "name": "",
                     "topic": "0_userdata.0.Test.Temperaturen.*.Temperatur",
                     "payloadType": "value",
                     "onlyack": "",
                     "func": "all",
                     "gap": "",
                     "fireOnStart": "false",
                     "outFormat": "MQTT",
                     "x": 210,
                     "y": 3180,
                     "wires": [
                         [
                             "d81ce08693b81463"
                         ]
                     ]
                 },
                 {
                     "id": "d81ce08693b81463",
                     "type": "switch",
                     "z": "7e6af0015415146d",
                     "name": "",
                     "property": "max",
                     "propertyType": "flow",
                     "rules": [
                         {
                             "t": "lt",
                             "v": "payload",
                             "vt": "msg"
                         },
                         {
                             "t": "null"
                         }
                     ],
                     "checkall": "true",
                     "repair": false,
                     "outputs": 2,
                     "x": 470,
                     "y": 3180,
                     "wires": [
                         [
                             "6db8ef90a96693aa"
                         ],
                         [
                             "6db8ef90a96693aa"
                         ]
                     ]
                 },
                 {
                     "id": "6db8ef90a96693aa",
                     "type": "change",
                     "z": "7e6af0015415146d",
                     "name": "",
                     "rules": [
                         {
                             "t": "set",
                             "p": "max",
                             "pt": "flow",
                             "to": "payload",
                             "tot": "msg"
                         }
                     ],
                     "action": "",
                     "property": "",
                     "from": "",
                     "to": "",
                     "reg": false,
                     "x": 640,
                     "y": 3180,
                     "wires": [
                         [
                             "2df53e5d19a0cb01"
                         ]
                     ]
                 },
                 {
                     "id": "1869413e4e017020",
                     "type": "inject",
                     "z": "7e6af0015415146d",
                     "name": "reset",
                     "props": [
                         {
                             "p": "reset",
                             "v": "true",
                             "vt": "bool"
                         }
                     ],
                     "repeat": "",
                     "crontab": "",
                     "once": false,
                     "onceDelay": 0.1,
                     "topic": "",
                     "x": 470,
                     "y": 3240,
                     "wires": [
                         [
                             "e98b2e244eb334ee"
                         ]
                     ]
                 },
                 {
                     "id": "e98b2e244eb334ee",
                     "type": "change",
                     "z": "7e6af0015415146d",
                     "name": "",
                     "rules": [
                         {
                             "t": "delete",
                             "p": "max",
                             "pt": "flow"
                         }
                     ],
                     "action": "",
                     "property": "",
                     "from": "",
                     "to": "",
                     "reg": false,
                     "x": 650,
                     "y": 3240,
                     "wires": [
                         []
                     ]
                 }
              ]
              

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

                Ok und hier nun meine Blockly Lösung - mit JS - ermittelt den Raum aus der Objekt ID

                4d5284df-f802-4b18-b660-a1e9ec5b02f6-image.png

                <xml xmlns="https://developers.google.com/blockly/xml">
                 <variables>
                   <variable id="ALTyF=LZs}rPzBcD(1^(">ID</variable>
                   <variable id="b1|*w2/IBSZtltFBq[mt">Max</variable>
                 </variables>
                 <block type="procedures_defcustomreturn" id="9M;cS2116}Q=Cw,Bj614" x="87" y="-363">
                   <mutation statements="false">
                     <arg name="ID" varid="ALTyF=LZs}rPzBcD(1^("></arg>
                   </mutation>
                   <field name="NAME">getRoom</field>
                   <field name="SCRIPT">dmFyIG9iaiA9IHt9Ow0Kb2JqLnNlYXJjaCA9IElEOw0Kb2JqLnJvb21zID0gZ2V0RW51bXMoJ3Jvb21zJyk7DQpyZXR1cm4gYXdhaXQganNvbmF0YUV4cHJlc3Npb24ob2JqLCIkLnJvb21zWyQkLnNlYXJjaCBpbiBtZW1iZXJzXS5uYW1lIik7</field>
                   <comment pinned="false" h="80" w="160">Beschreibe diese Funktion …</comment>
                 </block>
                 <block type="variables_set" id="hT|PTjDQZc|bKu:?[[zb" x="87" y="-287">
                   <field name="VAR" id="b1|*w2/IBSZtltFBq[mt">Max</field>
                   <value name="VALUE">
                     <block type="math_number" id="F05G|j80GCJgv+,@tW_@">
                       <field name="NUM">-30</field>
                     </block>
                   </value>
                   <next>
                     <block type="on_ext" id="4}3oeeat{mVDhPWIv#$@">
                       <mutation xmlns="http://www.w3.org/1999/xhtml" items="2"></mutation>
                       <field name="CONDITION">any</field>
                       <field name="ACK_CONDITION"></field>
                       <value name="OID0">
                         <shadow type="field_oid" id="O_Hiq6qP6{;ZCo,39k`U">
                           <field name="oid">0_userdata.0.Test.Temperaturen.Bad.Temperatur</field>
                         </shadow>
                       </value>
                       <value name="OID1">
                         <shadow type="field_oid" id="0@$.bMAo[1#1/2mYKs8T">
                           <field name="oid">0_userdata.0.Test.Temperaturen.Wohnzimmer.Temperatur</field>
                         </shadow>
                       </value>
                       <statement name="STATEMENT">
                         <block type="controls_if" id="`yyEGE6E{M?~Pe}kF4YB">
                           <value name="IF0">
                             <block type="logic_compare" id="El:P_-DP4vlJJY={Fd/(">
                               <field name="OP">GT</field>
                               <value name="A">
                                 <block type="on_source" id="FM-hrz1fFe+I2YfRZWY:">
                                   <field name="ATTR">state.val</field>
                                 </block>
                               </value>
                               <value name="B">
                                 <block type="variables_get" id="zb(D$R30?UAw~A{O76r9">
                                   <field name="VAR" id="b1|*w2/IBSZtltFBq[mt">Max</field>
                                 </block>
                               </value>
                             </block>
                           </value>
                           <statement name="DO0">
                             <block type="variables_set" id="ipx(~jBY#t{IEa/1Mr@Z">
                               <field name="VAR" id="b1|*w2/IBSZtltFBq[mt">Max</field>
                               <value name="VALUE">
                                 <block type="on_source" id="%G0r$1HCsZ3#[r!yrL4a">
                                   <field name="ATTR">state.val</field>
                                 </block>
                               </value>
                               <next>
                                 <block type="debug" id="Wg8Ay#ioly{/fkOTH:_R">
                                   <field name="Severity">log</field>
                                   <value name="TEXT">
                                     <shadow type="text" id="!VL#h,d@zxcAl#6!0ut+">
                                       <field name="TEXT">test</field>
                                     </shadow>
                                     <block type="procedures_callcustomreturn" id="YmgZHu$By;yP{|d}$XSE">
                                       <mutation name="getRoom">
                                         <arg name="ID"></arg>
                                       </mutation>
                                       <value name="ARG0">
                                         <block type="on_source" id="UzY1~8w~z7.Xs#x9v;l1">
                                           <field name="ATTR">id</field>
                                         </block>
                                       </value>
                                     </block>
                                   </value>
                                 </block>
                               </next>
                             </block>
                           </statement>
                         </block>
                       </statement>
                     </block>
                   </next>
                 </block>
                </xml>
                

                Der Reset wird momentan durch Neustart des Skripts gemacht. Aber das sollte ja kein Problem sein, das Maximum entsprechend zu setzen. Wenn ein Datenpunkt 2 Räumen zugeordnet ist, dann kommt ein Array mit beiden Räumen raus. 😉

                d2dd7028-bf4c-416b-bcde-dc8302dead73-image.png

                a8b40e48-3cc6-4e97-a80a-65391866afe8-image.png

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

                  In beiden Lösungen habe ich auf Arrays und Listen verzichtet, da es ja nur darum geht, ob es ein neues Maximum gibt und das wird einmal in der Variablen gespeichert. ggf. könnte man das Maximum auch in einem Datenpunkt festhalten. Die Werte, die kein Maximum darstellen sind mE unwichtig.

                  Das zyklische Auslesen aller Werte und speichern in Arrays kann man machen Ich bin davon kein Anhänger.

                  3be41ad4-55e2-41db-90cc-2cfec5981786-image.png

                  <xml xmlns="https://developers.google.com/blockly/xml">
                   <variables>
                     <variable id="ALTyF=LZs}rPzBcD(1^(">ID</variable>
                     <variable id="b1|*w2/IBSZtltFBq[mt">Max</variable>
                     <variable id="c|3E03D|}2G4$KV$KDcI">idsTemp</variable>
                   </variables>
                   <block type="procedures_defcustomreturn" id="9M;cS2116}Q=Cw,Bj614" x="-12" y="-362">
                     <mutation statements="false">
                       <arg name="ID" varid="ALTyF=LZs}rPzBcD(1^("></arg>
                     </mutation>
                     <field name="NAME">getRoom</field>
                     <field name="SCRIPT">dmFyIG9iaiA9IHt9Ow0Kb2JqLnNlYXJjaCA9IElEOw0Kb2JqLnJvb21zID0gZ2V0RW51bXMoJ3Jvb21zJyk7DQpyZXR1cm4gYXdhaXQganNvbmF0YUV4cHJlc3Npb24ob2JqLCIkLnJvb21zWyQkLnNlYXJjaCBpbiBtZW1iZXJzXS5uYW1lIik7</field>
                     <comment pinned="false" h="80" w="160">Beschreibe diese Funktion …</comment>
                   </block>
                   <block type="variables_set" id="lsecKayOZ4=Vf/5EgJCm" x="-13" y="-288">
                     <field name="VAR" id="b1|*w2/IBSZtltFBq[mt">Max</field>
                     <value name="VALUE">
                       <block type="math_number" id="e{A/ctXs0!;RsQl_8CBU">
                         <field name="NUM">-30</field>
                       </block>
                     </value>
                     <next>
                       <block type="variables_set" id="e|oEG20j1v?9MN[Ekgls">
                         <field name="VAR" id="c|3E03D|}2G4$KV$KDcI">idsTemp</field>
                         <value name="VALUE">
                           <block type="lists_create_with" id="s/k[)5H$IS*+,-X`C.vj">
                             <mutation items="2"></mutation>
                             <value name="ADD0">
                               <block type="field_oid" id="59TZ(Xip0eevyJ+Nz#W[">
                                 <field name="oid">0_userdata.0.Test.Temperaturen.Bad.Temperatur</field>
                               </block>
                             </value>
                             <value name="ADD1">
                               <block type="field_oid" id="QE7RX_:Zn@LO7PuoNdD*">
                                 <field name="oid">0_userdata.0.Test.Temperaturen.Wohnzimmer.Temperatur</field>
                               </block>
                             </value>
                           </block>
                         </value>
                         <next>
                           <block type="on_ext" id="a;ViTG!bb-pX.jTorvJ8">
                             <mutation xmlns="http://www.w3.org/1999/xhtml" items="1"></mutation>
                             <field name="CONDITION">ne</field>
                             <field name="ACK_CONDITION"></field>
                             <value name="OID0">
                               <shadow type="field_oid" id="i%1xDs6.nZ9wnp2aj.MM">
                                 <field name="oid">default</field>
                               </shadow>
                               <block type="variables_get" id="E@Gr[#Bwaf=tinJNsv+T">
                                 <field name="VAR" id="c|3E03D|}2G4$KV$KDcI">idsTemp</field>
                               </block>
                             </value>
                             <statement name="STATEMENT">
                               <block type="controls_forEach" id="8_xK-^laWl]^P}j::7mO">
                                 <field name="VAR" id="ALTyF=LZs}rPzBcD(1^(">ID</field>
                                 <value name="LIST">
                                   <block type="variables_get" id="c/y];d@:x;IgX3T?fOR3">
                                     <field name="VAR" id="c|3E03D|}2G4$KV$KDcI">idsTemp</field>
                                   </block>
                                 </value>
                                 <statement name="DO">
                                   <block type="controls_if" id="`yyEGE6E{M?~Pe}kF4YB">
                                     <value name="IF0">
                                       <block type="logic_compare" id="El:P_-DP4vlJJY={Fd/(">
                                         <field name="OP">GT</field>
                                         <value name="A">
                                           <block type="get_value_var" id="@@uymSTw|kZqu.WZ:fs.">
                                             <field name="ATTR">val</field>
                                             <value name="OID">
                                               <shadow type="text" id="`Gc7SE*~nsYba%DD$D`D">
                                                 <field name="TEXT"></field>
                                               </shadow>
                                               <block type="variables_get" id="-!Y0v9V:jSN{KYT#),!m">
                                                 <field name="VAR" id="ALTyF=LZs}rPzBcD(1^(">ID</field>
                                               </block>
                                             </value>
                                           </block>
                                         </value>
                                         <value name="B">
                                           <block type="variables_get" id="zb(D$R30?UAw~A{O76r9">
                                             <field name="VAR" id="b1|*w2/IBSZtltFBq[mt">Max</field>
                                           </block>
                                         </value>
                                       </block>
                                     </value>
                                     <statement name="DO0">
                                       <block type="variables_set" id="ipx(~jBY#t{IEa/1Mr@Z">
                                         <field name="VAR" id="b1|*w2/IBSZtltFBq[mt">Max</field>
                                         <value name="VALUE">
                                           <block type="get_value_var" id="Va7]-8]?5(d/GAUyT{!,">
                                             <field name="ATTR">val</field>
                                             <value name="OID">
                                               <shadow type="text">
                                                 <field name="TEXT"></field>
                                               </shadow>
                                               <block type="variables_get" id="j!GI7IU|Ri0M`gV`*tpg">
                                                 <field name="VAR" id="ALTyF=LZs}rPzBcD(1^(">ID</field>
                                               </block>
                                             </value>
                                           </block>
                                         </value>
                                         <next>
                                           <block type="debug" id="M%1)Q#tj4Zn(,C`Na^Y_">
                                             <field name="Severity">log</field>
                                             <value name="TEXT">
                                               <shadow type="text" id=":@[;Kk#l)s]su?JioeuF">
                                                 <field name="TEXT">test</field>
                                               </shadow>
                                               <block type="variables_get" id="/vI;M`yL[0/o4jJa1153">
                                                 <field name="VAR" id="b1|*w2/IBSZtltFBq[mt">Max</field>
                                               </block>
                                             </value>
                                             <next>
                                               <block type="debug" id="Wg8Ay#ioly{/fkOTH:_R">
                                                 <field name="Severity">log</field>
                                                 <value name="TEXT">
                                                   <shadow type="text" id="!VL#h,d@zxcAl#6!0ut+">
                                                     <field name="TEXT">test</field>
                                                   </shadow>
                                                   <block type="procedures_callcustomreturn" id="YmgZHu$By;yP{|d}$XSE">
                                                     <mutation name="getRoom">
                                                       <arg name="ID"></arg>
                                                     </mutation>
                                                     <value name="ARG0">
                                                       <block type="variables_get" id="U)I)Dcvbv7mJ%eMupUi=">
                                                         <field name="VAR" id="ALTyF=LZs}rPzBcD(1^(">ID</field>
                                                       </block>
                                                     </value>
                                                   </block>
                                                 </value>
                                               </block>
                                             </next>
                                           </block>
                                         </next>
                                       </block>
                                     </statement>
                                   </block>
                                 </statement>
                               </block>
                             </statement>
                           </block>
                         </next>
                       </block>
                     </next>
                   </block>
                  </xml>
                  

                  Wie gesagt ich präferiere die Lösung ohne Listen und damit das Ermitteln des Maximums mit den jeweils aktuell eintrudelnden Werten.

                  L 2 Replies Last reply Reply Quote 0
                  • L
                    Linedancer @mickym last edited by

                    @mickym

                    Auch dir vielen Dank für deine Lösungsvorschläge. Schau ich mir an.

                    1 Reply Last reply Reply Quote 0
                    • L
                      Linedancer @mickym last edited by

                      So, die Lösung von @paul53 hab ich umgesetzt. Funktioniert so wie ich es mir vorgestellt habe. Danke dafür.

                      Die Node Red Lösung von @mickym hab ich mir angeschaut, aber da ich (leider) immernoch kein wirkliche Erfahrung mit JavaScript habe, ist mir die reine Blockly Lösung näher. Trotzdem auch dir danke für deine Hilfe.

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

                        @linedancer Na meine Blockly-Lösungen greifen halt auf den Raum zu, den Du direkt im Admin eingegeben hast und nicht über eigene Zuordnungen. Und ich dachte das war Dein Hauptziel. Deswegen hab ich halt das Blockly entsprechend mit einer JS Funktion erweitert.

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

                        Support us

                        ioBroker
                        Community Adapters
                        Donate

                        937
                        Online

                        32.0k
                        Users

                        80.5k
                        Topics

                        1.3m
                        Posts

                        4
                        26
                        1092
                        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