Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. JavaScript
    5. getIDs() Funktion nicht verfügbar

    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

    getIDs() Funktion nicht verfügbar

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

      Hallo Community,
      ich bin dabei meine Scripte zu optimieren und dabei stellt sich mir eine Frage: Ein Kollege teilte mir mit, dass es eine Funktion beim Selector geben soll, der mir die gesamten ID in einem Array speichert.
      Beispiel:

      const pingIds = $('ping.0.iobroker.*').getIDs();
      
      

      Ist das so, oder muss ich über den traditionellen Weg gehen mit:

      let pingIds= [];
      $('ping.0.iobroker.*'').each(function (id) {
          pingIds.push(id);
      }
      
      T 1 Reply Last reply Reply Quote 0
      • T
        ticaki Developer @Kamikaze last edited by

        @kamikaze

        $().toArray();
        
        K 1 Reply Last reply Reply Quote 1
        • K
          Kamikaze @ticaki last edited by

          @ticaki VIELEN DANK. Das hat funktioniert.

          haus-automatisierung 1 Reply Last reply Reply Quote 0
          • haus-automatisierung
            haus-automatisierung Developer Most Active @Kamikaze last edited by

            @kamikaze Ansonsten auch gern anmerken, was Dir in der Doku dazu fehlt:

            https://github.com/ioBroker/ioBroker.javascript/blob/master/docs/en/javascript.md#---selector

            K 1 Reply Last reply Reply Quote 0
            • K
              Kamikaze @haus-automatisierung last edited by

              @haus-automatisierung Das mache ich doch glatt:

              $(selector).toArray(); // Requires version >= 8.2.0

              example:
              $('*.STATE').toArray() // select all states where id ends with ".STATE" and store ids in an array

              haus-automatisierung 1 Reply Last reply Reply Quote 0
              • haus-automatisierung
                haus-automatisierung Developer Most Active @Kamikaze last edited by

                @kamikaze Das heißt Du hast die Funktionen in der Doku gefunden, aber wusstest nur nicht wie diese anzuwenden sind, weil ein Beispiel gefehlt hat?

                K 1 Reply Last reply Reply Quote 0
                • K
                  Kamikaze @haus-automatisierung last edited by

                  @haus-automatisierung Das stimmt und es ist ein bisschen unscheinbar.
                  Erst als du mich darauf hingewiesen hast, das es in der Doku steht, habe ich es auch gefunden.
                  Btw gibt es noch eine zweite Frage, die letztendlich in die gleiche Richtung geht --> Doku verstehen:

                  Option - "Do not subscribe all states on start"
                  There are two modes of subscribing to states:
                  
                  Adapter subscribes to all changes at start and receives all changes of all states (it is easy to use getStates(id), but requires more CPU and RAM):
                  

                  Hier wird von getStates(id) gesprochen, aber finden kann ich diese nicht. Ich erwarte, dass ich hier mit einem Aufruf gleich mehrere States abfragen kann. Aber die Doku schweigt sich aus.

                  Hast du für mich hier auch eine Lösung, die ich in normalen Scripts verwenden kann?

                  haus-automatisierung 1 Reply Last reply Reply Quote 0
                  • haus-automatisierung
                    haus-automatisierung Developer Most Active @Kamikaze last edited by

                    @kamikaze Die Option ist dafür da, dass man synchron auf die States zugreifen kann. Sonst müsste man immer mit Callback bzw. Promise arbeiten.

                    K 1 Reply Last reply Reply Quote 0
                    • K
                      Kamikaze @haus-automatisierung last edited by

                      @haus-automatisierung Damit ich dass verstehe. getStates() ist in normalen Scripts nicht verfügbar, korrekt?

                      haus-automatisierung 1 Reply Last reply Reply Quote 0
                      • haus-automatisierung
                        haus-automatisierung Developer Most Active @Kamikaze last edited by

                        @kamikaze Das ist aktuell nicht implementiert. Sonst wäre die Funktion in der Doku ja zu finden. Ist ein s zu viel in dem Satz (wahrscheinlich Tippfehler, weil es die Funktion in den Adapter Utils ja gibt).

                        K 1 Reply Last reply Reply Quote 0
                        • K
                          Kamikaze @haus-automatisierung last edited by

                          @haus-automatisierung Alles klar. Danke.

                          haus-automatisierung 1 Reply Last reply Reply Quote 0
                          • haus-automatisierung
                            haus-automatisierung Developer Most Active @Kamikaze last edited by

                            @kamikaze Habs mal angepasst: https://github.com/ioBroker/ioBroker.javascript/pull/1829

                            klein0r created this issue in ioBroker/ioBroker.javascript

                            closed Updated documentation ($-selector) #1829

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

                            Support us

                            ioBroker
                            Community Adapters
                            Donate

                            789
                            Online

                            31.8k
                            Users

                            80.0k
                            Topics

                            1.3m
                            Posts

                            3
                            12
                            307
                            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