Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. Anzahl eingeschaltet Lichter (inkl. Dimmer)

    NEWS

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

    • ioBroker goes Matter ... Matter Adapter in Stable

    • Monatsrückblick - April 2025

    Anzahl eingeschaltet Lichter (inkl. Dimmer)

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

      Hallo zusammen,

      ich habe folgendes Script im Einsatz:

      createState('zählen_Lichter.anzahlLichterAn', 0);                   // Anzahl der Lichter, die an sind als Variable unter Javascript.0 anlegen
      
      var cacheSelectorState  = $('channel[state.id=*.STATE](functions=Licht)');
      
      function countLamps(obj) {
          var anzahlLichterAn = 0;
      
         cacheSelectorState.each(function (id, i) {                       // Schleife für jedes gefundenen Element *.STATE im Gewerk Licht
              var status = getState(id).val;                              // Zustand *.STATE abfragen (jedes Element)
              var obj    = getObject(id);
              if (status === true ) {                                      // wenn Zustand = true, dann wird die ANzahl der Lichter hochgezählt
                   ++anzahlLichterAn;                   // Zu Array hinzufügen
              }                
               }); 
           setState("zählen_Lichter.anzahlLichterAn", anzahlLichterAn);        // Schreibt die aktuelle Anzahl der eingeschalteten Lichter
        }
      cacheSelectorState.on(function(obj) {    // bei Zustandänderung *. STATE im Gewerk Fenster
         countLamps(obj);
      });
      

      Alles soweit OK.

      Allerdings bekomme ich es nicht hin, dass das Script auch bei einem Dimmer (Veränderung des Wert Level) anspringt. Hier gibt es den Datenpunkt State ja nicht.

      Kann mir hier jemand helfen ?

      Gruß

      MIchael

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

        http://forum.iobroker.org/viewtopic.php … hter#p5511

        1 Reply Last reply Reply Quote 0
        • P
          pix last edited by

          Hier ein aktueller Link:

          http://forum.iobroker.net/viewtopic.php … 673#p41673

          Pix

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

          Support us

          ioBroker
          Community Adapters
          Donate

          714
          Online

          31.7k
          Users

          79.8k
          Topics

          1.3m
          Posts

          3
          3
          1324
          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