[Beta] Unifi Wifi Presence

I have seen a few other Unifi ubiquiti api drivers but they required additional systems to run code on and I really wanted a driver that only ran on the hubitat. Now that the new ignore ssl feature is available it is possible. So you need to be running 2.1.8.117+.

This is very early stages just been using it on two cell phones for now.

Just wanted to see if others were interested in a hubitat only option?

Working on adding a block function. Want to be able to block the kids devices, really my main reason for getting the API going but the presense was a little easier to start with.

Update: Added another child driver for managing blocking and unblocking a device. If unifi is not blocking it will match a switch on if its blocked it will match a switch off. Thought this would be best to relate to the client. That way with your assitant you can ask it to turn off a device. Which would then block the device from joining wifi.
There is a function that every hour will check to see if the device is blocked or not to update the status just in case it gets out of sync. For that to work you have to put the device id info in the Preferences Client ID box. To get the ID click GetClientID. Will show up as _id.

Note: It does not currently work with UDM-Pro that runs the new UniFi OS.

Update 7/2/2020: Added driver to Hubitat Package Manager, so that you can install and update it easier.

20 Likes

I’ll be following this thread, thanks.

Me too.

I have read some of the other threads that combine wifi with geolocation and the benefits but it was on my todo list to do more reading.

I am interested.. I have one under development myself, but nothing working yet. I have too many other projects going so I would much rather someone else do it.. :+1:

3 Likes

Very interested. Didn't realize ignore ssl was needed to solve this one. I've installed the 2 drivers, it works nicely so far. What's on the Todo list, where do you need help? Refresh is needed. And they should become apps instead of drivers.

How are you using it to block kids devices?

Awesome! I'd been looking at their API before, but really couldnt get much "good" documentation on it. I'll be adding this, thank you!! :+1:

Update
Added my cell, and working great! Could I ask that the port used be a pref?
I'm not using 8443 here, so had to update that in the code, but once I did and logged in, all was great!!

Thanks for this. But it isnt working for me. I'm getting: (from nearly all buttons, except login).

I'm logged in from HE, and can see that I've logged in via the controller site. And also below.

It is on a synology NAS, if that makes a difference. Although it does work for Node-Red.

I know it's not a firewall issue, because I can login and get stats from node-red.

You are running the UniFi on Synology? In a rocket container? What port is needed to connect to UniFi on your Synology?

Yes, docker. 8443. It's on the "host network" which is recommended for Unifi.

This is my IP for the Unifi: h̶t̶t̶p̶:̶//192.168.1.200:8443/manage/site/(continued)

Added an update to make it easy to change to a different tcp port. If you are updating you will need to click the save the preferences button.

@mike are you using a different site other than the default?

1 Like

Many thanks @mike10 for the port :+1:

And feel free to tell me to "do one" here, but number of seconds would be another good Pref to add in the Child driver, so you can vary between a cell or other network device, then you could raise an alert based on "not present" for anything which may "drop off" the network.

This would mean I could extend its use for ANYTHING which may drop off my network, other Hubs (Hue, Harmony etc) or my Sonoff temp sensor (for the aqaurium), then raise the alert. I think that would be a very nice addition! I'm currently using Homeseer and Pushover for alerting me on my hubs, but would mean that I could do away with Homeseer with this :slight_smile:

This is an awesome driver, many thanks for creating!!

One thing I have noticed is, I cant seem to delete a child, no errors, it just doesnt delete.
Scratch that. just tried using the dni, and its gone :+1:

2 Likes

@Royski That was actually one of the items on my list todo. I updated github with a prefrence option for the number of seconds between checks.

FYI sometimes it takes a few minutes for unifi to detect a device is gone.

Good idea on monitoring if a device is down, nice use case.

1 Like

Presence on a network is not stateful. So I would bet that Unifi does a periodic check, then marks the devices as on or off network. So we have sort of a dual timeout period (one on Unifi and one on the HE). Just the nature of the integration.

I am. Unifi in docker changes the default name/site behind the scenes. Now that you mentioned it, I did need to change something in Node-Red as well. The Docker name of my site is nnrtpaqs

Edit: I changed /default/ in the driver to /nnrtpaqs/, and it worked. Thanks for the tip off above.

Many thanks for this. I have successfully installed and it appears to be working fine.

EDIT: loaded well and showed presence but didn't refresh present unless I selected update when a device had left otherwise no other issues.

Wow. That was easy. Installed all three drivers, popped username/pass in, and added MAC addresses.

Just came here to say thanks. Worked first try. Very cool.

@jchurch In the child device do you have a scheduled job that is called Update?

I'm really curious if this is any more reliable than the iPhone WiFi presence app? Not due to a fault of either app but due to the fact that phones tend to shutdown WiFi to conserve battery between email checks or push notifications.

I would try this however I'm not running firmware 2.1.8 since I have had issues with things slowing down on firmware updates so I've stayed at 2.1.5 for a while now, although since the new year things are intermittently slow on that firmware now as well so I will likely update soon.

1 Like

Are you referring to the slider button called "Enable Auto updating"? If so yes I do and it's enabled.

@jchurch no actually towards the bottom of the screen.

Should look like