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

    • Neuer Blog: Fotos und Eindrücke aus Solingen

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

    • ioBroker goes Matter ... Matter Adapter in Stable

    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:

      hab noch was gefunden und positiv getestet - ist ein linux-bash-script

      Hi, kann man das auch in ein normal Script oder Blockly umwandeln ?
      Oder wo/wie wendest Du das linux-bash-script an ?

      Ich würde es gern in z.B iQontrol nutzen.

      z.B. Gäste WLAN an oder Gäste WLAN aus

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

        @dslraser

        wenn du das linux script erzeugst auf einer console :

        • am besten im /opt/iobroker - ordner - da solltest du die rechte haben
        • nano unifi.sh (dann inhalt reinkopieren) - mit "<ALT>-x speichern unter dem namen unifi.sh
        • dann "chmod +x unifi.sh" - danmit es ausführbar ist

        dann kannst du mit einem blockly und result aktiviert (variable result einfach erstellen) das script aufrufen und das result weiterverarbeiten

        Image 7.png

        Image 6.png

        dslraser 1 Reply Last reply Reply Quote 0
        • dslraser
          dslraser Forum Testing Most Active @liv-in-sky last edited by

          @liv-in-sky
          Danke für Deine Geduld und Mühe.
          Also muss ich tatsächlich erst dieses Script installieren und dann über Blockly aufrufen.
          Ich dachte es gäbe eine Möglichkeit dies gleich mit "ioBroker Boardmitteln" zu erledigen ?

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

            @dslraser
            ja - ich steh auf diese linux scripts - dabei bin ich schneller als in javascript - old school halt!

            ein richtiger profi könnte das sicher in javascript umwandeln - aber das kann ich leider nicht bieten 😞

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

            dslraser 1 Reply Last reply Reply Quote 0
            • 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
                                            • First post
                                              Last post

                                            Support us

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

                                            629
                                            Online

                                            31.7k
                                            Users

                                            79.8k
                                            Topics

                                            1.3m
                                            Posts

                                            unifi
                                            170
                                            998
                                            310818
                                            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