www.homeseer.com    
 

Go Back   HomeSeer Message Board > HomeSeer Products & Services > HomeSeer General Discussion Area

HomeSeer General Discussion Area General discussion about HomeSeer that does not fall into any other category or are not specific to 1.x or 2.x versions of HomeSeer.

Reply
 
Thread Tools Display Modes
  #1  
Old August 12th, 2017, 04:12 PM
jono jono is offline
Seer Deluxe
 
Join Date: Dec 2006
Location: MA
Posts: 481
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.
Reply With Quote
  #2  
Old August 12th, 2017, 05:05 PM
Pete's Avatar
Pete Pete is online now
OverSeer
 
Join Date: Jan 2001
Location: House
Posts: 14,289
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.
__________________
- Pete

Automator

HS3 Pro & Lite
Edition Beta 3.0.0.387 | Ubuntu 16.04 64 bit | Oracle Windows Virtual Box ==> for Wintel only SAPI and HS3 plugins


Last edited by Pete; August 12th, 2017 at 05:16 PM.
Reply With Quote
  #3  
Old August 12th, 2017, 06:55 PM
vasrc's Avatar
vasrc vasrc is offline
Seer Master
 
Join Date: May 2003
Location: Locust Dale, VA
Posts: 1,153
Quote:
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
Reply With Quote
  #4  
Old August 12th, 2017, 07:20 PM
jono jono is offline
Seer Deluxe
 
Join Date: Dec 2006
Location: MA
Posts: 481
Quote:
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.
Reply With Quote
  #5  
Old August 12th, 2017, 07:26 PM
jono jono is offline
Seer Deluxe
 
Join Date: Dec 2006
Location: MA
Posts: 481
Quote:
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.
Reply With Quote
  #6  
Old August 12th, 2017, 07:33 PM
vasrc's Avatar
vasrc vasrc is offline
Seer Master
 
Join Date: May 2003
Location: Locust Dale, VA
Posts: 1,153
Quote:
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
Reply With Quote
  #7  
Old August 12th, 2017, 07:40 PM
vasrc's Avatar
vasrc vasrc is offline
Seer Master
 
Join Date: May 2003
Location: Locust Dale, VA
Posts: 1,153
Quote:
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
Reply With Quote
  #8  
Old August 12th, 2017, 07:52 PM
jono jono is offline
Seer Deluxe
 
Join Date: Dec 2006
Location: MA
Posts: 481
Quote:
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
Reply With Quote
  #9  
Old August 12th, 2017, 07:55 PM
vasrc's Avatar
vasrc vasrc is offline
Seer Master
 
Join Date: May 2003
Location: Locust Dale, VA
Posts: 1,153
Quote:
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
Reply With Quote
  #10  
Old August 12th, 2017, 08:13 PM
jono jono is offline
Seer Deluxe
 
Join Date: Dec 2006
Location: MA
Posts: 481
Quote:
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?
Reply With Quote
  #11  
Old August 12th, 2017, 08:48 PM
vasrc's Avatar
vasrc vasrc is offline
Seer Master
 
Join Date: May 2003
Location: Locust Dale, VA
Posts: 1,153
Quote:
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
Reply With Quote
  #12  
Old August 12th, 2017, 09:48 PM
S-F's Avatar
S-F S-F is online now
OverSeer
 
Join Date: Jun 2012
Location: Goobertown AR 72450
Posts: 2,888
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.
__________________
Quote:
Originally Posted by rprade View Post
There is no rhyme or reason to the anarchy a defective Z-Wave device can cause
Reply With Quote
  #13  
Old August 12th, 2017, 10:41 PM
vasrc's Avatar
vasrc vasrc is offline
Seer Master
 
Join Date: May 2003
Location: Locust Dale, VA
Posts: 1,153
Quote:
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
Reply With Quote
  #14  
Old August 12th, 2017, 11:36 PM
S-F's Avatar
S-F S-F is online now
OverSeer
 
Join Date: Jun 2012
Location: Goobertown AR 72450
Posts: 2,888
Quote:
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.
Reply With Quote
  #15  
Old August 12th, 2017, 11:44 PM
vasrc's Avatar
vasrc vasrc is offline
Seer Master
 
Join Date: May 2003
Location: Locust Dale, VA
Posts: 1,153
Quote:
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
Reply With Quote
  #16  
