Announcement

Collapse
No announcement yet.

Unifi Controller Wifi user connect/disconnect data

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Unifi Controller Wifi user connect/disconnect data

    The Unifi Controller is wifi access point software that logs events, for example who has connected or disconnected to a home network. I would think this could be useful to import into HS3. Then you would have data as to who is at a house and when based on their devices connecting to wifi.
    The trouble is that the data is not readily exported to syslog. It can be monitored on a webpage and can also be accessed by SSH using the command tail -f /var/log/messages
    but that just gets the data into a command window.
    I was hoping to get it into a text file where a log monitor could translate it into HS3.
    I'm getting out over my skiis so thought I would ask this community if anyone has found a way to get the "event" data (i.e. Jim's iphone has connected) from Unifi into HS3.

    #2
    Here been mapping a shared drive to the Homeseer Pro data directory for logging. IE: /HomeSeer/data/sharedirectoryname

    IE: for lightning it's just a lightning directory with the logs (not written currently to /var/log directory rather it is written to the /opt/lightning/log directory).

    Just share (use Samba) the log read only file then map the share on your Homeseer machine (well if Linux) using fstab.
    1 - configure the SAMBA share directory in the the /etc/samba/smb.conf file

    [ICS-Znet] ;the share name can be what ever you want
    browseable = yes
    path = /opt/digitemp
    guest ok = yes
    read only = no
    create mask = 777 * or 660 if this bugs you.


    2 - configure the mapping in FSTAB like so.

    # One Wire Share
    //192.168.244.169/ICS-Znet /HomeSeer/Data/1-wire cifs guest,uid=1000,iochars$

    3 - test it by remounting all.


    I used to do an ssh copy which really is a pita.

    If you are running Homeseer in Windows you can do the same.

    Thinking Jon00 has a plugin / script that will will help you with said endeavor.
    Last edited by Pete; August 12, 2017, 04:16 PM.
    - Pete

    Auto mator
    Homeseer 3 Pro - 3.0.0.548 (Linux) - Ubuntu 18.04/W7e 64 bit Intel Haswell CPU 16Gb
    Homeseer Zee2 (Lite) - 3.0.0.548 (Linux) - Ubuntu 18.04/W7e - CherryTrail x5-Z8350 BeeLink 4Gb BT3 Pro
    HS4 Lite - Ubuntu 22.04 / Lenovo Tiny M900 / 32Gb Ram

    HS4 Pro - V4.1.18.1 - Ubuntu 22.04 / Lenova Tiny M900 / 32Gb Ram
    HSTouch on Intel tabletop tablets (Jogglers) - Asus AIO - Windows 11

    X10, UPB, Zigbee, ZWave and Wifi MQTT automation-Tasmota-Espurna. OmniPro 2, Russound zoned audio, Alexa, Cheaper RFID, W800 and Home Assistant

    Comment


      #3
      Originally posted by jono View Post
      The Unifi Controller is wifi access point software that logs events, for example who has connected or disconnected to a home network. I would think this could be useful to import into HS3. Then you would have data as to who is at a house and when based on their devices connecting to wifi.
      The trouble is that the data is not readily exported to syslog. It can be monitored on a webpage and can also be accessed by SSH using the command tail -f /var/log/messages
      but that just gets the data into a command window.
      I was hoping to get it into a text file where a log monitor could translate it into HS3.
      I'm getting out over my skiis so thought I would ask this community if anyone has found a way to get the "event" data (i.e. Jim's iphone has connected) from Unifi into HS3.
      I've wanted to try this for awhile now but the Unifi SNMP doesn't list users (they're on the controller and SNMP looks at the individual AP devices) so I never attempted it. There is however a PHP class that does retrieve a LOT of info. There's also a Unifi Browser, (https://github.com/malle-pietje/UniFi-API-browser) where you can view the data stored on the controller.

      If you have PHP running, it should be a simple matter of retrieving the JSON data from the API class and then exporting it to HS3. I may have to look at it again as I had the same thought about using it to watch devices come and go from the property.

      Z

      Comment


        #4
        Originally posted by vasrc View Post
        I've wanted to try this for awhile now but the Unifi SNMP doesn't list users (they're on the controller and SNMP looks at the individual AP devices) so I never attempted it. There is however a PHP class that does retrieve a LOT of info. There's also a Unifi Browser, (https://github.com/malle-pietje/UniFi-API-browser) where you can view the data stored on the controller.

        If you have PHP running, it should be a simple matter of retrieving the JSON data from the API class and then exporting it to HS3. I may have to look at it again as I had the same thought about using it to watch devices come and go from the property.

        Z
        Thanks Z. I have 3 AP devices in my house, so was hoping there would be a way to get the devices coming/going from all 3. That is why the controller software is so frustrating. The info is all in the central controller, but just can't get it out. There may be a way to do it using a screen scraper on the web pages from port 8443, but it seems like that would be a pretty kludged workaround.
        Strangely, Unifi doesn't make the event database available, even though it would be incredibly useful to make it available.
        Please let me know if you decide to work on this. I'd be eager to help, though my skills are limited.

        Comment


          #5
          Originally posted by Pete View Post
          Here been mapping a shared drive to the Homeseer Pro data directory for logging. IE: /HomeSeer/data/sharedirectoryname

          IE: for lightning it's just a lightning directory with the logs (not written currently to /var/log directory rather it is written to the /opt/lightning/log directory).

          Just share (use Samba) the log read only file then map the share on your Homeseer machine (well if Linux) using fstab.
          1 - configure the SAMBA share directory in the the /etc/samba/smb.conf file

          [ICS-Znet] ;the share name can be what ever you want
          browseable = yes
          path = /opt/digitemp
          guest ok = yes
          read only = no
          create mask = 777 * or 660 if this bugs you.


          2 - configure the mapping in FSTAB like so.

          # One Wire Share
          //192.168.244.169/ICS-Znet /HomeSeer/Data/1-wire cifs guest,uid=1000,iochars$

          3 - test it by remounting all.


          I used to do an ssh copy which really is a pita.

          If you are running Homeseer in Windows you can do the same.

          Thinking Jon00 has a plugin / script that will will help you with said endeavor.
          Hi Pete, thanks for your reply. Unifi Customer Support told me that the file that includes the events is encrypted and therefore no use to me. So they suggested the SSH method, which I got up and running in a command window, but that was at the outer limits of my capabilities. I apologize but much of your post seems to be beyond what I might be able to do.

          Comment


            #6
            Originally posted by jono View Post
            Thanks Z. I have 3 AP devices in my house, so was hoping there would be a way to get the devices coming/going from all 3. That is why the controller software is so frustrating. The info is all in the central controller, but just can't get it out. There may be a way to do it using a screen scraper on the web pages from port 8443, but it seems like that would be a pretty kludged workaround.
            Strangely, Unifi doesn't make the event database available, even though it would be incredibly useful to make it available.
            Please let me know if you decide to work on this. I'd be eager to help, though my skills are limited.
            There is an JSON API you can use to retrieve BUT it requires a prior login, so it's not a simple one liner. There are several PHP examples, but you could easily do a VB/C .NET using HttpWebRequest.

            Try this and you'll see the events (which contain Connect/Disconnect)

            https://UnifiControllerIP:8443/api/s.../list/wlanconf

            JavaScriptSerializereserialize should be able to stick it in an array for you.

            Z

            Comment


              #7
              Originally posted by vasrc View Post
              There is an JSON API you can use to retrieve BUT it requires a prior login, so it's not a simple one liner. There are several PHP examples, but you could easily do a VB/C .NET using HttpWebRequest.

              Try this and you'll see the events (which contain Connect/Disconnect)

              https://UnifiControllerIP:8443/api/s.../list/wlanconf

              JavaScriptSerializereserialize should be able to stick it in an array for you.

              Z
              Oops wrong URL, https://IP:8443/api/s/default/stat/event)

              Z

              Comment


                #8
                Originally posted by vasrc View Post
                I get this:
                { "data" : [ ] , "meta" : { "msg" : "api.err.LoginRequired" , "rc" : "error"}}

                Not sure what it means, but may need a username/p.w. in the url

                Comment


                  #9
                  Originally posted by jono View Post
                  I get this:
                  { "data" : [ ] , "meta" : { "msg" : "api.err.LoginRequired" , "rc" : "error"}}

                  Not sure what it means, but may need a username/p.w. in the url
                  Yup.. Just for grins, try logging into the controller from the same browser your' entering the URL. See if that works. I can get it to respond but I also have the PHP code running in the background.


                  Z

                  Comment


                    #10
                    Originally posted by vasrc View Post
                    Yup.. Just for grins, try logging into the controller from the same browser your' entering the URL. See if that works. I can get it to respond but I also have the PHP code running in the background.


                    Z
                    I did log in on a different tab of the same (chrome) browser. Same response.
                    I'm not sure what the PHP code running in the background is, but is that easy to set up?

                    Comment


                      #11
                      Originally posted by jono View Post
                      I did log in on a different tab of the same (chrome) browser. Same response.
                      I'm not sure what the PHP code running in the background is, but is that easy to set up?
                      You need to have a device that can execute the PHP server code (I just use one of my Synology NAS boxes). You can also install it on your PC if you'd like.

                      Looking at the data, they pretty much show everything possible from the Unifi Controller, not just events.

                      Z

                      Comment


                        #12
                        I use UltraLog to determine which Unifi AP people are connected to. I send the Unifi logs to the UltraLog syslog server. Painless and works a treat especial. For example HS knows I'm outside right now so all TTS will be routed to the yard speakers.
                        Originally posted by rprade
                        There is no rhyme or reason to the anarchy a defective Z-Wave device can cause

                        Comment


                          #13
                          Originally posted by S-F View Post
                          I use UltraLog to determine which Unifi AP people are connected to. I send the Unifi logs to the UltraLog syslog server. Painless and works a treat especial. For example HS knows I'm outside right now so all TTS will be routed to the yard speakers.
                          That's way too easy
                          Are you remote syslogging the logs?

                          Z

                          Comment


                            #14
                            Originally posted by vasrc View Post
                            That's way too easy
                            Are you remote syslogging the logs?

                            Z
                            Not sure what you mean by "remote syslogging". I'm sure it makes sense to people who know what's going on but..... I ask that you keep in mind the fact that I'm only one or two IQ points away from removing tattoos with sand paper and the next step from smearing poop on the walls crazy. The controller and HS are running on the same machine but I don't think that makes one lick of difference. As an aside UltraLog saves all of the logs from my Unifi APs. I now have years of logs saved from both HS and Unifi by UltraLog that I can search. Pretty nifty right there.
                            Originally posted by rprade
                            There is no rhyme or reason to the anarchy a defective Z-Wave device can cause

                            Comment


                              #15
                              Originally posted by S-F View Post
                              Not sure what you mean by "remote syslogging". I'm sure it makes sense to people who know what's going on but..... I ask that you keep in mind the fact that I'm only one or two IQ points away from removing tattoos with sand paper and the next step from smearing poop on the walls crazy. The controller and HS are running on the same machine but I don't think that makes one lick of difference. As an aside UltraLog saves all of the logs from my Unifi APs. I now have years of logs saved from both HS and Unifi by UltraLog that I can search. Pretty nifty right there.
                              Actually it does (the running on the same machine)
                              my controller is on a Unifi cloud key (standalone device about the size of a carton of cigarettes) so there are no local files to access. Remote syslogging is just an old unix process that lets you log to another computer

                              Z

                              Comment

                              Working...
                              X