Navigation

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

    NEWS

    • Neuer Blog: Fotos und Eindrücke aus Solingen

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

    • ioBroker goes Matter ... Matter Adapter in Stable

    Batteriestatus

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

      Hy Leute
      Ich habe hier ein Batteriescript, welches mir die Anzahl Geräte, Anzahl Batterie schwach sowie die Geräte auflisten sollte.
      Und genau der letzte Punkt funktioniert nicht. Es wäre toll wenn man sehen könnte welches Gerät eine schwache Batterie hat.
      Wo muss ich am script was ändern damit das funktioniert? Ich verstehe nichts von Java.....

      Batteriedatenpunkte.jpg

      createState('Batteriescript.Anzahl_Geräte', 0, {type: 'number'});
      createState('Batteriescript.Batterie_schwach', 0, {type: 'number'});
      createState('Batteriescript.Gerät', " ", {type: 'string'});
      
      const mihome = $('mihome.0*.percent');
      const ble = $('ble.0*.battery');
      const zigbee = $('zigbee.0*.battery');
      const loggen = true;
      var arrLOWBAT;
      function lowbat(id) {
         var obj = getObject(id);
         arrLOWBAT.push(obj.common.name);
         if(loggen) log("Gerät: " + obj.common.name);
      }
      function countLowbat() {
         var moeglicheLOWBAT = 0;
         arrLOWBAT      = [];
         mihome.each(function (id, i) {
            if(getState(id).val < 30) lowbat(id);
            ++moeglicheLOWBAT;
         });  
          ble.each(function (id, i) {
              if(getState(id).val < 30) lowbat(id);
               ++moeglicheLOWBAT;
         }); 
         zigbee.each(function (id, i) {
              if(getState(id).val < 30) lowbat(id);
               ++moeglicheLOWBAT;
         }); 
      
         if(loggen) log("Text: " + arrLOWBAT.join(', '));
         if(loggen) log("Anzahl Geräte: " + moeglicheLOWBAT + " // davon mit schwacher Batterie: " +  arrLOWBAT.length);
         setState("Batteriescript.Gerät",     arrLOWBAT.join(',<br>'));
         setState("Batteriescript.Batterie_schwach",   arrLOWBAT.length);
         setState("Batteriescript.Anzahl_Geräte", moeglicheLOWBAT);
      }
      countLowbat();
      schedule("*/60 * * * *", countLowbat);
      
      sigi234 crunchip paul53 3 Replies Last reply Reply Quote 0
      • sigi234
        sigi234 Forum Testing Most Active @albi_63 last edited by

        @albi_63

        https://forum.iobroker.net/topic/28789/script-fürtabelle-der-batterie-zustände

        1 Reply Last reply Reply Quote 0
        • crunchip
          crunchip Forum Testing Most Active @albi_63 last edited by crunchip

          @albi_63 fehlt dir nicht ein Punkt zwischen 0 und *
          So wäre es richtig

          'mihome.0.devices.*.percent'

          A 1 Reply Last reply Reply Quote 0
          • A
            albi_63 @crunchip last edited by

            @crunchip
            Hy,
            Es ändert sich nichts wenn ich den Punkt hinter dem Stern setzte. Das Ergebnis bleibt das gleiche...
            Ich bekomme keine Namen der LowBatt Geräte
            const ble = $('ble.0.*.battery');

            Homoran 1 Reply Last reply Reply Quote 0
            • Homoran
              Homoran Global Moderator Administrators @albi_63 last edited by

              @albi_63
              Was steht denn im Datenpunkt komplett drin?

              Wo kommt dieses Battery percent her, das da am Anfang steht?

              crunchip A 2 Replies Last reply Reply Quote 0
              • crunchip
                crunchip Forum Testing Most Active @Homoran last edited by

                @Homoran vom mihome Adapter, habs oben korrigiert

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

                  @albi_63 sagte:

                  der letzte Punkt funktioniert nicht.

                     var obj = getObject(id);
                     arrLOWBAT.push(obj.common.name);
                  

                  Es werden die Datenpunktnamen in das Array geschrieben - nicht die Gerätenamen. Versuche es mal so:

                  function lowbat(id) {
                     id = id.substring(0, id.lastIndexOf('.'));
                     var obj = getObject(id);
                     arrLOWBAT.push(obj.common.name);
                  

                  Es setzt voraus, dass zu allen Datenpunkt-Objekten ein Parent-Objekt existiert und das einen sinnvollen Namen hat.

                  A 1 Reply Last reply Reply Quote 0
                  • A
                    albi_63 @Homoran last edited by

                    @Homoran
                    Hy
                    Die Batterie percent kommt vom mihome adapter
                    Percentmihome.jpg
                    Im datenpunkt "Gerät" steht nur : Battery percent,>br>Batterie

                    Homoran 1 Reply Last reply Reply Quote 0
                    • Homoran
                      Homoran Global Moderator Administrators @albi_63 last edited by Homoran

                      @albi_63 sagte in Batteriestatus:

                      Die Batterie percent kommt vom mihome adapter

                      dann sind wir jetzt genau da was @paul53 prophezeit hat 😂
                      Das ist der Datenpunkt Name

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

                        @paul53
                        Hy Paul
                        Danke für dein Feedback.
                        Jetzt bekomme ich die entsprechenden Werte:

                        Temp.-Kühlschrank,<br>Temp.-Aussenwand-nord

                        Jetzt muss ich noch schauen wie ich das in den iQontrol via Popup oder so bringe.
                        Ne Idee?
                        Danke dir

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

                        Support us

                        ioBroker
                        Community Adapters
                        Donate

                        950
                        Online

                        31.9k
                        Users

                        80.2k
                        Topics

                        1.3m
                        Posts

                        javascript
                        5
                        10
                        477
                        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