Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. Blockly
    5. Bewegung erkannt - Shelly schalten

    NEWS

    • Wir empfehlen: Node.js 22.x

    • Neuer Blog: Fotos und Eindrücke aus Solingen

    • ioBroker goes Matter ... Matter Adapter in Stable

    Bewegung erkannt - Shelly schalten

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

      Hallo,
      ich versuche mich grad an einem Blockly irgendwie geht es nicht obwohl ich es aus einem anderen Thread quasi fast rüberkopiert / nachgebildet habe.
      Was soll passieren:

      Ein Bewegungsmelder PIR (HC-SR501) hängt an einem NodeMcu an einem GPIO. Der POWER1 Wert wird auch in den Datenbank protokolliert mit true / false

      EIn Magnetventil soll geschaltet werden welches an einem Shelly 1 hängt. Manuell kann ich es per App schalten und im Adapter SHELLY wird auch der Datenpunkt mit true / false vom SWITCH korrekt protokolliert.

      Was mache ich falsch, da bei Bewegung der Shelly nicht eingeschaltet wird ?
      Hier der Blockly:
      981e8b23-77f9-44b7-8c86-e3b130a770f2-grafik.png

      J 1 Reply Last reply Reply Quote 0
      • J
        Jan1 @Segway last edited by

        @Segway
        Sollte so funktionieren, wobei man da einiges optimieren kann. Poste bitte mal den Code.

        Segway 1 Reply Last reply Reply Quote 0
        • Segway
          Segway @Jan1 last edited by Segway

          @Jan1
          Tja, dachte ich mir auch, aber leider wird bei Bewegung erkannt nicht der Switch vom Shelly auf true gesetzt 😞
          Bin auch für jede Optimierung offen 🙂

          Hier der Code:

          <xml xmlns="https://developers.google.com/blockly/xml">
            <variables>
              <variable type="timeout" id="timeout">timeout</variable>
            </variables>
            <block type="on_ext" id="YM.#/9w.1y~Z9?XJhnN5" x="-487" y="-387">
              <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="%jTnyCDn%PgYB{8*.0lt">
                  <field name="oid">sonoff.0.NodeMcu_Teich.POWER1</field>
                </shadow>
              </value>
              <statement name="STATEMENT">
                <block type="controls_if" id="f`]_ZnrJPO+/s2gj8/sr">
                  <mutation elseif="1"></mutation>
                  <value name="IF0">
                    <block type="logic_compare" id="r[c7):%ov;xLJI)7=6ST">
                      <field name="OP">EQ</field>
                      <value name="A">
                        <block type="get_value" id="2s0IhxORi+m%{cGpB*GO">
                          <field name="ATTR">val</field>
                          <field name="OID">sonoff.0.NodeMcu_Teich.POWER1</field>
                        </block>
                      </value>
                      <value name="B">
                        <block type="logic_boolean" id="`]V~(Hc7DDwYjOh=4tq=">
                          <field name="BOOL">TRUE</field>
                        </block>
                      </value>
                    </block>
                  </value>
                  <statement name="DO0">
                    <block type="timeouts_cleartimeout" id="7rw,zduV-62(pcZLAR4;">
                      <field name="NAME">timeout</field>
                      <next>
                        <block type="control" id="fn32UPV8!EY@LVl@l441">
                          <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>
                          <field name="OID">shelly.0.SHSW-1#F4CFA2D3A5F6#1.Relay0.Switch</field>
                          <field name="WITH_DELAY">FALSE</field>
                          <value name="VALUE">
                            <block type="logic_boolean" id="-+1Cq=~e/r9(P2:(wWxW">
                              <field name="BOOL">TRUE</field>
                            </block>
                          </value>
                          <next>
                            <block type="telegram" id="nz:m?9M:5{Ae#O.7xCt0">
                              <field name="INSTANCE"></field>
                              <field name="LOG"></field>
                              <field name="SILENT">FALSE</field>
                              <field name="PARSEMODE">default</field>
                              <value name="MESSAGE">
                                <shadow type="text" id="l7ocSs3*W?V)l/EdBQ.!">
                                  <field name="TEXT">Bewegung erkannt</field>
                                </shadow>
                              </value>
                            </block>
                          </next>
                        </block>
                      </next>
                    </block>
                  </statement>
                  <value name="IF1">
                    <block type="logic_compare" id="!h_WGeZ,Z/E._Rij{Sv}">
                      <field name="OP">EQ</field>
                      <value name="A">
                        <block type="get_value" id="PaS+Yp.5AFv=$*~sSP_o">
                          <field name="ATTR">val</field>
                          <field name="OID">sonoff.0.NodeMcu_Teich.POWER1</field>
                        </block>
                      </value>
                      <value name="B">
                        <block type="logic_boolean" id="(^/@91AbU*Q[Lm;I(sQ1">
                          <field name="BOOL">FALSE</field>
                        </block>
                      </value>
                    </block>
                  </value>
                  <statement name="DO1">
                    <block type="timeouts_cleartimeout" id="48kyiz7c9o!iu:6.^{Vw">
                      <field name="NAME">timeout</field>
                      <next>
                        <block type="timeouts_settimeout" id="EWUG;n=f.[20rin0,hE9">
                          <field name="NAME">timeout</field>
                          <field name="DELAY">5</field>
                          <field name="UNIT">sec</field>
                          <statement name="STATEMENT">
                            <block type="control" id="n,cWi0{qY;;2M`YgMX#.">
                              <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>
                              <field name="OID">shelly.0.SHSW-1#F4CFA2D3A5F6#1.Relay0.Switch</field>
                              <field name="WITH_DELAY">FALSE</field>
                              <value name="VALUE">
                                <block type="logic_boolean" id="/rl|kRWsx3,,oO79(wuR">
                                  <field name="BOOL">FALSE</field>
                                </block>
                              </value>
                            </block>
                          </statement>
                        </block>
                      </next>
                    </block>
                  </statement>
                </block>
              </statement>
            </block>
          </xml>
          
          J 1 Reply Last reply Reply Quote 0
          • J
            Jan1 @Segway last edited by Jan1

            @Segway
            teste das mal:

            <xml xmlns="https://developers.google.com/blockly/xml">
              <variables>
                <variable type="timeout" id="timeout">timeout</variable>
              </variables>
              <block type="on_ext" id="YM.#/9w.1y~Z9?XJhnN5" x="-512" y="-287">
                <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="%jTnyCDn%PgYB{8*.0lt">
                    <field name="oid">sonoff.0.NodeMcu_Teich.POWER1</field>
                  </shadow>
                </value>
                <statement name="STATEMENT">
                  <block type="debug" id="1Dl(1ls]6*GT7qVXh:R{">
                    <field name="Severity">log</field>
                    <value name="TEXT">
                      <shadow type="text" id="G!w1Eb8pjY5h2cu2WwG[">
                        <field name="TEXT">Bewegung am NodeMCU erkannt</field>
                      </shadow>
                    </value>
                    <next>
                      <block type="controls_if" id="f`]_ZnrJPO+/s2gj8/sr">
                        <mutation else="1"></mutation>
                        <value name="IF0">
                          <block type="on_source" id="+N}1g43YNn@(7[(F3}?x">
                            <field name="ATTR">state.val</field>
                          </block>
                        </value>
                        <statement name="DO0">
                          <block type="timeouts_cleartimeout" id="7rw,zduV-62(pcZLAR4;">
                            <field name="NAME">timeout</field>
                            <next>
                              <block type="control" id="fn32UPV8!EY@LVl@l441">
                                <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>
                                <field name="OID">shelly.0.SHSW-1#F4CFA2D3A5F6#1.Relay0.Switch</field>
                                <field name="WITH_DELAY">FALSE</field>
                                <value name="VALUE">
                                  <block type="logic_boolean" id="-+1Cq=~e/r9(P2:(wWxW">
                                    <field name="BOOL">TRUE</field>
                                  </block>
                                </value>
                                <next>
                                  <block type="telegram" id="nz:m?9M:5{Ae#O.7xCt0">
                                    <field name="INSTANCE"></field>
                                    <field name="LOG"></field>
                                    <field name="SILENT">FALSE</field>
                                    <field name="PARSEMODE">default</field>
                                    <value name="MESSAGE">
                                      <shadow type="text" id="l7ocSs3*W?V)l/EdBQ.!">
                                        <field name="TEXT">Bewegung erkannt</field>
                                      </shadow>
                                    </value>
                                  </block>
                                </next>
                              </block>
                            </next>
                          </block>
                        </statement>
                        <statement name="ELSE">
                          <block type="timeouts_cleartimeout" id="48kyiz7c9o!iu:6.^{Vw">
                            <field name="NAME">timeout</field>
                            <next>
                              <block type="timeouts_settimeout" id="EWUG;n=f.[20rin0,hE9">
                                <field name="NAME">timeout</field>
                                <field name="DELAY">5</field>
                                <field name="UNIT">sec</field>
                                <statement name="STATEMENT">
                                  <block type="control" id="n,cWi0{qY;;2M`YgMX#.">
                                    <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>
                                    <field name="OID">shelly.0.SHSW-1#F4CFA2D3A5F6#1.Relay0.Switch</field>
                                    <field name="WITH_DELAY">FALSE</field>
                                    <value name="VALUE">
                                      <block type="logic_boolean" id="/rl|kRWsx3,,oO79(wuR">
                                        <field name="BOOL">FALSE</field>
                                      </block>
                                    </value>
                                  </block>
                                </statement>
                              </block>
                            </next>
                          </block>
                        </statement>
                      </block>
                    </next>
                  </block>
                </statement>
              </block>
            </xml>
            

            und schau ob der debug Output beim Wechsel kommt

            Segway 1 Reply Last reply Reply Quote 0
            • Segway
              Segway @Jan1 last edited by

              @Jan1
              Mhhh, ich hab nix geändert und es geht nun. Kann es sein, dass beim ersten mal es NICHT geht ?
              Mein Debug terminal unter Skripte schmiss da eine fehlermeldung raus aber nun geht es. Hier mal screenshot: oben Bewegung erkannt und unten Magnetventil auf:

              b3cafa7b-54f9-4f10-9a52-feaaa2584797-grafik.png

              Zwei Fragen noch:

              1. Wie integriere ich einen Schalter ob dieses Szenario aktiv sein soll oder nicht ? Einfach oben in die Vorbedingung mit eintragen ?
              2. Kann ich noch was optimieren, wie du es schon gesagt hattest ?
              J 1 Reply Last reply Reply Quote 0
              • J
                Jan1 @Segway last edited by

                @Segway
                zu 1, ja einfach oben mit in die Bedingung, oder das Script ein und ausschalten
                zu 2, schau mal mein Export an, da sind die Optimierungen bereits drin 😉

                Segway 1 Reply Last reply Reply Quote 0
                • Segway
                  Segway @Jan1 last edited by

                  @Jan1
                  EY SUBBA !
                  Funktioniert einwandfrei 🙂

                  Jetzt hab ich aber doch noch eine Frage:
                  Was ist wenn die Bewegung länger als die 5 Sekunden erkannt wird, wo das Magnetventil geöffnet ist ? Muss ich das noch abfangen ?

                  Muss hier die UND Beziehung rein:
                  7e617287-0fa7-4cbc-b44d-479ee8a1a78d-grafik.png

                  J 1 Reply Last reply Reply Quote 0
                  • J
                    Jan1 @Segway last edited by

                    @Segway
                    Da muss Dich ran tasten. Ich kenne den BWM nicht und weiß deshalb nicht wie der reagiert. Da kann man noch viel durch ne zusätzliche UND Verknüpfung abfangen. Das schaffst aber auch alleine 🙂

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

                    Support us

                    ioBroker
                    Community Adapters
                    Donate

                    759
                    Online

                    32.0k
                    Users

                    80.4k
                    Topics

                    1.3m
                    Posts

                    blockly
                    2
                    8
                    427
                    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