Navigation

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

    NEWS

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

    • ioBroker goes Matter ... Matter Adapter in Stable

    • Monatsrückblick - April 2025

    Zeitdifferenz berechnen

    This topic has been deleted. Only users with topic management privileges can see it.
    • E
      erazor86 @paul53 last edited by

      @paul53
      Danke für die Infos.

      Ich habe die Änderung mit dem Intervall getestet, leider wird die Zeit aber nicht korrekt summiert... hast du eine Idee wo der Fehler liegt?

      <xml xmlns="https://developers.google.com/blockly/xml">
        <variables>
          <variable id="-8jUk([-^/E4KtM^jFpH">Einschaltdauer</variable>
          <variable type="interval" id="Intervall">Intervall</variable>
        </variables>
        <block type="on_ext" id="$kEbY#R6hv*pK~*3s7f~" x="-137" y="-887">
          <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="]RDHZN_H_)V(`JXk!Elr">
              <field name="oid">shelly.0.SHSW-PM#76B4A1#1.Relay0.Power</field>
            </shadow>
          </value>
          <statement name="STATEMENT">
            <block type="controls_if" id="Z1deQeC:Wf9EFWSp*9d.">
              <mutation elseif="1"></mutation>
              <value name="IF0">
                <block type="logic_compare" id="Und_gySW1{EKGEii[HCF">
                  <field name="OP">GT</field>
                  <value name="A">
                    <block type="get_value" id="||QIbPAQe`%W;0wg-{?#">
                      <field name="ATTR">val</field>
                      <field name="OID">shelly.0.SHSW-PM#76B4A1#1.Relay0.Power</field>
                    </block>
                  </value>
                  <value name="B">
                    <block type="math_number" id="HqE;j0Kf4sCPS7;z?]Q^">
                      <field name="NUM">30</field>
                    </block>
                  </value>
                </block>
              </value>
              <statement name="DO0">
                <block type="control" id="[,#g!m*(]K+img?eH=QG">
                  <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>
                  <field name="OID">0_userdata.0.Datenpunkte.Rechengrößen.Lüftung</field>
                  <field name="WITH_DELAY">FALSE</field>
                  <value name="VALUE">
                    <block type="logic_boolean" id="^Ac4Kzc_h}0.obCgF:E|">
                      <field name="BOOL">TRUE</field>
                    </block>
                  </value>
                </block>
              </statement>
              <value name="IF1">
                <block type="logic_compare" id="6KG7eQnX[B.%@aRx=z9d">
                  <field name="OP">LT</field>
                  <value name="A">
                    <block type="get_value" id="=F75;y^mPd(wsy0hYvB`">
                      <field name="ATTR">val</field>
                      <field name="OID">shelly.0.SHSW-PM#76B4A1#1.Relay0.Power</field>
                    </block>
                  </value>
                  <value name="B">
                    <block type="math_number" id="/!c,7EU$*|vt)O4#EhMu">
                      <field name="NUM">30</field>
                    </block>
                  </value>
                </block>
              </value>
              <statement name="DO1">
                <block type="control" id="mJ:W^[k+%f!(T#!`:)qC">
                  <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>
                  <field name="OID">0_userdata.0.Datenpunkte.Rechengrößen.Lüftung</field>
                  <field name="WITH_DELAY">FALSE</field>
                  <value name="VALUE">
                    <block type="logic_boolean" id="gFpUSs2H!_esXCo(IRSp">
                      <field name="BOOL">FALSE</field>
                    </block>
                  </value>
                </block>
              </statement>
            </block>
          </statement>
        </block>
        <block type="variables_set" id=")vn_uk6$xwFtS;?LfqDk" x="-137" y="-588">
          <field name="VAR" id="-8jUk([-^/E4KtM^jFpH">Einschaltdauer</field>
          <value name="VALUE">
            <block type="get_value" id="lxYUqLH.{;ScEd8_W{^t">
              <field name="ATTR">val</field>
              <field name="OID">0_userdata.0.Datenpunkte.Rechengrößen.Dauer</field>
            </block>
          </value>
          <next>
            <block type="on_ext" id="g10!%+,PQcoL^1CtCc1M">
              <mutation xmlns="http://www.w3.org/1999/xhtml" items="1"></mutation>
              <field name="CONDITION">true</field>
              <field name="ACK_CONDITION"></field>
              <value name="OID0">
                <shadow type="field_oid" id="1^6dn_Y//1Ld.:S1*pg/">
                  <field name="oid">0_userdata.0.Datenpunkte.Rechengrößen.Lüftung</field>
                </shadow>
              </value>
              <statement name="STATEMENT">
                <block type="timeouts_setinterval" id="F%|n+bdyr1u[T$eOo-O+">
                  <field name="NAME">Intervall</field>
                  <field name="INTERVAL">1</field>
                  <field name="UNIT">min</field>
                  <statement name="STATEMENT">
                    <block type="math_change" id="W|~lE[Qwmq@OL@N)v/_4">
                      <field name="VAR" id="-8jUk([-^/E4KtM^jFpH">Einschaltdauer</field>
                      <value name="DELTA">
                        <shadow type="math_number" id="fWsz,$6i4tL0Y7%pNn7F">
                          <field name="NUM">1</field>
                        </shadow>
                        <block type="math_arithmetic" id="8dbw%mT9A/DW6~o1_^,q" inline="false">
                          <field name="OP">MINUS</field>
                          <value name="A">
                            <shadow type="math_number" id="{,*U53G|oL{_f}d)G^$*">
                              <field name="NUM">1</field>
                            </shadow>
                            <block type="on_source" id="TK$!iiMRM!%JRabhC~fo">
                              <field name="ATTR">state.lc</field>
                            </block>
                          </value>
                          <value name="B">
                            <shadow type="math_number" id="9`6U/6qXEXc(}AK3z5/:">
                              <field name="NUM">1</field>
                            </shadow>
                            <block type="on_source" id="MDsgyx~9/!NR^RbOGcUb">
                              <field name="ATTR">oldState.lc</field>
                            </block>
                          </value>
                        </block>
                      </value>
                      <next>
                        <block type="update" id="+zK*btZIiTCUL)S.~[8D">
                          <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>
                          <field name="OID">0_userdata.0.Datenpunkte.Rechengrößen.Dauer</field>
                          <field name="WITH_DELAY">FALSE</field>
                          <value name="VALUE">
                            <block type="variables_get" id="5wD}KRR8({98*0W6r6o}">
                              <field name="VAR" id="-8jUk([-^/E4KtM^jFpH">Einschaltdauer</field>
                            </block>
                          </value>
                          <next>
                            <block type="update" id="g}hdq5eRT$=;qHw^zDv@">
                              <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>
                              <field name="OID">0_userdata.0.Datenpunkte.Rechengrößen.Dauer</field>
                              <field name="WITH_DELAY">FALSE</field>
                              <value name="VALUE">
                                <block type="convert_from_date" id="5zYzKU@-kYT+vYrXHim~">
                                  <mutation xmlns="http://www.w3.org/1999/xhtml" format="false" language="false"></mutation>
                                  <field name="OPTION">hh:mm:ss</field>
                                  <value name="VALUE">
                                    <block type="math_arithmetic" id="de6Osb3N2jOv]1ZE8LKs">
                                      <field name="OP">ADD</field>
                                      <value name="A">
                                        <shadow type="math_number" id="L,;}sdh*6EgE2`Me1YYz">
                                          <field name="NUM">1</field>
                                        </shadow>
                                        <block type="variables_get" id="?OEdL._f`+/(Z.!r^}`O">
                                          <field name="VAR" id="-8jUk([-^/E4KtM^jFpH">Einschaltdauer</field>
                                        </block>
                                      </value>
                                      <value name="B">
                                        <shadow type="math_number" id="v|/~JK[UhMh,%Mn!Xgh9">
                                          <field name="NUM">1</field>
                                        </shadow>
                                        <block type="convert_from_date" id="K:i9{k,$dbC{cRF0m%/e">
                                          <mutation xmlns="http://www.w3.org/1999/xhtml" format="false" language="false"></mutation>
                                          <field name="OPTION">object</field>
                                          <value name="VALUE">
                                            <block type="text" id="qhKVkD25/vl9XM(CX`Q0">
                                              <field name="TEXT">1970-01-01 00:00</field>
                                            </block>
                                          </value>
                                        </block>
                                      </value>
                                    </block>
                                  </value>
                                </block>
                              </value>
                            </block>
                          </next>
                        </block>
                      </next>
                    </block>
                  </statement>
                </block>
              </statement>
              <next>
                <block type="timeouts_clearinterval" id="PJ51GE9hrAOoR{osIItE">
                  <field name="NAME">Intervall</field>
                  <next>
                    <block type="schedule" id="|kytfE5cp$@M5Mjr?=aH">
                      <field name="SCHEDULE">0 0 * * *</field>
                      <statement name="STATEMENT">
                        <block type="variables_set" id="eS9Yhju/DoLFarLL^QXj">
                          <field name="VAR" id="-8jUk([-^/E4KtM^jFpH">Einschaltdauer</field>
                          <value name="VALUE">
                            <block type="math_number" id="50RLcx#=~4Lt|(*Ts50@">
                              <field name="NUM">0</field>
                            </block>
                          </value>
                          <next>
                            <block type="update" id="Ldq+96Oy#$LhNj2?O@o+">
                              <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>
                              <field name="OID">0_userdata.0.Datenpunkte.Rechengrößen.Dauer</field>
                              <field name="WITH_DELAY">FALSE</field>
                              <value name="VALUE">
                                <block type="math_number" id="VAB-z1%//`0bxPwp14r,">
                                  <field name="NUM">0</field>
                                </block>
                              </value>
                              <next>
                                <block type="update" id="O-+G9zJ.R4,~Y8b,(n+!">
                                  <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>
                                  <field name="OID">0_userdata.0.Datenpunkte.Rechengrößen.Dauer</field>
                                  <field name="WITH_DELAY">FALSE</field>
                                  <value name="VALUE">
                                    <block type="text" id="8jFlvBl*%rTvcjRF;3^l">
                                      <field name="TEXT">00:00:00</field>
                                    </block>
                                  </value>
                                </block>
                              </next>
                            </block>
                          </next>
                        </block>
                      </statement>
                    </block>
                  </next>
                </block>
              </next>
            </block>
          </next>
        </block>
      </xml>
      
      paul53 1 Reply Last reply Reply Quote 0
      • paul53
        paul53 @erazor86 last edited by paul53

        @erazor86 Man kann nicht den gleichen Datenpunkt für einen String ("SS:mm:ss") und auch für die Zeitdifferenz in ms verwenden. Das müssen verschiedene Datenpunkte sein.
        Versuche es mal hiermit:

        Bild_2021-12-12_234349.png

        <xml xmlns="https://developers.google.com/blockly/xml">
         <variables>
           <variable id="-8jUk([-^/E4KtM^jFpH">Einschaltdauer</variable>
           <variable id=".M;hWc%-tKkr1@W+1LrA">aktuelleED</variable>
           <variable type="interval" id="Intervall">Intervall</variable>
         </variables>
         <block type="on_ext" id="$kEbY#R6hv*pK~*3s7f~" x="-137" y="-887">
           <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="]RDHZN_H_)V(`JXk!Elr">
               <field name="oid">shelly.0.SHSW-PM#76B4A1#1.Relay0.Power</field>
             </shadow>
           </value>
           <statement name="STATEMENT">
             <block type="control" id="[,#g!m*(]K+img?eH=QG">
               <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>
               <field name="OID">0_userdata.0.Datenpunkte.Rechengrößen.Lüftung</field>
               <field name="WITH_DELAY">FALSE</field>
               <value name="VALUE">
                 <block type="logic_compare" id="Und_gySW1{EKGEii[HCF">
                   <field name="OP">GT</field>
                   <value name="A">
                     <block type="get_value" id="||QIbPAQe`%W;0wg-{?#">
                       <field name="ATTR">val</field>
                       <field name="OID">shelly.0.SHSW-PM#76B4A1#1.Relay0.Power</field>
                     </block>
                   </value>
                   <value name="B">
                     <block type="math_number" id="HqE;j0Kf4sCPS7;z?]Q^">
                       <field name="NUM">30</field>
                     </block>
                   </value>
                 </block>
               </value>
             </block>
           </statement>
           <next>
             <block type="variables_set" id=")vn_uk6$xwFtS;?LfqDk">
               <field name="VAR" id="-8jUk([-^/E4KtM^jFpH">Einschaltdauer</field>
               <value name="VALUE">
                 <block type="math_arithmetic" id="|OpM`7r4*#g{V(atOXeP" inline="false">
                   <field name="OP">MINUS</field>
                   <value name="A">
                     <shadow type="math_number" id="b]+0ib3EcZ~2_oMcuWye">
                       <field name="NUM">1</field>
                     </shadow>
                     <block type="convert_from_date" id="R366`43-0$M-yx[Ho$-S">
                       <mutation xmlns="http://www.w3.org/1999/xhtml" format="false" language="false"></mutation>
                       <field name="OPTION">object</field>
                       <value name="VALUE">
                         <block type="get_value" id="lxYUqLH.{;ScEd8_W{^t">
                           <field name="ATTR">val</field>
                           <field name="OID">0_userdata.0.Datenpunkte.Rechengrößen.Dauer</field>
                         </block>
                       </value>
                     </block>
                   </value>
                   <value name="B">
                     <shadow type="math_number" id="Maco,i~T7aXgM%`$#ZH=">
                       <field name="NUM">1</field>
                     </shadow>
                     <block type="convert_from_date" id="iZ|uy?-0G:C=QT{p_G.Y">
                       <mutation xmlns="http://www.w3.org/1999/xhtml" format="false" language="false"></mutation>
                       <field name="OPTION">object</field>
                       <value name="VALUE">
                         <block type="text" id="/JUQfzjSZ0|9RZsQqyYE">
                           <field name="TEXT">00:00:00</field>
                         </block>
                       </value>
                     </block>
                   </value>
                 </block>
               </value>
               <next>
                 <block type="on_ext" id="g10!%+,PQcoL^1CtCc1M">
                   <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="1^6dn_Y//1Ld.:S1*pg/">
                       <field name="oid">0_userdata.0.Datenpunkte.Rechengrößen.Lüftung</field>
                     </shadow>
                   </value>
                   <statement name="STATEMENT">
                     <block type="controls_if" id=".PO:1M;FRU?d].Nd5sPc">
                       <mutation else="1"></mutation>
                       <value name="IF0">
                         <block type="on_source" id="W+aPPoh~~slVC@YQcf;@">
                           <field name="ATTR">state.val</field>
                         </block>
                       </value>
                       <statement name="DO0">
                         <block type="variables_set" id="!OE$Ko{1N9#?t.4BPSg,">
                           <field name="VAR" id=".M;hWc%-tKkr1@W+1LrA">aktuelleED</field>
                           <value name="VALUE">
                             <block type="math_number" id="Re%ze)=eXwGl[S84%(G#">
                               <field name="NUM">0</field>
                             </block>
                           </value>
                           <next>
                             <block type="timeouts_setinterval" id="F%|n+bdyr1u[T$eOo-O+">
                               <field name="NAME">Intervall</field>
                               <field name="INTERVAL">1</field>
                               <field name="UNIT">min</field>
                               <statement name="STATEMENT">
                                 <block type="math_change" id="4`4wkv(iK;LhA;jCuNZL">
                                   <field name="VAR" id=".M;hWc%-tKkr1@W+1LrA">aktuelleED</field>
                                   <value name="DELTA">
                                     <shadow type="math_number" id="m4-Y_9;xuDdomh3@HwQ}">
                                       <field name="NUM">60000</field>
                                     </shadow>
                                   </value>
                                   <next>
                                     <block type="update" id="+zK*btZIiTCUL)S.~[8D">
                                       <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>
                                       <field name="OID">0_userdata.0.Datenpunkte.Rechengrößen.Dauer</field>
                                       <field name="WITH_DELAY">FALSE</field>
                                       <value name="VALUE">
                                         <block type="convert_from_date" id="lFVMWNt-~#geUqV:%$YI">
                                           <mutation xmlns="http://www.w3.org/1999/xhtml" format="false" language="false"></mutation>
                                           <field name="OPTION">hh:mm:ss</field>
                                           <value name="VALUE">
                                             <block type="math_arithmetic" id="Y,Wo/G)odmv`):~[qQBc">
                                               <field name="OP">ADD</field>
                                               <value name="A">
                                                 <shadow type="math_number" id="CnZ2|N^8d|}1:oyCMS2I">
                                                   <field name="NUM">1</field>
                                                 </shadow>
                                                 <block type="math_arithmetic" id="FGgA^p;#:H7W;hU-LpHs">
                                                   <field name="OP">ADD</field>
                                                   <value name="A">
                                                     <shadow type="math_number" id=".=cyKFyxrA=s-Wk4Wwt#">
                                                       <field name="NUM">1</field>
                                                     </shadow>
                                                     <block type="variables_get" id="5wD}KRR8({98*0W6r6o}">
                                                       <field name="VAR" id="-8jUk([-^/E4KtM^jFpH">Einschaltdauer</field>
                                                     </block>
                                                   </value>
                                                   <value name="B">
                                                     <shadow type="math_number" id="5|iqT4XOgkKp4XTFP_,S">
                                                       <field name="NUM">1</field>
                                                     </shadow>
                                                     <block type="variables_get" id="%eY8G+BT{E$3`DI:)sGp">
                                                       <field name="VAR" id=".M;hWc%-tKkr1@W+1LrA">aktuelleED</field>
                                                     </block>
                                                   </value>
                                                 </block>
                                               </value>
                                               <value name="B">
                                                 <shadow type="math_number" id="bnO%l+X9Gx/_M)S,d7[g">
                                                   <field name="NUM">1</field>
                                                 </shadow>
                                                 <block type="convert_from_date" id="K:i9{k,$dbC{cRF0m%/e">
                                                   <mutation xmlns="http://www.w3.org/1999/xhtml" format="false" language="false"></mutation>
                                                   <field name="OPTION">object</field>
                                                   <value name="VALUE">
                                                     <block type="text" id="qhKVkD25/vl9XM(CX`Q0">
                                                       <field name="TEXT">1970-01-01 00:00</field>
                                                     </block>
                                                   </value>
                                                 </block>
                                               </value>
                                             </block>
                                           </value>
                                         </block>
                                       </value>
                                     </block>
                                   </next>
                                 </block>
                               </statement>
                             </block>
                           </next>
                         </block>
                       </statement>
                       <statement name="ELSE">
                         <block type="timeouts_clearinterval" id="ii#;LBc`SXmzlL?)5[0h">
                           <field name="NAME">Intervall</field>
                           <next>
                             <block type="math_change" id="W|~lE[Qwmq@OL@N)v/_4">
                               <field name="VAR" id="-8jUk([-^/E4KtM^jFpH">Einschaltdauer</field>
                               <value name="DELTA">
                                 <shadow type="math_number" id="fWsz,$6i4tL0Y7%pNn7F">
                                   <field name="NUM">1</field>
                                 </shadow>
                                 <block type="math_arithmetic" id="8dbw%mT9A/DW6~o1_^,q" inline="false">
                                   <field name="OP">MINUS</field>
                                   <value name="A">
                                     <shadow type="math_number" id="{,*U53G|oL{_f}d)G^$*">
                                       <field name="NUM">1</field>
                                     </shadow>
                                     <block type="on_source" id="TK$!iiMRM!%JRabhC~fo">
                                       <field name="ATTR">state.lc</field>
                                     </block>
                                   </value>
                                   <value name="B">
                                     <shadow type="math_number" id="9`6U/6qXEXc(}AK3z5/:">
                                       <field name="NUM">1</field>
                                     </shadow>
                                     <block type="on_source" id="MDsgyx~9/!NR^RbOGcUb">
                                       <field name="ATTR">oldState.lc</field>
                                     </block>
                                   </value>
                                 </block>
                               </value>
                               <next>
                                 <block type="update" id="g}hdq5eRT$=;qHw^zDv@">
                                   <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>
                                   <field name="OID">0_userdata.0.Datenpunkte.Rechengrößen.Dauer</field>
                                   <field name="WITH_DELAY">FALSE</field>
                                   <value name="VALUE">
                                     <block type="convert_from_date" id="5zYzKU@-kYT+vYrXHim~">
                                       <mutation xmlns="http://www.w3.org/1999/xhtml" format="false" language="false"></mutation>
                                       <field name="OPTION">hh:mm:ss</field>
                                       <value name="VALUE">
                                         <block type="math_arithmetic" id="de6Osb3N2jOv]1ZE8LKs">
                                           <field name="OP">ADD</field>
                                           <value name="A">
                                             <shadow type="math_number" id="L,;}sdh*6EgE2`Me1YYz">
                                               <field name="NUM">1</field>
                                             </shadow>
                                             <block type="variables_get" id="?OEdL._f`+/(Z.!r^}`O">
                                               <field name="VAR" id="-8jUk([-^/E4KtM^jFpH">Einschaltdauer</field>
                                             </block>
                                           </value>
                                           <value name="B">
                                             <shadow type="math_number" id="v|/~JK[UhMh,%Mn!Xgh9">
                                               <field name="NUM">1</field>
                                             </shadow>
                                             <block type="convert_from_date" id="7vdBgw4zJVyR%+9o0iuW">
                                               <mutation xmlns="http://www.w3.org/1999/xhtml" format="false" language="false"></mutation>
                                               <field name="OPTION">object</field>
                                               <value name="VALUE">
                                                 <block type="text" id="kNJ7`:@%CLI`KBJ:(peF">
                                                   <field name="TEXT">1970-01-01 00:00</field>
                                                 </block>
                                               </value>
                                             </block>
                                           </value>
                                         </block>
                                       </value>
                                     </block>
                                   </value>
                                 </block>
                               </next>
                             </block>
                           </next>
                         </block>
                       </statement>
                     </block>
                   </statement>
                   <next>
                     <block type="schedule" id="|kytfE5cp$@M5Mjr?=aH">
                       <field name="SCHEDULE">0 0 * * *</field>
                       <statement name="STATEMENT">
                         <block type="variables_set" id="eS9Yhju/DoLFarLL^QXj">
                           <field name="VAR" id="-8jUk([-^/E4KtM^jFpH">Einschaltdauer</field>
                           <value name="VALUE">
                             <block type="math_number" id="50RLcx#=~4Lt|(*Ts50@">
                               <field name="NUM">0</field>
                             </block>
                           </value>
                           <next>
                             <block type="update" id="O-+G9zJ.R4,~Y8b,(n+!">
                               <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>
                               <field name="OID">0_userdata.0.Datenpunkte.Rechengrößen.Dauer</field>
                               <field name="WITH_DELAY">FALSE</field>
                               <value name="VALUE">
                                 <block type="text" id="8jFlvBl*%rTvcjRF;3^l">
                                   <field name="TEXT">00:00:00</field>
                                 </block>
                               </value>
                             </block>
                           </next>
                         </block>
                       </statement>
                     </block>
                   </next>
                 </block>
               </next>
             </block>
           </next>
         </block>
        </xml>
        

        E 2 Replies Last reply Reply Quote 0
        • E
          erazor86 @paul53 last edited by

          @paul53 es funktioniert 👍 super und besten Dank... auch wenn ich noch nicht ganz durch steige 😉 muss ich mir nochmal in einer ruhigen Minute zu Gemüte führen 😉

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

            @paul53 jetzt wird die Dauer der Lüftung in ss:mm:ss in den Datenpunkt geschrieben.

            Wie kann ich dieses Format jetzt in eine Dezimalzahl konvertieren? Bspw. aus 08:30:00 soll dann 8,5 werden.
            Ich habe es wie folgt probiert, allerdings wird mir nur die 8h ausgegeben..
            dezimal.JPG

            <block xmlns="https://developers.google.com/blockly/xml" type="on_ext" id="g10!%+,PQcoL^1CtCc1M" x="-162" y="-487">
              <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="1^6dn_Y//1Ld.:S1*pg/">
                  <field name="oid">0_userdata.0.Datenpunkte.Rechengrößen.Dauer</field>
                </shadow>
              </value>
              <statement name="STATEMENT">
                <block type="update" id="Qg5uQ5,C~h#CP}OXp,n|">
                  <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>
                  <field name="OID">0_userdata.0.Datenpunkte.Rechengrößen.Dauer_dezimal</field>
                  <field name="WITH_DELAY">FALSE</field>
                  <value name="VALUE">
                    <block type="convert_tonumber" id="7`9D*4n16D87os~S.wgX">
                      <value name="VALUE">
                        <block type="on_source" id="6QPqXzV(jXa`:A/Jy*s|">
                          <field name="ATTR">state.val</field>
                        </block>
                      </value>
                    </block>
                  </value>
                </block>
              </statement>
            </block>
            
            paul53 2 Replies Last reply Reply Quote 0
            • paul53
              paul53 @erazor86 last edited by

              @erazor86 sagte: Format jetzt in eine Dezimalzahl konvertieren?

              Schreibe besser den Wert als Dezimalzahl im ursprünglichen Skript:

              Bild_2021-12-14_214147.png

              Der untere Datenpunkt erhält den Dezimalwert.

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

                @erazor86
                Die Wandlung des Strings "SS:mm:ss" in eine Dezimalzahl ist etwas aufwändiger.

                Bild_2021-12-14_225151.png

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

                  @paul53 said in Zeitdifferenz berechnen:

                  @erazor86
                  Die Wandlung des Strings "SS:mm:ss" in eine Dezimalzahl ist etwas aufwändiger.

                  Bild_2021-12-14_225151.png

                  danke, doch irgendwie gibt es hierbei ein Problem... steige nicht ganz durch, wo das Problem liegt:
                  log.JPG

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

                    @erazor86 sagte: wo das Problem liegt:

                    Poste bitte den Javascript-Code ohne die letzte Zeile in Code tags.

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

                      @paul53

                      <xml xmlns="https://developers.google.com/blockly/xml">
                        <variables>
                          <variable id="H_b:)/lk~U=V#?2Fm-_6">Einschaltdauer</variable>
                          <variable id="9zZ/z:qt+2ur[Mg(U{^@">Liste</variable>
                        </variables>
                        <block type="on_ext" id="g10!%+,PQcoL^1CtCc1M" x="-187" y="-487">
                          <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="1^6dn_Y//1Ld.:S1*pg/">
                              <field name="oid">0_userdata.0.Datenpunkte.Rechengrößen.Dauer</field>
                            </shadow>
                          </value>
                          <statement name="STATEMENT">
                            <block type="variables_set" id="jmdG%dMd*=ZRFyjN};FO">
                              <field name="VAR" id="H_b:)/lk~U=V#?2Fm-_6">Einschaltdauer</field>
                              <value name="VALUE">
                                <block type="lists_split" id="UrkwL9|$/`pGV6dtQ4=#">
                                  <mutation mode="SPLIT"></mutation>
                                  <field name="MODE">SPLIT</field>
                                  <value name="INPUT">
                                    <block type="on_source" id="/tG2*O8M2}DxPJBVce+(">
                                      <field name="ATTR">state.val</field>
                                    </block>
                                  </value>
                                  <value name="DELIM">
                                    <shadow type="text" id="jddb#N[0ZokH]@uv|$^L">
                                      <field name="TEXT">:</field>
                                    </shadow>
                                  </value>
                                </block>
                              </value>
                              <next>
                                <block type="variables_set" id="yo,~CC4vFjRQ+!BI[Dj3">
                                  <field name="VAR" id="H_b:)/lk~U=V#?2Fm-_6">Einschaltdauer</field>
                                  <value name="VALUE">
                                    <block type="math_arithmetic" id=";{JdB#Q(L~2pI)@VEq]X" inline="false">
                                      <field name="OP">ADD</field>
                                      <value name="A">
                                        <shadow type="math_number" id="3c9}N}KuPq4SPU`Vi.}0">
                                          <field name="NUM">1</field>
                                        </shadow>
                                        <block type="convert_tonumber" id="6tSv_rtVlamrBt%%sdNk">
                                          <value name="VALUE">
                                            <block type="lists_getIndex" id="j;YZ-#|;ymc?7Z!/}m`$">
                                              <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="*zdTBCpC?k.-sQA7_Jd6">
                                                  <field name="VAR" id="9zZ/z:qt+2ur[Mg(U{^@">Liste</field>
                                                </block>
                                              </value>
                                              <value name="AT">
                                                <block type="math_number" id="8e{^1DPK0hDM:M;#X-S2">
                                                  <field name="NUM">1</field>
                                                </block>
                                              </value>
                                            </block>
                                          </value>
                                        </block>
                                      </value>
                                      <value name="B">
                                        <shadow type="math_number" id="pL0;D`,uYz`_FzqS0iED">
                                          <field name="NUM">1</field>
                                        </shadow>
                                        <block type="math_rndfixed" id="dngO+Sv-~SYJ@nbcCD?}">
                                          <field name="n">1</field>
                                          <value name="x">
                                            <shadow type="math_number" id="IkY$?m}d-0oo0[1S/kHE">
                                              <field name="NUM">3.1234</field>
                                            </shadow>
                                            <block type="math_arithmetic" id="W{h5)61$s9~M5v9,Fi-O">
                                              <field name="OP">DIVIDE</field>
                                              <value name="A">
                                                <shadow type="math_number" id="]yL|:!R]:vuM,{XmCAR+">
                                                  <field name="NUM">1</field>
                                                </shadow>
                                                <block type="lists_getIndex" id="}XJb*fL,oH]:}i%XL1@/">
                                                  <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="}~3#`VQg2s=7HTPvh~,0">
                                                      <field name="VAR" id="9zZ/z:qt+2ur[Mg(U{^@">Liste</field>
                                                    </block>
                                                  </value>
                                                  <value name="AT">
                                                    <block type="math_number" id="ge_58=bFeMNGFo7bk8`9">
                                                      <field name="NUM">2</field>
                                                    </block>
                                                  </value>
                                                </block>
                                              </value>
                                              <value name="B">
                                                <shadow type="math_number" id="1mGyZqUY*qCf4zf!K^TZ">
                                                  <field name="NUM">60</field>
                                                </shadow>
                                              </value>
                                            </block>
                                          </value>
                                        </block>
                                      </value>
                                    </block>
                                  </value>
                                  <next>
                                    <block type="update" id="Qg5uQ5,C~h#CP}OXp,n|">
                                      <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>
                                      <field name="OID">0_userdata.0.Datenpunkte.Rechengrößen.Dauer_dezimal</field>
                                      <field name="WITH_DELAY">FALSE</field>
                                      <value name="VALUE">
                                        <block type="variables_get" id=";*9U=xcn:`{pl^f5-rs,">
                                          <field name="VAR" id="H_b:)/lk~U=V#?2Fm-_6">Einschaltdauer</field>
                                        </block>
                                      </value>
                                    </block>
                                  </next>
                                </block>
                              </next>
                            </block>
                          </statement>
                        </block>
                      </xml>
                      
                      paul53 1 Reply Last reply Reply Quote 0
                      • paul53
                        paul53 @erazor86 last edited by

                        @erazor86
                        Tausche an 2 Stellen die Variable Liste gegen Einschaltdauer.

                        E B 2 Replies Last reply Reply Quote 0
                        • E
                          erazor86 @paul53 last edited by

                          @paul53
                          🤦 manchmal könnte es so einfach sein.... Vielen Dank.. 🙂

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

                            Hallo zusammen,

                            ich komme mit meiner Differenzzeit in Minuten ebenfalls nicht weiter. Ich versuche die Zeitdifferenz zwischen "Jetzt" und der letzten Aktualisierung eines Datenpunktes in Minuten zu errechnen und diese in den Datenpunkt "AbwesendSeitMinuten" zu schreiben.

                            Das folgende Blockly funktioniert bis 59 Minuten prima, alles darüber hinaus funktioniert jedoch nicht. Es werden also zum Beispiel nicht 67 Minuten Differenz dargestellt, sondern nur "7". Die restlichen 60 Minuten verschwinden.

                            7bbe51c6-f99c-4a96-96c4-53d43d4fe972-image.png

                            <xml xmlns="https://developers.google.com/blockly/xml">
                              <block type="comment" id="vdO3Z/b-^J_@l)?Eq_R+" x="13" y="38">
                                <field name="COMMENT">Abwesenheitszeit berechnen</field>
                                <next>
                                  <block type="on" id="-Se3D{`):B`]p/=p_aOI">
                                    <field name="OID">fb-checkpresence.0.presentCount</field>
                                    <field name="CONDITION">any</field>
                                    <field name="ACK_CONDITION"></field>
                                    <statement name="STATEMENT">
                                      <block type="controls_if" id="g$$Mh+_gT[pE?%~wmOw7">
                                        <value name="IF0">
                                          <block type="logic_compare" id="B~cGcXi@sZ~Vuxeg9NrH">
                                            <field name="OP">EQ</field>
                                            <value name="A">
                                              <block type="get_value" id="Ra3xND;{0=Gx-[pw@??P">
                                                <field name="ATTR">val</field>
                                                <field name="OID">fb-checkpresence.0.presentCount</field>
                                              </block>
                                            </value>
                                            <value name="B">
                                              <block type="text" id="|2l5jEGj$arki%U@aI1*">
                                                <field name="TEXT">0</field>
                                              </block>
                                            </value>
                                          </block>
                                        </value>
                                        <statement name="DO0">
                                          <block type="update" id="fO*d3{jQ-Q,Muo5?^aHF">
                                            <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>
                                            <field name="OID">0_userdata.0.AbwesendSeitMinuten</field>
                                            <field name="WITH_DELAY">FALSE</field>
                                            <value name="VALUE">
                                              <block type="convert_from_date" id="xF2Wqp~s/~y5PUaC_;7^">
                                                <mutation xmlns="http://www.w3.org/1999/xhtml" format="false" language="false"></mutation>
                                                <field name="OPTION">m</field>
                                                <value name="VALUE">
                                                  <block type="math_arithmetic" id="{)*krPx!rRWcV.lMNvs9">
                                                    <field name="OP">MINUS</field>
                                                    <value name="A">
                                                      <shadow type="math_number" id="rD[[`+/pH}Z,=`RaZDKb">
                                                        <field name="NUM">1</field>
                                                      </shadow>
                                                      <block type="time_get" id="{YtxVX%(xd!aZrGPIR%/">
                                                        <mutation xmlns="http://www.w3.org/1999/xhtml" format="false" language="false"></mutation>
                                                        <field name="OPTION">object</field>
                                                      </block>
                                                    </value>
                                                    <value name="B">
                                                      <shadow type="math_number" id="U}:)~D1u/;(DT4d+kNZM">
                                                        <field name="NUM">1</field>
                                                      </shadow>
                                                      <block type="get_value" id="}D,-3Ku3mkH){l1UJ|o?">
                                                        <field name="ATTR">lc</field>
                                                        <field name="OID">fb-checkpresence.0.presentCount</field>
                                                      </block>
                                                    </value>
                                                  </block>
                                                </value>
                                              </block>
                                            </value>
                                          </block>
                                        </statement>
                                      </block>
                                    </statement>
                                  </block>
                                </next>
                              </block>
                            </xml>
                            
                            paul53 1 Reply Last reply Reply Quote 0
                            • paul53
                              paul53 @brofelscher last edited by

                              @brofelscher sagte: Blockly funktioniert bis 59 Minuten prima

                              Das sind die Minuten der Uhrzeit.
                              Vorschlag:

                              Bild_2021-12-28_224042.png

                              <xml xmlns="https://developers.google.com/blockly/xml">
                               <block type="comment" id="vdO3Z/b-^J_@l)?Eq_R+" x="13" y="38">
                                 <field name="COMMENT">Abwesenheitszeit berechnen</field>
                                 <next>
                                   <block type="on" id="-Se3D{`):B`]p/=p_aOI">
                                     <field name="OID">fb-checkpresence.0.presentCount</field>
                                     <field name="CONDITION">any</field>
                                     <field name="ACK_CONDITION"></field>
                                     <statement name="STATEMENT">
                                       <block type="controls_if" id="g$$Mh+_gT[pE?%~wmOw7">
                                         <value name="IF0">
                                           <block type="logic_compare" id="B~cGcXi@sZ~Vuxeg9NrH">
                                             <field name="OP">EQ</field>
                                             <value name="A">
                                               <block type="get_value" id="Ra3xND;{0=Gx-[pw@??P">
                                                 <field name="ATTR">val</field>
                                                 <field name="OID">fb-checkpresence.0.presentCount</field>
                                               </block>
                                             </value>
                                             <value name="B">
                                               <block type="text" id="|2l5jEGj$arki%U@aI1*">
                                                 <field name="TEXT">0</field>
                                               </block>
                                             </value>
                                           </block>
                                         </value>
                                         <statement name="DO0">
                                           <block type="update" id="fO*d3{jQ-Q,Muo5?^aHF">
                                             <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>
                                             <field name="OID">0_userdata.0.AbwesendSeitMinuten</field>
                                             <field name="WITH_DELAY">FALSE</field>
                                             <value name="VALUE">
                                               <block type="math_round" id="jh5X6wfE6}koDRuR}h,7">
                                                 <field name="OP">ROUND</field>
                                                 <value name="NUM">
                                                   <shadow type="math_number" id="dsl{1yg*UVLul@F2*}_x">
                                                     <field name="NUM">3.1</field>
                                                   </shadow>
                                                   <block type="math_arithmetic" id="CG|Sg`nEt;fkO/q}:-Eg">
                                                     <field name="OP">DIVIDE</field>
                                                     <value name="A">
                                                       <shadow type="math_number" id="r16alN.iyJ)%|~KKF{p5">
                                                         <field name="NUM">1</field>
                                                       </shadow>
                                                       <block type="math_arithmetic" id="{)*krPx!rRWcV.lMNvs9">
                                                         <field name="OP">MINUS</field>
                                                         <value name="A">
                                                           <shadow type="math_number" id="rD[[`+/pH}Z,=`RaZDKb">
                                                             <field name="NUM">1</field>
                                                           </shadow>
                                                           <block type="time_get" id="{YtxVX%(xd!aZrGPIR%/">
                                                             <mutation xmlns="http://www.w3.org/1999/xhtml" format="false" language="false"></mutation>
                                                             <field name="OPTION">object</field>
                                                           </block>
                                                         </value>
                                                         <value name="B">
                                                           <shadow type="math_number" id="U}:)~D1u/;(DT4d+kNZM">
                                                             <field name="NUM">1</field>
                                                           </shadow>
                                                           <block type="on_source" id="75tkb;IKslfqIl;1JyN#">
                                                             <field name="ATTR">oldState.lc</field>
                                                           </block>
                                                         </value>
                                                       </block>
                                                     </value>
                                                     <value name="B">
                                                       <shadow type="math_number" id="7o1So,{6-3V~;lGxE-;P">
                                                         <field name="NUM">60000</field>
                                                       </shadow>
                                                     </value>
                                                   </block>
                                                 </value>
                                               </block>
                                             </value>
                                           </block>
                                         </statement>
                                       </block>
                                     </statement>
                                   </block>
                                 </next>
                               </block>
                              </xml>
                              

                              B 1 Reply Last reply Reply Quote 1
                              • B
                                brofelscher @paul53 last edited by

                                @paul53 said in Zeitdifferenz berechnen:

                                Vorschlag:

                                Bild_2021-12-28_224042.png

                                Hi, dein Vorschlag passt perfekt 🙂 Danke dir.

                                Ich habe wohl die Funktion "Minuten" missverstanden, da ich für die Minuten auch die Formatierung "mm" hätte nutzen können.
                                Und wieder ist man ein wenig schlauer 🙂

                                1 Reply Last reply Reply Quote 0
                                • E
                                  erazor86 last edited by

                                  Ich habe wieder eine neue Aufgabenstellung bzgl. Zeitverrechnung. Diesmal möchte ich die mittlere Außentemperatur der letzten 3h berechnen. Ich habe hierzu mal ein Blockly erstellt. Jedoch ist es nicht ganz korrekt, da die durchschnittliche Temp nur alle 3h neu berechnet wird. Habe es leider nicht hinbekommen wie ich es gerne hätte. Vielleicht hat jemand einen Tip?
                                  tempdurchschnitt.JPG

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

                                    @erazor86 sagte: Vielleicht hat jemand einen Tip?

                                    Suche mal im Forum nach "gleitender Mittelwert".

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

                                      @paul53
                                      Guten Abend,
                                      leider funktioniert die Zeitberechnung so leider nicht.
                                      Ich würde gerne immer die Zeitdifferenz bis zum nächsten Sonnenaufgang berechnen.
                                      Also 1h vor dem Sonnenaufgang müsste 1h rauskommen, eine Stunde nach dem Sonnenaufgang müsste 23h rauskommen.

                                      Mit folgendem Blockly kommt aber leider gar nichts raus:
                                      72191ec5-e308-416a-819f-4ce029ed05d6-grafik.png

                                      62cbb7ba-6d4e-4dcc-a86e-58aebfb1351d-grafik.png

                                      Hat vielleicht jemand eine Idee, wie ich das hinbekommen könnte?

                                      Besten Dank!

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

                                        @strobi sagte eine Stunde nach dem Sonnenaufgang müsste 23h rauskommen.

                                        Nein, dann kommt am gleichen Tag ein negativer Wert raus. Teste die Berechnung erst mal mit dem Debug-Block.

                                        Der Datenpunkt scheint keinen Zustand zu haben. Ist es der richtige DP? Das Skript ist aktiv, nicht unter der Gruppe "global" erstellt und der Debug-Modus (rechts oben) ist deaktiviert?

                                        Für positive Werte:

                                        Bild_2022-01-17_235843.png

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

                                          @paul53
                                          So geht es - falls es noch jemanden interessiert - Zeitspanne bis zum nächsten Sonnenaufgang 🙂
                                          e87b1c2e-3e72-4fb5-a526-b9fb563ca8f0-grafik.png

                                          1 Reply Last reply Reply Quote 0
                                          • JB_Sullivan
                                            JB_Sullivan last edited by

                                            Auch wenn dieser Thread schon "100 Jahre" alt ist, würde ich mich gerne mit meiner Frage hier anschließen, da es sich ebenfalls um eine "Zeit berechnen" Frage handelt.

                                            Konkrete Problemstellung:
                                            Ich habe zwei Datenpunkte - einmal die Zeit als UTC und dann den Lokalen Korrekturfaktor +2 Std. (CET)

                                            Wie kann ich den vorhandenen DP, welcher so aussieht 2022-10-25T13:23:32Z nun um + 2 Stunden hoch addieren?

                                            Das hier funktioniert jedenfalls nicht 😞

                                            178032b4-91c6-4d87-89aa-304ba35c05c0-image.png

                                            haus-automatisierung 1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post

                                            Support us

                                            ioBroker
                                            Community Adapters
                                            Donate

                                            1.1k
                                            Online

                                            31.7k
                                            Users

                                            79.7k
                                            Topics

                                            1.3m
                                            Posts

                                            blockly
                                            19
                                            93
                                            15091
                                            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