I wrote a SmartThings SmartApp, SmartThings Device Handler and a REST API server to enable the ability to use wireless clients on an Unifi Controller as presence sensors.
If you have a local Unifi Controller running on your local network, then you can use it’s wireless clients as presence sensors. I wrote this because of unreliable presence sensors. Hoping that by detecting if my phone is connected to my Unifi wireless network it will provide quicker / more reliable presence sensing for my automations.
If you would like to use Unifi wireless clients as presence sensors, give this solution a try and let me know what you think.
Awesome! Well with this option, I have it check every 5 seconds so really it’s 10-15 seconds from when your device connects to the wifi. So the real question is, at what point does your device connect to your wifi . I just finished all this yesterday so I have test presence sensors still on my phone to compare with the SmartThings mobile presence sensor and the Improved Mobile Presence. We’ll see which is quicker.
I’m bit of a docker noob never had any success with the bloody thing
I run the docker on a raspberry pi and the container just seems to be restarting every 8 seconds
Hello world doesn’t appear just get connection refused
@tmleafs I hear you. I’m new to Docker as well and had my fair share of hurdles. With my limited experience with Docker, I’ve only seen a Docker Container get stuck in a reboot loop when the image being used was not designed for the CPU architecture. Since you are running Docker on a Raspberry Pi, can you please make sure you are using the xtreme22886/unifi-presence-rest-arm image (specifically the arm variant).
Also, since new to Docker, I found it at ton easier to use Docker using a Docker manager like Portainer.
EDIT I just tested the ARM Docker image out and it isn’t working . So it isn’t just you. Let me fix this and once it’s fixed, I’ll let you know.
EDIT 2 The ARM Docker image has been fixed. Should work on Raspberry Pi now
Just wanted to say I’ve installed this and it works a treat! I had cobbled together another one in the past by hacking together a few other things, but this is much cleaner and faster! Thanks for the effort!
@tmleafs sweet! Glad it’s working now . It is very possible to monitor ‘wired’ clients as well. I thought about it while creating this but ended up going with just wireless clients. Let me look at the data I get from the Unifi API again and see how difficult it would be to include both wired and wireless devices.
Pruning the old data may remove your friend’s device and maybe cleaning up the DB will make your wife’s appear. If not, let me know and we can dig further into it. Also, please make sure your wife’s device is currently connected to your Unifi wireless and before tapping to select devices, sit on that screen for like 15 seconds to allow the SmartApp to get an updated list from the Unifi Bridge (you’ll see a spinning wheel on the page letting you know it’s constantly refreshing every 5 seconds).
@tmleafs, yes, that’s a stupid bug. But my Unifi Bridge accounts for this. That’s why I decided to only monitor for ‘wireless’ devices and not ‘wired’ devices. When a ‘wireless’ device disconnects from the network, it is then reported as ‘wired’. So 1) my SmartApp will only show ‘wireless’ clients. Maybe this is why your wife’s phone does not appear? 2) Makes it harder to try to monitor for ‘wired’ clients.
@tmleafs, did you get your wife’s phone sorted out? If you did, do you think I should allow people to select ‘wired’ clients as well from the SmartApp (to prevent the issue where they can’t find their wireless device)? This will allow people to select wireless clients that aren’t currently connected to the network. I wanted to filter out ‘isWired’ = True clients to reduce the list some people would have to sort though (depending on the size of their network).