Hi!
God job. Works awesome!
Is there any hack how to implement the HTTP Binding to send the items via JSON or something like this to a webserver?
I will use this to log the presence.
Regards
Roger.
Hi!
God job. Works awesome!
Is there any hack how to implement the HTTP Binding to send the items via JSON or something like this to a webserver?
I will use this to log the presence.
Regards
Roger.
Same here.
If you want to test your openHAB logic, open the unifi controller and force the client to reconnect. That will force it offline.
@Roger_Rehnelt Roger, if the objective is to log presence based on the status changes in OH using persistence is probably a more straightforward and cleaner solution.
You can persist the items you want to track and use a MySQL persistence for those. This way they are stored in a database and are probably more easily to use afterwards. Just a though of course.
Depending on what exactly youâre trying to accomplish, I agree with what @rswennen said: persistence (or possibly MQTT) is what youâre looking for - we donât like hacks around here!
Thanks for the tip!
Thinking about this a little more, what do you guys think I should do in the case of the controller reporting the client as offline before this new timeout?
IIRC, there were a few instances where the controller would return an empty response, thereby reporting all clients as offline. On the next refresh they were all back online.
Iâm thinking this should be an IFF type timeout. If the timeout is say 120s, once the client is online, it will not be reported as offline until at least 120s has passed - regardless of the controllerâs response.
Thank you for your hint. But I will attach the log to an existing user management on our server.
Should I still using âMySQL persistenceâ? How can I implement this to my configs? Are there some examples? Would be helpful⊠Thanks in advance!!
I think this would be an appropriate way to handle these scenarios. I have noticed in my log a few occasions where my devices, including the controller go offline with a Communication Error. In one case it was four minutes before it came back online. My assumption was that the controller stopped responding, although I canât say why.
Hello Roger,
you will most probably find more helpful answers by posting this question in a new thread with the right title. Itâs not really related to the Unifi Binding.
Good luck!
I just did. And it worked just as it should. Thx for this tipâŠ
I just checked my log. The lastseen is still counting even if the device isnât seen. Without having it verified it looks like RSSI stops updating imediately after leaving.I see a pattern that RSSI changing a lot when you are leaving (moving around). If it can be distinguised from other things isnât clear to me.
Thats strangeâŠ
Here the lastseen stops updating short time after I disconnect the mobilephone, at least in Basic UI.
I donât see any updates, but if I look at the disconnect event, it has been counting for the last 10 minutes. Therefore I am not sure if you can conclude that a missing update means disconnect. I would have to look deeper into my events.log file for that
Kim, what latest version are you talking about, of the Jackson jars? or did you use 2.4.5. Reason for asking is I run Openhabian and on my setup the Jackson dependencies are not fetched either but noticed there were more recent versions of those.
I have the JSONpath installed so that does not automatically install them despite whatâs said in some other post.
So Iâm happy to report Iâve managed to implement this âtimeoutâ weâve been discussing using the Insights data from the controller. Surprisingly, it was a lot easier that I expected
However, I had a long day and currently Iâm having a brain fart⊠I canât think of a good name for the configuration parameter
First I used timeout
but it doesnât make sense from the logical view of the controller - could be interpreted as the amount of time to wait for a response from the controller.
Then I used expiry
but just doesnât sound right to me
Once I nail this down, I can package this up for you guys to do some final testing!
Thoughts?
I downloaded and installed the 2.9.1 version of all the packages from the above link.
How about âpauseâ, or âwaitingâ
Latest build: org.openhab.binding.unifi-2.2.0-SNAPSHOT.jar
I chose considerHome
as the parameter - see the updated Binding Configuration
Depending on your controller, you may have to tweak the considerHome
interval so you donât get false positives (clients being prematurely marked as away).
For example, the controller at my office was only returning updates approx. every 60 seconds (Iâm not exactly sure why - maybe itâs an older version). When I tested with a considerHome
window of 60s, my phone was getting marked as away for one or two refresh
intervals since the lastSeen
channel wasnât being updated within 60s
In reality, the binding was doing exactly what it was supposed to do.
After you guys have tested this a bit and I fix some documentation in the code, I can open a PR to merge this into the master OH2 branch.
Let me know if you have any issues.
I just installed the latest build, and Iâm now seeing these WARNs in the log. Any idea whatâs causing this?
2017-09-18 08:22:14.135 [WARN ] [ing.unifi.handler.UniFiClientHandler] - Unable to update channel 'site' : device == null
2017-09-18 08:22:14.136 [WARN ] [ing.unifi.handler.UniFiClientHandler] - Unable to update channel 'ap' : device == null
In debug mode, Iâm seeing this.
2017-09-18 08:20:34.251 [DEBUG] [ing.unifi.handler.UniFiClientHandler] - Refreshing channel = unifi:client:a59319bd:online
2017-09-18 08:20:34.252 [DEBUG] [ing.unifi.handler.UniFiClientHandler] - Could not find a matching client: mac = fc:db:b3:XX:XX:XX, site = MD House
2017-09-18 08:20:34.253 [DEBUG] [ing.unifi.handler.UniFiClientHandler] - Refreshing channel = unifi:client:a59319bd:site
2017-09-18 08:20:34.253 [DEBUG] [ing.unifi.handler.UniFiClientHandler] - Could not find a matching client: mac = fc:db:b3:XX:XX:XX, site = MD House
2017-09-18 08:20:34.254 [WARN ] [ing.unifi.handler.UniFiClientHandler] - Unable to update channel 'site' : device == null
2017-09-18 08:20:34.254 [DEBUG] [ing.unifi.handler.UniFiClientHandler] - Refreshing channel = unifi:client:a59319bd:ap
2017-09-18 08:20:34.255 [DEBUG] [ing.unifi.handler.UniFiClientHandler] - Could not find a matching client: mac = fc:db:b3:XX:XX:XX, site = MD House
2017-09-18 08:20:34.255 [WARN ] [ing.unifi.handler.UniFiClientHandler] - Unable to update channel 'ap' : device == null
2017-09-18 08:20:34.256 [DEBUG] [ing.unifi.handler.UniFiClientHandler] - Refreshing channel = unifi:client:a59319bd:essid
2017-09-18 08:20:34.256 [DEBUG] [ing.unifi.handler.UniFiClientHandler] - Could not find a matching client: mac = fc:db:b3:XX:XX:XX, site = MD House
2017-09-18 08:20:34.257 [DEBUG] [ing.unifi.handler.UniFiClientHandler] - Refreshing channel = unifi:client:a59319bd:rssi
2017-09-18 08:20:34.257 [DEBUG] [ing.unifi.handler.UniFiClientHandler] - Could not find a matching client: mac = fc:db:b3:XX:XX:XX, site = MD House
2017-09-18 08:20:34.257 [DEBUG] [ing.unifi.handler.UniFiClientHandler] - Refreshing channel = unifi:client:a59319bd:uptime
2017-09-18 08:20:34.258 [DEBUG] [ing.unifi.handler.UniFiClientHandler] - Could not find a matching client: mac = fc:db:b3:XX:XX:XX, site = MD House
2017-09-18 08:20:34.258 [DEBUG] [ing.unifi.handler.UniFiClientHandler] - Refreshing channel = unifi:client:a59319bd:lastSeen
2017-09-18 08:20:34.258 [DEBUG] [ing.unifi.handler.UniFiClientHandler] - Could not find a matching client: mac = fc:db:b3:XX:XX:XX, site = MD House
2017-09-18 08:20:34.258 [DEBUG] [ing.unifi.handler.UniFiClientHandler] - Refreshing channel = unifi:client:4dc07647:online
2017-09-18 08:20:34.259 [DEBUG] [ing.unifi.handler.UniFiClientHandler] - Could not find a matching client: mac = ac:cf:85:YY:YY:YY, site = MD House
2017-09-18 08:20:34.259 [DEBUG] [ing.unifi.handler.UniFiClientHandler] - Refreshing channel = unifi:client:4dc07647:site
2017-09-18 08:20:34.260 [DEBUG] [ing.unifi.handler.UniFiClientHandler] - Could not find a matching client: mac = ac:cf:85:YY:YY:YY, site = MD House
2017-09-18 08:20:34.260 [WARN ] [ing.unifi.handler.UniFiClientHandler] - Unable to update channel 'site' : device == null
2017-09-18 08:20:34.260 [DEBUG] [ing.unifi.handler.UniFiClientHandler] - Refreshing channel = unifi:client:4dc07647:ap
2017-09-18 08:20:34.261 [DEBUG] [ing.unifi.handler.UniFiClientHandler] - Could not find a matching client: mac = ac:cf:85:YY:YY:YY, site = MD House
2017-09-18 08:20:34.261 [WARN ] [ing.unifi.handler.UniFiClientHandler] - Unable to update channel 'ap' : device == null
2017-09-18 08:20:34.261 [DEBUG] [ing.unifi.handler.UniFiClientHandler] - Refreshing channel = unifi:client:4dc07647:essid
2017-09-18 08:20:34.261 [DEBUG] [ing.unifi.handler.UniFiClientHandler] - Could not find a matching client: mac = ac:cf:85:YY:YY:YY, site = MD House
2017-09-18 08:20:34.262 [DEBUG] [ing.unifi.handler.UniFiClientHandler] - Refreshing channel = unifi:client:4dc07647:rssi
2017-09-18 08:20:34.262 [DEBUG] [ing.unifi.handler.UniFiClientHandler] - Could not find a matching client: mac = ac:cf:85:YY:YY:YY, site = MD House
2017-09-18 08:20:34.262 [DEBUG] [ing.unifi.handler.UniFiClientHandler] - Refreshing channel = unifi:client:4dc07647:uptime
2017-09-18 08:20:34.263 [DEBUG] [ing.unifi.handler.UniFiClientHandler] - Could not find a matching client: mac = ac:cf:85:YY:YY:YY, site = MD House
2017-09-18 08:20:34.263 [DEBUG] [ing.unifi.handler.UniFiClientHandler] - Refreshing channel = unifi:client:4dc07647:lastSeen
2017-09-18 08:20:34.263 [DEBUG] [ing.unifi.handler.UniFiClientHandler] - Could not find a matching client: mac = ac:cf:85:YY:YY:YY, site = MD House
I did the update remotely, so neither device represented by the client things is present at the site.
Edit: I was running this version and was not seeing these WARNs.
2017-09-18 08:49:06.247 [INFO ] [unifi.handler.UniFiControllerHandler] - UniFi Binding v2.2.0.201709020839
Edit 2: I went back to this version and all is well again.
Hi Mark,
Those logging statements were mistakenly outside of the if (clientOnline) { ... }
checks.
I just pushed an update which should quiet the warnings whenever a client is offline.
Please update and let me know if you have any more issues.
Yes, much better now.
Thanks!!
Found this binding and was hoping it would solve my presence problems once and for all
but the binding generates an error:
2017-09-19 21:22:11.681 [ERROR] [nding.unifi.internal.UniFiController] - Error GETâing URL: https://192.168.1.40:8443/api/s/default/stat/alluser
com.fasterxml.jackson.databind.JsonMappingException: Unexpected token (END_OBJECT), expected FIELD_NAME: missing property âis_wiredâ that is to contain type id (for class org.openhab.binding.unifi.internal.api.UniFiClient) at [Source: { âdataâ : [ { â_idâ : â596704f0cddcb36â , âdurationâ : 3081941 , âfirst_seenâ : 1499923267 , âhostnameâ : âAppoPadâ , âis_guestâ : false , âis_wiredâ : false , âlast_seenâ : 1505849431 , âmacâ : âxx;xx:xx:xxâ , ânotedâ : false , âouiâ : âAppleâ , ârx_bytesâ : 1634123047 , ârx_packetsâ : 7745351 , âsite_idâ : âabcdefgâ , âtx_bytesâ : 18065290694 , âtx_packetsâ : 13999876} , { â_idâ : â58f123e14f0c16â , âdurationâ : 10169615 , âfirst_seenâ : 1492198369 , âhostnameâ : âThuispadâ , âis_guestâ
etcâŠ
Controller is reported as offline, as are the clients.
I am running OH2.1 and Unifi 5.5.20. UniFi Binding 2.2.0.201709191042
What can I check or change?
kr Han