Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. ioBroker Allgemein
    4. Adapter: ioBroker.unifi

    NEWS

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

    • ioBroker goes Matter ... Matter Adapter in Stable

    • Monatsrückblick - April 2025

    Adapter: ioBroker.unifi

    This topic has been deleted. Only users with topic management privileges can see it.
    • dslraser
      dslraser Forum Testing Most Active @liv-in-sky last edited by

      @liv-in-sky sagte in Adapter: ioBroker.unifi:

      ansonsten mit nodered - weiß nicht, ob du das magst

      Ich weiß nicht ob ich das mag, habe ich noch nie benutzt 😅

      thewhobox 1 Reply Last reply Reply Quote 0
      • thewhobox
        thewhobox @dslraser last edited by

        @dslraser Hab ich noch nicht getestet, sollte aber eig funktionieren.

        const request = require('request');
        const unifi_username = "user";
        const unifi_password = "pass";
        const unifi_controller = "https://192.168.x.xx:xxxx";
        const wifi_id = "dsa4fsda6g46fdsg984";
        
        
        function login() {
            request.post({
                    url: unifi_controller + "/api/login",
                    body: JSON.stringify({ username: unifi_username, password: unifi_password }),
                    headers: { 'Content-Type': 'application/json' }
                }, (err, resp) => {
                
                if(!err) {
                    console.log("Login war erfolgreich!");
                    getStatus();
                } else {
                    console.log("Login Fehler! " + err);
                }
            })
        }
        
        function getStatus() {
            request.get(unifi_controller + "/api/s/default/rest/wlanconf/" + wifi_id, (err, resp) => {
                if(!err) {
                    console.log("Status erfolgreich geholt!");
                    console.log(resp);
                    let status = JSON.parse(resp);
                    let wlanOn = status.data[0].enabled;
                    console.log("WLAN ist: " + (wlanOn ? "an" : "aus"));
                } else {
                    console.log("Status konnte nicht geholt werden. " + err);
                }
            })
        }
        
        login();
        
        dslraser liv-in-sky 3 Replies Last reply Reply Quote 1
        • dslraser
          dslraser Forum Testing Most Active @thewhobox last edited by

          @thewhobox
          danke Dir, probiere ich heute Abend mal aus. Ich sage hier Bescheid ob es funktioniert.

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

            @thewhobox hi,

            bekomme das zurück

            unifiWLAN: Login Fehler! Error: self signed certificate
            
            thewhobox 1 Reply Last reply Reply Quote 0
            • dslraser
              dslraser Forum Testing Most Active @thewhobox last edited by

              @thewhobox

              habe es doch schnell probiert, gleicher Fehler wie @liv-in-sky

              Login Fehler! Error: self signed certificate
              
              1 Reply Last reply Reply Quote 0
              • thewhobox
                thewhobox @liv-in-sky last edited by thewhobox

                @liv-in-sky @dslraser dann probiert mal in der ersten zeile

                const request = require('request').defaults({ rejectUnauthorized: false });
                
                dslraser liv-in-sky 4 Replies Last reply Reply Quote 0
                • dslraser
                  dslraser Forum Testing Most Active @thewhobox last edited by

                  @thewhobox sagte in Adapter: ioBroker.unifi:

                  const request = require('request').defaults({ rejectUnauthorized: false });

                  18:10:40.222	error	javascript.0 script.js.Heiko.04Telegram.Unifi: SyntaxError: Unexpected token o in JSON at position 1
                  18:10:40.222	error	javascript.0 at Request.request.get [as _callback] (script.js.Heiko.04Telegram.Unifi:29:31)
                  
                  1 Reply Last reply Reply Quote 0
                  • liv-in-sky
                    liv-in-sky @thewhobox last edited by

                    @thewhobox

                    Image 4.png

                    1 Reply Last reply Reply Quote 0
                    • dslraser
                      dslraser Forum Testing Most Active @thewhobox last edited by

                      @thewhobox

                      javascript.0	2019-08-26 18:12:12.553	error	at endReadableNT (_stream_readable.js:1145:12)
                      javascript.0	2019-08-26 18:12:12.553	error	at IncomingMessage.emit (events.js:203:15)
                      javascript.0	2019-08-26 18:12:12.553	error	at Object.onceWrapper (events.js:286:20)
                      javascript.0	2019-08-26 18:12:12.553	error	at IncomingMessage.<anonymous> (/opt/iobroker/node_modules/iobroker.javascript/node_modules/request/request.js:1083:12)
                      javascript.0	2019-08-26 18:12:12.553	error	at Request.emit (events.js:198:13)
                      javascript.0	2019-08-26 18:12:12.553	error	at Request.<anonymous> (/opt/iobroker/node_modules/iobroker.javascript/node_modules/request/request.js:1161:10)
                      javascript.0	2019-08-26 18:12:12.553	error	at Request.emit (events.js:198:13)
                      javascript.0	2019-08-26 18:12:12.553	error	at Request.self.callback (/opt/iobroker/node_modules/iobroker.javascript/node_modules/request/request.js:185:22)
                      javascript.0	2019-08-26 18:12:12.553	error	at Request.request.get [as _callback] (script.js.Heiko.04Telegram.Unifi:29:31)
                      javascript.0	2019-08-26 18:12:12.553	error	at JSON.parse (<anonymous>:null:null)
                      javascript.0	2019-08-26 18:12:12.552	error	script.js.Heiko.04Telegram.Unifi: SyntaxError: Unexpected token o in JSON at position 1
                      javascript.0	2019-08-26 18:12:12.552	info	script.js.Heiko.04Telegram.Unifi: {'statusCode':401,'body':'{\'meta\':{\'rc\':\'error\',\'msg\':\'api.err.LoginRequired\'},\'data\':[]}','headers':{'cache-control':'private','expires':'Thu, 01 Jan 19
                      
                      1 Reply Last reply Reply Quote 0
                      • liv-in-sky
                        liv-in-sky @thewhobox last edited by

                        @thewhobox
                        falls nützlich: info vor fehler

                        javascript.2 script.js.Armin_Schalter.ALLERLEI.UnifiWLAN1: {'statusCode':401,'body':'{\'meta\':{\'rc\':\'error\',\'msg\':\'api.err.LoginRequired\'},\'data\':[]}','headers':{'cache-control':'private','expires':'Thu, 01 Jan 1970 00:00:00 GMT','vary':'Origin','access-control-allow-credentials':'true','access-control-expose-headers':'Access-Control-Allow-Origin,Access-Control-Allow-Credentials','x-frame-options':'DENY','content-type':'application/json;charset=UTF-8','content-length':'63','date':'Mon, 26 Aug 2019 16:15:40 GMT','connection':'close'},'request':{'uri':{'protocol':'https:','slashes':true,'auth':null,'host':'192.168.178.157:8443','port':'8443','hostname':'192.168.178.157','hash':null,'search':null,'query':null,'pathname':'/api/s/default/rest/wlanconf/5cadxxxxxxxxxxxxd7e5381','path':'/api/s/default/rest/wlanconf/5cadxxxxxxxxxxdd7e5381','href':'https://192.168.178.157:8443/api/s/default/rest/wlanconf/5cadca8e3b6a3967dd7e5381'},'method':'GET','headers':{}}}
                        
                        dslraser 1 Reply Last reply Reply Quote 0
                        • dslraser
                          dslraser Forum Testing Most Active @liv-in-sky last edited by dslraser

                          @liv-in-sky
                          @thewhobox
                          das aus aus dem Log unterm Script

                          26.8.2019, 18:16:40.833	[info ]: javascript.0 Start javascript script.js.Heiko.Unifi.unifi_wifi
                          26.8.2019, 18:16:40.833	[info ]: javascript.0 script.js.Heiko.Unifi.unifi_wifi: registered 0 subscriptions and 0 schedules
                          26.8.2019, 18:16:41.126	[info ]: javascript.0 script.js.Heiko.Unifi.unifi_wifi: Login war erfolgreich!
                          26.8.2019, 18:16:41.149	[info ]: javascript.0 script.js.Heiko.Unifi.unifi_wifi: Status erfolgreich geholt!
                          26.8.2019, 18:16:41.149	[info ]: javascript.0 script.js.Heiko.Unifi.unifi_wifi: {'statusCode':401,'body':'{\'meta\':{\'rc\':\'error\',\'msg\':\'api.err.LoginRequired\'},\'data\':[]}','headers':{'cache-control':'private','expires':'Thu, 01 Jan 1970 00:00:00 GMT','vary':'Origin','access-control-allow-credentials':'true','access-control-expose-headers':'Access-Control-Allow-Origin,Access-Control-Allow-Credentials','x-frame-options':'DENY','content-type':'application/json;charset=UTF-8','content-length':'63','date':'Mon, 26 Aug 2019 16:16:41 GMT','connection':'close'},'request':{'uri':{'protocol':'https:','slashes':true,'auth':null,'host':'192.168.180.110:8443','port':'8443','hostname':'192.168.180.110','hash':null,'search':null,'query':null,'pathname':'/api/s/default/rest/wlanconf/5d3c5be0bc96040011365fe5','path':'/api/s/default/rest/wlanconf/5d3c5be0bc96040011365fe5','href':'https://192.168.180.110:8443/api/s/default/rest/wlanconf/5d3c5be0bc96040011365fe5'},'method':'GET','headers':{}}}
                          26.8.2019, 18:16:41.149	[error]: javascript.0 script.js.Heiko.Unifi.unifi_wifi: SyntaxError: Unexpected token o in JSON at position 1
                          26.8.2019, 18:16:41.149	[error]: javascript.0     at Request.request.get [as _callback] (script.js.Heiko.Unifi.unifi_wifi:29:31)
                          
                          thewhobox 2 Replies Last reply Reply Quote 0
                          • thewhobox
                            thewhobox @dslraser last edited by

                            @dslraser Okay, dann speichert er leider den Login cookie nicht automatisch. Muss ich mir heute Abend nochmal anschauen

                            1 Reply Last reply Reply Quote 0
                            • thewhobox
                              thewhobox @dslraser last edited by

                              @dslraser @liv-in-sky Könnte einer von euch mal nach "Login erfolgreich" folgende Zeilen einfügen?

                              console.log('HEADERS: ' + JSON.stringify(resp.headers));
                              onsole.log('Cookies: ' + resp.getHeader("Set-Cookie"));
                              
                              liv-in-sky 1 Reply Last reply Reply Quote 0
                              • liv-in-sky
                                liv-in-sky @thewhobox last edited by

                                moin @thewhobox

                                Image 5.png

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

                                  @liv-in-sky Moin. Danke fürs ausprobieren. Hier nochmal das angepasste Script für die cookies.
                                  Edit: Siehe unten

                                  liv-in-sky dslraser 2 Replies Last reply Reply Quote 1
                                  • liv-in-sky
                                    liv-in-sky @thewhobox last edited by

                                    @thewhobox - danke fürs programmieren

                                    jetzt kommt der erste fehler wieder 😞

                                    bei "const request = require('request');"

                                    10:08:00.824	info	javascript.2 Stop script script.js.Armin_Schalter.ALLERLEI.UnifiWLAN1
                                    10:08:01.924	info	javascript.2 Start javascript script.js.Armin_Schalter.ALLERLEI.UnifiWLAN1
                                    10:08:01.924	info	javascript.2 script.js.Armin_Schalter.ALLERLEI.UnifiWLAN1: registered 0 subscriptions and 0 schedules
                                    10:08:01.941	info	javascript.2 script.js.Armin_Schalter.ALLERLEI.UnifiWLAN1: Login Fehler! Error: self signed certificate
                                    10:08:03.833	info	javascript.2 Stop script script.js.Armin_Schalter.ALLERLEI.UnifiWLAN1
                                    

                                    bei "const request = require('request').defaults({ rejectUnauthorized: false });"
                                    Image 6.png

                                    thewhobox 1 Reply Last reply Reply Quote 0
                                    • dslraser
                                      dslraser Forum Testing Most Active @thewhobox last edited by

                                      @thewhobox sagte in Adapter: ioBroker.unifi:

                                      let cookies = [];
                                      bei mir auch

                                      10:15:42.843	info	javascript.0 script.js.Heiko.Unifi.unifi_wifi: Login war erfolgreich!
                                      10:15:42.843	info	javascript.0 script.js.Heiko.Unifi.unifi_wifi: Cookies: ["unifises=GyZZk8h1ERsg5Kn9AeYyD2sL5Lcduutx","csrf_token=dKB4b1jFoeScvPlh97hKMywEdt1oUdBI"]
                                      10:15:42.893	info	javascript.0 script.js.Heiko.Unifi.unifi_wifi: Status erfolgreich geholt!
                                      10:15:42.893	info	javascript.0 script.js.Heiko.Unifi.unifi_wifi: {'statusCode':200,'body':'{\'meta\':{\'rc\':\'ok\'},\'data\':[{\'_id\':\'5d3c5be0bc96040011365fe5\',\'enabled\':true,\'security\':\'open\',\'wep_idx\':1,\'wpa_mode\':\'wpa2\',\'wpa_enc\':\'ccmp\',\'usergroup_id\':\'5d3b2323bc9604001132d2c5\',\'dtim_mode\':\'default\',\'dtim_ng\':1,\'dtim_na\':1,\'minrate_ng_enabled\':false,\'minrate_ng_advertising_rates\':false,\'minrate_ng_data_rate_kbps\':1000,\'minrate_ng_cck_rates_enabled\':true,\'minrate_na_enabled\':false,\'minrate_na_advertising_rates\':false,\'minrate_na_data_rate_kbps\':6000,\'mac_filter_enabled\':false,\'mac_filter_policy\':\'allow\',\'mac_filter_list\':[],\'bc_filter_enabled\':false,\'bc_filter_list\':[],\'group_rekey\':3600,\'name\':\'Hübis Gäste\',\'is_guest\':true,\'x_passphrase\':\'dashieristprivat\',\'wlangroup_id\':\'5d3b2323bc9604001132d2c6\',\'schedule\':[],\'minrate_ng_mgmt_rate_kbps\':1000,\'minrate_na_mgmt_rate_kbps\':6000,\'minrate_ng_beacon_rate_kbps\':1000,\'minrate_na_beacon_rate_kbps\':6000,\'site_id\':\'5d3b231abc9604001132d2b8\',\'x_iapp_key\':\'0613db2263d118bc9e21936a202a964e\',\'fast_roaming_enabled\':false,\'no2ghz_oui\':true}]}','headers':{'cache-control':'private','expires':'Thu, 01 Jan 1970 00:00:00 GMT','vary':'Origin,Accept-Encoding','access-control-allow-credentials':'true','access-control-expose-headers':'Access-Control-Allow-Origin,Access-Control-Allow-Credentials','x-frame-options':'DENY','content-type':'application/json;charset=UTF-8','content-length':'1000','date':'Tue, 27 Aug 2019 08:15:42 GMT','connection':'close'},'request':{'uri':{'protocol':'https:','slashes':true,'auth':null,'host':'192.168.180.110:8443','port':'8443','hostname':'192.168.180.110','hash':null,'search':null,'query':null,'pathname':'/api/s/default/rest/wlanconf/5d3c5be0bc96040011365fe5','path':'/api/s/default/rest/wlanconf/5d3c5be0bc96040011365fe5','href':'https://192.168.180.110:8443/api/s/default/rest/wlanconf/5d3c5be0bc96040011365fe5'},'method':'GET','headers':{'Cookie':'unifises=GyZZk8h1ERsg5Kn9AeYyD2sL5Lcduutx; csrf_token=dKB4b1jFoeScvPlh97hKMywEdt1oUdBI'}}}
                                      10:15:42.893	error	javascript.0 script.js.Heiko.Unifi.unifi_wifi: SyntaxError: Unexpected token o in JSON at position 1
                                      10:15:42.893	error	javascript.0 at Request.request.get [as _callback] (script.js.Heiko.Unifi.unifi_wifi:39:31)
                                      
                                      1 Reply Last reply Reply Quote 0
                                      • thewhobox
                                        thewhobox @liv-in-sky last edited by

                                        @liv-in-sky Ja hast recht. Hab den teil vergessen zu ändern.
                                        Hab das Skript oben angepasst. einfach mal das JSON.parse weg lassen.

                                        1 Reply Last reply Reply Quote 0
                                        • dslraser
                                          dslraser Forum Testing Most Active last edited by

                                          @thewhobox
                                          @liv-in-sky

                                          Unexpected token o in JSON at position 1
                                          
                                          

                                          Ich habe keine Ahnung davon, aber wenn ich google dazu befrage, dann kommt Sinngemäß oft die Antwort, das es schon ein Objekt ist und man es direkt verwenden kann und nicht parsen braucht ?

                                          Danke für die Mühe.

                                          thewhobox 1 Reply Last reply Reply Quote 0
                                          • thewhobox
                                            thewhobox @dslraser last edited by

                                            @dslraser Ja das stimmt. Hab das Skript oben angepasst.

                                            liv-in-sky 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

                                            703
                                            Online

                                            31.6k
                                            Users

                                            79.5k
                                            Topics

                                            1.3m
                                            Posts

                                            unifi
                                            170
                                            991
                                            282518
                                            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