@jb37
Was mir bei deinem Script auffällt:
der dritte "falls" Block da prüfst du ob die Deckenlampe an ist, dabei hast du sie im Block davor schon angeschalten. Dieser Abschnitt wird also immer ausgeführt.
du prüfst auf "anwesend = falsch" allerdings wurde die Variable vorher nicht vorbelegt das kann zu Fehlern führen da du in diesem Moment nicht weißt ob sie falsch oder wahr ist.
mehr hab ich noch nicht angeschaut.
Hier ist mein Script vom Flur, da sind mehrere Türen die abgehen. Wenn eine Tür geöffnet wird geht das Licht an, erkennt der Bewegungsmelder was geht das Licht auch an. So lange der Bewegungsmelder was erkennt geht das Licht nicht aus.
Das Licht geht nur an wenn die Helligkeit im Flur unter 100 Lux ist und in zwei bestimmten Zeitslots. Ansonsten geht das Licht aus wenn 2 Minuten nichts mehr erkannt wird.
<xml xmlns="https://developers.google.com/blockly/xml">
<variables>
<variable type="timeout" id="timeout">timeout</variable>
</variables>
<block type="comment" id="24WBt~:i2zGn9:^KBRSt" x="-313" y="-138">
<field name="COMMENT">Türen</field>
<next>
<block type="on_ext" id="1t?n./2g#;fDu7E%U(ju">
<mutation xmlns="http://www.w3.org/1999/xhtml" items="5"></mutation>
<field name="CONDITION">gt</field>
<field name="ACK_CONDITION"></field>
<value name="OID0">
<shadow type="field_oid" id="t}+0OPJU%H/kC13Eh_94">
<field name="oid">deconz.0.Sensors.00158d0002bff095.open</field>
</shadow>
</value>
<value name="OID1">
<shadow type="field_oid" id="`=)joAfpFR*bJkN,F{7o">
<field name="oid">deconz.0.Sensors.00158d0002ecefee.open</field>
</shadow>
</value>
<value name="OID2">
<shadow type="field_oid" id="tD,r#t6f?=sV-Ui|hp$@">
<field name="oid">deconz.0.Sensors.00158d0002e738ae.open</field>
</shadow>
</value>
<value name="OID3">
<shadow type="field_oid" id="eDD]7D19UzlbQwCFw~oP">
<field name="oid">deconz.0.Sensors.00158d000313af12.open</field>
</shadow>
</value>
<value name="OID4">
<shadow type="field_oid" id="1TaDX!6,q+J3tgKyN1IG">
<field name="oid">deconz.0.Sensors.00158d0003120d31.open</field>
</shadow>
</value>
<statement name="STATEMENT">
<block type="timeouts_cleartimeout" id="G}T3d5/tTCZArHquVV[k">
<field name="NAME">timeout</field>
<next>
<block type="procedures_callnoreturn" id="M{F9f-du:dPI{T3:m.uq">
<mutation name="LichtEin"></mutation>
</block>
</next>
</block>
</statement>
<next>
<block type="comment" id=":[3WVwf9a/GV:C)8{?g[">
<field name="COMMENT">Bewegungsmelder</field>
<next>
<block type="on" id="id7(?96)l,-6OwK`LwW@">
<field name="OID">deconz.0.Sensors.00158d0002d43d4b.presence</field>
<field name="CONDITION">any</field>
<field name="ACK_CONDITION"></field>
<statement name="STATEMENT">
<block type="timeouts_cleartimeout" id="BT=mGNUd~mWHF+kl#11U">
<field name="NAME">timeout</field>
<next>
<block type="controls_if" id="(Ce+%mE-HRR6O$gb~Sls">
<mutation elseif="1"></mutation>
<value name="IF0">
<block type="logic_compare" id="K10cGU-t%TNXu+@J%*?M">
<field name="OP">EQ</field>
<value name="A">
<block type="get_value" id=",yc4^XLr2U5?+^YgrR!T">
<field name="ATTR">val</field>
<field name="OID">deconz.0.Sensors.00158d0002d43d4b.presence</field>
</block>
</value>
<value name="B">
<block type="logic_boolean" id="~:dFe}Yb7^;/SF6Bh=+4">
<field name="BOOL">TRUE</field>
</block>
</value>
</block>
</value>
<statement name="DO0">
<block type="procedures_callnoreturn" id="#fz;`L9%Yp=E3:sYSlm@">
<mutation name="LichtEin"></mutation>
</block>
</statement>
<value name="IF1">
<block type="logic_compare" id="HSI.+K:-sG9.A4OI__=U">
<field name="OP">EQ</field>
<value name="A">
<block type="get_value" id="WU+UP~d:ISVWl_|~hG4S">
<field name="ATTR">val</field>
<field name="OID">deconz.0.Sensors.00158d0002d43d4b.presence</field>
</block>
</value>
<value name="B">
<block type="logic_boolean" id="f5YF`[jqGQt8pl40N)_(">
<field name="BOOL">FALSE</field>
</block>
</value>
</block>
</value>
<statement name="DO1">
<block type="procedures_callnoreturn" id="Rk$$~)GZm%whvB0e~H*1">
<mutation name="LichtAus"></mutation>
</block>
</statement>
</block>
</next>
</block>
</statement>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
<block type="procedures_defnoreturn" id="9T}@DOgWdP.GEALkAk9X" x="-312" y="513">
<field name="NAME">LichtEin</field>
<comment pinned="false" h="80" w="160">Beschreibe diese Funktion …</comment>
<statement name="STACK">
<block type="controls_if" id="TUiz]p4B[pD~gN|{F,7l">
<mutation elseif="1"></mutation>
<value name="IF0">
<block type="logic_operation" id="z)^!=0I4q:WWFunj9ygd" inline="false">
<field name="OP">AND</field>
<value name="A">
<block type="logic_operation" id="u9RjU|a}*28mOj,tG-,;" inline="false">
<field name="OP">OR</field>
<value name="A">
<block type="time_compare" id="EB/~V-z]tuo|2tBR1POk">
<mutation xmlns="http://www.w3.org/1999/xhtml" end_time="true"></mutation>
<field name="OPTION">between</field>
<field name="START_TIME">05:30</field>
<field name="END_TIME">08:00</field>
</block>
</value>
<value name="B">
<block type="time_compare" id="?A#F7RpvVmXm@wr2vtM#">
<mutation xmlns="http://www.w3.org/1999/xhtml" end_time="true"></mutation>
<field name="OPTION">between</field>
<field name="START_TIME">16:00</field>
<field name="END_TIME">22:00</field>
</block>
</value>
</block>
</value>
<value name="B">
<block type="logic_compare" id="/:RA=ZP,R-2e..{3,2w.">
<field name="OP">LT</field>
<value name="A">
<block type="convert_tonumber" id="fnaSHiPMg%;ZZ;ruJvha">
<value name="VALUE">
<block type="get_value" id="vOakpERq;jq0]}8?8cYj">
<field name="ATTR">val</field>
<field name="OID">deconz.0.Sensors.00158d0002d43d4b.lux</field>
</block>
</value>
</block>
</value>
<value name="B">
<block type="math_number" id="ZI9GGUFaWh70Ugqu$ecj">
<field name="NUM">100</field>
</block>
</value>
</block>
</value>
</block>
</value>
<statement name="DO0">
<block type="control" id="?JHRF*ODZl%XZq4mm,p.">
<mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>
<field name="OID">deconz.0.Groups.1.on</field>
<field name="WITH_DELAY">FALSE</field>
<value name="VALUE">
<block type="logic_boolean" id="yIyhYREzaTVt@V,{NcX3">
<field name="BOOL">TRUE</field>
</block>
</value>
<next>
<block type="procedures_callnoreturn" id="Y1=H.H,.}}n{w]zW[KBU">
<mutation name="LichtAus"></mutation>
</block>
</next>
</block>
</statement>
<value name="IF1">
<block type="logic_compare" id="!r(rbS19ouJh-nd0c$5l">
<field name="OP">LT</field>
<value name="A">
<block type="convert_tonumber" id="]1#.1vzepNm!*~@qOnGw">
<value name="VALUE">
<block type="get_value" id="{93H-SI[.RQPdgM^z`ax">
<field name="ATTR">val</field>
<field name="OID">deconz.0.Sensors.00158d0002d43d4b.lux</field>
</block>
</value>
</block>
</value>
<value name="B">
<block type="math_number" id="/kevQ]0S22MIC|egbz*-">
<field name="NUM">100</field>
</block>
</value>
</block>
</value>
<statement name="DO1">
<block type="control" id="0|F*{PWMY]s7K;kuh)]~">
<mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>
<field name="OID">deconz.0.Lights.00124b001d3aaae6.on</field>
<field name="WITH_DELAY">FALSE</field>
<value name="VALUE">
<block type="logic_boolean" id="6ddypsl^ZMfdfP,okh}=">
<field name="BOOL">TRUE</field>
</block>
</value>
<next>
<block type="procedures_callnoreturn" id="1gYte?9]y%7X7y]L^Fl!">
<mutation name="LichtAus"></mutation>
</block>
</next>
</block>
</statement>
</block>
</statement>
</block>
<block type="procedures_defnoreturn" id="r(epVeh_IflZ$Y!a`,Y4" x="-312" y="863">
<field name="NAME">LichtAus</field>
<comment pinned="false" h="80" w="160">Beschreibe diese Funktion …</comment>
<statement name="STACK">
<block type="timeouts_settimeout" id="ueQ0=sPHwCIOWe%z?#59">
<field name="NAME">timeout</field>
<field name="DELAY">2</field>
<field name="UNIT">min</field>
<statement name="STATEMENT">
<block type="control" id="LlC{;8$bl[Xl$9+gJS!p">
<mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>
<field name="OID">deconz.0.Groups.1.on</field>
<field name="WITH_DELAY">FALSE</field>
<value name="VALUE">
<block type="logic_boolean" id="O#NeHQmE;/l)(#M/ieLa">
<field name="BOOL">FALSE</field>
</block>
</value>
<next>
<block type="control" id="4{*V]GX:R)![Gg|dohJy">
<mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>
<field name="OID">deconz.0.Lights.00124b001d3aaae6.on</field>
<field name="WITH_DELAY">FALSE</field>
<value name="VALUE">
<block type="logic_boolean" id=":sfjf-f4rWYA2F4j0Xy#">
<field name="BOOL">FALSE</field>
</block>
</value>
</block>
</next>
</block>
</statement>
</block>
</statement>
</block>
</xml>