ioBroker - mehrere Xiaomi Bewegungsmelder - Blockly Skript

  • Hallo,

    in meinem Schlafzimmer befinden sich zwei Xiaomi Bewegungsmelder.

    Wenn ein Bewegungsmelder eine Bewegung erkennt, dann soll das Licht für 125 Sekunden angehen. Sollte innerhalb der 125 Sekunden der zweite Bewegungsmelder ebenfalls ausgelöst werden, dann soll der Timer wieder zurückgestellt werden und für weitere 125 Sekunden soll das Licht an bleiben.

    Leider klappt mein Skript nicht so ganz, die erste Auslösung ist kein Problem, das Licht bleibt dann für 125 Sekunden an und schaltet sich dann auch aus, löst dann aber der zweite Bewegungsmelder aus, funktioniert es nicht.

    Hat jemand einen Lösungsvorschlag?


    Und hier der Code aus dem ioBroker:

    Spoiler anzeigen

    <xml xmlns="https://developers.google.com/blockly/xml">

    <variables>

    <variable type="timeout" id="timeout">timeout</variable>

    <variable type="timeout" id="timeout2">timeout2</variable>

    </variables>

    <block type="on_ext" id="II(l-3pSZFj:(ZQrMO_R" x="-562" y="-137">

    <mutation xmlns="http://www.w3.org/1999/xhtml" items="1"></mutation>

    <field name="CONDITION">any</field>

    <field name="ACK_CONDITION"></field>

    <value name="OID0">

    <shadow type="field_oid" id="p*+%v}A%lm^bk]*hn5j~">

    <field name="oid">mihome.0.devices.sensor_motion_aq2_158d00054a78fd.state</field>

    </shadow>

    <block type="field_oid" id="nS~BG1FkbX=A+EeG4MR1">

    <field name="oid">mihome.0.devices.sensor_motion_aq2_158d00054a78fd.state</field>

    </block>

    </value>

    <statement name="STATEMENT">

    <block type="controls_if" id="155upG%6~0RrJ4EYmPT4">

    <value name="IF0">

    <block type="logic_operation" id="Vi,lXW_MucdpywZt4]L!">

    <field name="OP">AND</field>

    <value name="A">

    <block type="logic_compare" id="Ec$MxgB$oh)?Sn-c~Rh9">

    <field name="OP">EQ</field>

    <value name="A">

    <block type="logic_boolean" id="~?)f`z~3{o#r6dDGpM=~">

    <field name="BOOL">TRUE</field>

    </block>

    </value>

    <value name="B">

    <block type="get_value" id="[Lnt0f_otaboX?)x2:V!">

    <field name="ATTR">val</field>

    <field name="OID">mihome.0.devices.sensor_motion_aq2_158d00054a78fd.state</field>

    </block>

    </value>

    </block>

    </value>

    <value name="B">

    <block type="logic_compare" id="K57U=0Gkb55Aq-Wi!6.@">

    <field name="OP">LT</field>

    <value name="A">

    <block type="get_value" id="H9(xim1JaESjqpHpuPF.">

    <field name="ATTR">val</field>

    <field name="OID">mihome.0.devices.sensor_motion_aq2_158d00054a78fd.lux</field>

    </block>

    </value>

    <value name="B">

    <block type="math_number" id=";-lu:d}N`I}caZTD,Amd">

    <field name="NUM">7</field>

    </block>

    </value>

    </block>

    </value>

    </block>

    </value>

    <statement name="DO0">

    <block type="timeouts_cleartimeout" id="BZ0mlmZNq;=g[0/*C`=T">

    <field name="NAME">timeout</field>

    <next>

    <block type="control" id="q^R/wP^+Cjiw9O5,um7]">

    <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>

    <field name="OID">sonoff.0.Bettbeleuchtung.POWER</field>

    <field name="WITH_DELAY">FALSE</field>

    <value name="VALUE">

    <block type="logic_boolean" id="|F.V7J~6m6B6})Z@@S$Y">

    <field name="BOOL">TRUE</field>

    </block>

    </value>

    <next>

    <block type="control" id="WOR|DZHr1uht4r#)A$mf">

    <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>

    <field name="OID">sonoff.0.Bettbeleuchtung.Color</field>

    <field name="WITH_DELAY">FALSE</field>

    <value name="VALUE">

    <block type="text" id="cl.=%)%@/t*AT7Ty?.Gp">

    <field name="TEXT">#FAFF78</field>

    </block>

    </value>

    <next>

    <block type="timeouts_settimeout" id="vPE9]DplXO6x+o6Lq-c7">

    <field name="NAME">timeout</field>

    <field name="DELAY">125</field>

    <field name="UNIT">sec</field>

    <statement name="STATEMENT">

    <block type="control" id="mY^9]f-JlbSIby0G5m^l">

    <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>

    <field name="OID">sonoff.0.Bettbeleuchtung.POWER</field>

    <field name="WITH_DELAY">FALSE</field>

    <value name="VALUE">

    <block type="logic_boolean" id="H-(oEWhEVF+k7s]eSfo=">

    <field name="BOOL">FALSE</field>

    </block>

    </value>

    </block>

    </statement>

    </block>

    </next>

    </block>

    </next>

    </block>

    </next>

    </block>

    </statement>

    </block>

    </statement>

    <next>

    <block type="on_ext" id="F[E11Gqq|:[5YQB[Ebcw">

    <mutation xmlns="http://www.w3.org/1999/xhtml" items="1"></mutation>

    <field name="CONDITION">any</field>

    <field name="ACK_CONDITION"></field>

    <value name="OID0">

    <shadow type="field_oid">

    <field name="oid">mihome.0.devices.sensor_motion_aq2_158d00054a78fd.state</field>

    </shadow>

    <block type="field_oid" id="m0`*!{^Rp$`@eoJHNEz,">

    <field name="oid">mihome.0.devices.sensor_motion_aq2_158d00054a7778.state</field>

    </block>

    </value>

    <statement name="STATEMENT">

    <block type="controls_if" id="@+t`o`g@fY:kenD|@m4Z">

    <value name="IF0">

    <block type="logic_operation" id="//V[YdrjkqjYa28/XT}9">

    <field name="OP">AND</field>

    <value name="A">

    <block type="logic_compare" id="NPMt9gQ4Evp%qoSyj8mI">

    <field name="OP">EQ</field>

    <value name="A">

    <block type="logic_boolean" id="{NRM_L+X6=nCcJ2,9%6H">

    <field name="BOOL">TRUE</field>

    </block>

    </value>

    <value name="B">

    <block type="get_value" id="-m3]wmF{q`!|qF^G^;7N">

    <field name="ATTR">val</field>

    <field name="OID">mihome.0.devices.sensor_motion_aq2_158d00054a7778.state</field>

    </block>

    </value>

    </block>

    </value>

    <value name="B">

    <block type="logic_compare" id="Zhscns,!T6IrD+@g[U*_">

    <field name="OP">LT</field>

    <value name="A">

    <block type="get_value" id="lATODmS+:t2p,!g2]c/;">

    <field name="ATTR">val</field>

    <field name="OID">mihome.0.devices.sensor_motion_aq2_158d00054a78fd.lux</field>

    </block>

    </value>

    <value name="B">

    <block type="math_number" id="+n?G_h$aDDm!;(e6rF04">

    <field name="NUM">7</field>

    </block>

    </value>

    </block>

    </value>

    </block>

    </value>

    <statement name="DO0">

    <block type="timeouts_cleartimeout" id="cz]l`Qm+ESGY-,^W}~M`">

    <field name="NAME">timeout</field>

    <next>

    <block type="control" id="g25;SwmMLcQwUKJq5F^L">

    <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>

    <field name="OID">sonoff.0.Bettbeleuchtung.POWER</field>

    <field name="WITH_DELAY">FALSE</field>

    <value name="VALUE">

    <block type="logic_boolean" id="EG_qF?!mHsTB}k0|z;F5">

    <field name="BOOL">TRUE</field>

    </block>

    </value>

    <next>

    <block type="control" id="3GwLjUoG)q!P,$TLnS{^">

    <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>

    <field name="OID">sonoff.0.Bettbeleuchtung.Color</field>

    <field name="WITH_DELAY">FALSE</field>

    <value name="VALUE">

    <block type="text" id="L/;E0.l*zs;r(5|@#g;X">

    <field name="TEXT">#FAFF78</field>

    </block>

    </value>

    <next>

    <block type="timeouts_settimeout" id="B9)1@rMqlqz*/JUxR4B8">

    <field name="NAME">timeout2</field>

    <field name="DELAY">125</field>

    <field name="UNIT">sec</field>

    <statement name="STATEMENT">

    <block type="control" id="+nL@|O(Fg-#UHG#)i[Q%">

    <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>

    <field name="OID">sonoff.0.Bettbeleuchtung.POWER</field>

    <field name="WITH_DELAY">FALSE</field>

    <value name="VALUE">

    <block type="logic_boolean" id="pCaC.f|c3YUwQ?R]ZGjM">

    <field name="BOOL">FALSE</field>

    </block>

    </value>

    </block>

    </statement>

    </block>

    </next>

    </block>

    </next>

    </block>

    </next>

    </block>

    </statement>

    </block>

    </statement>

    </block>

    </next>

    </block>

    </xml>

  • was genau funktioniert denn nicht? Schaltet der 2te BWM nicht an oder geht dann das Licht gar nicht mehr aus?

    Erstmal brauchst du nicht 2 "falls"-Blöcke...

    klick mal oben auf das blaue Zahnrad vor dem "falls", da kannst du auch mehrere Datenpunkte als trigger hinterlegen.

    außerdem hast du unten ein "timeout2" im "ausführen"-Block. die "2" muss da auf jeden Fall weg.

    Ich würde es so machen...

    kanns natürlich (mangels Bewegunsmeldern) nicht testen...

    Hier der Code.

    Spoiler anzeigen

    <xml xmlns="https://developers.google.com/blockly/xml">

    <variables>

    <variable type="timeout" id="timeout">timeout</variable>

    </variables>

    <block type="on_ext" id="II(l-3pSZFj:(ZQrMO_R" x="-562" y="-137">

    <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="p*+%v}A%lm^bk]*hn5j~">

    <field name="oid">mihome.0.devices.sensor_motion_aq2_158d00054a78fd.state</field>

    </shadow>

    <block type="field_oid" id="nS~BG1FkbX=A+EeG4MR1">

    <field name="oid">mihome.0.devices.sensor_motion_aq2_158d00054a78fd.state</field>

    </block>

    </value>

    <value name="OID1">

    <shadow type="field_oid" id="#$)H8*UWVi0$gq0BLu;A">

    <field name="oid">default</field>

    </shadow>

    <block type="field_oid" id="m0`*!{^Rp$`@eoJHNEz,">

    <field name="oid">mihome.0.devices.sensor_motion_aq2_158d00054a7778.state</field>

    </block>

    </value>

    <statement name="STATEMENT">

    <block type="controls_if" id="155upG%6~0RrJ4EYmPT4">

    <value name="IF0">

    <block type="logic_operation" id="Vi,lXW_MucdpywZt4]L!" inline="false">

    <field name="OP">AND</field>

    <value name="A">

    <block type="logic_compare" id="K57U=0Gkb55Aq-Wi!6.@">

    <field name="OP">LT</field>

    <value name="A">

    <block type="get_value" id="H9(xim1JaESjqpHpuPF.">

    <field name="ATTR">val</field>

    <field name="OID">mihome.0.devices.sensor_motion_aq2_158d00054a78fd.lux</field>

    </block>

    </value>

    <value name="B">

    <block type="math_number" id=";-lu:d}N`I}caZTD,Amd">

    <field name="NUM">7</field>

    </block>

    </value>

    </block>

    </value>

    <value name="B">

    <block type="logic_operation" id="//V[YdrjkqjYa28/XT}9" inline="false">

    <field name="OP">OR</field>

    <value name="A">

    <block type="logic_compare" id="NPMt9gQ4Evp%qoSyj8mI">

    <field name="OP">EQ</field>

    <value name="A">

    <block type="get_value" id="-m3]wmF{q`!|qF^G^;7N">

    <field name="ATTR">val</field>

    <field name="OID">mihome.0.devices.sensor_motion_aq2_158d00054a7778.state</field>

    </block>

    </value>

    <value name="B">

    <block type="logic_boolean" id="{NRM_L+X6=nCcJ2,9%6H">

    <field name="BOOL">TRUE</field>

    </block>

    </value>

    </block>

    </value>

    <value name="B">

    <block type="logic_compare" id="0?|_2|(Z=a4u0nR%,sRe">

    <field name="OP">EQ</field>

    <value name="A">

    <block type="get_value" id=".;hE#f#75^I{j3}DgJO(">

    <field name="ATTR">val</field>

    <field name="OID">mihome.0.devices.sensor_motion_aq2_158d00054a78fd.state</field>

    </block>

    </value>

    <value name="B">

    <block type="logic_boolean" id="f]9We:Jcwwtc7ewP6XL)">

    <field name="BOOL">TRUE</field>

    </block>

    </value>

    </block>

    </value>

    </block>

    </value>

    </block>

    </value>

    <statement name="DO0">

    <block type="timeouts_cleartimeout" id="BZ0mlmZNq;=g[0/*C`=T">

    <field name="NAME">timeout</field>

    <next>

    <block type="control" id="q^R/wP^+Cjiw9O5,um7]">

    <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>

    <field name="OID">sonoff.0.Bettbeleuchtung.POWER</field>

    <field name="WITH_DELAY">FALSE</field>

    <value name="VALUE">

    <block type="logic_boolean" id="|F.V7J~6m6B6})Z@@S$Y">

    <field name="BOOL">TRUE</field>

    </block>

    </value>

    <next>

    <block type="control" id="WOR|DZHr1uht4r#)A$mf">

    <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>

    <field name="OID">sonoff.0.Bettbeleuchtung.Color</field>

    <field name="WITH_DELAY">FALSE</field>

    <value name="VALUE">

    <block type="text" id="cl.=%)%@/t*AT7Ty?.Gp">

    <field name="TEXT">#FAFF78</field>

    </block>

    </value>

    <next>

    <block type="timeouts_settimeout" id="vPE9]DplXO6x+o6Lq-c7">

    <field name="NAME">timeout</field>

    <field name="DELAY">125</field>

    <field name="UNIT">sec</field>

    <statement name="STATEMENT">

    <block type="control" id="mY^9]f-JlbSIby0G5m^l">

    <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>

    <field name="OID">sonoff.0.Bettbeleuchtung.POWER</field>

    <field name="WITH_DELAY">FALSE</field>

    <value name="VALUE">

    <block type="logic_boolean" id="H-(oEWhEVF+k7s]eSfo=">

    <field name="BOOL">FALSE</field>

    </block>

    </value>

    </block>

    </statement>

    </block>

    </next>

    </block>

    </next>

    </block>

    </next>

    </block>

    </statement>

    </block>

    </statement>

    </block>

    </xml>

    --- Signaturen werden völlig überbewertet --- X/

  • Supermicha

    danke für deinen Beitrag.


    Derzeit ist es so, dass der 1. Bewegungsmelder auslöst und das Licht geht nach 125 Sek. wieder aus.

    Löst der 2. Bewegungsmelder aber nach ca. 100 Sek. aus, dann ist das Licht trotzdem nach den ersten 125 Sek. wieder aus, also es bleibt dann nur 25 Sekunden an und startet nicht von vorne.

    Wenn der 1. Bewegungsmelder nach 125 Sek. abschaltet und direkt danach der 2. auslöst, dann bleibt das Licht aus.

    Ich werde deinen Code mal testen und melde mich dann.

    Danke.

  • Mit den Timeout-Schleifen habe ich mich auch schon rumgeärgert. Versuch doch mal was ganz anderes:

    Auf dem Sonoff der die Leuchte schaltet ist ja wahrscheinlich Tasmota installiert.

    Das Ausschalten lässt Du daher nicht über die Blockly-Routine machen sondern den Sonoff selbst übernehmen:

    Dazu in der Console "PulseTime1 225" einstellen (100 Offset plus Deine 125 Sek.)

    Mit jedem PowerOn startet PulseTime auf's neue, egal welcher Bewegungsmelder das initiiert.

    Aber aufpassen: wahrscheinlich muss aber "Falls Objekt" "wurde geändert" auf "wurde aktualisiert" umgestellt werden.