i am using the UniFi Binding (V3.3.0) and now added things and items for the ports of one of my switches.
The things are all “online” but the items just got the state “NULL”. Also there are no messages in the logs.
I am running a UDM Pro and want to switch a port on a USW8 POE.
If you run on 3.3.0 I suggest to install the marketplace version of this binding due to a bug in controlling Poe ports. It should not be related to the issue you are experiencing, but to not have other problems.
You can enable debug or trace log to see what information is actually obtained from the UniFi device. Maybe this can give some insight into why ita not working.
If it sets everything to null it means it can’t find the PoE port in the data. If you set the log level to debug or trace you can see the raw data (on console; log:set DEBUG org.openhab.bindng.unifi. This might give a a indication on why it doesn’t see the port.
Sorry - there was something wrong with the loglevel…
At debug level i get this error after a few other operations:
19:58:15.561 [DEBUG] [l.handler.UniFiControllerThingHandler] - Unhandled exception while refreshing the UniFi Controller unifi:controller:a05c3c94a6
java.lang.NullPointerException: null
at org.openhab.binding.unifi.internal.handler.UniFiPoePortThingHandler.getChannelState(UniFiPoePortThingHandler.java:101) ~[?:?]
at org.openhab.binding.unifi.internal.handler.UniFiPoePortThingHandler.getChannelState(UniFiPoePortThingHandler.java:1) ~[?:?]
at org.openhab.binding.unifi.internal.handler.UniFiBaseThingHandler.lambda$1(UniFiBaseThingHandler.java:139) ~[?:?]
at java.util.Optional.map(Optional.java:265) ~[?:?]
at org.openhab.binding.unifi.internal.handler.UniFiBaseThingHandler.updateState(UniFiBaseThingHandler.java:139) ~[?:?]
at org.openhab.binding.unifi.internal.handler.UniFiBaseThingHandler.lambda$0(UniFiBaseThingHandler.java:133) ~[?:?]
at java.util.ArrayList.forEach(ArrayList.java:1541) ~[?:?]
at java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1085) ~[?:?]
at org.openhab.binding.unifi.internal.handler.UniFiBaseThingHandler.refresh(UniFiBaseThingHandler.java:133) ~[?:?]
at org.openhab.binding.unifi.internal.handler.UniFiControllerThingHandler.lambda$2(UniFiControllerThingHandler.java:192) ~[?:?]
at java.util.ArrayList.forEach(ArrayList.java:1541) ~[?:?]
at java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1085) ~[?:?]
at org.openhab.binding.unifi.internal.handler.UniFiControllerThingHandler.refresh(UniFiControllerThingHandler.java:190) ~[?:?]
at org.openhab.binding.unifi.internal.handler.UniFiControllerThingHandler.run(UniFiControllerThingHandler.java:171) ~[?:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305) [?:?]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305) [?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
at java.lang.Thread.run(Thread.java:829) [?:?]
When i change the POE mode i get these entries into the log:
20:05:28.084 [DEBUG] [nternal.handler.UniFiBaseThingHandler] - Handling command = auto for channel = unifi:poePort:a05c3c94a6:USW8_Port5:mode
20:05:28.085 [INFO ] [rnal.handler.UniFiPoePortThingHandler] - Could not change the PoE port state for thing 'unifi:poePort:a05c3c94a6:USW8_Port5': device UniFiDevice{mac: 'xx:xx:xx:xx', name: 'USW-8POE-WZ', model: 'US8P60', site: UniFiSite{id: 'xxxx', name: 'default', desc: 'Default'}} or portToUpdate null null
I was unable to determine the exact switch you are using. From the logs it appears you have an 8 port POE 60 Watt switch. From my research most, if not all, of the 60W switches have on 4 POE ports. If that is the case then you are trying to change the POE mode on a non-POE port.
I have seen POE “Things” automatically added to the Inbox for ports that do not have POE capability.
Yes, thats right - i got a USW 8 POE 60W with 8 ports - 4 of them with PoE.
The PoE ports are the ports 5-8 of the switch, thats the reason why i tried it with port 5.
Now i tried it with port 1 in the thing-settings (–> 1. PoE port), but its still the same result.
Also i dont get the poe ports or other unifi things suggested in the inbox.
Here the logs after changing to port 1:
18:51:14.821 [DEBUG] [l.handler.UniFiControllerThingHandler] - Unhandled exception while refreshing the UniFi Controller unifi:controller:a05c3c94a6
java.lang.NullPointerException: null
at org.openhab.binding.unifi.internal.handler.UniFiPoePortThingHandler.getChannelState(UniFiPoePortThingHandler.java:101) ~[?:?]
at org.openhab.binding.unifi.internal.handler.UniFiPoePortThingHandler.getChannelState(UniFiPoePortThingHandler.java:1) ~[?:?]
at org.openhab.binding.unifi.internal.handler.UniFiBaseThingHandler.lambda$1(UniFiBaseThingHandler.java:139) ~[?:?]
at java.util.Optional.map(Optional.java:265) ~[?:?]
at org.openhab.binding.unifi.internal.handler.UniFiBaseThingHandler.updateState(UniFiBaseThingHandler.java:139) ~[?:?]
at org.openhab.binding.unifi.internal.handler.UniFiBaseThingHandler.lambda$0(UniFiBaseThingHandler.java:133) ~[?:?]
at java.util.ArrayList.forEach(ArrayList.java:1541) ~[?:?]
at java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1085) ~[?:?]
at org.openhab.binding.unifi.internal.handler.UniFiBaseThingHandler.refresh(UniFiBaseThingHandler.java:133) ~[?:?]
at org.openhab.binding.unifi.internal.handler.UniFiControllerThingHandler.lambda$2(UniFiControllerThingHandler.java:192) ~[?:?]
at java.util.ArrayList.forEach(ArrayList.java:1541) ~[?:?]
at java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1085) ~[?:?]
at org.openhab.binding.unifi.internal.handler.UniFiControllerThingHandler.refresh(UniFiControllerThingHandler.java:190) ~[?:?]
at org.openhab.binding.unifi.internal.handler.UniFiControllerThingHandler.run(UniFiControllerThingHandler.java:171) ~[?:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305) [?:?]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305) [?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
at java.lang.Thread.run(Thread.java:829) [?:?]
When i have a look at further debug logs of the binding, i see the device listed in device cache:
Now i found out, that i get scan results, when i do a manual scan for the binding.
At this manual scan i get the site, wired client, wireless clients and wifis, but no unifi devices and poe ports.
I also removed all things i had configured before (with stable binding) and recreated them from inbox.
When i check the sections of the debug logs, i just get the following - i dont know, if something is missing there…
When i search the debug log for “port” i get no matches.
20:28:25.696 [DEBUG] [ifi.internal.api.cache.UniFiSiteCache] - Put #1 entries in UniFiSiteCache:
...
20:28:25.718 [DEBUG] [ifi.internal.api.cache.UniFiWlanCache] - Put #4 entries in UniFiWlanCache:
...
20:33:11.473 [DEBUG] [i.internal.api.cache.UniFiDeviceCache] - Put #8 entries in UniFiDeviceCache:
...
20:28:25.800 [DEBUG] [i.internal.api.cache.UniFiClientCache] - Put #31 entries in UniFiClientCache:
...
20:28:25.820 [DEBUG] [i.internal.api.cache.UniFiClientCache] - Put #18 entries in UniFiClientCache:
It looks like the binding can’t find the PoE port information in the API data it gets from the UniFi controller. Can you run with log level set to TRACE. This will log the actual json received from the UniFi controller. If you can send that to me if you want (via direct message, as contains all kind of sensitive data) so I can check what is missing.
In the log you won’t find the PoE entries as this is in the device information itself and not logged separately.
I’ve also updated the market place binding to set the PoE port offline in case it can’t find the port (instead of throwing an NullPointer)