Ubiquiti Unifi Binding Feature Discussion

ubiquiti
unifi
Tags: #<Tag:0x00007f0148a687e0> #<Tag:0x00007f0148a68678>

(Matthew) #1

I’ve been prototyping a new UniFi Binding for OH2 which connects to the UniFi controller and track devices for “presence” detection. One thing I cannot wrap my head around is how to accomplish this using the new OH2 concepts. According to the new opeHAB 2 concepts overview, “Channels can be linked to multiple Items and Items can be linked to multiple Channels.” I don’t quite fully understand how this n to m relationship of Channels and Items is even possible.

I initially thought I would need one instance of the binding per device, which to track multiple devices results in a lot of duplicate config, a lot of redundant network round trips and would create an all around confusing user experience. Yes, this would work, but it feels like I’m trying to use a hammer when what I need is a screwdriver.

Ideally, I should only need one instance of the binding connected to the UniFi controller (the Thing) that could track n devices (the Channels) which would be linked to n (read-only) “presence” Switches (the Items). Where I’m drawing a blank is the fact that each Channel requires a user supplied MAC address which obviously can’t be pre-defined in the thing-types.xml file.

From searching the community, it appears there might be a way to dynamically create channels at runtime. So following that logic, I could create a channel per device that’s discovered and the user would be able to link items to just the devices of interest (assuming simple linking was disabled). Am I heading in the right direction with this?

Thanks in advance!


Ubiquiti Unifi binding
Ubiquiti Unifi binding
In development addon - how to run (unresolved requirements)
MQTT, MQTTitude & OwnTracks
OpenHAB - some Things stay "Uninitialized" on boot
Initial planning zwave in a long home
Custom Widget: Who's home?
Unifi Ubiquiti - Different subnet device alive. DHCP or ARP?
(Ben Jones) #2

Sorry I have only written OH1 bindings so can’t help with your question, but I am very interested in this - I am running a Unifi controller and have a custom python script for monitoring device presence but a dedicated binding would be much preferrable.

Will be keeping a close eye on this. Good luck.


(Matthew) #3

I’m doing exactly the same :slight_smile: I figured a UniFi binding would be a simple enough starting point to get me familiar with the new OH2 concepts so I dove in head first.

After a little more research, I think the proper implementation is to expose the UniFi controller as a Bridge. Then each device to be tracked becomes a Thing and their respective Channels are attributes like online, ssid name, ap name, etc… (to name a few).

Since you’ve stated interest in this, what properties would you like to see be supported?


(Ben Jones) #4

I have 2 UAPs and have a switch for each person/UAP combination - this allows me to track roughly where in the house someone is (since the UAPs) are at either end of my place. I also display the RSSI but that is just cos I can, not really useful for anything currently.

So I guess AP name/mac that each device is connected to, and RSSI would be the most use. Would be interesting to get notified when new items join an AP as well.


(Matthew) #5

I too have 2 UAPs (one per floor) and thought maybe this could be used to determine if I’m downstairs or upstairs (if my minimum RSSI values are tweaked properly).

Interesting idea, not quite sure how this could be implemented but definitely something to keep in mind.

I’ve also had the idea about “guest” ssid tracking where one could determine if there were guests present.

To keep things simple, I’ll start with the base cases for the skeleton of the binding and then add the meat as ideas come.

Will keep you posted on my progress.


(Marcel Will) #6

Hi Matthew,
have you ever had the chance to continue on your idea for an UniFi binding? I would be very much interested to realize presence detection with my 3 UAPs.
Regards,
Marcel


(Mark Lavercombe) #7

I just bought my first unifi gear and am very interested in this as well…


(Matthew) #8

Hey guys,

Sorry I haven’t posted anything here lately.

I started the binding back in October, but as is the case with all my “free time” projects, it’s hard to find the time :frowning:

My goal with this binding was to get familiar with OH2 development and give myself enough of a reason to upgrade to OH2 but unfortunately, I never got around to it.

I’m going to be gone all next month, but since there seems to be some interest in the binding, I will do my best to finish it and publish it after I get back.

Sorry I don’t have better news.


(Mark Lavercombe) #9

Hi Matthew,
Thanks for update.
Mark


(Mats Paulsson) #10

I’m too interested in this bindning. Currently I have no UAP but as soon we got our fibre connected I plan to set up one UAP for each floor (3).
Will follow with great interest!


(Matthew) #11

I do have the basic framework for it working. I don’t leave for another 10 days so if I can find some time this week to clean it up, I will put out a very very alpha version 0.0.1 that maybe you guys can test while I’m away.

Will do my best.


(Stian) #12

I have a UAP running as well and will be happy to help you test the binding.


(Matthew) #13

Sorry it took me a while to get to this - I’ve been deathly ill for the past few days but feeling much better today.

Please test out the first release of the binding by downloading it here: https://github.com/mgbowman/openhab2-addons/releases/tag/20170125

I’ve tested this with v4 of the UniFi controller. If any of you are running v5, please let me know if doesn’t work for you - I think there’s some minor differences in the API calls that should be easily fixed.

Matthew


(Angelos) #14

I will also try this out and let you know. Thanx for the binding!
I am running 5.4.9


(Rossko57) #15

Chipping in uninvited … would [quote=“mgbowman, post:1, topic:14520”]
(read-only) “presence” Switches (the Items)
[/quote]
be better represented as Contacts at the channel level?


(Matthew) #16

@rossko57 yeah, that makes more logical sense since they are read-only


(Mark Lavercombe) #17

Thanks @mgbowman for getting this done and hope you’re feeling better!

I am running 5.4.9 as well. Have installed ok, entered details for my controller and my access point. In the Paper UI the access point is showing as ‘Online’. I plan to turn off the UAP and test whether OH senses it’s offline as soon as I can get my kid away from the computer running the controller :wink:

Nice job!


(Dirk) #18

Hi Matthew,

Thanks providing the link to the UniFi binding. I would like to test it and provide feedback to you.

But: How do I configure the binding?

Thanks!!
Dirk


(Tim W) #19

Thank you so much for your work! Hope your openhab2 unifi add-on will make it in the normal distribution soon :slight_smile:

I use it with 5.4.11 and 4 AP and it works great.

The only request/wish I would have - to get informations about the connected AP. I would like to trigger different events depending on the location of the User.


(Martin Eskildsen) #20

I just discovered your binding as I was considering starting my own development. I think it pretty much supports my needs (presence detection).
I installed your binding and tried to configure it - it works just fine on Unifi Controller 5.4.11.

I have a few ideas on how presence detection could be improved:

You could considder adding the following bridges
A specialized “Presence Bridge”, The primarily use of that bridge is pretty much what you already are doing presence detection. The bridge should come in two or three flavours: One representing the controller and one a AP, the last one could represent a person (as a person could have many devices).

The thing should be the client that you already has created.

There should be a property on each bridge telling if some of the clients monitored in openHAB is Online. The presence detection is then done at Bridge level, and you have the possibility to monitor a room (if you have enough AP’s) a location or just track a persons presence.

Version 2 would be to add some probability calculation to determine the probability if a person is present. As an example we have a tablet that we use as “remote” for our ChromeCast. It is primarily my wife and one of the kids that uses this tablet. So it would be obvious to use that tablet to determine who is at home. Since the tablet is always present, it would be relevant to check if it is transfering data. Sometime ago I stumpled over a article about that topic, and it seems quite interesting (although it is complex).

Just my thoughts, I would be happy helping, I have just finished first version of the ZoneMidner Binding, so I have a little experience in openHAB 2 Bindings, though my Java experience is very limited.