Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. Gelöst: Bluetooth Geräte zählen

    NEWS

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

    • ioBroker goes Matter ... Matter Adapter in Stable

    • Monatsrückblick - April 2025

    Gelöst: Bluetooth Geräte zählen

    This topic has been deleted. Only users with topic management privileges can see it.
    • bahnuhr
      bahnuhr Forum Testing Most Active @michihorn last edited by

      @michihorn sagte in Bluetooth Geräte zählen:

      @bahnuhr Eigentlich war mein Verständnis, sofern eines der gelisteten Geräte "true" wird, werden alle Geräte die "true" sind gezählt und in einen Datenpunkt geschrieben, dass passiert aber nicht und ja, der DP hat die Eigenschaft "number" 😉

      Nein, das Script startet 1x bei Aktivierung des Scriptes.
      Das was du willst musst du mit on machen.

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

        @bahnuhr Auch beim Start wird nix gezählt

        bahnuhr 1 Reply Last reply Reply Quote 0
        • bahnuhr
          bahnuhr Forum Testing Most Active @michihorn last edited by

          @michihorn sagte in Bluetooth Geräte zählen:

          @bahnuhr Auch beim Start wird nix gezählt

          Na, dann steht dort halt nix drin.

          Mach doch mal einen Screenshot der DP

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

            @bahnuhr
            so sieht tr-064 aus:
            tr-064.png

            so sieht 0_userdata aus:
            aw.png

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

              @michihorn sagte: Leider klappt es nicht.

              Stimmt der Selektor? Überprüfe es:

              const ids = $('tr-064.*.devices');
              const idCnt='0_userdata.0.Haus.AW.EnteredBt'
               
              log(ids);
              
              1 Reply Last reply Reply Quote 0
              • paul53
                paul53 @michihorn last edited by

                @michihorn sagte: so sieht tr-064 aus:

                Dann passt der Selektor nicht. Welche Datenpunkte sind die richtigen unter den Kanälen?

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

                  @paul53 Tatsächlich stimmte der Selector nicht ganz

                  const ids = $('tr-064.0.devices');
                  

                  hatte die Instance vergessen, trotzdem läuft es nicht

                  Überprüfen möchte ich:

                  tr-064.0.devices.IPhone-Noel
                  tr-064.0.devices.S20-FE-von-Heike
                  tr-064.0.devices.S20-FE-von-Michael
                  
                  paul53 1 Reply Last reply Reply Quote 0
                  • paul53
                    paul53 @michihorn last edited by

                    @michihorn sagte: hatte die Instance vergessen

                    Das genügt nicht, denn so werden keine Datenpunkte gefunden.

                    @paul53 sagte in Bluetooth Geräte zählen:

                    Welche Datenpunkte sind die richtigen unter den Kanälen?

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

                      @paul53 Überprüfen möchte ich:

                      tr-064.0.devices.IPhone-Noel
                      tr-064.0.devices.S20-FE-von-Heike
                      tr-064.0.devices.S20-FE-von-Michael
                      

                      tr-064.png

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

                        @michihorn sagte: Überprüfen möchte ich:

                        const ids = $('tr-064.0.devices.*');
                        

                        Da die Datenpunkte Ordner sind, werden noch weitere Datenpunkt (unterhalb der Ordner) selektiert. Das kann ein Problem sein.

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

                          @paul53 sagte in Bluetooth Geräte zählen:

                          const ids = $('tr-064.0.devices.*');

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

                            @paul53 ja stimmt, ich will nur die 3 Geräte ermitteln, nun wird mir die 6 ermittelt

                            Also würde ich nun, da der Vorgang ja statisch ist und immer nur diese 3 Ordner umfasst, dass Script soweit abwandeln:

                            const ids = $('tr-064.0.devices.*');
                            const idCnt='0_userdata.0.Haus.AW.EnteredBt'
                            
                            //*****FUNKTION ENTERED******************************************/
                            function cntBt() {
                                let cnt = 0;
                                ids.each(function (id, i) {
                                    if (getState(id).val == true) cnt++;
                                });
                                
                                setState(idCnt, cnt-3, true);
                                log(cnt-3);
                            }
                            cntBt(); // Skriptstart
                            ids.on(cntBt);
                            

                            Zumindest das Ergebnis passt 😉
                            Bei jeder Veränderung der DP löst das Script aus, tut was es soll. Erstmal Danke an Paul53 und Bahnuhr

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

                              @michihorn sagte: Zumindest das Ergebnis passt

                              Ist der Wert der Datenpunkte unterhalb der Ordner immer true? Was sind das für Datenpunkte?

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

                                @paul53
                                JA sobald ACTIVE true ist, ist auch das Verzeichnis true
                                aw2.png

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

                                  @michihorn sagte: sobald ACTIVE true ist, ist auch das Verzeichnis true

                                  Dann beschränke den Selektor auf "active".

                                  const ids = $('tr-064.0.devices.*.active');
                                  
                                  M 1 Reply Last reply Reply Quote 0
                                  • M
                                    michihorn @paul53 last edited by

                                    @paul53 sagte in Gelöst: Bluetooth Geräte zählen:

                                    const ids = $('tr-064.0.devices.*.active');

                                    Paul...Du bist der Beste. Danke für Deine Unterstützung

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

                                    Support us

                                    ioBroker
                                    Community Adapters
                                    Donate

                                    301
                                    Online

                                    31.7k
                                    Users

                                    79.8k
                                    Topics

                                    1.3m
                                    Posts

                                    javascript
                                    3
                                    19
                                    289
                                    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