Presence Detection

From Wildsong
Jump to navigationJump to search


Unifi is this Ubiquiti thing where you run a Unifi server (for example on Bellman on port 8443) and it watches all the supported WiFi APs on your LAN and lets you manage all of them from one place. In my case it's just one AP right now. I live in a small house, it's all I need.

I can run python scripts to pull data from the UniFi server, see

https://github.com/calmh/unifi-api

This is pure coolness.

sudo pip install unifi
./unifi-ls-clients -c bellman -u readonlyuser -p YOURPASSWORDHERE -v v5 -s default
NAME                             MAC          AP           CHAN  RSSI  RX   TX
vastra-preseed           3c:15:c2:dd:15:9c  eLab            60    47  400  400
SqueezeboxRadio          00:04:20:2a:c6:3f  eLab             6    39   54   54
android-e6e08e8b3a7b051f a0:0b:ba:e8:c5:8a  eLab             6    38   39   65
Swift                    60:c5:47:00:90:5a  eLab            60    32  162  117
android-d16cb9f5371c2cf6 30:85:a9:5b:af:57  eLab             6    27    6   63

Better even is turning on logging (in the web settings?) and watching daemon.log

Dec  8 17:05:25 192.168.1.104 ("U7LT,802aa890cd65,v3.7.17.5220") hostapd: ath0: STA 3c:15:c2:dd:15:9c IEEE 802.11: associated
Dec  8 17:05:38 192.168.1.104 ("U7LT,802aa890cd65,v3.7.17.5220") hostapd: ath0: STA a0:0b:ba:e8:c5:8a IEEE 802.11: disassociated

I can see when a device comes into my network even before it's finished its key handshake and gotten an IP address.

Flask project

I started a flask project and it's in source/presence on Bellman.

Originally I was doing a micro web server but it's morphing into an MQTT publisher.

It will listen to STDOUT from the Unifi Docker container (which is where log messages go by default.)