Old August 13th, 2017, 07:21 AM
S-F's Avatar
S-F S-F is online now
OverSeer
 
Join Date: Jun 2012
Location: Goobertown AR 72450
Posts: 2,888
Quote:
Originally Posted by vasrc View Post
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

Gotcha. It doesn't matter as long as it's all on the same network. The logs aren't generated by the controller. They com from the APs themselves. Just like most things Unifi this works when the controller is down. You use the controller to point the logs from the APs to the HS machine. I often don't have the controller running. One of the options for event triggers with UltraLog is the source IP. When I get a log from the outside AP saying that the MAC of my phone has connected I run an event.
Reply With Quote
  #17  
Old August 13th, 2017, 08:00 AM
vasrc's Avatar
vasrc vasrc is offline
Seer Master
 
Join Date: May 2003
Location: Locust Dale, VA
Posts: 1,153
Quote:
Originally Posted by S-F View Post
Gotcha. It doesn't matter as long as it's all on the same network. The logs aren't generated by the controller. They com from the APs themselves. Just like most things Unifi this works when the controller is down. You use the controller to point the logs from the APs to the HS machine. I often don't have the controller running. One of the options for event triggers with UltraLog is the source IP. When I get a log from the outside AP saying that the MAC of my phone has connected I run an event.
I guess that's the part I'm missing. How are you actually getting the logs from the AP's (or controller for that matter) to your PC?
Also, what text are you parsing for? There's a ton of data sent in the logs..

Thanks,
Z
Reply With Quote
  #18  
Old August 13th, 2017, 09:27 AM
S-F's Avatar
S-F S-F is online now
OverSeer
 
Join Date: Jun 2012
Location: Goobertown AR 72450
Posts: 2,888
In the Unifi controller you select use a syslog server or whatever and give it the ip address and syslog port of your HS machine. The APs then start sending logs and you can shut down the Unifi controller. For UltraLog events I look for a line indicating that a certain phones MAC has connected or disconnected and I also look for a unique identifier for the specific AP I'm wanting to work with. I just looked at the syslog output in UltraLog to figure out what meant what.
Attached Images
  
Reply With Quote
  #19  
Old August 13th, 2017, 09:32 AM
jono jono is offline
Seer Deluxe
 
Join Date: Dec 2006
Location: MA
Posts: 481
Mine is now working! The key was to use the ip address of the access point for syslog entries. I was using the ip address of the computer that was running the controller software. My syslog software is Kiwi and it requires one to enter the ip address of the source that the syslog files are coming from.

Now that I have the APs logging, I can use mac address to know when someone is at my house or not, or even to do geolocating within my house. I have BLLogmonitor scan the syslog files for the mac address and turn on virtual variables representing presence or absence.

Thank you all for helping me out!
Reply With Quote
  #20  
Old August 13th, 2017, 09:38 AM
vasrc's Avatar
vasrc vasrc is offline
Seer Master
 
Join Date: May 2003
Location: Locust Dale, VA
Posts: 1,153
Quote:
Originally Posted by S-F View Post
In the Unifi controller you select use a syslog server or whatever and give it the ip address and syslog port of your HS machine. The APs then start sending logs and you can shut down the Unifi controller. For UltraLog events I look for a line indicating that a certain phones MAC has connected or disconnected and I also look for a unique identifier for the specific AP I'm wanting to work with. I just looked at the syslog output in UltraLog to figure out what meant what.
Ahh... Remote syslogging

Do you ever have problems when your device "moves" to another AP? I'm assuming you'll get a disconnect then?

Thanks,
Z
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding Serial Connect and Disconnect Actions travisdh HS3 Plug-In Development 2 April 16th, 2014 03:47 AM
HSTouch Client connect - disconnect Ken LaCapria HSTouch™ 1 September 3rd, 2013 06:33 AM
How to force disconnect and ask on connect? msbreton Clients - Apple iPhone/iPod/iPad 4 February 3rd, 2011 07:47 PM
User data not loading - shows as Unknown user dmronning UltraM1G HSPI 3 September 16th, 2008 06:48 PM
Speaker Client connect/disconnect issues... surovich HS2 / HSPRO 2 February 13th, 2006 07:46 PM


All times are GMT -4. The time now is 09:32 PM.


Copyright HomeSeer Technologies, LLC