NEWS
Bewegung erkannt - Shelly schalten
-
Hallo,
ich versuche mich grad an einem Blockly irgendwie geht es nicht obwohl ich es aus einem anderen Thread quasi fast rüberkopiert / nachgebildet habe.
Was soll passieren:Ein Bewegungsmelder PIR (HC-SR501) hängt an einem NodeMcu an einem GPIO. Der POWER1 Wert wird auch in den Datenbank protokolliert mit true / false
EIn Magnetventil soll geschaltet werden welches an einem Shelly 1 hängt. Manuell kann ich es per App schalten und im Adapter SHELLY wird auch der Datenpunkt mit true / false vom SWITCH korrekt protokolliert.
Was mache ich falsch, da bei Bewegung der Shelly nicht eingeschaltet wird ?
Hier der Blockly:
-
@Segway
Sollte so funktionieren, wobei man da einiges optimieren kann. Poste bitte mal den Code. -
@Jan1
Tja, dachte ich mir auch, aber leider wird bei Bewegung erkannt nicht der Switch vom Shelly auf true gesetzt
Bin auch für jede Optimierung offenHier der Code:
<xml xmlns="https://developers.google.com/blockly/xml"> <variables> <variable type="timeout" id="timeout">timeout</variable> </variables> <block type="on_ext" id="YM.#/9w.1y~Z9?XJhnN5" x="-487" y="-387"> <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="%jTnyCDn%PgYB{8*.0lt"> <field name="oid">sonoff.0.NodeMcu_Teich.POWER1</field> </shadow> </value> <statement name="STATEMENT"> <block type="controls_if" id="f`]_ZnrJPO+/s2gj8/sr"> <mutation elseif="1"></mutation> <value name="IF0"> <block type="logic_compare" id="r[c7):%ov;xLJI)7=6ST"> <field name="OP">EQ</field> <value name="A"> <block type="get_value" id="2s0IhxORi+m%{cGpB*GO"> <field name="ATTR">val</field> <field name="OID">sonoff.0.NodeMcu_Teich.POWER1</field> </block> </value> <value name="B"> <block type="logic_boolean" id="`]V~(Hc7DDwYjOh=4tq="> <field name="BOOL">TRUE</field> </block> </value> </block> </value> <statement name="DO0"> <block type="timeouts_cleartimeout" id="7rw,zduV-62(pcZLAR4;"> <field name="NAME">timeout</field> <next> <block type="control" id="fn32UPV8!EY@LVl@l441"> <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation> <field name="OID">shelly.0.SHSW-1#F4CFA2D3A5F6#1.Relay0.Switch</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"> <block type="logic_boolean" id="-+1Cq=~e/r9(P2:(wWxW"> <field name="BOOL">TRUE</field> </block> </value> <next> <block type="telegram" id="nz:m?9M:5{Ae#O.7xCt0"> <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="l7ocSs3*W?V)l/EdBQ.!"> <field name="TEXT">Bewegung erkannt</field> </shadow> </value> </block> </next> </block> </next> </block> </statement> <value name="IF1"> <block type="logic_compare" id="!h_WGeZ,Z/E._Rij{Sv}"> <field name="OP">EQ</field> <value name="A"> <block type="get_value" id="PaS+Yp.5AFv=$*~sSP_o"> <field name="ATTR">val</field> <field name="OID">sonoff.0.NodeMcu_Teich.POWER1</field> </block> </value> <value name="B"> <block type="logic_boolean" id="(^/@91AbU*Q[Lm;I(sQ1"> <field name="BOOL">FALSE</field> </block> </value> </block> </value> <statement name="DO1"> <block type="timeouts_cleartimeout" id="48kyiz7c9o!iu:6.^{Vw"> <field name="NAME">timeout</field> <next> <block type="timeouts_settimeout" id="EWUG;n=f.[20rin0,hE9"> <field name="NAME">timeout</field> <field name="DELAY">5</field> <field name="UNIT">sec</field> <statement name="STATEMENT"> <block type="control" id="n,cWi0{qY;;2M`YgMX#."> <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation> <field name="OID">shelly.0.SHSW-1#F4CFA2D3A5F6#1.Relay0.Switch</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"> <block type="logic_boolean" id="/rl|kRWsx3,,oO79(wuR"> <field name="BOOL">FALSE</field> </block> </value> </block> </statement> </block> </next> </block> </statement> </block> </statement> </block> </xml>
-
@Segway
teste das mal:<xml xmlns="https://developers.google.com/blockly/xml"> <variables> <variable type="timeout" id="timeout">timeout</variable> </variables> <block type="on_ext" id="YM.#/9w.1y~Z9?XJhnN5" x="-512" y="-287"> <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="%jTnyCDn%PgYB{8*.0lt"> <field name="oid">sonoff.0.NodeMcu_Teich.POWER1</field> </shadow> </value> <statement name="STATEMENT"> <block type="debug" id="1Dl(1ls]6*GT7qVXh:R{"> <field name="Severity">log</field> <value name="TEXT"> <shadow type="text" id="G!w1Eb8pjY5h2cu2WwG["> <field name="TEXT">Bewegung am NodeMCU erkannt</field> </shadow> </value> <next> <block type="controls_if" id="f`]_ZnrJPO+/s2gj8/sr"> <mutation else="1"></mutation> <value name="IF0"> <block type="on_source" id="+N}1g43YNn@(7[(F3}?x"> <field name="ATTR">state.val</field> </block> </value> <statement name="DO0"> <block type="timeouts_cleartimeout" id="7rw,zduV-62(pcZLAR4;"> <field name="NAME">timeout</field> <next> <block type="control" id="fn32UPV8!EY@LVl@l441"> <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation> <field name="OID">shelly.0.SHSW-1#F4CFA2D3A5F6#1.Relay0.Switch</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"> <block type="logic_boolean" id="-+1Cq=~e/r9(P2:(wWxW"> <field name="BOOL">TRUE</field> </block> </value> <next> <block type="telegram" id="nz:m?9M:5{Ae#O.7xCt0"> <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="l7ocSs3*W?V)l/EdBQ.!"> <field name="TEXT">Bewegung erkannt</field> </shadow> </value> </block> </next> </block> </next> </block> </statement> <statement name="ELSE"> <block type="timeouts_cleartimeout" id="48kyiz7c9o!iu:6.^{Vw"> <field name="NAME">timeout</field> <next> <block type="timeouts_settimeout" id="EWUG;n=f.[20rin0,hE9"> <field name="NAME">timeout</field> <field name="DELAY">5</field> <field name="UNIT">sec</field> <statement name="STATEMENT"> <block type="control" id="n,cWi0{qY;;2M`YgMX#."> <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation> <field name="OID">shelly.0.SHSW-1#F4CFA2D3A5F6#1.Relay0.Switch</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"> <block type="logic_boolean" id="/rl|kRWsx3,,oO79(wuR"> <field name="BOOL">FALSE</field> </block> </value> </block> </statement> </block> </next> </block> </statement> </block> </next> </block> </statement> </block> </xml>
und schau ob der debug Output beim Wechsel kommt
-
@Jan1
Mhhh, ich hab nix geändert und es geht nun. Kann es sein, dass beim ersten mal es NICHT geht ?
Mein Debug terminal unter Skripte schmiss da eine fehlermeldung raus aber nun geht es. Hier mal screenshot: oben Bewegung erkannt und unten Magnetventil auf:Zwei Fragen noch:
- Wie integriere ich einen Schalter ob dieses Szenario aktiv sein soll oder nicht ? Einfach oben in die Vorbedingung mit eintragen ?
- Kann ich noch was optimieren, wie du es schon gesagt hattest ?
-
@Segway
zu 1, ja einfach oben mit in die Bedingung, oder das Script ein und ausschalten
zu 2, schau mal mein Export an, da sind die Optimierungen bereits drin -
@Jan1
EY SUBBA !
Funktioniert einwandfreiJetzt hab ich aber doch noch eine Frage:
Was ist wenn die Bewegung länger als die 5 Sekunden erkannt wird, wo das Magnetventil geöffnet ist ? Muss ich das noch abfangen ?Muss hier die UND Beziehung rein:
-
@Segway
Da muss Dich ran tasten. Ich kenne den BWM nicht und weiß deshalb nicht wie der reagiert. Da kann man noch viel durch ne zusätzliche UND Verknüpfung abfangen. Das schaffst aber auch alleine