Unifi Binding doesn't turn off device online status

Tags: #<Tag:0x00007efec725d650> #<Tag:0x00007efec725d588>

I have an issue with 2.5.10 version of the Unifi binding. It seems that it doesn’t detect that a device is offline.

I’ve turned off wifi on my Oneplus 7T and the item connected to the appropriate channel does not go offline and the “lastSeen” still updates, even after 20 minutes. I’ve tested this repeatedly.

I’ve tried to restart the binding, but the problem persists.

I have openHAB 2.5.10 and the latest Unifi binding. My Unfi controller is 5.12.72 (yes, I need to get it updated).

Any suggestions as to where to look?

Thanks!

I did some additional testing and only when restarting openhab or the server does the binding correctly detect the status of a device.

this topic pops up every seconds month, e.g.



and the conclusion until now was that it is unifi fault and we have no way to detect the status correctly.
but now, if you say, openhab restart solves the issue, then potentially it could openhab binding issue

Well, I can do one better. :wink: I have an older OH install that works just fine.

My Unifi controller is on 5.12.72 and has been for a while. I just finished moving from OH 2.5.7. on an old RPI 3+ to a new RPI4 with OH 2.5.10.

The old OH 2.5.7 had an older Unifi binding and the on that the online/offline detection worked. On the new 2.5.10, I converted the Things configuration to reflect the new binding.

To me that suggests that there’s a bug in the binding, not in Unifi.

I’ll happily drag the old OH install out and give you all the details, just let me know what to look for.

So, I did some testing to try to help getting closer to where the problem lies.

The background is that I migrated my 2.5.7. OH setup on an overworked Raspberry pi 3+ over to a new 2.5.10 setup on a brand new Raspberry PI 4 (2GB). As part of that transition, I also changed over to the new 2.5.10 Unifi binding and things configuration.

Unifi Setup
I’m on a Unifi controller v.5.12.72.

2.5.7 Configuration
bundle:

270 │ Active │  80 │ 2.5.9                   │ openHAB Add-ons :: Bundles :: UniFi Binding

Things:

Bridge unifi:controller:home "UniFi Controller" [ host="192.xxx.xxx.xxx", port=8443, username="someuser", password="somepassword", refresh=10 ] 
{
	Thing client BjarnesPhone "Bjarne's 1Plus7T" [ mac="xx:xx:xx:xx:xx:xx", considerHome=180 ]
} 

2.5.10 Configuration
Bundle:

278 │ Active │  80 │ 2.5.10                  │ openHAB Add-ons :: Bundles :: UniFi Binding 

Things:

{
	Thing wirelessClient bjarnesPhone "Bjarne's 1Plus7T" [ cid="xx:xx:xx:xx:xx:xx", considerHome=180 ]	
} 

2.5.7. Logs

Log:
Startup
2020-11-03 10:41:50.551 [vent.ItemStateChangedEvent] - BjarnesPhone changed from NULL to ON

Turned off wifi
2020-11-03 10:51:25.490 [vent.ItemStateChangedEvent] - BjarnesPhone changed from ON to OFF

Turned on wifi
2020-11-03 10:52:08.421 [vent.ItemStateChangedEvent] - BjarnesPhone changed from OFF to ON

2.5.10 Logs

Log
Left house (i.e. turned wifi off )
2020-11-02 17:20:44.045 [vent.ItemStateChangedEvent] - Shellydw2_Entrance_Door changed from OPEN to CLOSED

Unifi wificlient turned off
2020-11-02 17:55:52.933 [vent.ItemStateChangedEvent] - BjarnesPhone changed from ON to OFF

Came back to house (i.e. turned wifi on)
2020-11-02 18:00:08.047 [vent.ItemStateChangedEvent] - BjarnesPhone changed from OFF to ON

Left house (i.e. turned wifi off )
2020-11-03 08:45:38.354 [vent.ItemStateChangedEvent] - Shellydw2_Entrance_Door changed from OPEN to CLOSED

Unifi wificlient turned off
2020-11-03 09:28:17.786 [vent.ItemStateChangedEvent] - LisetsPhone changed from ON to OFF

2.5.7 Summary of Logs
The old logs don’t show an indicator of when I “left” the wifi, but OH received an “offline” within seconds ad likewise showed me online, almost as soon as I turned wifi back on again.

2.5.10 Summary of Logs
The Shellydw2_Entrance_Door changed from OPEN to CLOSED event shows when I left the wifi network and the BjarnesPhone changed from ON to OFF indicates when OH believes me offline.

I ran the above test on the 2.5.10 setup twice (my Android phone and my wife’s iPhone) and in both cases there’s a 30-45 minutes “gap” between Unifi showing me offline and OH showing me offline.

In both cases, there’s little time between my phones showing up in the Unifi console and the OH log.

From the above tests using the same controller and the same phone, I would tend to suspect something in the new binding.

I’ve kept the old server/boot disk, so let me know if you need me to do more testing.

Regards,
Bjarne

1 Like

@mgbowman Did you have a chance to check the data in my post?

Just a follow-up on my previous post.

I decided to try out the https://jenkins.otr.mx/job/openhab2-unifi-binding/lastSuccessfulBuild/artifact/bundles/org.openhab.binding.unifi/target/org.openhab.binding.unifi-2.5.5-SNAPSHOT.jar provided by @mgbowman. It completely solved my issues with Unifi, now my wireless devices show up correctly and leave within the time-out set in the thing configuration.

the SNAPSHOT binding also introduces some nifty things including the number of clients and the ability to track wired clients.

you can read more about the new features here: https://github.com/mgbowman/openhab-addons/blob/unifi-binding/bundles/org.openhab.binding.unifi/README.md

Kudos to @mgbowman

1 Like

Had the same issue, installing this package solved my issue as well! Thanks for sharing

Using unifi controller 6, openhab 2.5.2

Glad to hear and the pleasure is all mine…

How did you find out the Jenkins link? I have the same issue in 3.0 (stable) and 3.1 (snapshot) and the 2.5.5-binding doesn’t work in OH3.

Thank you!

I found them in the Unifi bindings topic. To the best of my knowledge, @mgbowman actually posted the link himself.

I had a check to on the unifi binding. Currently installed 3.1.0 on openhab 3.1.0 snapshot.
The binding doesn’t work well. All devices are shown online. My own shell script which also gathers information from unifi controller is working fine and providing the correct status for each device.

What’s the issue with the unifi binding? Why is it working sometimes and why not?!?