Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. Gelöst: Zustände in Objekten Zählen

    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

    Gelöst: Zustände in Objekten Zählen

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

      Hallo,
      ich habe 3 "IOT" (0,2,3) Instanzen in meiner Installation
      Jede Instanz hat auch den Objektbereich "Services", dort ist jeweils ein Objekt das heißt "custom_CAS". Dieses Objekt kann den Zustand "entered" oder "exited" haben. Ich suche eine elegante Scriptlösung um zu Zählen wie oft "exited" oder "entered" vorhanden ist.
      Gruß
      Michael

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

        @michihorn sagte: Scriptlösung um zu Zählen wie oft "exited"

        // IDs anpassen!
        const ids = $('iot.*.xyz.custom_CAS');
        const idCnt = '0_userdata.0.xyz';
        
        function cntCAS() {
            let cnt = 0;
            ids.each(function(id, i) {
                if(getState(id).val == 'exited') cnt++;
            });
            setState(idCnt, cnt, true);
        }
        
        cntCAS(); // Skriptstart
        
        ids.on(cntCAS);
        
        1 Reply Last reply Reply Quote 0
        • M
          michihorn last edited by

          @paul53 sagte in Zustände in Objekten Zählen:

          // IDs anpassen! const ids = $('iot.*.xyz.custom_CAS'); const idCnt = '0_userdata.0.xyz'; function cntCAS() { let cnt = 0; ids.each(function(id, i) { if(getState(id).val == 'exited') cnt++; }); setState(idCnt, cnt, true); } cntCAS(); // Skriptstart ids.on(cntCAS);

          Super Danke

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

          Support us

          ioBroker
          Community Adapters
          Donate

          481
          Online

          31.8k
          Users

          80.0k
          Topics

          1.3m
          Posts

          javascript
          2
          3
          117
          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