Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. JavaScript
    5. getObject();

    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

    getObject();

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

      Hallo Christoph,
      ohne das verwendete Script zu kennen ist glaub keine Hilfe möglich
      Gruß
      LausiD

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

        @chrweh34 sagte in getObject();:

        Leider bekomme ich bei der Zeile
        var windows = getObject(id).common.members ; immer angezeigt das members keine Eigenschaft des Objektes ist.

        id muss die ID einer existierenden Aufzählung sein, z.B. "enum.functions.fenster".

        1 Reply Last reply Reply Quote 0
        • C
          chrweh34 last edited by

          Hallo nochmal,
          danke für die Rückmeldung!

          @LausiD
          Der code ist von der Seite www.smarthome-tricks.de. Hier der ganze Code:

          function listEnumDevices() {
          log("Liste der Fenster und Status:");
          var windows = getObject('enum.functions.windowstatus').common.members;
          for(let i = 0; i < windows.length; i++) {
          var Status = getState(windows[i]).val;
          log(windows[i] + " " + Status);
          }

          log("Liste der Türen und Status:");
          var doors = getObject("enum.functions.doorstatus").common.members;
          for(let i = 0; i < doors.length; i++) {
          var Status = getState(doors[i]).val;
          log(doors[i] + " " + Status);
          }
          }

          Ich habe die Aufzählungen entsprechend angelegt, nutze allerdings innogy-smarthome fenster-sensoren.

          @paul53: "id" war nur zur Verallgemeinerung. Ich benutze "enum.functions.windowstatus" als Aufzählung
          .

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

            @chrweh34 sagte in getObject();:

            immer angezeigt das members keine Eigenschaft des Objektes ist.

            Wo und wann bekommst Du es angezeigt ?

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

              @paul53

              Es wird immer dann angezeigt wenn ich das Script im compiler (Administrator) aufrufe.

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

                @chrweh34 sagte in getObject();:

                Es wird immer dann angezeigt wenn ich das Script im compiler (Administrator) aufrufe.

                Also vom Editor/Parser und nicht bei der Ausführung ? Dann kannst Du es ignorieren.

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

                  @paul53

                  Funktioniert - alles klar!

                  Dank für Deine Hilfe!

                  1 Reply Last reply Reply Quote 0
                  • M
                    mumurik last edited by

                    Ich habe noch eine Verständnisfrage, mit

                    log(windows[i] + " " + Status);
                    

                    bekomme ich den Status aller Fenster im Log angezeigt, das funktioniert einwandfrei.

                    Wie kriege ich aber diesen Status (Liste aller offenen Fenster) in ein Datenpunkt übergeben, so dass ich z.B. VIS danach triggern kann?

                    Danke, viele Grüße

                    AlCalzone 1 Reply Last reply Reply Quote 0
                    • AlCalzone
                      AlCalzone Developer @mumurik last edited by

                      @mumurik mit der Funktion setState:
                      https://github.com/ioBroker/ioBroker.javascript/blob/master/docs/en/javascript.md#setstate

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

                        @AlCalzone
                        danke, das habe ich mir schon gedacht, allerdings verstehe ich nicht ganz, wie es in diesem konkreten Beispiel aussehen soll.

                        So etwa?

                        setState('Datenpunkte.0.StatusWindowOpenText', Status );
                        

                        bzw.

                        function listEnumDevices() {
                        log("Liste der Fenster und Status:");
                        var windows = getObject('enum.functions.windowstatus').common.members;
                        for(let i = 0; i < windows.length; i++) {
                        var Status = getState(windows[i]).val;
                        log(windows[i] + " " + Status);
                        setState('Datenpunkte.0.StatusWindowOpenText', Status );
                        }

                        ???

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

                          @mumurik sagte:

                          (Liste aller offenen Fenster) in ein Datenpunkt übergeben

                          Etwa so:

                          function listEnumDevices() {
                             log("Liste der Fenster und Status:");
                             var windows = getObject('enum.functions.windowstatus').common.members;
                             var txt = '';
                             for(let i = 0; i < windows.length; i++) {
                                var Status = getState(windows[i]).val;
                                log(windows[i] + " " + Status);
                                if(Status) txt = txt + windows[i] + ',<br>';
                             }
                             if(txt.length == 0) txt = 'Alle Fenster geschlossen';
                             setState('Datenpunkte.0.StatusWindowOpenText', txt, true );
                          }
                          
                          1 Reply Last reply Reply Quote 0
                          • M
                            mumurik last edited by mumurik

                            @paul53 sagte in getObject();:

                            function listEnumDevices() { log("Liste der Fenster und Status:"); var windows = getObject('enum.functions.windowstatus').common.members; var txt = ''; for(let i = 0; i < windows.length; i++) { var Status = getState(windows[i]).val; log(windows[i] + " " + Status); if(Status) txt = txt + windows[i] + ',<br>'; } if(txt.length == 0) txt = 'Alle Fenster geschlossen'; setState('Datenpunkte.0.StatusWindowOpenText', txt, true ); }

                            Super, vielen Dank!

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

                            Support us

                            ioBroker
                            Community Adapters
                            Donate

                            418
                            Online

                            31.8k
                            Users

                            80.0k
                            Topics

                            1.3m
                            Posts

                            javascript
                            5
                            13
                            1125
                            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