Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. Blockly
    5. Zeitstempel von Sensoren prüfen und benachrichtigen

    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

    Zeitstempel von Sensoren prüfen und benachrichtigen

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

      Moin zusammen,

      ich habe die Corona-Zeit mal sinnvoll nutzen wollen und an einem Skript gefeilt, was mir nach 2 Tagen Inaktivität irgendeines meiner Zigbee-Sensoren eine Telegram-Nachricht sendet. Ich hatte die Grundlage dazu schon mal von einem Bekannten gekriegt, das aber nun etwas komfortabler machen wollen, ohne bei Hinzukommen eines Objekts wieder zig Sachen hinzuzufügen.

      71feb866-0f89-4cf1-a13e-100476bd1bdd-image.png

      Habe jetzt mal die Batterie aus meinem Thermometer rausgenommen und sehe übermorgen (falls meine Geduld ausreicht), ob alles so hinhaut.

      Was mir noch fehlt: Wie kriege ich zu einer ObjectID den Namen raus? Da bin ich einfach zu blöd zu. Habe das Skript extra so gebaut, dass ich nur den Ordner des Objekts wählen muss, dachte dann wäre das mit dem Namen am einfachsten..

      <xml xmlns="http://www.w3.org/1999/xhtml">
       <variables>
         <variable type="" id="gSJJyp2LaU@d0/v3dtg_">tage</variable>
         <variable type="" id="bXP#7zt#,VAx~,Z1h2v$">differenz</variable>
         <variable type="" id="zKZUuE/7%v#4}+]y56)p">i</variable>
       </variables>
       <block type="variables_set" id="=DWa2RBxFI#d-+:vq.#," x="1087" y="-187">
         <field name="VAR" id="gSJJyp2LaU@d0/v3dtg_" variabletype="">tage</field>
         <value name="VALUE">
           <block type="math_number" id="g1#WIj)-4UF%qq5}.k[|">
             <field name="NUM">2</field>
           </block>
         </value>
         <next>
           <block type="schedule" id="K4oL*bX.:R94R#/y3W:,">
             <field name="SCHEDULE">25 0 * * *</field>
             <statement name="STATEMENT">
               <block type="variables_set" id="VK9b9IP{I{f[k;PIoGNC">
                 <field name="VAR" id="bXP#7zt#,VAx~,Z1h2v$" variabletype="">differenz</field>
                 <value name="VALUE">
                   <block type="math_arithmetic" id="^X~+|s_9;44]5GgYJh-8">
                     <field name="OP">MULTIPLY</field>
                     <value name="A">
                       <shadow type="math_number" id="Q)rdfuEPB#~yo=?#m3EZ">
                         <field name="NUM">1</field>
                       </shadow>
                       <block type="variables_get" id="tt~}L@HuDnQ_~Rw]LSb_">
                         <field name="VAR" id="gSJJyp2LaU@d0/v3dtg_" variabletype="">tage</field>
                       </block>
                     </value>
                     <value name="B">
                       <shadow type="math_number" id="?/Mg}ztPAO?k60UuRxo[">
                         <field name="NUM">86400000</field>
                       </shadow>
                     </value>
                   </block>
                 </value>
                 <next>
                   <block type="controls_forEach" id="QdZ;WS8a9pFL@=UGtz,K">
                     <field name="VAR" id="zKZUuE/7%v#4}+]y56)p" variabletype="">i</field>
                     <value name="LIST">
                       <block type="lists_create_with" id="VEu;{^GN^fWGL=:-^Qkt">
                         <mutation items="19"></mutation>
                       </block>
                     </value>
                     <statement name="DO">
                       <block type="controls_if" id="[%]0dVc8E^D;0~{?^)m}">
                         <value name="IF0">
                           <block type="logic_compare" id="Ef_vn=gj=deSDYs)+i1e">
                             <field name="OP">GT</field>
                             <value name="A">
                               <block type="math_arithmetic" id="N;]`?THQvmvp(=u/OR8.">
                                 <field name="OP">MINUS</field>
                                 <value name="A">
                                   <shadow type="math_number" id="Bs9FNTr#^jC#?;4EU$mh">
                                     <field name="NUM">1</field>
                                   </shadow>
                                   <block type="time_get" id="{:3xE%KN$-}h_5;?L@0X">
                                     <mutation format="false" language="false"></mutation>
                                     <field name="OPTION">object</field>
                                   </block>
                                 </value>
                                 <value name="B">
                                   <shadow type="math_number" id="+-Nb3#:Rm$4E`sZZ5Iu{">
                                     <field name="NUM">172800000</field>
                                   </shadow>
                                   <block type="variables_get" id="Whn)zr3/ja{_GYd%1b5+">
                                     <field name="VAR" id="bXP#7zt#,VAx~,Z1h2v$" variabletype="">differenz</field>
                                   </block>
                                 </value>
                               </block>
                             </value>
                             <value name="B">
                               <block type="get_value_var" id="`n,Z5bu%fJoFo%$*I%Kv">
                                 <field name="ATTR">ts</field>
                                 <value name="OID">
                                   <shadow type="text" id="m43DcH;OI{lo1y|%d{tT">
                                     <field name="TEXT"></field>
                                   </shadow>
                                   <block type="get_attr" id=",wSG8n#f{L)yva/YKT9v">
                                     <value name="PATH">
                                       <shadow type="text" id="uo^y0nEt%=jp[T|Y|(lf">
                                         <field name="TEXT">link_quality</field>
                                       </shadow>
                                     </value>
                                     <value name="OBJECT">
                                       <block type="variables_get" id="NJ!9zCJ(R:UoE[#eHaTe">
                                         <field name="VAR" id="zKZUuE/7%v#4}+]y56)p" variabletype="">i</field>
                                       </block>
                                     </value>
                                   </block>
                                 </value>
                               </block>
                             </value>
                           </block>
                         </value>
                         <statement name="DO0">
                           <block type="telegram" id="/{-uA?As.6`ZolQ/wH,6">
                             <field name="INSTANCE"></field>
                             <field name="LOG"></field>
                             <field name="SILENT">FALSE</field>
                             <field name="PARSEMODE">default</field>
                             <value name="MESSAGE">
                               <shadow type="text" id="IR_,m!91~[cX;Z93ul1J">
                                 <field name="TEXT">2 Tage keine Änderung bei Steckdose Ender.</field>
                               </shadow>
                               <block type="text_join" id="W:Z{//;/ML;mWhecy,4@">
                                 <mutation items="3"></mutation>
                                 <value name="ADD0">
                                   <block type="text" id="#y68;cqNT:5{oVXC^r4Y">
                                     <field name="TEXT">2 Tage keine Änderung bei </field>
                                   </block>
                                 </value>
                                 <value name="ADD1">
                                   <block type="variables_get" id="Iv$7$f8s31A,vT0~J)jD">
                                     <field name="VAR" id="zKZUuE/7%v#4}+]y56)p" variabletype="">i</field>
                                   </block>
                                 </value>
                                 <value name="ADD2">
                                   <block type="text" id="nPM^}GEpiG1/R=mge9u_">
                                     <field name="TEXT">. Eventuell ist die Batterie leer?</field>
                                   </block>
                                 </value>
                               </block>
                             </value>
                           </block>
                         </statement>
                       </block>
                     </statement>
                   </block>
                 </next>
               </block>
             </statement>
           </block>
         </next>
       </block>
      </xml>
      

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

        @parabelflug1
        "link_quality" ist kein Objekt-Attribut, sondern der letzte Teil der Datenpunkt-ID.

        @parabelflug1 sagte in Zeitstempel von Sensoren prüfen und benachrichtigen:

        Wie kriege ich zu einer ObjectID den Namen raus?

        Das ist in Blockly nur mit einer Javascript-Funktion möglich.

        <xml xmlns="http://www.w3.org/1999/xhtml">
         <variables>
           <variable type="" id="gSJJyp2LaU@d0/v3dtg_">tage</variable>
           <variable type="" id="O/ihJadFK42uuQ{fFvp|">id</variable>
           <variable type="" id="~9Hys7RvT93(?~Mmi-h!">Namen</variable>
           <variable type="" id="bXP#7zt#,VAx~,Z1h2v$">differenz</variable>
           <variable type="" id="zKZUuE/7%v#4}+]y56)p">i</variable>
         </variables>
         <block type="variables_set" id="=DWa2RBxFI#d-+:vq.#," x="1087" y="-187">
           <field name="VAR" id="gSJJyp2LaU@d0/v3dtg_" variabletype="">tage</field>
           <value name="VALUE">
             <block type="math_number" id="g1#WIj)-4UF%qq5}.k[|">
               <field name="NUM">2</field>
             </block>
           </value>
           <next>
             <block type="schedule" id="K4oL*bX.:R94R#/y3W:,">
               <field name="SCHEDULE">25 0 * * *</field>
               <statement name="STATEMENT">
                 <block type="variables_set" id="+`4/WoqXDErfyuYl`n:n">
                   <field name="VAR" id="~9Hys7RvT93(?~Mmi-h!" variabletype="">Namen</field>
                   <value name="VALUE">
                     <block type="text" id="xBN[3;12AC#BB{yv3HA+">
                       <field name="TEXT"></field>
                     </block>
                   </value>
                   <next>
                     <block type="variables_set" id="VK9b9IP{I{f[k;PIoGNC">
                       <field name="VAR" id="bXP#7zt#,VAx~,Z1h2v$" variabletype="">differenz</field>
                       <value name="VALUE">
                         <block type="math_arithmetic" id="^X~+|s_9;44]5GgYJh-8">
                           <field name="OP">MULTIPLY</field>
                           <value name="A">
                             <shadow type="math_number" id="Q)rdfuEPB#~yo=?#m3EZ">
                               <field name="NUM">1</field>
                             </shadow>
                             <block type="variables_get" id="tt~}L@HuDnQ_~Rw]LSb_">
                               <field name="VAR" id="gSJJyp2LaU@d0/v3dtg_" variabletype="">tage</field>
                             </block>
                           </value>
                           <value name="B">
                             <shadow type="math_number" id="?/Mg}ztPAO?k60UuRxo[">
                               <field name="NUM">86400000</field>
                             </shadow>
                           </value>
                         </block>
                       </value>
                       <next>
                         <block type="controls_forEach" id="QdZ;WS8a9pFL@=UGtz,K">
                           <field name="VAR" id="zKZUuE/7%v#4}+]y56)p" variabletype="">i</field>
                           <value name="LIST">
                             <block type="lists_create_with" id="VEu;{^GN^fWGL=:-^Qkt">
                               <mutation items="19"></mutation>
                             </block>
                           </value>
                           <statement name="DO">
                             <block type="controls_if" id="[%]0dVc8E^D;0~{?^)m}">
                               <value name="IF0">
                                 <block type="logic_compare" id="Ef_vn=gj=deSDYs)+i1e">
                                   <field name="OP">GT</field>
                                   <value name="A">
                                     <block type="math_arithmetic" id="N;]`?THQvmvp(=u/OR8.">
                                       <field name="OP">MINUS</field>
                                       <value name="A">
                                         <shadow type="math_number" id="Bs9FNTr#^jC#?;4EU$mh">
                                           <field name="NUM">1</field>
                                         </shadow>
                                         <block type="time_get" id="{:3xE%KN$-}h_5;?L@0X">
                                           <mutation format="false" language="false"></mutation>
                                           <field name="OPTION">object</field>
                                         </block>
                                       </value>
                                       <value name="B">
                                         <shadow type="math_number" id="+-Nb3#:Rm$4E`sZZ5Iu{">
                                           <field name="NUM">172800000</field>
                                         </shadow>
                                         <block type="variables_get" id="Whn)zr3/ja{_GYd%1b5+">
                                           <field name="VAR" id="bXP#7zt#,VAx~,Z1h2v$" variabletype="">differenz</field>
                                         </block>
                                       </value>
                                     </block>
                                   </value>
                                   <value name="B">
                                     <block type="get_value_var" id="`n,Z5bu%fJoFo%$*I%Kv">
                                       <field name="ATTR">ts</field>
                                       <value name="OID">
                                         <shadow type="text" id="m43DcH;OI{lo1y|%d{tT">
                                           <field name="TEXT"></field>
                                         </shadow>
                                         <block type="text_join" id="e4@;}+S(Cg}Mt$+k|.@S">
                                           <mutation items="2"></mutation>
                                           <value name="ADD0">
                                             <block type="variables_get" id="NJ!9zCJ(R:UoE[#eHaTe">
                                               <field name="VAR" id="zKZUuE/7%v#4}+]y56)p" variabletype="">i</field>
                                             </block>
                                           </value>
                                           <value name="ADD1">
                                             <block type="text" id="$@:H%p3cnQyCa.+$[8PJ">
                                               <field name="TEXT">.link_quality</field>
                                             </block>
                                           </value>
                                         </block>
                                       </value>
                                     </block>
                                   </value>
                                 </block>
                               </value>
                               <statement name="DO0">
                                 <block type="variables_set" id="Q4:W2t^c~BX?!ttDtEp`">
                                   <field name="VAR" id="~9Hys7RvT93(?~Mmi-h!" variabletype="">Namen</field>
                                   <value name="VALUE">
                                     <block type="text_join" id="[#r-mN)q@lMiNh`@I*84">
                                       <mutation items="3"></mutation>
                                       <value name="ADD0">
                                         <block type="variables_get" id=";/+C:@X5.q.jOH8x[0mw">
                                           <field name="VAR" id="~9Hys7RvT93(?~Mmi-h!" variabletype="">Namen</field>
                                         </block>
                                       </value>
                                       <value name="ADD1">
                                         <block type="procedures_callcustomreturn" id="w$2PWjuZh0al,@7j,^U*" inline="true">
                                           <mutation name="getName">
                                             <arg name="id"></arg>
                                           </mutation>
                                           <value name="ARG0">
                                             <block type="variables_get" id="Iv$7$f8s31A,vT0~J)jD">
                                               <field name="VAR" id="zKZUuE/7%v#4}+]y56)p" variabletype="">i</field>
                                             </block>
                                           </value>
                                         </block>
                                       </value>
                                       <value name="ADD2">
                                         <block type="text" id="Zp?A.YzzOlYK?5W+G($G">
                                           <field name="TEXT">, </field>
                                         </block>
                                       </value>
                                     </block>
                                   </value>
                                 </block>
                               </statement>
                             </block>
                           </statement>
                           <next>
                             <block type="controls_if" id="(QC0bu2k=,%#o=*-t.|?">
                               <value name="IF0">
                                 <block type="variables_get" id="qu}igvw?RT];VN/*#9Rj">
                                   <field name="VAR" id="~9Hys7RvT93(?~Mmi-h!" variabletype="">Namen</field>
                                 </block>
                               </value>
                               <statement name="DO0">
                                 <block type="telegram" id="/{-uA?As.6`ZolQ/wH,6">
                                   <field name="INSTANCE"></field>
                                   <field name="LOG"></field>
                                   <field name="SILENT">FALSE</field>
                                   <field name="PARSEMODE">default</field>
                                   <value name="MESSAGE">
                                     <shadow type="text" id="IR_,m!91~[cX;Z93ul1J">
                                       <field name="TEXT">2 Tage keine Änderung bei Steckdose Ender.</field>
                                     </shadow>
                                     <block type="text_join" id="W:Z{//;/ML;mWhecy,4@">
                                       <mutation items="3"></mutation>
                                       <value name="ADD0">
                                         <block type="text" id="#y68;cqNT:5{oVXC^r4Y">
                                           <field name="TEXT">2 Tage keine Änderung bei </field>
                                         </block>
                                       </value>
                                       <value name="ADD1">
                                         <block type="variables_get" id="7;i2m0^+Z7Z4[p:8Psj^">
                                           <field name="VAR" id="~9Hys7RvT93(?~Mmi-h!" variabletype="">Namen</field>
                                         </block>
                                       </value>
                                       <value name="ADD2">
                                         <block type="text" id="nPM^}GEpiG1/R=mge9u_">
                                           <field name="TEXT">. Eventuell ist die Batterie leer?</field>
                                         </block>
                                       </value>
                                     </block>
                                   </value>
                                 </block>
                               </statement>
                             </block>
                           </next>
                         </block>
                       </next>
                     </block>
                   </next>
                 </block>
               </statement>
             </block>
           </next>
         </block>
         <block type="procedures_defcustomreturn" id=":Yg0wc=LxMg6nfHK`J4c" x="1537" y="612">
           <mutation statements="false">
             <arg name="id" varid="O/ihJadFK42uuQ{fFvp|"></arg>
           </mutation>
           <field name="NAME">getName</field>
           <field name="SCRIPT">cmV0dXJuIGdldE9iamVjdChpZCkuY29tbW9uLm5hbWU7</field>
           <comment pinned="false" h="80" w="160">Beschreibe diese Funktion …</comment>
         </block>
        </xml>
        

        Blockly_temp.JPG

        Funktion getName(id):

        getNamet.JPG

        P 1 Reply Last reply Reply Quote 2
        • P
          parabelflug1 @paul53 last edited by

          @paul53 Danke, probiere ich aus! Sieht ja noch etwas eleganter aus.

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

            @parabelflug1
            Kannst Du nicht anstelle der Zuweisung von vielen Geräte-IDs den Selektor verwenden ? Etwa so:

            Blockly_temp.JPG

            Funktion getParentName(id):

            getParentName.JPG

            1 Reply Last reply Reply Quote 2
            • P
              parabelflug1 last edited by

              Gute Idee. Aktuell möchte ich nur Benachrichtigungen zu allen batteriebetriebenen Zigbee-Geräten haben - es kann halt auch mal sein, dass eine Lampe mehr als 48h ausgeschaltet ist - da möchte man dann nicht benachrichtigt werden.
              Könnte man natürlich der Einfachheit halber auch über ne weitere Falls-Verknüpfung machen.. Falls "Sensor" in Name..

              Danke!

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

                @parabelflug1 sagte:

                dass eine Lampe mehr als 48h ausgeschaltet ist

                Von Netzspannung getrennt ?

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

                  @paul53 Genau.

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

                  Support us

                  ioBroker
                  Community Adapters
                  Donate

                  575
                  Online

                  31.9k
                  Users

                  80.2k
                  Topics

                  1.3m
                  Posts

                  2
                  7
                  809
                  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