Navigation

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

    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

    Hex zu Dezimal wandeln

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

      Hallo!

      Ich muss einen Hexadezimalen Wert in einen dezimalen Zahlenwert umwandeln. Kriegs aber nicht hin diese Funktion in Blockly einzubauen. 😞

      Die Javascript-Funktion ist laut meiner google-Forschung:

      yourNumber = parseInt(hexString, 16);
      

      "0800" bekomme ich als Wert beim "debug output/warning".
      Und DER Wert muss umgewandelt werden.
      Hab noch kein Tutorial dazu finden können wir man externen JavaScript einbinden kann...

      hex1.jpg

      <xml xmlns="http://www.w3.org/1999/xhtml">
        <variables>
          <variable type="" id="s~NW?gEWyMa:exT(zi~e">result</variable>
          <variable type="" id="@+Cn|lE(3]0eu-`.DI^h">Liste</variable>
        </variables>
        <block type="schedule" id="j5{{PJPs5weVFqWD9b;!" x="-862" y="-887">
          <field name="SCHEDULE">*/3 * * * * *</field>
          <statement name="STATEMENT">
            <block type="debug" id="EcQt=m_*L:Fs!?Mc+W`D">
              <field name="Severity">warn</field>
              <value name="TEXT">
                <shadow type="text" id="h!6ySBv9*gj7+}IOE*4N">
                  <field name="TEXT">3 Sekunden Trigger</field>
                </shadow>
              </value>
              <next>
                <block type="request" id="n8Dr(.}Qe)!GH.yiUxaI">
                  <mutation with_statement="true"></mutation>
                  <field name="WITH_STATEMENT">TRUE</field>
                  <field name="LOG">debug</field>
                  <value name="URL">
                    <shadow type="text" id="`{D-$HwW!%t4.pdlipp*">
                      <field name="TEXT">http://192.168.1.58/allout?PW=33118&amp;</field>
                    </shadow>
                  </value>
                  <statement name="STATEMENT">
                    <block type="debug" id="2EItp@uj{t?bGqvpDCM2">
                      <field name="Severity">log</field>
                      <value name="TEXT">
                        <shadow type="text" id=",b.x;q*3$jX-[Nm%M!1(">
                          <field name="TEXT">Request gesendet</field>
                        </shadow>
                        <block type="variables_get" id=",oKkXH#Z^PsRH8A10y7b">
                          <field name="VAR" id="s~NW?gEWyMa:exT(zi~e" variabletype="">result</field>
                        </block>
                      </value>
                      <next>
                        <block type="variables_set" id=",9sIQO1?SEt){mJ!3v0K">
                          <field name="VAR" id="@+Cn|lE(3]0eu-`.DI^h" variabletype="">Liste</field>
                          <value name="VALUE">
                            <block type="lists_split" id="dlg`Mso*E#!A}[1!Ny]4">
                              <mutation mode="SPLIT"></mutation>
                              <field name="MODE">SPLIT</field>
                              <value name="INPUT">
                                <block type="variables_get" id="q}Gg0G2u_.Kbu~NFg[z)">
                                  <field name="VAR" id="s~NW?gEWyMa:exT(zi~e" variabletype="">result</field>
                                </block>
                              </value>
                              <value name="DELIM">
                                <shadow type="text" id="hFr=?wGeHGPMjg.,(c4B">
                                  <field name="TEXT">;</field>
                                </shadow>
                              </value>
                            </block>
                          </value>
                          <next>
                            <block type="debug" id="KjJH5^SQaU:;Gn=+v+`q">
                              <field name="Severity">warn</field>
                              <value name="TEXT">
                                <shadow type="text" id=",b.x;q*3$jX-[Nm%M!1(">
                                  <field name="TEXT">Request gesendet</field>
                                </shadow>
                                <block type="lists_getIndex" id="X9xwVN?rrUXw1sGf^k0,">
                                  <mutation statement="false" at="true"></mutation>
                                  <field name="MODE">GET</field>
                                  <field name="WHERE">FROM_START</field>
                                  <value name="VALUE">
                                    <block type="variables_get" id="}w%en#e^CBF6%_8iB:tX">
                                      <field name="VAR" id="@+Cn|lE(3]0eu-`.DI^h" variabletype="">Liste</field>
                                    </block>
                                  </value>
                                  <value name="AT">
                                    <block type="math_number" id="5`egA^s=sW_PD4Oz.OV1">
                                      <field name="NUM">2</field>
                                    </block>
                                  </value>
                                </block>
                              </value>
                            </block>
                          </next>
                        </block>
                      </next>
                    </block>
                  </statement>
                </block>
              </next>
            </block>
          </statement>
        </block>
      </xml>
      
      paul53 1 Reply Last reply Reply Quote 0
      • paul53
        paul53 @Roelli last edited by

        @Roelli sagte:

        man externen JavaScript einbinden kann...

        Es gibt den Block JS-Funktion mit Ergebnis:

        Blockly_temp.JPG

        Inhalt der Funktion:

        return parseInt(hex, 16);
        
        1 Reply Last reply Reply Quote 1
        • padrino
          padrino Most Active last edited by padrino

          @paul53
          Da warste schneller, ich war noch am Screenshots machen... 😁

          Edit: aber wieder was gelernt, denn meine Funktion sieht so aus. 😃
          funktion.png
          (dass man auf die Variable verzichten kann, wusste ich nicht.
          Kenn mich JS null aus, nur Blockly, aber wenn ich es jetzt so sehe, dann macht es Sinn... 😌 )

          1 Reply Last reply Reply Quote 0
          • R
            Roelli last edited by Roelli

            Supergeil! Danke!

            Ich brauche natürlich nochmal Hilfe! 👶

            Ich habe diese Ding hier. Das hat 12 Ein und 12 Ausgänge.
            Die Eingänge will ich alle 3 Sekunden abfragen.
            webio1.jpg

            Ich schicke an das Gerät: http://192.168.1.65/allout?PW=33118&
            Und das Gerät schickt zurück: input;0800;output;0000;counter;126;111;0;0;0;0;0;0;0;0;0;0

            Das hinter dem Semikolon "0800" ist wohl der hexadezimale Wert.

            Das ist quasi der Zustand aller 12 Eingänge.

            Wie kann ma das denn sinnvoll und einfach so umwandeln das man damit 12 Datenpunkte steuert?
            Ich glaube Hex zu Binär wäre besser? Und dann das 1. Element davon nehmen und checken ob es eine 0 oder 1 ist und damit den Datenpunkt steuern?

            Ich hab mal
            Integer.parseInt(hex, 16);
            als JS-Funktion ausprobiert (hab rumgegoogelt) Aber als Anwort kommt "0000NaN" Ich hätte mir an der Stelle etwas 12-stelligeres gewünscht. 🤠

            Hier gibt's ein paar Infos zu dem Modul - welche ich natürlich nicht verstehe. 👷
            WEB-IO Modul Programmieranleitung als PDF

            Jemand ne Idee?

            Danke!

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

              @Roelli sagte:

              input;0800;output;0000;counter;126;111;0;0;0;0;0;0;0;0;0;0
              Das hinter dem Semikolon "0800" ist wohl der hexadezimale Wert.

              Versuche es mal so-

              Blockly_temp.JPG

              <xml xmlns="http://www.w3.org/1999/xhtml">
               <variables>
                 <variable type="" id="+Wx]Q{.2Vkv!?A*?.tX6">hex</variable>
                 <variable type="" id="fV]_W~CP:]59f8qG-O4m">Liste</variable>
                 <variable type="" id="eELu()QjMt4,hC(NI7T(">inputs</variable>
                 <variable type="" id="mM]N!hc@{IM}8ekQy6:f">i</variable>
                 <variable type="" id="%JU_.mp8ag]0UW_idbv[">input</variable>
               </variables>
               <block type="on_ext" id="|g+DV6`6UQeauN+v5=|b" x="113" y="289">
                 <mutation items="1"></mutation>
                 <field name="CONDITION">ne</field>
                 <field name="ACK_CONDITION"></field>
                 <value name="OID0">
                   <shadow type="field_oid" id="3FjWqfGEYxtb8*I,E/4E">
                     <field name="oid">default</field>
                   </shadow>
                 </value>
                 <statement name="STATEMENT">
                   <block type="variables_set" id="OkT.UVUtc!i%^~`TO2?N">
                     <field name="VAR" id="fV]_W~CP:]59f8qG-O4m" variabletype="">Liste</field>
                     <value name="VALUE">
                       <block type="lists_split" id="i08=)H0_KB1Cf@cP;_4n">
                         <mutation mode="SPLIT"></mutation>
                         <field name="MODE">SPLIT</field>
                         <value name="INPUT">
                           <block type="on_source" id="E{t~gUjNjcUl(K%OppgA">
                             <field name="ATTR">state.val</field>
                           </block>
                         </value>
                         <value name="DELIM">
                           <shadow type="text" id="q_5%bEi2,UfYL=0tK^n6">
                             <field name="TEXT">;</field>
                           </shadow>
                         </value>
                       </block>
                     </value>
                     <next>
                       <block type="variables_set" id="]@iBF.d.u{_s:T3=;[8P">
                         <field name="VAR" id="eELu()QjMt4,hC(NI7T(" variabletype="">inputs</field>
                         <value name="VALUE">
                           <block type="procedures_callcustomreturn" id="kCs7#/d-5%XO2*:5zxf2">
                             <mutation name="hex2dec">
                               <arg name="hex"></arg>
                             </mutation>
                             <value name="ARG0">
                               <block type="lists_getIndex" id="biR1P_*+V^NEU=VIW2G3">
                                 <mutation statement="false" at="true"></mutation>
                                 <field name="MODE">GET</field>
                                 <field name="WHERE">FROM_START</field>
                                 <value name="VALUE">
                                   <block type="variables_get" id="hO-UwvXU(@9ID!o?{=N!">
                                     <field name="VAR" id="fV]_W~CP:]59f8qG-O4m" variabletype="">Liste</field>
                                   </block>
                                 </value>
                                 <value name="AT">
                                   <block type="math_number" id="y,Oz*A@(gel|Sk`Y,adn">
                                     <field name="NUM">2</field>
                                   </block>
                                 </value>
                               </block>
                             </value>
                           </block>
                         </value>
                         <next>
                           <block type="controls_for" id="_.@hA-6H_F][RKc/LIjJ">
                             <field name="VAR" id="mM]N!hc@{IM}8ekQy6:f" variabletype="">i</field>
                             <value name="FROM">
                               <shadow type="math_number" id="dbD|@1[PxJMBLcuyaJxC">
                                 <field name="NUM">1</field>
                               </shadow>
                             </value>
                             <value name="TO">
                               <shadow type="math_number" id="_P$t!8T*sVFcjqpV=2H.">
                                 <field name="NUM">12</field>
                               </shadow>
                             </value>
                             <value name="BY">
                               <shadow type="math_number" id="`s0jmRRd,HbBJ=7{C(n.">
                                 <field name="NUM">1</field>
                               </shadow>
                             </value>
                             <statement name="DO">
                               <block type="controls_if" id="XFoJ7*e~bRrj)B^cPDru">
                                 <mutation else="1"></mutation>
                                 <value name="IF0">
                                   <block type="math_number_property" id="Zl#t@/WE5H1UR41l?~gC">
                                     <mutation divisor_input="false"></mutation>
                                     <field name="PROPERTY">ODD</field>
                                     <value name="NUMBER_TO_CHECK">
                                       <shadow type="math_number" id="S3.Q4ag!#PYlB`U4=(Zu">
                                         <field name="NUM">0</field>
                                       </shadow>
                                       <block type="variables_get" id="oF-uzcGt`/wKKW8xujdW">
                                         <field name="VAR" id="eELu()QjMt4,hC(NI7T(" variabletype="">inputs</field>
                                       </block>
                                     </value>
                                   </block>
                                 </value>
                                 <statement name="DO0">
                                   <block type="variables_set" id="fM@h*e!:[cV~,=xNNnkT">
                                     <field name="VAR" id="%JU_.mp8ag]0UW_idbv[" variabletype="">input</field>
                                     <value name="VALUE">
                                       <block type="logic_boolean" id="S]y5e@]b8^R4r9X?x5-U">
                                         <field name="BOOL">TRUE</field>
                                       </block>
                                     </value>
                                   </block>
                                 </statement>
                                 <statement name="ELSE">
                                   <block type="variables_set" id="QS_r{(*KSI?]!5W,W[Xq">
                                     <field name="VAR" id="%JU_.mp8ag]0UW_idbv[" variabletype="">input</field>
                                     <value name="VALUE">
                                       <block type="logic_boolean" id="2x3]UTM~Sj/_o/XR=oWL">
                                         <field name="BOOL">FALSE</field>
                                       </block>
                                     </value>
                                   </block>
                                 </statement>
                                 <next>
                                   <block type="control_ex" id="VlY,7}^qDvlRF%.hv(m]">
                                     <field name="TYPE">true</field>
                                     <field name="CLEAR_RUNNING">FALSE</field>
                                     <value name="OID">
                                       <shadow type="field_oid" id="WT]BKW#bT4,U{^7Gpn_Y">
                                         <field name="oid">Object ID</field>
                                       </shadow>
                                       <block type="text_join" id="z[m8ZWQR#B!G)mj(T6:;">
                                         <mutation items="2"></mutation>
                                         <value name="ADD0">
                                           <block type="text" id="=Y=8=,)oyTw(gkYJ5$Qt">
                                             <field name="TEXT">0_userdata.0.iomodul.input</field>
                                           </block>
                                         </value>
                                         <value name="ADD1">
                                           <block type="variables_get" id="%#q7sr!LtiB(8L7U2(](">
                                             <field name="VAR" id="mM]N!hc@{IM}8ekQy6:f" variabletype="">i</field>
                                           </block>
                                         </value>
                                       </block>
                                     </value>
                                     <value name="VALUE">
                                       <shadow type="logic_boolean" id="V5pb!@LAF{jKKKc]KBin">
                                         <field name="BOOL">TRUE</field>
                                       </shadow>
                                       <block type="variables_get" id="@uShH_2Znnwjgasr2h8,">
                                         <field name="VAR" id="%JU_.mp8ag]0UW_idbv[" variabletype="">input</field>
                                       </block>
                                     </value>
                                     <value name="DELAY_MS">
                                       <shadow type="math_number" id="l[~=5ireGI|.*R_I)K%k">
                                         <field name="NUM">0</field>
                                       </shadow>
                                     </value>
                                     <next>
                                       <block type="variables_set" id="uwX9ZAPeLCjl65AL_uxX">
                                         <field name="VAR" id="eELu()QjMt4,hC(NI7T(" variabletype="">inputs</field>
                                         <value name="VALUE">
                                           <block type="math_round" id="JqM+{NH2JJNL8pHI9b}n">
                                             <field name="OP">ROUNDDOWN</field>
                                             <value name="NUM">
                                               <shadow type="math_number" id="zy)6PU~Pu1K5lR9,hllR">
                                                 <field name="NUM">3.1</field>
                                               </shadow>
                                               <block type="math_arithmetic" id="=biT14(x2b[Ds$5s:TF#">
                                                 <field name="OP">DIVIDE</field>
                                                 <value name="A">
                                                   <shadow type="math_number" id="+y4[u,GCBy/HjOmkZG$Z">
                                                     <field name="NUM">1</field>
                                                   </shadow>
                                                   <block type="variables_get" id="_(szGPd$*cli2aCRn[dd">
                                                     <field name="VAR" id="eELu()QjMt4,hC(NI7T(" variabletype="">inputs</field>
                                                   </block>
                                                 </value>
                                                 <value name="B">
                                                   <shadow type="math_number" id=":VHGmM0GxKp@D|!o?Y,b">
                                                     <field name="NUM">2</field>
                                                   </shadow>
                                                 </value>
                                               </block>
                                             </value>
                                           </block>
                                         </value>
                                       </block>
                                     </next>
                                   </block>
                                 </next>
                               </block>
                             </statement>
                           </block>
                         </next>
                       </block>
                     </next>
                   </block>
                 </statement>
               </block>
               <block type="procedures_defcustomreturn" id="o~vB.~:vTH*8{L}s{=xx" x="312" y="337">
                 <mutation statements="false">
                   <arg name="hex" varid="+Wx]Q{.2Vkv!?A*?.tX6"></arg>
                 </mutation>
                 <field name="NAME">hex2dec</field>
                 <field name="SCRIPT">cmV0dXJuIHBhcnNlSW50KGhleCwgMTYpOw==</field>
                 <comment pinned="false" h="80" w="160">Beschreibe diese Funktion …</comment>
               </block>
              </xml>
              

              Die 12 Datenpunkte "0_userdata.0.iomodul.input1 .. 12" vom Typ "Logikwert" müssen vorher erzeugt werden.

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

              Support us

              ioBroker
              Community Adapters
              Donate

              942
              Online

              31.9k
              Users

              80.1k
              Topics

              1.3m
              Posts

              blockly
              3
              5
              1786
              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