I’m on version 2.5.9 with the 2.5.9 unifi binding. Unifi Controller is 6.0.23.
The poll-time for the controller in the binding is set to 2 seconds, the Consider Home Interval is set to 30 seconds.
As long as I’m online everything is fine. The device is detected and the LastSeen time gets updated every few seconds.
Once I take a device offline, the LastSeen time holds, but the Online indicator doesn’t change. The last line related the the item in events.log indicates a change in LastSeen:
2020-09-28 23:42:42.862 [vent.ItemStateChangedEvent] - Dev1_Uptime changed from 2456 to 2478
2020-09-28 23:42:42.862 [vent.ItemStateChangedEvent] - Dev1_LastSeen changed from 2020-09-28T23:42:20.000+0200 to 2020-09-28T23:42:42.000+0200
nothing more. 20 minutes later the device still shows as online, even though last seen time is very old now.
What device? Do you mean the Thing? Thing online/offline status does not necessarily track any real device status. So far as openHAB is concerned, the Thing is still available to try and communicate with your device.
Which means it’s looking at lastSeen. If lastSeens is updated correctly online should work too, unlesss there are exceptions or warnings.
You can however “fix” this with you own rule that looks at last seen rather than online as a last resort if no developer is around to take a look.
You could also add your own debug logging in the binding and build it yourself and test (requires some knowledge, but is not rocket science).
Thanks. No output in openhab.log from unifi binding. Ok, I’ll write my own rule for now, thanks for the input I want to write a rule to react to this state anyway, so I can just instead react to lastseen
I’ve gone Seaside-described custom code leveraging getLastSeen, but after some trials managed to get built-in functionality working very reliably. Here is my config as a sample:
Group gPeople_Presence <presence>
Switch Presence_myCellphone "My Cellphone [MAP(unifi.map):%s]" (gPeople_Presence) {channel="unifi:wirelessClient:home:myPhone:online"}
unifi.map file
ON=Home
OFF=Away
Note that the Item has to be a Switch.
I’ve created special read-only user for unifi interface with OH2.
I’m running into the same issue. If I manually flip the switch off, it will stay off if my phone is not on my network. It will switch on when I connect to the network (after thing refresh time of course). It will never turn the switch off.
I added uptime and last seen. They update every refresh interval when the phone is on the network but freeze in time once it leaves the network.
My configuration mimics the example and guterm’s config above.