What needs to be done to include this in a 2.2 or 2.3 release?
Really just a rebase and squash which should result in a clean PR.
Iāll try to do this today.
I was about to open a PR and I remembered the two outstanding issuesā¦
-
@psyciknz did you ever sort out your issue or are you still getting
**null**
in the calls to your controller? Do you have asite
parameter defined on the UniFi Controller bridge? -
Is the consensus to change the
online
channel to aContact
? It makes sense to me as itās read-only.
Iām going to wait for your feedback before I open the PR. Hopefully we can do this quick enough to get it into the 2.2 release.
sounds good to me
Where is the site parameter set?
I have a Things, Unifi Controller, but it only has a name as and location (or should I set location to be the name of the network?
Iāve tried removing my controller and found the binding in resolved state to gave it a restart. Then I was able to see the binding config - couldnāt see a site in there, so tried adding the controller again. Now I see to be in some sort of mess where i canāt see the binding config anywhere.
So still not sure where I add the site.
EDIT. Just moved to the 2.2.0-SNAPSHOT and now I can get it to work.
I use a things file:
root@homer:~# more /etc/openhab2/things/Unifi.things
Bridge unifi:controller:Unifi_HomeR "Unifi Controller: HomeR" @ "Unifi" [host="172.16.13.100", username="angelos", password="whatever", port=8443, refresh=10]
{
Thing client Angelos_S6 "Angelos_S6" @ "Unifi" [mac="ec:1f:72:17:xx:xx", site="default"]
Thing client Simona_I6 "Simona_I6" @ "Unifi" [mac="a8:66:7f:e3:xx:xx", site="default"]
}
Site is defined at the thing level (not the Bridge). I havenāt changed the ādefaultā name of the site in the Unifi Controller to test if it will work (but it should).
In PaperUI, the site option appears under the thingās configuration parameters
and here are my items (I only link to the main 2 channels)
root@homer:~# more /etc/openhab2/items/Unifi.items
/* Unifi Items */
Switch Angelos_S6_PRES "Angelos S6 Presence" <present> (gUnifi) {channel="unifi:client:Unifi_HomeR:Angelos_S6:online"}
Number Angelos_S6_RSSI "Angelos S6 RSSI [%s]" <signal> (gUnifi) {channel="unifi:client:Unifi_HomeR:Angelos_S6:rssi"}
Switch Simona_I6_PRES "Simonas I6 Presence" <present> (gUnifi) {channel="unifi:client:Unifi_HomeR:Simona_I6:online"}
Number Simona_I6_RSSI "Simonas I6 RSSI [%s]" <signal> (gUnifi) {channel="unifi:client:Unifi_HomeR:Simona_I6:rssi"}
Yeah I could only see it there when setting up an item. Where it sounded
like I was supposed to be seeing it in the controller.
Youāll notice that after updating to 2.2 snapshot it started working for me.
I am currently running:
openHAB 2.2.0 Snapshot Build #1028 on a Debian Jessie with Oracleās JVM 8u144 with 2.1.0.201706081307 org.openhab.binding.unifi and Unifi Controller version 5.5.19 (need to up to 5.5.20)
the binding works fine on this latest release. I never had problems with it since I started using it.
@psyciknz: what is your opinion on changing the channel type for the Online channel from Switch to Contact? (I am in favor since it is a āread onlyā setting)
Iāve never used a contact item. But if its read only as you say (and I assume interacting with it on the UI is disabled?) then Iād be for it.
I just realized that I am behind on the org.openhab.binding.unifi build that I am using (#29)
There is build #33 available: https://jenkins.otr.mx/job/openhab2-unifi-binding/
downloading now
@psyciknz sorry for the confusion, as @Dim said, the site
parameter was moved to the Thing
. Glad to hear the 2.2.0-SNAPSHOT
is working.
@Dim Those builds were coming from my rebase / squash commits I was pushing last night - automation ftw!
I will put together a Contact
variant today and push it - probably as a new branch. Should be pretty straight forward but it will break existing configs so I would like to see some testing in the wild before I open a PR.
I will keep everybody posted.
should be very easy to adjust: Simply change the item type from Switch
to Contact
in our Unifi.items
:
Contact Angelos_S6_PRES "Angelos S6 Presence" <present> (gUnifi) {channel="unifi:client:Unifi_HomeR:Angelos_S6:online"}
keep up the greatness coming @mgbowman
This binding is used by me for presence detection (one of many possible uses)ā¦
and it is (by far) the best presence detection solution that I have used so far (and I have tried several )
Agreed
The fact most phones keep the wireless association - therefore visible in the UniFi controller - make this a much more reliable presence detection solution than any other ānetwork monitoringā or GPS (read: battery drain) approach out there.
The only (minor) drawback is the delay introduced by the controller in marking a client as away. This could be fixed in the binding but it would take a bit of rework as the binding was designed to be stateless (as it should be).
Off to work!
I have a problem with this one.
I downloaded the jar, placed it in the addon folder, but nothing happens. Cant see the binding anywhere?? What went wrong?
I assume itĀ“s suppose to go into usr/share/openhab2/addons/ ??
Greets
Kim
PS forgot to mention, its and apt-get installation.
Hi.
Is it possible to ad the uptime value of a connected client as a new channel ?
I need to know now long a client has been there and the value is there in the Unify controller?
Or add the last seen value (to get beter results) in presence detection?
Thanks.
Agreement here as well.
I was originally planning on needing to rely on an aggregate of several sensors to get reliable data, but so far there doesnāt seem to be a need. Admittedly I havenāt started to actually use the presence data for anything, but I have never seen it be inaccurate.
Any way in which it might fail, other methods are just as, if not more, susceptible to. Wifi being turned off, device left behind, etc.
Reducing the time for reporting as away would be a nice improvement for future versions. As it stands now though this binding is pretty sweet.
Here you goā¦
Please checkout the updated README
Noteworthy changes:
-
The
online
channel was changed to aContact
- The normal (state) of theContact
can be configured on the Thing definition allowing you to change the polarity*. -
Added an
uptime
channel (Number
) - This is the time, in seconds, the wireless client has been connected to the controller. The UniFi Controller UI displays this value in the UPTIME column. -
Added a
lastSeen
channel (DateTime
) - This is the date & time the wireless client was last seen by the controller.
* Since I couldnāt decide what the normal Contact
state should be for absent vs present states, I added a Thing Configuration parameter contactType
so you get to decide
Please update to the latest build org.openhab.binding.unifi-2.2.0-SNAPSHOT.jar and report back if you guys have any issues.
For now, Iām leaving the binding purely stateless. We will just have to live with the delay introduced by the controller when it comes to marking a client as absent. Maybe in the future I will find a simple way to support some kind of binding specific timeout.
Looking forward to feedback.
I can give you one of my use cases that may switch on a lightbulb (no pun intendedā¦ ok maybe a little)
I track my wife and Iās iPhones. I have a āItās Bedtimeā scene that is trigged when the living roomās harmony switches off in the evening. All the lights along the path to the bedroom dim up and both of our bedside table lamps turn on.
When both bedside table lamps turn off, this means āweāre in bedā and all the lights in the house turn off.
What does this have to do with presence detection?
My wife travels a lot for work so when sheās not home, her bedside lamp doesnāt come on - I only have to turn mine off. I got annoyed having to roll over every night and turn hers off whenever she was away. Am I lazy? Yes, yes I am!
This is the main valid reason for all automation
I need to ask, why is this method better than others, e.g. the normal network binding dhcplisten+ping method? Seems to me both have the same benefits and restrictionsā¦