Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. Blockly
    5. powerstatus enigma in variable schreiben.

    NEWS

    • Neuer Blog: Fotos und Eindrücke aus Solingen

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

    • ioBroker goes Matter ... Matter Adapter in Stable

    powerstatus enigma in variable schreiben.

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

      Hallo!

      Ich bin bezüglich der Statusabfrage, hier im Forum schon fündig geworden.
      @Matten-Matten hat hier große Arbeit geleistet.
      link

      Gerne würde ich nun den Rückgabewert true und fals in eine variable schreiben.
      Wenn in die variable "fals" geschrieben wird, dann soll folgender http Post gesendet werden.

      "http://192.168.1.29/web/powerstate?newstate=5"

      Leider scheitere ich aber daran überhaupt die Rückgabe in eine variable zu schreiben.
      Bisheriger Aufbau:

      <xml xmlns="https://developers.google.com/blockly/xml">
        <variables>
          <variable id="y3dARA/_o@E|kxjn=A[n">state</variable>
          <variable type="timeout" id="timeout">timeout</variable>
          <variable id=";9CBz{(BK7Ex27NC:z%r">result</variable>
        </variables>
        <block type="on" id="2;+{kYg+D^#svH$hLz00" x="113" y="-337">
          <field name="OID">hm-rpc.0.LEQ1345108.1.STATE</field>
          <field name="CONDITION">any</field>
          <field name="ACK_CONDITION"></field>
          <statement name="STATEMENT">
            <block type="controls_if" id=":*ENAV:f[9[D7aehYSyC">
              <value name="IF0">
                <block type="logic_compare" id="fj*Fi(Hd/tsuGMPzG~Gh">
                  <field name="OP">EQ</field>
                  <value name="A">
                    <block type="get_value" id="Za=1:SMcD}6zf)LMjFK-">
                      <field name="ATTR">val</field>
                      <field name="OID">hm-rpc.0.LEQ1345108.1.STATE</field>
                    </block>
                  </value>
                  <value name="B">
                    <block type="logic_boolean" id="uFe.tXqgHH+[V1Haqk8Q">
                      <field name="BOOL">FALSE</field>
                    </block>
                  </value>
                </block>
              </value>
              <statement name="DO0">
                <block type="request" id="uxf0BShS(t!v2mbkO45]">
                  <mutation xmlns="http://www.w3.org/1999/xhtml" with_statement="true"></mutation>
                  <field name="WITH_STATEMENT">TRUE</field>
                  <field name="LOG"></field>
                  <value name="URL">
                    <shadow type="text" id="e%[XlWK=k:#`6by40Ozi">
                      <field name="TEXT">http://192.168.1.29/web/powerstate</field>
                    </shadow>
                  </value>
                  <statement name="STATEMENT">
                    <block type="variables_set" id="2cL}9M=cvzRwWQ]9u%T0">
                      <field name="VAR" id="y3dARA/_o@E|kxjn=A[n">state</field>
                      <value name="VALUE">
                        <block type="convert_tostring" id="py1IL/=N]C-Q1=h0oZ?.">
                          <value name="VALUE">
                            <block type="text_getSubstring" id="hE{L1tLh[K*:MMiJ1Qc2">
                              <mutation at1="true" at2="true"></mutation>
                              <field name="WHERE1">FROM_START</field>
                              <field name="WHERE2">FROM_START</field>
                              <value name="STRING">
                                <block type="variables_get" id="dU$XzHsoVl_LAyOI2!9i">
                                  <field name="VAR" id=";9CBz{(BK7Ex27NC:z%r">result</field>
                                </block>
                              </value>
                              <value name="AT1">
                                <block type="text_indexOf" id="dCY}+}+~4KNIMbHLwthq">
                                  <field name="END">FIRST</field>
                                  <value name="VALUE">
                                    <block type="variables_get" id="Z=G-l$(9CchRC!]Z/JQB">
                                      <field name="VAR" id=";9CBz{(BK7Ex27NC:z%r">result</field>
                                    </block>
                                  </value>
                                  <value name="FIND">
                                    <shadow type="text" id="/e*kLf5?Fj?mI*^Cs/%|">
                                      <field name="TEXT">&lt;e2instandby&gt;</field>
                                    </shadow>
                                  </value>
                                </block>
                              </value>
                              <value name="AT2">
                                <block type="text_indexOf" id="v^3[9u3j*q1XLl2/avuo">
                                  <field name="END">FIRST</field>
                                  <value name="VALUE">
                                    <block type="variables_get" id="J):/+yU+yR?oP*rfkIrw">
                                      <field name="VAR" id=";9CBz{(BK7Ex27NC:z%r">result</field>
                                    </block>
                                  </value>
                                  <value name="FIND">
                                    <shadow type="text" id="e_5rZ=mtCygJxdqK7z(G">
                                      <field name="TEXT">&lt;/e2instandby&gt;</field>
                                    </shadow>
                                  </value>
                                </block>
                              </value>
                            </block>
                          </value>
                        </block>
                      </value>
                      <next>
                        <block type="timeouts_settimeout" id="hSTpoP}Fc_J,w!Ej9La@">
                          <field name="NAME">timeout</field>
                          <field name="DELAY">1000</field>
                          <field name="UNIT">ms</field>
                          <statement name="STATEMENT">
                            <block type="debug" id="V/*DU;hnvcw7m=H8M%i_">
                              <field name="Severity">log</field>
                              <value name="TEXT">
                                <shadow type="text" id="#?=XLpp:xAH)V;nt4Znn">
                                  <field name="TEXT">test</field>
                                </shadow>
                                <block type="convert_toboolean" id="qqe4L3}wb~5baO@vbZ{]">
                                  <value name="VALUE">
                                    <block type="text_trim" id="V:P]bH0UxB~o68dn-/)/">
                                      <field name="MODE">BOTH</field>
                                      <value name="TEXT">
                                        <shadow xmlns="http://www.w3.org/1999/xhtml" type="text" id="4f0QKBDM7$~@]A|ImT(Q">
                                          <field name="TEXT">abc</field>
                                        </shadow>
                                        <block type="text_getSubstring" id="aryL(bbn{bt/u4s}OMC=">
                                          <mutation at1="true" at2="true"></mutation>
                                          <field name="WHERE1">FROM_START</field>
                                          <field name="WHERE2">FROM_END</field>
                                          <value name="STRING">
                                            <block type="variables_get" id="U=qtyS%EnO45GEQ=1/QV">
                                              <field name="VAR" id="y3dARA/_o@E|kxjn=A[n">state</field>
                                            </block>
                                          </value>
                                          <value name="AT1">
                                            <block type="math_number" id="TUyTOuLW+|J7AlRYT4q|">
                                              <field name="NUM">-7</field>
                                            </block>
                                          </value>
                                          <value name="AT2">
                                            <block type="math_number" id="K89g{7}+.gI|S~J#IJ-*">
                                              <field name="NUM">2</field>
                                            </block>
                                          </value>
                                        </block>
                                      </value>
                                    </block>
                                  </value>
                                </block>
                              </value>
                            </block>
                          </statement>
                        </block>
                      </next>
                    </block>
                  </statement>
                </block>
              </statement>
            </block>
          </statement>
        </block>
      </xml>
      

      Screenshot 2022-03-08 155319.png

      SBorg 1 Reply Last reply Reply Quote 0
      • SBorg
        SBorg Forum Testing Most Active @lexnared last edited by

        @lexnared Ui, ist das kompliziert... 😉

        Aber mal ganz ohne "von-hinten-durch-die-Brust-und-von-vorne-mitten-durchs-Auge":
        Bild 1.png

        <xml xmlns="https://developers.google.com/blockly/xml">
         <variables>
           <variable id="5~3Li$$lRO(!EQ$E=7!X">result</variable>
         </variables>
         <block type="variables_set" id="TDoOi.wae|-5A@lA,c]2" x="63" y="63">
           <field name="VAR" id="5~3Li$$lRO(!EQ$E=7!X">result</field>
           <value name="VALUE">
             <block type="text_join" id="qLb8a]zo|W70?(e8Xhlp">
               <mutation items="4"></mutation>
               <value name="ADD0">
                 <block type="text" id="N2.B$F@EX***[@N2VSLZ">
                   <field name="TEXT">&lt;?xml version="1.0" encoding="UTF-8"?&gt;</field>
                 </block>
               </value>
               <value name="ADD1">
                 <block type="text" id="oJTxvE*;)X4c`EawTFDw">
                   <field name="TEXT">&lt;e2powerstate&gt;</field>
                 </block>
               </value>
               <value name="ADD2">
                 <block type="text" id="*r}Bgm.F0TeTsNSpowca">
                   <field name="TEXT">&lt;e2instandby&gt;false&lt;/e2instandby&gt;</field>
                 </block>
               </value>
               <value name="ADD3">
                 <block type="text" id="{%)5zI~svoA~CZ?rRUn0">
                   <field name="TEXT">&lt;/e2powerstate&gt;</field>
                 </block>
               </value>
             </block>
           </value>
           <next>
             <block type="controls_if" id="Jn6h%hIrz;7qx4D|yHio">
               <value name="IF0">
                 <block type="logic_compare" id="pw[1#-|f8NT`H?Cj[Li2">
                   <field name="OP">NEQ</field>
                   <value name="A">
                     <block type="text_indexOf" id="Pa=y%HFVI4E^-ib(Fgu0">
                       <field name="END">FIRST</field>
                       <value name="VALUE">
                         <block type="variables_get" id="f}z]51C`$roQT9~%VFY%">
                           <field name="VAR" id="5~3Li$$lRO(!EQ$E=7!X">result</field>
                         </block>
                       </value>
                       <value name="FIND">
                         <shadow type="text" id="N0w0Vzn.jgKR?uAv,54L">
                           <field name="TEXT">false</field>
                         </shadow>
                       </value>
                     </block>
                   </value>
                   <value name="B">
                     <block type="math_number" id="YMcl^gd@j,^~BT:bSMk{">
                       <field name="NUM">0</field>
                     </block>
                   </value>
                 </block>
               </value>
               <statement name="DO0">
                 <block type="debug" id="y=*BpdS519SR*yZ;w3L(">
                   <field name="Severity">log</field>
                   <value name="TEXT">
                     <shadow type="text" id="+.MLRo$9eS){j-OM$/Pd">
                       <field name="TEXT">Receiver ist an...</field>
                     </shadow>
                   </value>
                 </block>
               </statement>
             </block>
           </next>
         </block>
        </xml>
        

        Zur Erklärung:
        Das Ergebnis des requests landet bei aktiviertem "mit Ergebnissen" immer in der Variable result (muss man per Hand anlegen).
        Da ich weder den Trigger habe, noch den passenden request erzeugen kann, habe ich ihn hier halt händisch mit "setzte result..." erzeugt.
        Dann kommt schon der ganze Voodoo. Der Antwortstring wird nun nach "false" durchsucht. Wäre nun "e2instandby" true findet er kein false und die Position an der er "nun nix findet" ist 0. Findet er aber false ist es eben nicht 0, sondern Position xy (eben die Position im String wo das false steht) und er führt das "mache" aus (hier der Text, bei dir eben dann ein weiterer request mit "http://192.168.1.29/web/powerstate?newstate=5").

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

        Support us

        ioBroker
        Community Adapters
        Donate

        546
        Online

        31.9k
        Users

        80.2k
        Topics

        1.3m
        Posts

        2
        2
        107
        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