IOBroker automatisch Licht Ein/Aus

IOBroker automatisch Licht Ein/Aus

In IOBroker gibt es nahezu grenzenlose Möglichkeiten, eine Möglichkeit ist in diesem Fall das Licht automatisch ein und auszuschalten in diesem Fall benutze ich, als Bewegungsinformation einen Xiaomi Aqara Bewegungsmelder dieser hat die Eigenschaft: Ist eine Bewegung erkannt worden muss man ca. 60 sec warten damit dieser erneut eine Bewegung erkennen kann aufheben lässt sich das, nur wenn man auf den Knopf drückt der Modus bewirkt Bewegung im Sekunden Takt, als Einschränkung gilt, bewegt sich innerhalb von einer stunde nichts, geht der Bewegungsmelder wieder in Energiesparmodus.

<xml xmlns="http://www.w3.org/1999/xhtml">
  <variables>
    <variable type="undefined" id="timeout">timeout</variable>
  </variables>
  <block type="on_ext" id="0t?aYneZ:k$H}9s_Ks7T" x="113" y="38">
    <mutation items="1"></mutation>
    <field name="CONDITION">any</field>
    <field name="ACK_CONDITION"></field>
    <value name="OID0">
      <shadow type="field_oid" id="E5!`Fn{*kbH%FB=b9b*S">
        <field name="oid">zigbee.0.00158d0002fd5693.occupancy</field>
      </shadow>
    </value>
    <statement name="STATEMENT">
      <block type="timeouts_cleartimeout" id="ENqMipoL=I(GU.~O)3SJ">
        <field name="NAME">timeout</field>
        <next>
          <block type="control" id="k41?5RQTpmd-QL0;b2fF">
            <mutation delay_input="false"></mutation>
            <field name="OID">sonoff.0.Sonoff-S20-4.POWER</field>
            <field name="WITH_DELAY">FALSE</field>
            <value name="VALUE">
              <block type="logic_boolean" id="roqL,{7tP_VwO;dZzu1(">
                <field name="BOOL">TRUE</field>
              </block>
            </value>
            <next>
              <block type="control" id="!=2mCq]c%c7j{Q.aeFio">
                <mutation delay_input="false"></mutation>
                <field name="OID">sonoff.0.Sonoff-S20-5.POWER</field>
                <field name="WITH_DELAY">FALSE</field>
                <value name="VALUE">
                  <block type="logic_boolean" id="GQL6D=Y=oY{ml|[(Gw]I">
                    <field name="BOOL">TRUE</field>
                  </block>
                </value>
                <next>
                  <block type="timeouts_settimeout" id="Cr..m^+jv(81lHd+1GhI">
                    <field name="NAME">timeout</field>
                    <field name="DELAY">180</field>
                    <field name="UNIT">sec</field>
                    <statement name="STATEMENT">
                      <block type="control" id="YoUieB6_)Yqrpq*h;n,`">
                        <mutation delay_input="false"></mutation>
                        <field name="OID">sonoff.0.Sonoff-S20-4.POWER</field>
                        <field name="WITH_DELAY">FALSE</field>
                        <value name="VALUE">
                          <block type="logic_boolean" id="0YMn21HQFTvI~M}C|8Iy">
                            <field name="BOOL">FALSE</field>
                          </block>
                        </value>
                        <next>
                          <block type="control" id="kHG{W[VMnOH.f-I?(7%T">
                            <mutation delay_input="false"></mutation>
                            <field name="OID">sonoff.0.Sonoff-S20-5.POWER</field>
                            <field name="WITH_DELAY">FALSE</field>
                            <value name="VALUE">
                              <block type="logic_boolean" id="0LLzHD`C4#j]a:{6@3lz">
                                <field name="BOOL">FALSE</field>
                              </block>
                            </value>
                          </block>
                        </next>
                      </block>
                    </statement>
                  </block>
                </next>
              </block>
            </next>
          </block>
        </next>
      </block>
    </statement>
  </block>
</xml>

Code aufbau

  • Bewegung wurde erkannt
  • Stobt Timer (Falls einer schon Läuft)
  • Schaltet die Geräte mit wahr an
  • Nach 180 Sek gehen die Geräte wieder aus wen keine Bewegung vorhanden ist

Als weitere Möglichkeit gibt es das Licht erst anzuschalten, wenn es dunkel ist

