Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. Blockly
    5. Nutzungsdauer vom Handy anzeigen lassen (unifi)

    NEWS

    • Wir empfehlen: Node.js 22.x

    • Neuer Blog: Fotos und Eindrücke aus Solingen

    • ioBroker goes Matter ... Matter Adapter in Stable

    Nutzungsdauer vom Handy anzeigen lassen (unifi)

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

      Hallo.

      Ich habe einen Uptime Datenpunkt im Unify-Adapter. Der zeigt mir alle 30 Sekunden einen aktuellen Wert in Sekunden an wie lange ein Gerät online ist.

      Ich würde gerne in der VIS anzeigen lassen wie lange jemand z.B. mit dem Handy online ist.
      (alle Blockly-Beispiele die ich im Netz gefunden und ausprobiert habe, haben leider nicht funktioniert)

      Hier ist mal mein nicht funktionierendes Skript:

      tutnich.jpg

      <xml xmlns="https://developers.google.com/blockly/xml">
        <variables>
          <variable id="fY_F9{eY1;h}wP?vcr()">UptimeZeit</variable>
        </variables>
        <block type="comment" id="/;ZRw=#X-(8q/6mmWt-j" x="88" y="-362">
          <field name="COMMENT">Datenpunkt anlegen</field>
          <next>
            <block type="create" id="K(QDlz0t6.{2Pq+PF_A^">
              <field name="NAME">0_userdata.0.unifi.Nutzungsdauer_Frank</field>
              <value name="VALUE">
                <block type="math_number" id="F:fd)tm:n!J6^vPJg$:H">
                  <field name="NUM">0</field>
                </block>
              </value>
              <value name="COMMON">
                <block type="text" id="q6Pk,4oOFfz~N`%)`^jw">
                  <field name="TEXT">{"name": "NutzungsdauerFrank", "type": "string", "unit": "h", "write": true, "read": true}</field>
                </block>
              </value>
              <next>
                <block type="comment" id="dwTsB5EXpHuS0=+=4Gp.">
                  <field name="COMMENT">um 0:01 den Wert auf 0 setzen</field>
                  <next>
                    <block type="schedule" id="b[lyw/{nfZfvqKs4+VvL">
                      <field name="SCHEDULE">{"time":{"exactTime":true,"start":"00:01"},"period":{"days":1}}</field>
                      <statement name="STATEMENT">
                        <block type="variables_set" id="_WC{AOB{MCn`w+CZ0:[F">
                          <field name="VAR" id="fY_F9{eY1;h}wP?vcr()">UptimeZeit</field>
                          <value name="VALUE">
                            <block type="math_number" id="ce?-+ZAn1^Gn=!,`A^J[">
                              <field name="NUM">0</field>
                            </block>
                          </value>
                        </block>
                      </statement>
                      <next>
                        <block type="comment" id="hx=3,gLEAlY2M5P9|.Zs">
                          <field name="COMMENT">Berechnen</field>
                          <next>
                            <block type="on_ext" id="8,jc8wcL/E4r7n$HaBfB">
                              <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="?xFLO|`y~#Vhz,Q~=yLv">
                                  <field name="oid">unifi.1.default.clients.18:65:90:81:be:bf.uptime</field>
                                </shadow>
                              </value>
                              <statement name="STATEMENT">
                                <block type="debug" id="?UPgrIZ-lci;kNCIfRn?">
                                  <field name="Severity">log</field>
                                  <value name="TEXT">
                                    <shadow type="text" id="ZoX+2y9fnOMe?v%6h$lZ">
                                      <field name="TEXT">test</field>
                                    </shadow>
                                    <block type="get_value" id="JmvnIHh%bV[/d-2oHxn,">
                                      <field name="ATTR">val</field>
                                      <field name="OID">unifi.1.default.clients.18:65:90:81:be:bf.uptime</field>
                                    </block>
                                  </value>
                                  <next>
                                    <block type="controls_if" id="T_5#n@lBG-_83OFlf|)D">
                                      <value name="IF0">
                                        <block type="logic_negate" id="9O]ctrj~[QMSl;srQEr@">
                                          <value name="BOOL">
                                            <block type="on_source" id="i%Re+gm?HisoQvZ;y2H?">
                                              <field name="ATTR">state.val</field>
                                            </block>
                                          </value>
                                        </block>
                                      </value>
                                      <statement name="DO0">
                                        <block type="variables_set" id="LE?[]!rh4Vs2JM3NZN5t">
                                          <field name="VAR" id="fY_F9{eY1;h}wP?vcr()">UptimeZeit</field>
                                          <value name="VALUE">
                                            <block type="math_arithmetic" id="PZ:nIxCw/6AX!Fk!_TBg" inline="false">
                                              <field name="OP">ADD</field>
                                              <value name="A">
                                                <shadow type="math_number">
                                                  <field name="NUM">1</field>
                                                </shadow>
                                                <block type="variables_get" id="xcrw1;dE|qXShSx-otl[">
                                                  <field name="VAR" id="fY_F9{eY1;h}wP?vcr()">UptimeZeit</field>
                                                </block>
                                              </value>
                                              <value name="B">
                                                <shadow type="math_number">
                                                  <field name="NUM">1</field>
                                                </shadow>
                                                <block type="math_arithmetic" id="Invk3@2?f1O75MEI=sS!" inline="false">
                                                  <field name="OP">MINUS</field>
                                                  <value name="A">
                                                    <shadow type="math_number">
                                                      <field name="NUM">1</field>
                                                    </shadow>
                                                    <block type="on_source" id="e7iCe8|M,+^]3/?~+(:v">
                                                      <field name="ATTR">state.lc</field>
                                                    </block>
                                                  </value>
                                                  <value name="B">
                                                    <shadow type="math_number">
                                                      <field name="NUM">1</field>
                                                    </shadow>
                                                    <block type="on_source" id="lpoYv%diwkTMG@(m(`Xg">
                                                      <field name="ATTR">oldState.lc</field>
                                                    </block>
                                                  </value>
                                                </block>
                                              </value>
                                            </block>
                                          </value>
                                          <next>
                                            <block type="comment" id=")8ne~ZLQBD(i(Yud=L:}">
                                              <field name="COMMENT">in Datenpunkt schreiben</field>
                                              <next>
                                                <block type="update" id=",wh2(O`,J,1c4LrU5Xd2">
                                                  <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>
                                                  <field name="OID">0_userdata.0.unifi.Nutzungsdauer_Frank</field>
                                                  <field name="WITH_DELAY">FALSE</field>
                                                  <value name="VALUE">
                                                    <block type="variables_get" id="4+929|Af=:Z(!b}{w_Sc">
                                                      <field name="VAR" id="fY_F9{eY1;h}wP?vcr()">UptimeZeit</field>
                                                    </block>
                                                  </value>
                                                  <next>
                                                    <block type="debug" id="#;K;/u%_kmz(l?i0Vr5X">
                                                      <field name="Severity">log</field>
                                                      <value name="TEXT">
                                                        <shadow type="text" id="Tvr?+gMKk$:J/eB:;db[">
                                                          <field name="TEXT">test</field>
                                                        </shadow>
                                                        <block type="variables_get" id="C$k?WDu//?ZuRK?AN,ko">
                                                          <field name="VAR" id="fY_F9{eY1;h}wP?vcr()">UptimeZeit</field>
                                                        </block>
                                                      </value>
                                                    </block>
                                                  </next>
                                                </block>
                                              </next>
                                            </block>
                                          </next>
                                        </block>
                                      </statement>
                                    </block>
                                  </next>
                                </block>
                              </statement>
                            </block>
                          </next>
                        </block>
                      </next>
                    </block>
                  </next>
                </block>
              </next>
            </block>
          </next>
        </block>
        <block type="convert_from_date" id="dY(:0?U]KEwy5hgz}SVt" disabled="true" x="863" y="-37">
          <mutation xmlns="http://www.w3.org/1999/xhtml" format="false" language="false"></mutation>
          <field name="OPTION">m</field>
          <value name="VALUE">
            <block type="variables_get" id="rN1L)t5e]@iqV^2z`ypW">
              <field name="VAR" id="fY_F9{eY1;h}wP?vcr()">UptimeZeit</field>
            </block>
          </value>
        </block>
      </xml>
      
      paul53 1 Reply Last reply Reply Quote 0
      • paul53
        paul53 @Roelli last edited by

        @roelli sagte: Uptime Datenpunkt im Unify-Adapter. Der zeigt mir alle 30 Sekunden einen aktuellen Wert in Sekunden an wie lange ein Gerät online ist.

        Wert in s kumulativ? Ohne Zeit-Begrenzung?

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

          @paul53
          Sieht so aus. Der Wert steigt immer nur positiv an. Ich habe allerdings auch nicht beobachten können ob, wie und wann das mal zurückgesetzt wird.

          Vermutlich ist das ja auch egal?
          Denn bei anderen Skripten scheint man lediglich die Differenz zu berechnen.
          Also.. wenn keine Änderung.. dann nix machen.
          Wenn Änderung, dann Differenz berechnen und ausgeben.

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

            @roelli
            Der Datenpunkt ist mit unit "h" erstellt. Du möchtest "hh:mm"?

            Blockly_temp.JPG

            <xml xmlns="https://developers.google.com/blockly/xml">
             <variables>
               <variable id="fY_F9{eY1;h}wP?vcr()">UptimeZeit</variable>
               <variable id="?EJ`gu88:dm2f6c(O0fA">uptimeHeute</variable>
             </variables>
             <block type="comment" id="/;ZRw=#X-(8q/6mmWt-j" x="88" y="-362">
               <field name="COMMENT">Datenpunkt anlegen</field>
               <next>
                 <block type="create" id="K(QDlz0t6.{2Pq+PF_A^">
                   <field name="NAME">0_userdata.0.unifi.Nutzungsdauer_Frank</field>
                   <value name="VALUE">
                     <block type="math_number" id="F:fd)tm:n!J6^vPJg$:H">
                       <field name="NUM">0</field>
                     </block>
                   </value>
                   <value name="COMMON">
                     <block type="text" id="q6Pk,4oOFfz~N`%)`^jw">
                       <field name="TEXT">{"name": "NutzungsdauerFrank", "type": "string", "unit": "h", "write": true, "read": true}</field>
                     </block>
                   </value>
                   <next>
                     <block type="comment" id="dwTsB5EXpHuS0=+=4Gp.">
                       <field name="COMMENT">um 0:01 den Wert merken</field>
                       <next>
                         <block type="schedule" id="b[lyw/{nfZfvqKs4+VvL">
                           <field name="SCHEDULE">1 0 * * *</field>
                           <statement name="STATEMENT">
                             <block type="variables_set" id="_WC{AOB{MCn`w+CZ0:[F">
                               <field name="VAR" id="fY_F9{eY1;h}wP?vcr()">UptimeZeit</field>
                               <value name="VALUE">
                                 <block type="get_value" id="9Ox]xc@g|k2Vl5XwkWf6">
                                   <field name="ATTR">val</field>
                                   <field name="OID">unifi.1.default.clients.18:65:90:81:be:bf.uptime</field>
                                 </block>
                               </value>
                             </block>
                           </statement>
                           <next>
                             <block type="comment" id="hx=3,gLEAlY2M5P9|.Zs">
                               <field name="COMMENT">Berechnen</field>
                               <next>
                                 <block type="on_ext" id="8,jc8wcL/E4r7n$HaBfB">
                                   <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="?xFLO|`y~#Vhz,Q~=yLv">
                                       <field name="oid">unifi.1.default.clients.18:65:90:81:be:bf.uptime</field>
                                     </shadow>
                                   </value>
                                   <statement name="STATEMENT">
                                     <block type="debug" id="?UPgrIZ-lci;kNCIfRn?">
                                       <field name="Severity">log</field>
                                       <value name="TEXT">
                                         <shadow type="text" id="ZoX+2y9fnOMe?v%6h$lZ">
                                           <field name="TEXT">test</field>
                                         </shadow>
                                         <block type="on_source" id="i%Re+gm?HisoQvZ;y2H?">
                                           <field name="ATTR">state.val</field>
                                         </block>
                                       </value>
                                       <next>
                                         <block type="variables_set" id="+Ad_I(4;Hx9C#}vW2u:3">
                                           <field name="VAR" id="?EJ`gu88:dm2f6c(O0fA">uptimeHeute</field>
                                           <value name="VALUE">
                                             <block type="math_arithmetic" id="#.(*={p.K+|SSE3~X`4." inline="false">
                                               <field name="OP">ADD</field>
                                               <value name="A">
                                                 <shadow type="math_number" id="ic3~jzU3Heq7a]h$my[N">
                                                   <field name="NUM">1</field>
                                                 </shadow>
                                                 <block type="math_arithmetic" id=".mm%y[Glk7cd6%LuRXa-">
                                                   <field name="OP">MULTIPLY</field>
                                                   <value name="A">
                                                     <shadow type="math_number" id="HcdJJ1aCFn?dZ]YwAv5h">
                                                       <field name="NUM">1000</field>
                                                     </shadow>
                                                   </value>
                                                   <value name="B">
                                                     <shadow type="math_number" id="Wkax6/#15pV!${E9IE@4">
                                                       <field name="NUM">1</field>
                                                     </shadow>
                                                     <block type="math_arithmetic" id="Invk3@2?f1O75MEI=sS!">
                                                       <field name="OP">MINUS</field>
                                                       <value name="A">
                                                         <shadow type="math_number">
                                                           <field name="NUM">1</field>
                                                         </shadow>
                                                         <block type="on_source" id="e7iCe8|M,+^]3/?~+(:v">
                                                           <field name="ATTR">state.val</field>
                                                         </block>
                                                       </value>
                                                       <value name="B">
                                                         <shadow type="math_number" id="F`gi#wosHQ0g`l.:#+pc">
                                                           <field name="NUM">1</field>
                                                         </shadow>
                                                         <block type="variables_get" id="xcrw1;dE|qXShSx-otl[">
                                                           <field name="VAR" id="fY_F9{eY1;h}wP?vcr()">UptimeZeit</field>
                                                         </block>
                                                       </value>
                                                     </block>
                                                   </value>
                                                 </block>
                                               </value>
                                               <value name="B">
                                                 <shadow type="math_number" id="5]u@T|+HV0Op_TI4:g(w">
                                                   <field name="NUM">1</field>
                                                 </shadow>
                                                 <block type="convert_from_date" id="AwmW29lLcLxZG%k;H#]4">
                                                   <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="7Um.T_hWoFIoi=UF/(xS">
                                                       <field name="TEXT">1970-01-01 00:00</field>
                                                     </block>
                                                   </value>
                                                 </block>
                                               </value>
                                             </block>
                                           </value>
                                           <next>
                                             <block type="variables_set" id="mkdE@1?+[f.d7?[}%U5V">
                                               <field name="VAR" id="?EJ`gu88:dm2f6c(O0fA">uptimeHeute</field>
                                               <value name="VALUE">
                                                 <block type="convert_from_date" id="c.j)Fc5=0bDEWf6xx#+m">
                                                   <mutation xmlns="http://www.w3.org/1999/xhtml" format="false" language="false"></mutation>
                                                   <field name="OPTION">hh:mm</field>
                                                   <value name="VALUE">
                                                     <block type="variables_get" id="_re-~2thuGY^uWubf{Kp">
                                                       <field name="VAR" id="?EJ`gu88:dm2f6c(O0fA">uptimeHeute</field>
                                                     </block>
                                                   </value>
                                                 </block>
                                               </value>
                                               <next>
                                                 <block type="comment" id=")8ne~ZLQBD(i(Yud=L:}">
                                                   <field name="COMMENT">in Datenpunkt schreiben</field>
                                                   <next>
                                                     <block type="update" id=",wh2(O`,J,1c4LrU5Xd2">
                                                       <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>
                                                       <field name="OID">0_userdata.0.unifi.Nutzungsdauer_Frank</field>
                                                       <field name="WITH_DELAY">FALSE</field>
                                                       <value name="VALUE">
                                                         <block type="variables_get" id="4+929|Af=:Z(!b}{w_Sc">
                                                           <field name="VAR" id="?EJ`gu88:dm2f6c(O0fA">uptimeHeute</field>
                                                         </block>
                                                       </value>
                                                       <next>
                                                         <block type="debug" id="#;K;/u%_kmz(l?i0Vr5X">
                                                           <field name="Severity">log</field>
                                                           <value name="TEXT">
                                                             <shadow type="text" id="Tvr?+gMKk$:J/eB:;db[">
                                                               <field name="TEXT">test</field>
                                                             </shadow>
                                                             <block type="variables_get" id="C$k?WDu//?ZuRK?AN,ko">
                                                               <field name="VAR" id="?EJ`gu88:dm2f6c(O0fA">uptimeHeute</field>
                                                             </block>
                                                           </value>
                                                         </block>
                                                       </next>
                                                     </block>
                                                   </next>
                                                 </block>
                                               </next>
                                             </block>
                                           </next>
                                         </block>
                                       </next>
                                     </block>
                                   </statement>
                                 </block>
                               </next>
                             </block>
                           </next>
                         </block>
                       </next>
                     </block>
                   </next>
                 </block>
               </next>
             </block>
            </xml>
            

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

              @paul53

              Danke! Sieht wesentlich schlauer aus als mein Versuch!
              Hab's gerade ausprobiert... im Datenpunkt wird aber nur "NaN:NaN" geschrieben.
              Hab ich da was falsch gemacht? Datenpunkt falsch formatiert?
              Aber der Debugwert ist auch schon "NaN:NaN"

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

                @roelli
                Füge mal eine weitere Logausgabe ein, die den Typ anzeigt:

                Bild_2021-09-05_194518.png

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

                  @paul53

                  fehler2.jpg

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

                    @roelli
                    Die Variable UptimeZeit muss bei Skriptstart initialisiert werden, da sie sonst bis 00:01 Uhr undefined enthält.

                    Bild_2021-09-05_215142.png

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

                      @paul53

                      Das Script scheint generell zu funktionieren. Es zählt hoch.
                      Allerdings scheint es zu viel und/oder zu oft zu zählen.
                      (ich habe morgens früh schon 10Stunden dort stehen)

                      Möglicherweise ist aber auch der Datenpunkt vom unify Controller nicht der beste.
                      Hast Du auch unify? Läuft's bei Dir?

                      Danke,
                      Frank.

                      Homoran paul53 2 Replies Last reply Reply Quote 0
                      • Homoran
                        Homoran Global Moderator Administrators @Roelli last edited by Homoran

                        @roelli sagte in Nutzungsdauer vom Handy anzeigen lassen (unifi):

                        Möglicherweise ist aber auch der Datenpunkt vom unify Controller nicht der beste.

                        der zeigt IMHO die komplette Verbindungszeit zum AP an, nicht die Onlinezeit

                        Passt es denn zu den Werten im Unifi-Controller
                        unifi_Betriebszeit.png
                        hier die letzte Spalte.
                        Ich nutze den Adapter nicht

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

                          @roelli sagte: Hast Du auch unify?

                          Nein.

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

                          Support us

                          ioBroker
                          Community Adapters
                          Donate

                          843
                          Online

                          32.0k
                          Users

                          80.5k
                          Topics

                          1.3m
                          Posts

                          3
                          11
                          229
                          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