Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. Blockly
    5. Bewegungsmelder script

    NEWS

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    • Monatsrückblick - April 2025

    Bewegungsmelder script

    This topic has been deleted. Only users with topic management privileges can see it.
    • Michael Schmitt
      Michael Schmitt @Michael Schmitt last edited by

      var timeout;
      
      
      on({id: new RegExp('deconz\\.0\\.Sensors\\.10\\.presence' + "$|" + 'deconz\\.0\\.Sensors\\.12\\.presence' + "$"), change: "ne"}, async function (obj) {
          if ((getState("deconz.0.Sensors.10.presence").val == true || getState("deconz.0.Sensors.12.presence").val == true) && compareTime('16:00', '09:00', "between", null)) {
          setState("deconz.0.Lights.17.on"/*Flurlicht Telefon on*/, true);
          setState("deconz.0.Lights.17.level"/*Flurlicht Telefon level*/, 85);
          console.log('Bewegung im Flur erkannt und Licht ein');
          (function () {if (timeout) {clearTimeout(timeout); timeout = null;}})();
        } else {
          timeout = setTimeout(async function () {
            setState("deconz.0.Lights.17.on"/*Flurlicht Telefon on*/, false);
            console.log('Keine Bewegung im Flur erkannt und Licht aus');
          }, 180000);
        }
      });
      
      paul53 1 Reply Last reply Reply Quote 0
      • paul53
        paul53 @Michael Schmitt last edited by paul53

        @michael-schmitt
        Das sollte so funktionieren.

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

          @paul53 seit dem Neustart kommen auch nur noch "normale" Meldungen. Kann/soll man einen einen Neustart des Javascriptadapters per Cronjob machen (täglich einmal) ?

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

            @michael-schmitt sagte: Kann/soll man einen einen Neustart des Javascriptadapters per Cronjob machen (täglich einmal) ?

            Nein!
            Einen Instanz-Start sollte man machen, nachdem man ein fehlerhaftes Skript korrigiert hat, um evtl. vorhandene Timer-Puffer zu löschen.

            Michael Schmitt 2 Replies Last reply Reply Quote 1
            • Michael Schmitt
              Michael Schmitt @paul53 last edited by

              @paul53 dann wird das der Fehler gewesen sein, hoffe ich. Glaube nicht das ich das gemacht habe.

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

                Hallo,
                das Script läuft nun gut. Jetzt wollte ich noch daß die Lichter nicht an geschalten werden (zweite Lampe & Lüftung ist nicht Smart) wenn der Lux Wert über einen bestimmten Bereich ist, also wenn die Lampe&Lüftung schon an ist. Dann braucht man ja die anderen Lichter nicht.

                so läuft es jetzt
                alt.jpg

                und ich dachte mit Lux so (funktioniert aber nicht)
                neu.jpg

                Wo ist der Fehler ?

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

                  @michael-schmitt sagte: wenn der Lux Wert über einen bestimmten Bereich ist, also wenn die Lampe&Lüftung schon an ist.

                  Ist der Lux-Wert über 30, wenn die nicht smarte Lampe leuchtet?

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

                    @paul53 Ja der Wert ist auf über 80

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

                      @michael-schmitt sagte: der Wert ist auf über 80

                      Trotzdem schaltet die smarte Lampe bei Bewegung mit 60 % ein?

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

                        @paul53 ja

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

                          @michael-schmitt
                          Das kann laut Skript nicht sein, wenn der richtige Datenpunkt verglichen wird. Bau mal eine Debug-Ausgabe des Lux-Wertes ein.

                          Damit das Licht nicht bei Bewegung ausgeschaltet wird, wenn die smarte Lampe > 30 Lux erzeugt, mache es besser so:

                          Bild_2021-04-03_191054.png

                          Michael Schmitt 1 Reply Last reply Reply Quote 1
                          • Michael Schmitt
                            Michael Schmitt @paul53 last edited by

                            @paul53 So hab das mal umgebaut und anstatt der Luxwerte den Wert "daylight" genommen, der ändert sich bei Licht von false auf true. Scheint zu funktionieren
                            1.jpg

                            Michael Schmitt 1 Reply Last reply Reply Quote 0
                            • Michael Schmitt
                              Michael Schmitt @Michael Schmitt last edited by Michael Schmitt

                              Leider scheint das zu langsam zu reagieren. Sprich wenn man den Lichtschalter drückt, öffnet man ja fast gleichzeitig die Tür und der Wert braucht ca. 3-6 Sek bis er geändert ist.

                              Michael Schmitt 1 Reply Last reply Reply Quote 0
                              • Michael Schmitt
                                Michael Schmitt @Michael Schmitt last edited by

                                Hallo,
                                mein Script für den Flur (weiter oben im Thread) habe ich nun nochmal geändert und anstatt das nur zu bestimmten Zeiten zu steuern soll nun auch noch mit Lux gesteuert werden. Der Flur ist bei teilweise geschlossenen Zimmertüren recht dunkel. Das was ich nun habe sieht so aus, kann man da noch was optimieren/verbessern ?
                                flur.jpg

                                Michael Schmitt 1 Reply Last reply Reply Quote 1
                                • Michael Schmitt
                                  Michael Schmitt @Michael Schmitt last edited by

                                  Hallo,
                                  ich würde gerne mein Blockly dahingehend ändern, dass 30 Sekunden vor Ablauf des Timeouts (301Sek) das Licht ein wenig gedimmt wird. Damit man die Möglichkeit hat sich nochmal kurz zu bewegen, damit das Licht nicht ausgeht.

                                  <xml xmlns="https://developers.google.com/blockly/xml">
                                    <variables>
                                      <variable id="qrCfu6RSlbXJjjCPf/P-">manuell_ein</variable>
                                      <variable type="timeout" id="timeout">timeout</variable>
                                      <variable type="timeout" id="timeout2">timeout2</variable>
                                    </variables>
                                    <block type="on_ext" id="XZShE%!^7aSwliAf9~Rx" x="-137" y="-87">
                                      <mutation xmlns="http://www.w3.org/1999/xhtml" items="2"></mutation>
                                      <field name="CONDITION">ne</field>
                                      <field name="ACK_CONDITION"></field>
                                      <value name="OID0">
                                        <shadow type="field_oid" id="L{OHfK*J*RCS6SxTvn.W">
                                          <field name="oid">alias.0.Bewegungsmelder.BWM_Bad_1</field>
                                        </shadow>
                                      </value>
                                      <value name="OID1">
                                        <shadow type="field_oid" id="G/Yr4W}YyjpF]+|%z/EC">
                                          <field name="oid">alias.0.Bewegungsmelder.BWM_Bad_2</field>
                                        </shadow>
                                      </value>
                                      <statement name="STATEMENT">
                                        <block type="timeouts_cleartimeout" id="/RL0jba2]_3:HxV/l8Ew">
                                          <field name="NAME">timeout</field>
                                          <next>
                                            <block type="controls_if" id="Vwd`yH-?dfX(g?Yz#vYe">
                                              <value name="IF0">
                                                <block type="logic_negate" id=",LLLwoaashRhQLF/$id:">
                                                  <value name="BOOL">
                                                    <block type="variables_get" id="inbzB=3u.=59#v8Z=b=6">
                                                      <field name="VAR" id="qrCfu6RSlbXJjjCPf/P-">manuell_ein</field>
                                                    </block>
                                                  </value>
                                                </block>
                                              </value>
                                              <statement name="DO0">
                                                <block type="controls_if" id="e@LN;c0-3IiQ3mPlWpKL">
                                                  <mutation else="1"></mutation>
                                                  <value name="IF0">
                                                    <block type="logic_operation" id="8e(k771IWU7%#IjR{c5a" inline="false">
                                                      <field name="OP">AND</field>
                                                      <value name="A">
                                                        <block type="on_source" id="cRq(*e^$wwz39yls}{S-">
                                                          <field name="ATTR">state.val</field>
                                                        </block>
                                                      </value>
                                                      <value name="B">
                                                        <block type="logic_compare" id="*ZCE)GOz2,J$~hQIU5oz">
                                                          <field name="OP">LT</field>
                                                          <value name="A">
                                                            <block type="get_value" id="6wR+e).a1]VM%0Xi/8Wb">
                                                              <field name="ATTR">val</field>
                                                              <field name="OID">deconz.0.Sensors.53.lux</field>
                                                            </block>
                                                          </value>
                                                          <value name="B">
                                                            <block type="math_number" id=")WR61J+C}769J}O3dm]:">
                                                              <field name="NUM">20</field>
                                                            </block>
                                                          </value>
                                                        </block>
                                                      </value>
                                                    </block>
                                                  </value>
                                                  <statement name="DO0">
                                                    <block type="control" id="$XZ-=YslQG]u-p;EEF#U">
                                                      <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>
                                                      <field name="OID">deconz.0.Groups.8.on</field>
                                                      <field name="WITH_DELAY">FALSE</field>
                                                      <value name="VALUE">
                                                        <block type="logic_boolean" id="w~mMGbfeV-X~0!%vn`c.">
                                                          <field name="BOOL">TRUE</field>
                                                        </block>
                                                      </value>
                                                      <next>
                                                        <block type="control" id="*SPNj7{@=N{N%oO!3H~]">
                                                          <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>
                                                          <field name="OID">deconz.0.Groups.8.level</field>
                                                          <field name="WITH_DELAY">FALSE</field>
                                                          <value name="VALUE">
                                                            <block type="math_number" id="t}=aW)^Z`;h+qCZbF2XT">
                                                              <field name="NUM">60</field>
                                                            </block>
                                                          </value>
                                                          <next>
                                                            <block type="debug" id="/}Lh|M^gv9R|glZ_S1#S">
                                                              <field name="Severity">log</field>
                                                              <value name="TEXT">
                                                                <shadow type="text" id="Kjf7:mgncC3)9VTO/OC]">
                                                                  <field name="TEXT">Bewegung Bad erkannt und Licht ein</field>
                                                                </shadow>
                                                              </value>
                                                            </block>
                                                          </next>
                                                        </block>
                                                      </next>
                                                    </block>
                                                  </statement>
                                                  <statement name="ELSE">
                                                    <block type="timeouts_settimeout" id="yCutu!$pMQ|(uT+cjX(N">
                                                      <field name="NAME">timeout</field>
                                                      <field name="DELAY">301</field>
                                                      <field name="UNIT">sec</field>
                                                      <statement name="STATEMENT">
                                                        <block type="control" id="*^7bIYM3vHC69N7p1xbg">
                                                          <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>
                                                          <field name="OID">deconz.0.Groups.8.on</field>
                                                          <field name="WITH_DELAY">FALSE</field>
                                                          <value name="VALUE">
                                                            <block type="logic_boolean" id="qboY~;^nMM6jj;+3$MC/">
                                                              <field name="BOOL">FALSE</field>
                                                            </block>
                                                          </value>
                                                          <next>
                                                            <block type="debug" id="e?zC_:GX/.@u!`}SQ7P4">
                                                              <field name="Severity">log</field>
                                                              <value name="TEXT">
                                                                <shadow type="text" id="HfoKib*o7AG:EM$;dKxK">
                                                                  <field name="TEXT">Keine Bewegung Bad erkannt und Licht aus</field>
                                                                </shadow>
                                                              </value>
                                                            </block>
                                                          </next>
                                                        </block>
                                                      </statement>
                                                    </block>
                                                  </statement>
                                                </block>
                                              </statement>
                                            </block>
                                          </next>
                                        </block>
                                      </statement>
                                    </block>
                                    <block type="on_ext" id="6Ep1xYZhs;fE6{ULi%Jt" x="612" y="-87">
                                      <mutation xmlns="http://www.w3.org/1999/xhtml" items="2"></mutation>
                                      <field name="CONDITION">ne</field>
                                      <field name="ACK_CONDITION"></field>
                                      <value name="OID0">
                                        <shadow type="field_oid" id="AE4kvQEZVO!/B=Wlkv4T">
                                          <field name="oid">deconz.0.Sensors.33.buttonpressed</field>
                                        </shadow>
                                      </value>
                                      <value name="OID1">
                                        <shadow type="field_oid" id="La(|naQX?J|zf8Q^n5VV">
                                          <field name="oid">deconz.0.Sensors.43.buttonpressed</field>
                                        </shadow>
                                      </value>
                                      <statement name="STATEMENT">
                                        <block type="controls_if" id="Fkmp#,:[](:u|m1#rZ_M">
                                          <mutation elseif="1"></mutation>
                                          <value name="IF0">
                                            <block type="logic_compare" id="^)G:O?pb#Tbd271bURO$">
                                              <field name="OP">EQ</field>
                                              <value name="A">
                                                <block type="on_source" id="?6-BDA}x4o%Aln2|96fd">
                                                  <field name="ATTR">state.val</field>
                                                </block>
                                              </value>
                                              <value name="B">
                                                <block type="math_number" id="@%Ajr9?},raMKRV!(=/=">
                                                  <field name="NUM">1002</field>
                                                </block>
                                              </value>
                                            </block>
                                          </value>
                                          <statement name="DO0">
                                            <block type="variables_set" id="F{0JN,.1_g`wZWYrw.pR">
                                              <field name="VAR" id="qrCfu6RSlbXJjjCPf/P-">manuell_ein</field>
                                              <value name="VALUE">
                                                <block type="logic_boolean" id="*wTIZ1^W|{M;oGnj3Q0+">
                                                  <field name="BOOL">TRUE</field>
                                                </block>
                                              </value>
                                              <next>
                                                <block type="control" id="._;caH:!d941]JJqQ)Bq">
                                                  <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>
                                                  <field name="OID">deconz.0.Groups.8.on</field>
                                                  <field name="WITH_DELAY">FALSE</field>
                                                  <value name="VALUE">
                                                    <block type="logic_boolean" id="`16Y0trSNFT_B7k@{9BC">
                                                      <field name="BOOL">TRUE</field>
                                                    </block>
                                                  </value>
                                                  <next>
                                                    <block type="control" id="+aG3-VAYoW0pMMChPL1?">
                                                      <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>
                                                      <field name="OID">deconz.0.Groups.8.level</field>
                                                      <field name="WITH_DELAY">FALSE</field>
                                                      <value name="VALUE">
                                                        <block type="math_number" id="A3zgfihO$uonYS1s~`O=">
                                                          <field name="NUM">90</field>
                                                        </block>
                                                      </value>
                                                      <next>
                                                        <block type="debug" id="s27(YkT^AGc`83_%J3Zd">
                                                          <field name="Severity">log</field>
                                                          <value name="TEXT">
                                                            <shadow type="text" id="Q||#DNqJ/[9n5RS[6PP2">
                                                              <field name="TEXT">Bad Licht ein</field>
                                                            </shadow>
                                                          </value>
                                                          <next>
                                                            <block type="timeouts_cleartimeout" id="m:`.KX;MDj^|ED^4z4aW">
                                                              <field name="NAME">timeout2</field>
                                                              <next>
                                                                <block type="timeouts_settimeout" id="0:sb5p?!eZ!znzO[1(69">
                                                                  <field name="NAME">timeout2</field>
                                                                  <field name="DELAY">30</field>
                                                                  <field name="UNIT">min</field>
                                                                  <statement name="STATEMENT">
                                                                    <block type="variables_set" id="-s[lpxk5doij*w1,UvMA">
                                                                      <field name="VAR" id="qrCfu6RSlbXJjjCPf/P-">manuell_ein</field>
                                                                      <value name="VALUE">
                                                                        <block type="logic_boolean" id="w?GQqiy04Q492pLC(nU)">
                                                                          <field name="BOOL">FALSE</field>
                                                                        </block>
                                                                      </value>
                                                                      <next>
                                                                        <block type="control" id="sM[^@W|+zd]m9ARP?-gD">
                                                                          <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>
                                                                          <field name="OID">deconz.0.Groups.8.on</field>
                                                                          <field name="WITH_DELAY">FALSE</field>
                                                                          <value name="VALUE">
                                                                            <block type="logic_boolean" id="eD@WOW(a|3-0(ry1xknq">
                                                                              <field name="BOOL">FALSE</field>
                                                                            </block>
                                                                          </value>
                                                                          <next>
                                                                            <block type="debug" id="/4|EcQ]TynC4o+noB;3a">
                                                                              <field name="Severity">log</field>
                                                                              <value name="TEXT">
                                                                                <shadow type="text" id=";PqhWZ5LTye-)S}yNyT8">
                                                                                  <field name="TEXT">Bad Licht aus</field>
                                                                                </shadow>
                                                                              </value>
                                                                            </block>
                                                                          </next>
                                                                        </block>
                                                                      </next>
                                                                    </block>
                                                                  </statement>
                                                                </block>
                                                              </next>
                                                            </block>
                                                          </next>
                                                        </block>
                                                      </next>
                                                    </block>
                                                  </next>
                                                </block>
                                              </next>
                                            </block>
                                          </statement>
                                          <value name="IF1">
                                            <block type="logic_compare" id=";4#O$q`D[B#=f,^9NGI*">
                                              <field name="OP">EQ</field>
                                              <value name="A">
                                                <block type="on_source" id="H.t!a2Lu/rQwl^GKA1u#">
                                                  <field name="ATTR">state.val</field>
                                                </block>
                                              </value>
                                              <value name="B">
                                                <block type="math_number" id="YLPM8pOSPN|R3K2~Mfma">
                                                  <field name="NUM">2002</field>
                                                </block>
                                              </value>
                                            </block>
                                          </value>
                                          <statement name="DO1">
                                            <block type="variables_set" id="Gn_Ru)Jnrgbqz6q7oVxn">
                                              <field name="VAR" id="qrCfu6RSlbXJjjCPf/P-">manuell_ein</field>
                                              <value name="VALUE">
                                                <block type="logic_boolean" id="f-CJ_Jv6Vs%FG!m-1V_r">
                                                  <field name="BOOL">FALSE</field>
                                                </block>
                                              </value>
                                              <next>
                                                <block type="control" id="8rIG})y1{r`bWzJaxSfc">
                                                  <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>
                                                  <field name="OID">deconz.0.Groups.8.on</field>
                                                  <field name="WITH_DELAY">FALSE</field>
                                                  <value name="VALUE">
                                                    <block type="logic_boolean" id="kS1@UaWUS.|}:!En8EjD">
                                                      <field name="BOOL">FALSE</field>
                                                    </block>
                                                  </value>
                                                  <next>
                                                    <block type="debug" id="k)[PJ.|/R~/N#P#WB`Ix">
                                                      <field name="Severity">log</field>
                                                      <value name="TEXT">
                                                        <shadow type="text" id="]vzf`[9YDH~Mx(_k=!cT">
                                                          <field name="TEXT">Bad Licht aus</field>
                                                        </shadow>
                                                      </value>
                                                    </block>
                                                  </next>
                                                </block>
                                              </next>
                                            </block>
                                          </statement>
                                        </block>
                                      </statement>
                                    </block>
                                  </xml>
                                  
                                  paul53 1 Reply Last reply Reply Quote 0
                                  • paul53
                                    paul53 @Michael Schmitt last edited by

                                    @michael-schmitt sagte: 30 Sekunden vor Ablauf des Timeouts (301Sek) das Licht ein wenig gedimmt wird.

                                    Bild_2022-07-10_155448761.png

                                    Michael Schmitt 2 Replies Last reply Reply Quote 1
                                    • Michael Schmitt
                                      Michael Schmitt @paul53 last edited by

                                      @paul53 Danke läuft 👍

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

                                        @paul53 Hab mich zu früh gefreut. Wenn ich nun das Licht per Schalter manuell ausschalte, dann wird nachdem die Zeit abgelaufen ist das licht mit 40% eingeschalten und nach 30Sek ausgeschalten.

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

                                          @michael-schmitt
                                          Den zusätzlichen Timer-Stop hast Du oben eingebaut?

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

                                            @paul53 ja habe ich

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

                                            Support us

                                            ioBroker
                                            Community Adapters
                                            Donate

                                            857
                                            Online

                                            31.6k
                                            Users

                                            79.6k
                                            Topics

                                            1.3m
                                            Posts

                                            4
                                            84
                                            5368
                                            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