openhab / org.openhab.binding.zigbee

openHAB binding for ZigBee
Eclipse Public License 2.0
73 stars 111 forks source link

[Bug OH 4] Pass the ChannelID instead of toString in call to getThing().getChannel() #794

Closed rkoshak closed 1 year ago

rkoshak commented 1 year ago

Outline

See the discussion at https://github.com/openhab/openhab-core/issues/3336.

As of at least OH 4 build 3292 the Zigbee binging is broken. Based on the discussion at the above issue in core, the corrective action that needs to take place is to modify line 377 of ZigBeeThingHandler to pass the ChannelID Object instead of the toString of that Object.

It is unclear if this is the only place this needs to be changed. A quick search of the repo shows only one other potential other place where an adjustment might be needed.

[zigbee/handler/ZigBeeThingHandlerTest.java](https://github.com/openhab/org.openhab.binding.zigbee/blob/aa4ea5371ed7c18011f2c0a980029905ec54c69e/org.openhab.binding.zigbee/src/test/java/org/openhab/binding/zigbee/handler/ZigBeeThingHandlerTest.java) line 206 wheregetAsString` is used (maybe that works where toString does not?)

At present, on OH 4 the Zigbee binding will not work, throwing the following exception for every Thing during initialization.

  │2023-01-24 09:41:46.714 [ERROR] [ng.zigbee.handler.ZigBeeThingHandler] - 282C02BFFFE726CD: Exception creating channels                                                  │
  │java.lang.IllegalArgumentException: UID segment 'zigbee:device:zg_coordinator:282c02bfffe726cd:282C02BFFFE726CD_1_batterylevel' contains invalid characters. The last se│
  │gment of the channel UID must match the pattern '[\w-]*|[\w-]*#[\w-]*'.                                                                                                 │
  │        at org.openhab.core.thing.ChannelUID.validateSegment(ChannelUID.java:136) ~[bundleFile:?]                                                                       │
  │        at org.openhab.core.common.AbstractUID.<init>(AbstractUID.java:76) ~[bundleFile:?]                                                                              │
  │        at org.openhab.core.thing.UID.<init>(UID.java:66) ~[bundleFile:?]                                                                                               │
  │        at org.openhab.core.thing.ChannelUID.<init>(ChannelUID.java:59) ~[bundleFile:?]                                                                                 │
  │        at org.openhab.core.thing.internal.ThingImpl.getChannel(ThingImpl.java:125) ~[?:?]                                                                              │
  │        at org.openhab.binding.zigbee.handler.ZigBeeThingHandler.doNodeInitialisation(ZigBeeThingHandler.java:377) [bundleFile:?]                                       │
  │        at org.openhab.binding.zigbee.handler.ZigBeeThingHandler$1.call(ZigBeeThingHandler.java:244) [bundleFile:?]                                                     │
  │        at org.openhab.binding.zigbee.handler.ZigBeeThingHandler$1.call(ZigBeeThingHandler.java:1) [bundleFile:?]                                                       │
  │        at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]                                                                                               │  Ca│        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) [?:?]                                         │  00│        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) [?:?]                                                                        │3120│        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) [?:?]                                                                        │
20│        at java.lang.Thread.run(Thread.java:833) [?:?]  

Configuration

Configuration Description
Coordinator used HUSZB-1
openHAB version OH 4.0 SNAPSHOT #3292
Hardware Ubuntu VM with OH running in Docker
Memory 390/1187MB available memory
Java version openjdk 17.0.5 2022-10-18
Devices I don't think this is relevant for this issue but can provide if needed
norem commented 1 year ago

This also occurs with Windows and 4.0.0-SNAPSHOT - Build #3306 making Zigbee Binding unusable, cannot add devices and current devices no longer function.