<xml xmlns="http://www.w3.org/1999/xhtml">
  <variables>
    <variable type="undefined" id="timeout">timeout</variable>
    <variable type="undefined" id="timeout2">timeout2</variable>
  </variables>
  <block type="on_ext" id="01a;TBRc~`$~ZE0Q.vQ{" x="113" y="63">
    <mutation items="1"></mutation>
    <field name="CONDITION">any</field>
    <field name="ACK_CONDITION"></field>
    <value name="OID0">
      <shadow type="field_oid" id="]INtcOT%M~Ijbf3TF]|1">
        <field name="oid">zigbee.0.00158d00032c1351.occupancy</field>
      </shadow>
    </value>
    <statement name="STATEMENT">
      <block type="controls_if" id="tr(_BtiQoThICxP4W5li">
        <mutation elseif="1"></mutation>
        <value name="IF0">
          <block type="time_compare_ex" id="xkn^8GsL;7#]TBd]^G*o">
            <mutation end_time="true" actual_time="true"></mutation>
            <field name="USE_ACTUAL_TIME">TRUE</field>
            <field name="OPTION">between</field>
            <value name="START_TIME">
              <shadow type="text" id="RpKFd8?oK)DDp5-:]A~G">
                <field name="TEXT">22:00</field>
              </shadow>
            </value>
            <value name="END_TIME">
              <shadow type="text" id="Af86BDcMQ@/UH|i.kg8B">
                <field name="TEXT">6:00</field>
              </shadow>
            </value>
          </block>
        </value>
        <statement name="DO0">
          <block type="timeouts_cleartimeout" id="}(..P`.Jiki--mu|F_gM">
            <field name="NAME">timeout</field>
            <next>
              <block type="control" id="F/}Pkscq@?/-%)-Q@ni6">
                <mutation delay_input="false"></mutation>
                <field name="OID">zigbee.0.001788010410a637.brightness</field>
                <field name="WITH_DELAY">FALSE</field>
                <value name="VALUE">
                  <block type="math_number" id="jlJ*I^O_X~m0Mmo2vxR8">
                    <field name="NUM">20</field>
                  </block>
                </value>
                <next>
                  <block type="timeouts_settimeout" id="K$g$XQ3%#)a,wHC+B(k-">
                    <field name="NAME">timeout</field>
                    <field name="DELAY">65</field>
                    <field name="UNIT">sec</field>
                    <statement name="STATEMENT">
                      <block type="control" id="F3v.6@}wUs^hf5^pFO`K">
                        <mutation delay_input="false"></mutation>
                        <field name="OID">zigbee.0.001788010410a637.brightness</field>
                        <field name="WITH_DELAY">FALSE</field>
                        <value name="VALUE">
                          <block type="logic_boolean" id="i{A^`esPA]^TpL8v1SoT">
                            <field name="BOOL">FALSE</field>
                          </block>
                        </value>
                      </block>
                    </statement>
                  </block>
                </next>
              </block>
            </next>
          </block>
        </statement>
        <value name="IF1">
          <block type="time_compare_ex" id="6s[;QbRCy]=oat?Elds(">
            <mutation end_time="true" actual_time="true"></mutation>
            <field name="USE_ACTUAL_TIME">TRUE</field>
            <field name="OPTION">between</field>
            <value name="START_TIME">
              <shadow type="text" id="uhM?qM!H/J~3Us)QD7X1">
                <field name="TEXT">6:01</field>
              </shadow>
            </value>
            <value name="END_TIME">
              <shadow type="text" id="4h8`U%z_+W`8QV1a=G@:">
                <field name="TEXT">21:59</field>
              </shadow>
            </value>
          </block>
        </value>
        <statement name="DO1">
          <block type="controls_if" id="?v.=@frmYLO7,HY[3-C?">
            <value name="IF0">
              <block type="logic_compare" id="+otCIJlWV3)s~?mhMr9j">
                <field name="OP">LT</field>
                <value name="A">
                  <block type="convert_tonumber" id="ZCqOukl35~{cFGKkWnDj">
                    <value name="VALUE">
                      <block type="get_value" id="}eC,eNSS:Yh:7xek2!8+">
                        <field name="ATTR">val</field>
                        <field name="OID">zigbee.0.00158d00032c1351.illuminance</field>
                      </block>
                    </value>
                  </block>
                </value>
                <value name="B">
                  <block type="math_number" id="R]CAFeJQ,#I8w`cSR6zG">
                    <field name="NUM">40</field>
                  </block>
                </value>
              </block>
            </value>
            <statement name="DO0">
              <block type="timeouts_cleartimeout" id="#[-r6yz|ArQ4?{ndZ6~(">
                <field name="NAME">timeout2</field>
                <next>
                  <block type="control" id="6BhZW[-=Ym%wU*MY,A2i">
                    <mutation delay_input="false"></mutation>
                    <field name="OID">zigbee.0.001788010410a637.brightness</field>
                    <field name="WITH_DELAY">FALSE</field>
                    <value name="VALUE">
                      <block type="math_number" id="P^^LuT;h!Ogid02QB](!">
                        <field name="NUM">100</field>
                      </block>
                    </value>
                    <next>
                      <block type="timeouts_settimeout" id="~OZRNXi|wR3[fKVITVV1">
                        <field name="NAME">timeout2</field>
                        <field name="DELAY">65</field>
                        <field name="UNIT">sec</field>
                        <statement name="STATEMENT">
                          <block type="control" id="r?Y_g+pxuOJ?5yQ]!KiR">
                            <mutation delay_input="false"></mutation>
                            <field name="OID">zigbee.0.001788010410a637.brightness</field>
                            <field name="WITH_DELAY">FALSE</field>
                            <value name="VALUE">
                              <block type="logic_boolean" id="Kzi8).vwh+%OSubDO0,X">
                                <field name="BOOL">FALSE</field>
                              </block>
                            </value>
                          </block>
                        </statement>
                      </block>
                    </next>
                  </block>
                </next>
              </block>
            </statement>
          </block>
        </statement>
      </block>
    </statement>
  </block>
</xml>

Code Aufbau

  • Bewegung wurde erkannt
  • Es wird geprüft, ob es zwischen 22Uhr und 6Uhr ist
  • Wenn es in diesem Zeitraum ist der Ablauf wie oben genannt
  • Außerhalb des Zeitraums
  • wird zusätzlich geprüft, ob es außerhalb des Zeitraums ist
  • Danach wird geprüft, ob es dunkler als 40 Lux ist