Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. ioBroker Allgemein
    4. Unifi Steuern ohne Adapter (Script,SSH)

    NEWS

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

    • ioBroker goes Matter ... Matter Adapter in Stable

    • Monatsrückblick - April 2025

    Unifi Steuern ohne Adapter (Script,SSH)

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

      Wollte es jetzt auch mal ausprobieren. Scheitere aber schon bei dem Grundskript....
      Wo muss den bei der IP, Port, Benutzername, Passwort die Hockklammern etc. weg und wo müsse welche hin? Nicht das hier schon das Problem liegt....

      
      
      const Unifi = require('node-unifi');
      
      const unifi = new Unifi.Controller({hostname:"192.168.168.5",port:'8443', sslverify: false});
      
      (async () => {
       try {
         // LOGIN
         const loginData = await unifi.login('unifi-iobroker', '34523452345!');
         console.log('login: ' + loginData);
      
      //   const clientVoucher = await unifi.createVouchers(123,1,0,"testthis");
      
         // LOGOUT
         const logoutData = await unifi.logout();
         console.log('logout: ' + JSON.stringify(logoutData));
       } catch (error) {
         console.log('ERROR: ' + error);
       }
      })();
      
      log(getObject('system.host.iobroker59').native.os.platform)
      
      

      Im log steht nur:

      javascript.0	07:53:19.785	info	Start JavaScript script.js.common.Netzwerk.Voucher_erstellen (Javascript/js)
      javascript.0	07:53:19.804	warn	script.js.common.Netzwerk.Voucher_erstellen: Object "system.host.iobroker59" does not exist
      javascript.0	07:53:19.807	error	script.js.common.Netzwerk.Voucher_erstellen: TypeError: Cannot read properties of null (reading 'native')
      javascript.0	07:53:19.807	error	at script.js.common.Netzwerk.Voucher_erstellen:24:40
      javascript.0	07:53:19.807	error	at script.js.common.Netzwerk.Voucher_erstellen:33:3
      javascript.0	07:53:20.635	info	script.js.common.Netzwerk.Voucher_erstellen: ERROR: AxiosError: Request failed with status code 400
      javascript.0	07:53:23.368	info	Stopping script script.js.common.Netzwerk.Voucher_erstellen
      
      Neuschwansteini liv-in-sky A 3 Replies Last reply Reply Quote 0
      • Neuschwansteini
        Neuschwansteini @draexler last edited by

        @draexler

        zwei Sachen fallen mir auf:

        1. wenn du ne UDM Pro hast, mach aus dem Port 8443 nur 443
        2. in dem Script heisst der iobroker Host "iobroker59" - musste ich bei mir auf iobroker aendern, meiner heisst halt einfach nur iobroker..

        Probiers mal aus!
        🙂

        draexler 1 Reply Last reply Reply Quote 0
        • draexler
          draexler @Neuschwansteini last edited by

          @ilovegym Merce 🙂 Es war nur das Problem mit iobroker59. Das Basisscript läuft.
          Frage an alle: Gibts irgendeine Möglichkeit das PW nicht im Klartext anzuzeigen?

          1 Reply Last reply Reply Quote 0
          • liv-in-sky
            liv-in-sky @draexler last edited by liv-in-sky

            @draexler sagte in Adapter: ioBroker.unifi:

            log(getObject('system.host.iobroker59').native.os.platform)

            diese zeile (letzte) bitte löschen - war ein test für ganz was anderes und gehört nicht ins script - sorry

            draexler 1 Reply Last reply Reply Quote 0
            • draexler
              draexler @liv-in-sky last edited by draexler

              @liv-in-sky Jetzt bin ich mir gerade unsicher ob das schon war oder nicht... Jetzt ist das node-unifi rot unterstrichen. In der Javascript Instanz ist es aber angegeben. Instanz wurde auch schon neu gestartet.
              64bb85f2-c853-45be-94e8-3595c5acec44-image.png
              85583475-31db-4d71-969e-60ef96f07cac-image.png

              Woran kann das liegen? Wo kann ich was prüfen?

              Jetzt kommt auch diese Fehlermeldung im Log...
              Bin mir sicher das es meiner Erfolgsmeldung vorher nicht drinstand....

              javascript.0	10:12:58.289	info	script.js.common.Netzwerk.Voucher_erstellen: ERROR: AxiosError: Request failed with status code 400
              
              liv-in-sky 1 Reply Last reply Reply Quote 0
              • liv-in-sky
                liv-in-sky @draexler last edited by liv-in-sky

                @draexler das ist kein problem - ist bei mir immer so - du kannst mit rechter maustaste darauf gehen und fehler unterdrücken

                draexler 1 Reply Last reply Reply Quote 0
                • draexler
                  draexler @liv-in-sky last edited by

                  @liv-in-sky

                  Jetzt ist diese Fehlermeldung im Log. Bin mir aber ziemlich sicher das es bei meiner Erfolgsmeldung vorher nicht so war....

                  javascript.0 10:12:58.289 info script.js.common.Netzwerk.Voucher_erstellen: ERROR: AxiosError: Request failed with status code 400
                  
                  liv-in-sky 1 Reply Last reply Reply Quote 0
                  • liv-in-sky
                    liv-in-sky @draexler last edited by liv-in-sky

                    @draexler

                    probier es nochmal - das bedeutet, der server ist nicht erreichbar - evtl traffic im netz

                    draexler 1 Reply Last reply Reply Quote 0
                    • draexler
                      draexler @liv-in-sky last edited by

                      @liv-in-sky Keine Änderung. Kann es ja später nochmal probieren... Sehr komisch.

                      liv-in-sky 1 Reply Last reply Reply Quote 0
                      • liv-in-sky
                        liv-in-sky @draexler last edited by liv-in-sky

                        @draexler hast du am script was geändert ?

                        poste mal das script- mach das kennwort unkenntlich

                        draexler 1 Reply Last reply Reply Quote 0
                        • draexler
                          draexler @liv-in-sky last edited by

                          @liv-in-sky Denke nicht... Meines Erachtens nur das Basisscript:

                          const Unifi = require('node-unifi');
                          
                          const unifi = new Unifi.Controller({hostname:"192.168.168.5",port:'8443', sslverify: false});
                          
                          (async () => {
                           try {
                             // LOGIN
                             const loginData = await unifi.login('unifi-iobroker', '34523452345');
                             console.log('login: ' + loginData);
                          
                          //   const clientVoucher = await unifi.createVouchers(123,1,0,"testthis");
                            //const clientVoucher = await unifi.createVouchers(1,1,0,"testthis");
                          
                             // LOGOUT
                             const logoutData = await unifi.logout();
                             console.log('logout: ' + JSON.stringify(logoutData));
                           } catch (error) {
                             console.log('ERROR: ' + error);
                           }
                          })();
                          
                          
                          liv-in-sky 2 Replies Last reply Reply Quote 0
                          • liv-in-sky
                            liv-in-sky @draexler last edited by

                            @draexler

                            mit meinen daten kommt da kein axios fehler

                            mach mal die klammer auf und zu weg

                            Image 062.png

                            du kannst evtl noch unter den alarms im controller nachsehen, ob da was steht

                            1 Reply Last reply Reply Quote 0
                            • liv-in-sky
                              liv-in-sky @draexler last edited by

                              @draexler und restarte mal die javascript instanz

                              draexler 1 Reply Last reply Reply Quote 0
                              • draexler
                                draexler @liv-in-sky last edited by

                                @liv-in-sky Instanz ist neugestartet und die Klammern entfernt. Keine Fehlermeldung mehr, aber es scheint als würde gar nichts mehr ausgeführt. Vorher konnte ich im Controller Anmeldeversuche sehen:

                                const Unifi = require('node-unifi');
                                
                                const unifi = new Unifi.Controller({hostname:"192.168.168.5",port:'8443', sslverify: false});
                                
                                (async () => {
                                 try {
                                   // LOGIN
                                   const loginData = await unifi.login('unifi-iobroker', '34523452345!');
                                   console.log('login: ' + loginData);
                                
                                  const clientVoucher = await unifi.createVouchers(800,1,5,"testthis");
                                
                                   // LOGOUT
                                   const logoutData = await unifi.logout();
                                   console.log('logout: ' + JSON.stringify(logoutData));
                                 } catch (error) {
                                   console.log('ERROR: ' + error);
                                 }
                                });
                                
                                31.5.2024, 11:26:58.954	[info ]: javascript.0 (3780) Stopping script script.js.common.Netzwerk.Voucher_erstellen
                                31.5.2024, 11:26:59.646	[info ]: javascript.0 (3780) Start JavaScript script.js.common.Netzwerk.Voucher_erstellen (Javascript/js)
                                31.5.2024, 11:26:59.649	[info ]: javascript.0 (3780) script.js.common.Netzwerk.Voucher_erstellen: registered 0 subscriptions, 0 schedules, 0 messages, 0 logs and 0 file subscriptions
                                
                                liv-in-sky 2 Replies Last reply Reply Quote 0
                                • liv-in-sky
                                  liv-in-sky @draexler last edited by liv-in-sky

                                  @draexler

                                  nimm mal das:

                                  const Unifi = require('node-unifi');
                                   
                                  const unifi = new Unifi.Controller({hostname:"192.168.168.5",port:'8443', sslverify: false});
                                   
                                  async function main() {
                                   try {
                                     // LOGIN
                                     const loginData = await unifi.login('unifi-iobroker', '34523452345!');
                                     console.log('login: ' + loginData);
                                   
                                  const clientVoucher = await unifi.createVouchers(800,1,5,"testthis");
                                  
                                  
                                     // LOGOUT
                                     const logoutData = await unifi.logout();
                                     console.log('logout: ' + JSON.stringify(logoutData));
                                   } catch (error) {
                                     console.log('ERROR: ' + error);
                                   }
                                  }
                                  
                                  main();
                                  
                                  1 Reply Last reply Reply Quote 0
                                  • liv-in-sky
                                    liv-in-sky @draexler last edited by

                                    @draexler

                                    ohne das klammer auf/zu konnte es nicht funktionieren 😞 - habe die funktion benannt als main und diese wird dann aufgerufen - letzte zeile main();

                                    draexler 1 Reply Last reply Reply Quote 0
                                    • A
                                      andr3 @draexler last edited by

                                      @draexler nur damit ich hier nicht ganz falsch bin: ich möchte mit dem Unifi PROTECT-Adapter Kameras steuern. Das funktioniert bei mir aktuell nur über den Login mit der Emailadresse (in den Adapter-Einstellungen). Wenn ich dort den neu angelegten Local-User eintrage, kann ich keine Zustände mehr steuern 😞

                                      Samson71 1 Reply Last reply Reply Quote 0
                                      • draexler
                                        draexler @liv-in-sky last edited by

                                        @liv-in-sky Hat zwar auf das erste mal nicht funktioniert. Aber wie ich jetzt alles Runtergefahren habe (Proxmox) geht es jetzt auf einmal. Vorher hatte ich zwar auch einmal den iobroker gestoppt, aber das hat anscheinend nicht ausgereicht...

                                        DANKE DIR. Jetzt kann ich mal weiterbasteln.

                                        1 Reply Last reply Reply Quote 0
                                        • Samson71
                                          Samson71 Global Moderator @andr3 last edited by

                                          @andr3 sagte in Adapter: ioBroker.unifi:

                                          mit dem Unifi PROTECT-Adapter Kameras steuern.

                                          Hier geht es nicht um den PROTECT-Adapter. Der hat einen eigenen Thread.

                                          A 1 Reply Last reply Reply Quote 0
                                          • A
                                            andr3 @Samson71 last edited by

                                            @samson71 oh sorry - DANKE! 🙂

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

                                            Support us

                                            ioBroker
                                            Community Adapters
                                            Donate
                                            FAQ Cloud / IOT
                                            HowTo: Node.js-Update
                                            HowTo: Backup/Restore
                                            Downloads
                                            BLOG

                                            724
                                            Online

                                            31.7k
                                            Users

                                            79.8k
                                            Topics

                                            1.3m
                                            Posts

                                            16
                                            152
                                            10924
                                            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