- Home
- Deutsch
- Skripten / Logik
- Blockly
- Script für Prüfung Luftfeuchtigkeit und Übergabe Telegramm
Script für Prüfung Luftfeuchtigkeit und Übergabe Telegramm
-
Hallo zusammen,
ich versuche aktuell ein Blocky Script zu erstellen um mich per Telegramm benachrichtigen zu lassen, wenn in einem der Räume die Luftfeuchtigkeit angestiegen ist. Hier im Forum bin ich auf einige Blocky Scripts gestoßen, welche ich versucht habe nach meinen Anforderungen zu formen.
Mein erster Versuch, inspiriert von @Kueppert und @paul53 [gelöst] Zigbee Überwachung via Blockly
<xml xmlns="https://developers.google.com/blockly/xml"> <variables> <variable id="Hxgr,3rW59z?c[p:m55!">id</variable> <variable id="GQCJ-ywGYI:D%^3R]1zy">Namen</variable> <variable id="jk_f9Bsj*{k?NKo`D5g(">Grenzwert</variable> <variable id="^fQ?5!9i6[PA6I~$jq?*">i</variable> </variables> <block type="procedures_defcustomreturn" id="?)C+XJ:/T[|h7CJ#).Lc" x="-987" y="-12"> <mutation statements="false"> <arg name="id" varid="Hxgr,3rW59z?c[p:m55!"></arg> </mutation> <field name="NAME">getParentName</field> <field name="SCRIPT">cmV0dXJuIGdldE9iamVjdChpZC5zdWJzdHJpbmcoMCwgaWQubGFzdEluZGV4T2YoJy4nKSkpLmNvbW1vbi5uYW1lOw0KDQovL3JldHVybiBnZXRPYmplY3QoaWQpLmNvbW1vbi5uYW1l</field> <comment pinned="false" h="80" w="160">Beschreibe diese Funktion …</comment> </block> <block type="on_ext" id="1@Iml#9o^})_M?GJjRe." x="-988" y="37"> <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="PvwKFl=u7Iq-J8q20M-?"> <field name="oid">default</field> </shadow> <block type="selector" id="pIAq4:XhU8]e)P+e_}}-"> <field name="TEXT">state[id=zigbee.0.*.humidity]</field> </block> </value> <statement name="STATEMENT"> <block type="comment" id="AoM~eZ.gn~hhULL5g0H)"> <field name="COMMENT">Setzt die Namen zurück</field> <next> <block type="variables_set" id="VU4J0DT0q;}1,``D{dBE"> <field name="VAR" id="GQCJ-ywGYI:D%^3R]1zy">Namen</field> <value name="VALUE"> <block type="text" id="deb5rSpqc9d4C[E=K1`T"> <field name="TEXT"></field> </block> </value> <next> <block type="comment" id="^/{nn-d(_m=4F}.H4-Hq"> <field name="COMMENT">Setzt die Tage auf Milisekunden</field> <next> <block type="variables_set" id=":GT*_Z9OU[RtXTywPw*^"> <field name="VAR" id="jk_f9Bsj*{k?NKo`D5g(">Grenzwert</field> <comment pinned="false" h="80" w="160">1min = 60.000ms 30min = 1.800 000ms 60min = 3.600 000ms 1 Tag = 86.400 000 ms</comment> <value name="VALUE"> <block type="math_number" id=".O,*:@~=njs=Gc8p1;r]"> <field name="NUM">65</field> </block> </value> <next> <block type="controls_forEach" id="%ZUL,hL5JdgS*s;w1[Y4"> <field name="VAR" id="^fQ?5!9i6[PA6I~$jq?*">i</field> <value name="LIST"> <block type="selector" id="XG$Hl55rP5Q.wN(Y|-a_"> <field name="TEXT">state[id=zigbee.0.*.humidity]</field> </block> </value> <statement name="DO"> <block type="comment" id="%n,bYUduP1=IOoD8H0qU"> <field name="COMMENT">Werte</field> <next> <block type="controls_if" id="t+/u-1wx-dpU;79:ZI6!"> <value name="IF0"> <block type="logic_compare" id="lhj)!bvO}E:TNr*Szp@+" inline="false"> <field name="OP">GT</field> <value name="A"> <block type="get_value_var" id="Db0M1=*/jWOrdy1oqC@n"> <field name="ATTR">val</field> <value name="OID"> <shadow type="text" id="!)hz[%)c:tf;pQW9-Z{C"> <field name="TEXT"></field> </shadow> <block type="variables_get" id="28]O6g7kc4E.!hNFx=*0"> <field name="VAR" id="^fQ?5!9i6[PA6I~$jq?*">i</field> </block> </value> </block> </value> <value name="B"> <block type="variables_get" id="pIN!*$R=Z$#K6}jVVHd#"> <field name="VAR" id="jk_f9Bsj*{k?NKo`D5g(">Grenzwert</field> </block> </value> </block> </value> <statement name="DO0"> <block type="variables_set" id="E+e|wvC1Di,taMrerrfs"> <field name="VAR" id="GQCJ-ywGYI:D%^3R]1zy">Namen</field> <value name="VALUE"> <block type="text_join" id=".jHkp#s7a+!79P]}siFt"> <mutation items="3"></mutation> <value name="ADD0"> <block type="variables_get" id="%UJ$nh%tH69sTzpQ=5X^"> <field name="VAR" id="GQCJ-ywGYI:D%^3R]1zy">Namen</field> </block> </value> <value name="ADD1"> <block type="procedures_callcustomreturn" id="*$ts29/9F}?n@hoGbmfS"> <mutation name="getParentName"> <arg name="id"></arg> </mutation> <value name="ARG0"> <block type="variables_get" id="u/QZXqTi_FT:6Z$)e[x)"> <field name="VAR" id="^fQ?5!9i6[PA6I~$jq?*">i</field> </block> </value> </block> </value> <value name="ADD2"> <block type="text_newline" id="TF{w[(Qt{PzLI2:RlX-H"> <field name="Type">\n</field> </block> </value> </block> </value> </block> </statement> </block> </next> </block> </statement> <next> <block type="comment" id="vO/{c*FTfCtm}+=zC|3S"> <field name="COMMENT">Ausgabe im Debug Log</field> <next> <block type="debug" id="mv5[gr$eRnX%]9f{InZ."> <field name="Severity">log</field> <value name="TEXT"> <shadow type="text" id="`G:cXrbpWICu?.!0m/xl"> <field name="TEXT">test</field> </shadow> <block type="variables_get" id="QE~=rd{D_)VkU,~#g+zI"> <field name="VAR" id="GQCJ-ywGYI:D%^3R]1zy">Namen</field> </block> </value> <next> <block type="comment" id="~P*M7*XWmbPg[F,6B|J1"> <field name="COMMENT">Übermittlung an Telegram - Wenn Namen Ausgabe größer 0</field> <next> <block type="controls_if" id="IX}i.n9Z$8Oh7RnZ`_GS"> <value name="IF0"> <block type="logic_compare" id="y%mgm]jySOCJn5UJ?R]h"> <field name="OP">GT</field> <value name="A"> <block type="text_length" id="IQul02DUhqp:8vi^={XP"> <value name="VALUE"> <shadow type="text" id="Y3nXhm`ji,cLy*@!Amcq"> <field name="TEXT">abc</field> </shadow> <block type="variables_get" id="Ao_|9Whl}FgM:}@t:#h{"> <field name="VAR" id="GQCJ-ywGYI:D%^3R]1zy">Namen</field> </block> </value> </block> </value> <value name="B"> <block type="math_number" id="E+vohsdRwSwSZz8#ZBj9"> <field name="NUM">0</field> </block> </value> </block> </value> <statement name="DO0"> <block type="telegram" id="e/Yf#38+yVzNcIn?dUnK"> <field name="INSTANCE"></field> <field name="LOG"></field> <field name="SILENT">FALSE</field> <field name="PARSEMODE">default</field> <field name="DISABLE_WEB_PAGE_PREVIEW">FALSE</field> <value name="MESSAGE"> <shadow type="text" id="xXm}h]MuLh=Nz4r7v3TN"> <field name="TEXT">text</field> </shadow> <block type="text_join" id="*+n0G`a,MXHl7|IQN1{j"> <mutation items="4"></mutation> <value name="ADD0"> <block type="text" id="D]+8_PT@|=D,!(7BMN$0"> <field name="TEXT">Luftfeuchtigkeit in folgenden Räumen zu hoch </field> </block> </value> <value name="ADD1"> <block type="text_newline" id=":UcndGsUc~[AMw_%5,Y}"> <field name="Type">\n</field> </block> </value> <value name="ADD2"> <block type="variables_get" id="xq{`=O2WVDtd0p=FXR}X"> <field name="VAR" id="GQCJ-ywGYI:D%^3R]1zy">Namen</field> </block> </value> <value name="ADD3"> <block type="text" id="2^bB|K1#@shQtQtqv%$Z"> <field name="TEXT"> bitte lüften!</field> </block> </value> </block> </value> </block> </statement> </block> </next> </block> </next> </block> </next> </block> </next> </block> </next> </block> </next> </block> </next> </block> </next> </block> </statement> </block> </xml>
Funktioniert soweit gut, ich möchte jedoch nur einmal alle 60 - 120 Minuten benachrichtigt werden und nicht alle paar Minuten.
Daher hatte ich mich an dem Beitrag von @stinkzor Blockly Telegram Luftfeuchtigkeit orientiert und versucht das folgende anzupassen:
Mein Ergebniss ist gelinde gesagt, katastrophal. Aus einem mir noch nicht klaren Grund greift die Schleife zu oft und ich bekomme 12 Telegramm Nachrichten. Den Fehler kann ich auf die Falls Abfragen / Schleife zurückführen, jedoch nicht entstören.
<xml xmlns="https://developers.google.com/blockly/xml"> <variables> <variable id="Hxgr,3rW59z?c[p:m55!">id</variable> <variable id="GQCJ-ywGYI:D%^3R]1zy">Namen</variable> <variable id="jk_f9Bsj*{k?NKo`D5g(">Grenzwert</variable> <variable id="^fQ?5!9i6[PA6I~$jq?*">i</variable> <variable id="(UFDg4|9r0Gz2r`0}}m}">Unterbrechung</variable> <variable type="interval" id="Unterbrechung">Unterbrechung</variable> </variables> <block type="procedures_defcustomreturn" id="?)C+XJ:/T[|h7CJ#).Lc" x="337" y="63"> <mutation statements="false"> <arg name="id" varid="Hxgr,3rW59z?c[p:m55!"></arg> </mutation> <field name="NAME">getParentName</field> <field name="SCRIPT">cmV0dXJuIGdldE9iamVjdChpZC5zdWJzdHJpbmcoMCwgaWQubGFzdEluZGV4T2YoJy4nKSkpLmNvbW1vbi5uYW1lOw0KDQovL3JldHVybiBnZXRPYmplY3QoaWQpLmNvbW1vbi5uYW1l</field> <comment pinned="false" h="80" w="160">Beschreibe diese Funktion …</comment> </block> <block type="on_ext" id="L`!tV:jaN7k(S3X@#20^" x="163" y="112"> <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="],o!dEeXD6p$MaD`.,(M"> <field name="oid">default</field> </shadow> <block type="selector" id="$Re)z#Wk?-U,@Ph}[)re"> <field name="TEXT">state[id=zigbee.0.*.humidity]</field> </block> </value> <statement name="STATEMENT"> <block type="variables_set" id="vp;~MNRGnSO}V.CnU23)"> <field name="VAR" id="GQCJ-ywGYI:D%^3R]1zy">Namen</field> <value name="VALUE"> <block type="text" id="9Zq}o{14rySSx3zFHo-S"> <field name="TEXT"></field> </block> </value> <next> <block type="variables_set" id="kI$W1o|$9)RRrzeL(0M3"> <field name="VAR" id="jk_f9Bsj*{k?NKo`D5g(">Grenzwert</field> <comment pinned="false" h="80" w="160">1min = 60.000ms 30min = 1.800 000ms 60min = 3.600 000ms 1 Tag = 86.400 000 ms</comment> <value name="VALUE"> <block type="math_number" id="qV6g4I^B~2Y^=ks/H_zQ"> <field name="NUM">65</field> </block> </value> <next> <block type="controls_forEach" id="mq2JsQ^cK$7*CDAf;^fN"> <field name="VAR" id="^fQ?5!9i6[PA6I~$jq?*">i</field> <value name="LIST"> <block type="selector" id=";[u6lz(rf^Ta?q1y)V7o"> <field name="TEXT">state[id=zigbee.0.*.humidity]</field> </block> </value> <statement name="DO"> <block type="controls_if" id=";T0WIKJ[qK9M_p[Qv*-?"> <mutation else="1"></mutation> <value name="IF0"> <block type="logic_compare" id="mylF;8c[+7J1tvAKR_}g"> <field name="OP">GT</field> <value name="A"> <block type="on_source" id="p;ZFG|2CW6u3D8N?[L_."> <field name="ATTR">state.val</field> </block> </value> <value name="B"> <block type="variables_get" id="wkDO1=BbA/;uhkA)[+QA"> <field name="VAR" id="jk_f9Bsj*{k?NKo`D5g(">Grenzwert</field> </block> </value> </block> </value> <statement name="DO0"> <block type="controls_if" id="D#^pObt8bE#Ng=a{wjT."> <value name="IF0"> <block type="logic_negate" id="+;aMooV)h#Cnu_RkBsMG"> <value name="BOOL"> <block type="variables_get" id="To8OsKga]xlpW6y$b)_N"> <field name="VAR" id="(UFDg4|9r0Gz2r`0}}m}">Unterbrechung</field> </block> </value> </block> </value> <statement name="DO0"> <block type="controls_if" id="0eNFyEt}W9tTxSD~Wk$Y"> <value name="IF0"> <block type="logic_compare" id="Maz7Fh,z=^6;jow8wB/9" inline="false"> <field name="OP">GT</field> <value name="A"> <block type="get_value_var" id="(di}B+yg6JIHMvkr,N*W"> <field name="ATTR">val</field> <value name="OID"> <shadow type="text"> <field name="TEXT"></field> </shadow> <block type="variables_get" id="5{bF%$7O:3dZGFW3+!{^"> <field name="VAR" id="^fQ?5!9i6[PA6I~$jq?*">i</field> </block> </value> </block> </value> <value name="B"> <block type="variables_get" id=":%Qw@0qX_2IRxGM9aZ4M"> <field name="VAR" id="jk_f9Bsj*{k?NKo`D5g(">Grenzwert</field> </block> </value> </block> </value> <statement name="DO0"> <block type="variables_set" id=")za3VVU:8QCu?vx;m:|Y"> <field name="VAR" id="GQCJ-ywGYI:D%^3R]1zy">Namen</field> <value name="VALUE"> <block type="text_join" id="FIlc7=xC9enaX+c,FWJ$"> <mutation items="3"></mutation> <value name="ADD0"> <block type="variables_get" id="vfTB1TKr(LdX}|x_F[zK"> <field name="VAR" id="GQCJ-ywGYI:D%^3R]1zy">Namen</field> </block> </value> <value name="ADD1"> <block type="procedures_callcustomreturn" id="3,d]szaY-j4?onNT^`2G"> <mutation name="getParentName"> <arg name="id"></arg> </mutation> <value name="ARG0"> <block type="variables_get" id="T8osv};!vQFZ!6j(}6I("> <field name="VAR" id="^fQ?5!9i6[PA6I~$jq?*">i</field> </block> </value> </block> </value> <value name="ADD2"> <block type="text_newline" id="%FKDIdRUxZi/^9t}XH=,"> <field name="Type">\n</field> </block> </value> </block> </value> </block> </statement> <next> <block type="debug" id="l?,zA7(*@ZYWHu7nvR!}"> <field name="Severity">log</field> <value name="TEXT"> <shadow type="text" id=";^1/y*c_6rE]otgm(p+`"> <field name="TEXT">test</field> </shadow> <block type="variables_get" id="y$|mlNh!mR6`.0d)e^EG"> <field name="VAR" id="GQCJ-ywGYI:D%^3R]1zy">Namen</field> </block> </value> <next> <block type="controls_if" id=":[1JXN|jYp.4km)r4VAZ"> <value name="IF0"> <block type="logic_compare" id="WzIt[D|{bmWHM`o*5pv#"> <field name="OP">GT</field> <value name="A"> <block type="text_length" id="E-dL_Rtf7aYIbog*^a2."> <value name="VALUE"> <shadow type="text"> <field name="TEXT">abc</field> </shadow> <block type="variables_get" id="R#3JnBCLndJ~GP+h/5p~"> <field name="VAR" id="GQCJ-ywGYI:D%^3R]1zy">Namen</field> </block> </value> </block> </value> <value name="B"> <block type="math_number" id="Zkw6QFPc0z4SSo^G$8^k"> <field name="NUM">0</field> </block> </value> </block> </value> <statement name="DO0"> <block type="telegram" id=";+}qb#-3{i3gYP@qXU[X"> <field name="INSTANCE"></field> <field name="LOG"></field> <field name="SILENT">FALSE</field> <field name="PARSEMODE">default</field> <field name="DISABLE_WEB_PAGE_PREVIEW">FALSE</field> <value name="MESSAGE"> <shadow type="text"> <field name="TEXT">text</field> </shadow> <block type="text_join" id="Sm6p359oX0mv#d1`xdGv"> <mutation items="4"></mutation> <value name="ADD0"> <block type="text" id="9KzbgvHvYZ#v)Z:(!yf|"> <field name="TEXT">Luftfeuchtigkeit in folgenden Räumen zu hoch </field> </block> </value> <value name="ADD1"> <block type="text_newline" id="RL2yt0TL4zeSGXKaPg`Z"> <field name="Type">\n</field> </block> </value> <value name="ADD2"> <block type="variables_get" id="uWQ8d8KV)+B,vdvYv~tL"> <field name="VAR" id="GQCJ-ywGYI:D%^3R]1zy">Namen</field> </block> </value> <value name="ADD3"> <block type="text" id="1jCnh,!?lRfM^zM|Ob[*"> <field name="TEXT"> bitte lüften!</field> </block> </value> </block> </value> </block> </statement> <next> <block type="timeouts_setinterval" id="GpFl8kE3v8RHDWq?sQ7:"> <field name="NAME">Unterbrechung</field> <field name="INTERVAL">120</field> <field name="UNIT">min</field> <statement name="STATEMENT"> <block type="telegram" id="?)~x{+_ROVNb,(|x3PI4"> <field name="INSTANCE"></field> <field name="LOG"></field> <field name="SILENT">FALSE</field> <field name="PARSEMODE">default</field> <field name="DISABLE_WEB_PAGE_PREVIEW">FALSE</field> <value name="MESSAGE"> <shadow type="text"> <field name="TEXT">text</field> </shadow> <block type="text_join" id="3z8gwf|dV`TkF,Ucq#)x"> <mutation items="4"></mutation> <value name="ADD0"> <block type="text" id="t[Tf@$Oj?X#I0cHe[@mC"> <field name="TEXT">Luftfeuchtigkeit in folgenden Räumen zu hoch </field> </block> </value> <value name="ADD1"> <block type="text_newline" id="R5(Y.H]u48;sGfY.Jq/s"> <field name="Type">\n</field> </block> </value> <value name="ADD2"> <block type="variables_get" id="L=0ZAuo1_8OA9CyW)GsE"> <field name="VAR" id="GQCJ-ywGYI:D%^3R]1zy">Namen</field> </block> </value> <value name="ADD3"> <block type="text" id="*yhkE~5)rxab#*:pJ+6%"> <field name="TEXT"> bitte lüften!</field> </block> </value> </block> </value> </block> </statement> </block> </next> </block> </next> </block> </next> </block> </statement> </block> </statement> <statement name="ELSE"> <block type="timeouts_clearinterval" id="iydDephsnE3_Q*7ucvsb"> <field name="NAME">Unterbrechung</field> </block> </statement> </block> </statement> </block> </next> </block> </next> </block> </statement> </block> </xml>
Ich hoffe es hat einer von euch eine Idee / Verbesserungsvorschlag für mich. Eine Möglichkeit wäre mit einem Trigger zu arbeiten und einfach alle 120 Minuten zu prüfen ob etwas ist - was aber dem Wunsch zeitnah informiert zu werden wiederspricht.
-
@cruelthunder sagte: nur einmal alle 60 - 120 Minuten benachrichtigt werden
Länge von Namen = 0 ist das Kriterium, um das Intervall zu beenden.
-
@paul53 Vielen Dank für die schnelle Hilfe. Habe es eben umgebaut und auch zwei Sensoren ausschlagen lassen - Ohne den Timeout kommt auch direkt eine Nachricht - Mit Timeout werde ich etwas warten müssen
.
-
@cruelthunder
Die Prüfung von "Länge von Namen" ist falsch! Sie muss an dieser Stelle auf = 0 geprüft werden. -
@paul53 Danke, wer lesen kann ist klar im Vorteil.