Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. Blockly
    5. Blockly Küchenbeleuchtung mit Optimierungsbedarf

    NEWS

    • Wir empfehlen: Node.js 22.x

    • Neuer Blog: Fotos und Eindrücke aus Solingen

    • ioBroker goes Matter ... Matter Adapter in Stable

    Blockly Küchenbeleuchtung mit Optimierungsbedarf

    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      smarthome2020 last edited by smarthome2020

      Hi Leute,

      das unten angefügte Skript funktioniert an sich gut. Nur, wenn ich den Mini-PC vom Strom nehme/neu boote, dann geht die Küchenbeleuchtung über den Bewegungsmelder erst dann wieder, wenn ich den Datenpunkt "Küchenbeleuchtung" einmal auf "an" und dann auf "aus" stelle. Das ist bisschen nervig.
      Nun könnte ich nach Neustart ein Blockly laufen lassen, dass den Datenpunkt einmalig an und aus schaltet. Mich würde aber interessieren, ob es nicht auch eleganter geht?

      Zum Verständnis: Ich lasse die Beleuchtung über einen BWM einschalten, da dieser schneller ist als der Präsenzmelder über Radar. Die Anwesenheit wird allerdings dann über das Radar festgestellt und die Beleuchtung entsprechend lange angelassen. Für den Fall, dass man in einer Ecke der Küche arbeitet, die nicht gut abgedeckt ist vom Radar, kann man die Beleuchtung über "Küchenbeleuchtung" auch fest einschalten. Das funktioniert alles an sich tiptop, so dass sogar der WAF bei 100% liegt (woman accepting factor xD).

      Hier das Blockly:

      <xml xmlns="https://developers.google.com/blockly/xml">
        <variables>
          <variable id="4fKH0Ly6T)rDvJ(eYvP=">manuell</variable>
          <variable type="timeout" id="timeout">timeout</variable>
        </variables>
        <block type="on_ext" id="mxpD+]oy|IzOmt}:+zx|" x="538" y="-713">
          <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="5044In7*LZF6Bq|}+l;M">
              <field name="oid">sonoff.0.Radar_Kueche.Presence</field>
            </shadow>
          </value>
          <value name="OID1">
            <shadow type="field_oid" id="IwJ$][kd]:h)wUL%=Mv1">
              <field name="oid">zigbee.0.00158d00047b9993.occupancy</field>
            </shadow>
          </value>
          <statement name="STATEMENT">
            <block type="controls_if" id="#@vx+r#,pf{zp.zr;F`(">
              <value name="IF0">
                <block type="logic_compare" id="H8Jbq/Xfz%oc?[]J3go/">
                  <field name="OP">EQ</field>
                  <value name="A">
                    <block type="variables_get" id="S@3uNRI/aK=z%Eo4!F:R">
                      <field name="VAR" id="4fKH0Ly6T)rDvJ(eYvP=">manuell</field>
                    </block>
                  </value>
                  <value name="B">
                    <block type="logic_boolean" id="{TCk=r)QH8XS~uEI?cR:">
                      <field name="BOOL">FALSE</field>
                    </block>
                  </value>
                </block>
              </value>
              <statement name="DO0">
                <block type="controls_if" id="cqU`E7x`da}6Eem!=LNI">
                  <value name="IF0">
                    <block type="logic_operation" id="9!]cxlQ{{g}UL+R$p%@h" inline="false">
                      <field name="OP">AND</field>
                      <value name="A">
                        <block type="logic_compare" id="eL|/T:VROm@VK^o5xld/">
                          <field name="OP">EQ</field>
                          <value name="A">
                            <block type="get_value" id="D[]6)tPIA7)4Lty%uU[H">
                              <field name="ATTR">val</field>
                              <field name="OID">zigbee.0.00158d00047b9993.occupancy</field>
                            </block>
                          </value>
                          <value name="B">
                            <block type="logic_boolean" id="1/l79_H1@i.Q5LW1.I0n">
                              <field name="BOOL">TRUE</field>
                            </block>
                          </value>
                        </block>
                      </value>
                      <value name="B">
                        <block type="logic_compare" id="601(1I}I_C(OdVd}J%A4">
                          <field name="OP">EQ</field>
                          <value name="A">
                            <block type="get_value" id="*zTh.s,m3DQB9{)g{VVM">
                              <field name="ATTR">val</field>
                              <field name="OID">shelly.0.SHSW-1#05F3F2#1.Relay0.Switch</field>
                            </block>
                          </value>
                          <value name="B">
                            <block type="logic_boolean" id="%n|;{:R63se9bB3qA,N|">
                              <field name="BOOL">FALSE</field>
                            </block>
                          </value>
                        </block>
                      </value>
                    </block>
                  </value>
                  <statement name="DO0">
                    <block type="control" id="H%m[I4VW%FyD^p0Z)cBV">
                      <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="true"></mutation>
                      <field name="OID">shelly.0.SHSW-1#05F3F2#1.Relay0.Switch</field>
                      <field name="WITH_DELAY">TRUE</field>
                      <field name="DELAY_MS">1000</field>
                      <field name="UNIT">ms</field>
                      <field name="CLEAR_RUNNING">FALSE</field>
                      <value name="VALUE">
                        <block type="logic_boolean" id="nGizQpq65*S#+T-uO*~j">
                          <field name="BOOL">TRUE</field>
                        </block>
                      </value>
                    </block>
                  </statement>
                  <next>
                    <block type="controls_if" id="Fr53[^@(L(1`!,6h`Imv">
                      <value name="IF0">
                        <block type="logic_operation" id="h)yBIMP9{6_fI/.g/V[q" inline="false">
                          <field name="OP">AND</field>
                          <value name="A">
                            <block type="logic_compare" id="Tu3$xJ}J/yvovU=}5D`h">
                              <field name="OP">EQ</field>
                              <value name="A">
                                <block type="get_value" id="IpCi4*I%$|]gB:+)k6BT">
                                  <field name="ATTR">val</field>
                                  <field name="OID">shelly.0.SHSW-1#05F3F2#1.Relay0.Switch</field>
                                </block>
                              </value>
                              <value name="B">
                                <block type="logic_boolean" id="Cd63`s9S#9*l,D!=4G|7">
                                  <field name="BOOL">TRUE</field>
                                </block>
                              </value>
                            </block>
                          </value>
                          <value name="B">
                            <block type="logic_compare" id="r(kqF1nT4KDnu?IeRzS{">
                              <field name="OP">EQ</field>
                              <value name="A">
                                <block type="get_value" id="T905GS(m#FX{Utw2iuVc">
                                  <field name="ATTR">val</field>
                                  <field name="OID">sonoff.0.Radar_Kueche.Presence</field>
                                </block>
                              </value>
                              <value name="B">
                                <block type="math_number" id="z@N7:lhFr=a.3h0N)cwP">
                                  <field name="NUM">0</field>
                                </block>
                              </value>
                            </block>
                          </value>
                        </block>
                      </value>
                      <statement name="DO0">
                        <block type="control" id="#r`4x:8%$%bJauKpdZY;">
                          <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>
                          <field name="OID">shelly.0.SHSW-1#05F3F2#1.Relay0.Switch</field>
                          <field name="WITH_DELAY">FALSE</field>
                          <value name="VALUE">
                            <block type="logic_boolean" id="]u)I$(kz9[H=:`GvR4K`">
                              <field name="BOOL">FALSE</field>
                            </block>
                          </value>
                        </block>
                      </statement>
                    </block>
                  </next>
                </block>
              </statement>
            </block>
          </statement>
          <next>
            <block type="on_ext" id="5.Ti1wxL-mzsrZ98R7$!">
              <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="w]2HUFt?]Qa_MQ=W@{92">
                  <field name="oid">shelly.0.SHSW-1#05F3F2#1.Relay0.Switch</field>
                </shadow>
              </value>
              <statement name="STATEMENT">
                <block type="controls_if" id="CDC.|K|`c-mIO`b~m7uB">
                  <mutation elseif="1"></mutation>
                  <value name="IF0">
                    <block type="logic_compare" id="59KSNL#V3:f$N*;|5)$}">
                      <field name="OP">EQ</field>
                      <value name="A">
                        <block type="get_value" id=":00ao!@`ZbwV{.eN@gjr">
                          <field name="ATTR">val</field>
                          <field name="OID">shelly.0.SHSW-1#05F3F2#1.Relay0.Switch</field>
                        </block>
                      </value>
                      <value name="B">
                        <block type="logic_boolean" id="([Zt;89/(mlN;E(_{hm,">
                          <field name="BOOL">TRUE</field>
                        </block>
                      </value>
                    </block>
                  </value>
                  <statement name="DO0">
                    <block type="timeouts_cleartimeout" id="J2!Z~k:?.h)jr5sSbikR">
                      <field name="NAME">timeout</field>
                      <next>
                        <block type="timeouts_settimeout" id="Fycgtk!*I^i6f,G#4;;6">
                          <field name="NAME">timeout</field>
                          <field name="DELAY">30</field>
                          <field name="UNIT">min</field>
                          <statement name="STATEMENT">
                            <block type="controls_if" id="IpCoUx=3H#=jIWQ//aV+">
                              <value name="IF0">
                                <block type="logic_compare" id=")~s5d*}JefSz_PVN0CV}">
                                  <field name="OP">EQ</field>
                                  <value name="A">
                                    <block type="get_value" id=";_e$uHx5oxAA[L,:JyOM">
                                      <field name="ATTR">val</field>
                                      <field name="OID">shelly.0.SHSW-1#05F3F2#1.Relay0.Switch</field>
                                    </block>
                                  </value>
                                  <value name="B">
                                    <block type="logic_boolean" id="Z)V4.rqBA-mb:s(mmN:`">
                                      <field name="BOOL">TRUE</field>
                                    </block>
                                  </value>
                                </block>
                              </value>
                              <statement name="DO0">
                                <block type="control" id="@p[BHUs:5Tx=,/EQkh%7">
                                  <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="true"></mutation>
                                  <field name="OID">shelly.0.SHSW-1#05F3F2#1.Relay0.Switch</field>
                                  <field name="WITH_DELAY">TRUE</field>
                                  <field name="DELAY_MS">20</field>
                                  <field name="UNIT">ms</field>
                                  <field name="CLEAR_RUNNING">TRUE</field>
                                  <value name="VALUE">
                                    <block type="logic_boolean" id="+xj~X~q8:]%MCGY3ygwS">
                                      <field name="BOOL">FALSE</field>
                                    </block>
                                  </value>
                                </block>
                              </statement>
                              <next>
                                <block type="timeouts_cleartimeout" id="IHNG#L=izzhK/%,e27#-">
                                  <field name="NAME">timeout</field>
                                </block>
                              </next>
                            </block>
                          </statement>
                        </block>
                      </next>
                    </block>
                  </statement>
                  <value name="IF1">
                    <block type="logic_compare" id="A(dPPnl4BJ)W%OV_%N^m">
                      <field name="OP">EQ</field>
                      <value name="A">
                        <block type="get_value" id="Dxy=KRdqPSB%2IVq5$L2">
                          <field name="ATTR">val</field>
                          <field name="OID">shelly.0.SHSW-1#05F3F2#1.Relay0.Switch</field>
                        </block>
                      </value>
                      <value name="B">
                        <block type="logic_boolean" id="V?k*u*yagq28fYR[@|W8">
                          <field name="BOOL">FALSE</field>
                        </block>
                      </value>
                    </block>
                  </value>
                  <statement name="DO1">
                    <block type="timeouts_cleartimeout" id="P%3S4@h6HWa0;1QMwx3z">
                      <field name="NAME">timeout</field>
                    </block>
                  </statement>
                </block>
              </statement>
            </block>
          </next>
        </block>
        <block type="on_ext" id="*o?=f5C/$Cv9%yhd_(s]" x="538" y="188">
          <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="d|fU=9n]Pl4G4mV_GV%2">
              <field name="oid">0_userdata.0.Trigger-Datenpunkte.Küchenbeleuchtung</field>
            </shadow>
          </value>
          <statement name="STATEMENT">
            <block type="controls_if" id="$~h9,;}2B+[USdrO:ixw">
              <mutation elseif="1"></mutation>
              <value name="IF0">
                <block type="logic_compare" id="Y-=j^yFdOVaL0kVW#Q|#">
                  <field name="OP">EQ</field>
                  <value name="A">
                    <block type="get_value" id="jd#0]Rmz9r3j`v@_]Dil">
                      <field name="ATTR">val</field>
                      <field name="OID">0_userdata.0.Trigger-Datenpunkte.Küchenbeleuchtung</field>
                    </block>
                  </value>
                  <value name="B">
                    <block type="logic_boolean" id="R1Q$NY^elsPO{Jt]z8$@">
                      <field name="BOOL">TRUE</field>
                    </block>
                  </value>
                </block>
              </value>
              <statement name="DO0">
                <block type="variables_set" id="B~t1QvHR@|HjIL9y5/$d">
                  <field name="VAR" id="4fKH0Ly6T)rDvJ(eYvP=">manuell</field>
                  <value name="VALUE">
                    <block type="logic_boolean" id="XZ1w@cJ|TOLh17OSyY^W">
                      <field name="BOOL">TRUE</field>
                    </block>
                  </value>
                  <next>
                    <block type="control" id="Y3-8bFF]g%^!H1f9AChR">
                      <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>
                      <field name="OID">shelly.0.SHSW-1#05F3F2#1.Relay0.Switch</field>
                      <field name="WITH_DELAY">FALSE</field>
                      <value name="VALUE">
                        <block type="logic_boolean" id="-%q@K[tbnhLaKQ`J6o-v">
                          <field name="BOOL">TRUE</field>
                        </block>
                      </value>
                    </block>
                  </next>
                </block>
              </statement>
              <value name="IF1">
                <block type="logic_compare" id="1!|Ppz:Ft8BE0^@sO{Q|">
                  <field name="OP">EQ</field>
                  <value name="A">
                    <block type="get_value" id="ZB)}3$pc=l_`O.]3zyb-">
                      <field name="ATTR">val</field>
                      <field name="OID">0_userdata.0.Trigger-Datenpunkte.Küchenbeleuchtung</field>
                    </block>
                  </value>
                  <value name="B">
                    <block type="logic_boolean" id="mrjrsxEN2H^x+Pd*eU-t">
                      <field name="BOOL">FALSE</field>
                    </block>
                  </value>
                </block>
              </value>
              <statement name="DO1">
                <block type="variables_set" id="t~xLq@61eLXeJZ58-g~A">
                  <field name="VAR" id="4fKH0Ly6T)rDvJ(eYvP=">manuell</field>
                  <value name="VALUE">
                    <block type="logic_boolean" id="(dd:!nuV(@-Kdu4+f-v@">
                      <field name="BOOL">FALSE</field>
                    </block>
                  </value>
                  <next>
                    <block type="control" id="YlS!nK^QMzsgto);,4NZ">
                      <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>
                      <field name="OID">shelly.0.SHSW-1#05F3F2#1.Relay0.Switch</field>
                      <field name="WITH_DELAY">FALSE</field>
                      <value name="VALUE">
                        <block type="logic_boolean" id="@7bYiXZRAHT)qp3ybH5l">
                          <field name="BOOL">FALSE</field>
                        </block>
                      </value>
                    </block>
                  </next>
                </block>
              </statement>
            </block>
          </statement>
        </block>
      </xml>
      

      Blockly.png

      Viele Grüße

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

        @smarthome2020 sagte: erst dann wieder, wenn ich den Datenpunkt "Küchenbeleuchtung" einmal auf "an" und dann auf "aus" stelle.

        Setze die Variable manuell bei Skriptstart:

        Blockly_temp.JPG

        EDIT: Der zweite Trigger-Block lässt sich mit weniger Aufwand realisieren:

        Blockly_temp.JPG

        S 1 Reply Last reply Reply Quote 0
        • S
          smarthome2020 @paul53 last edited by

          @paul53

          Besten Dank, das war ja eigentlich einfach 😄
          Mir war nicht bewusst, dass es keines Triggers bedarf, um die Variable zu setzen.

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

            @smarthome2020 sagte: Mir war nicht bewusst, dass es keines Triggers bedarf, um die Variable zu setzen.

            Der Trigger ist erforderlich, aber auch das Setzen den Variable bei Skriptstart, wenn mit falsch verglichen wird. Mit "falls nicht manuell" wäre das Setzen bei Skriptstart nicht unbedingt erforderlich.

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

            Support us

            ioBroker
            Community Adapters
            Donate

            545
            Online

            32.0k
            Users

            80.3k
            Topics

            1.3m
            Posts

            2
            4
            238
            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