ZigBee binding throws ClassCastException when adding Tuya wall plug as Thing

I’m trying to add a ZigBee Tuya wall plug to an POPP ZB-Stick (Ember).
The scan shows it as Unknown Device (dont remember the exact wording).

When adding, or pausing and restarting the Thing, I get a ClassCastException error in the log: “class java.lang.Integer cannot be cast to class java.lang.Long” near “appendZigBeeType” method.

Any help would be appreciated. I believe @chris is behind the ZigBee binding?

Other ZigBee devices are working fine. Using OH3.

Thanks

java.lang.ClassCastException: class java.lang.Integer cannot be cast to class java.lang.Long (java.lang.Integer and java.lang.Long are in module java.base of loader 'bootstrap')
	at com.zsmartsystems.zigbee.serialization.DefaultSerializer.appendZigBeeType(DefaultSerializer.java:209) ~[bundleFile:?]
	at com.zsmartsystems.zigbee.zcl.field.AttributeReportingConfigurationRecord.serialize(AttributeReportingConfigurationRecord.java:361) ~[bundleFile:?]
	at com.zsmartsystems.zigbee.zcl.ZclFieldSerializer.serialize(ZclFieldSerializer.java:38) ~[bundleFile:?]
	at com.zsmartsystems.zigbee.zcl.clusters.general.ConfigureReportingCommand.serialize(ConfigureReportingCommand.java:107) ~[bundleFile:?]
	at com.zsmartsystems.zigbee.ZigBeeNetworkManager.sendCommand(ZigBeeNetworkManager.java:905) ~[bundleFile:?]
	at com.zsmartsystems.zigbee.transaction.ZigBeeTransactionManager.send(ZigBeeTransactionManager.java:443) ~[bundleFile:?]
	at com.zsmartsystems.zigbee.transaction.ZigBeeTransactionManager.sendNextTransaction(ZigBeeTransactionManager.java:681) ~[bundleFile:?]
	at com.zsmartsystems.zigbee.transaction.ZigBeeTransactionManager.queueTransaction(ZigBeeTransactionManager.java:372) ~[bundleFile:?]
	at com.zsmartsystems.zigbee.transaction.ZigBeeTransactionManager.sendTransaction(ZigBeeTransactionManager.java:351) ~[bundleFile:?]
	at com.zsmartsystems.zigbee.ZigBeeNetworkManager.sendTransaction(ZigBeeNetworkManager.java:2032) ~[bundleFile:?]
	at com.zsmartsystems.zigbee.ZigBeeNode.sendTransaction(ZigBeeNode.java:926) ~[bundleFile:?]
	at com.zsmartsystems.zigbee.ZigBeeEndpoint.sendTransaction(ZigBeeEndpoint.java:596) ~[bundleFile:?]
	at com.zsmartsystems.zigbee.zcl.ZclCluster.sendCommand(ZclCluster.java:294) ~[bundleFile:?]
	at com.zsmartsystems.zigbee.zcl.ZclCluster.sendCommand(ZclCluster.java:305) ~[bundleFile:?]
	at com.zsmartsystems.zigbee.zcl.ZclCluster.setReporting(ZclCluster.java:1767) ~[bundleFile:?]
	at com.zsmartsystems.zigbee.zcl.ZclCluster.setReporting(ZclCluster.java:589) ~[bundleFile:?]
	at com.zsmartsystems.zigbee.zcl.ZclAttribute.setReporting(ZclAttribute.java:431) ~[bundleFile:?]
	at org.openhab.binding.zigbee.internal.converter.ZigBeeConverterMeteringSummationDelivered.initializeDevice(ZigBeeConverterMeteringSummationDelivered.java:81) ~[bundleFile:?]
	at org.openhab.binding.zigbee.handler.ZigBeeThingHandler.initializeDevice(ZigBeeThingHandler.java:514) ~[bundleFile:?]
	at org.openhab.binding.zigbee.handler.ZigBeeThingHandler.doNodeInitialisation(ZigBeeThingHandler.java:377) [bundleFile:?]
	at org.openhab.binding.zigbee.handler.ZigBeeThingHandler$1.call(ZigBeeThingHandler.java:227) [bundleFile:?]
	at org.openhab.binding.zigbee.handler.ZigBeeThingHandler$1.call(ZigBeeThingHandler.java:1) [bundleFile:?]
	at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) [?:?]
	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) [?:?]

zigbee_device_intialized should be true, not false.

Remove the device, factory reset it and include it again.

If the problem persists, please provide additional information:

  1. type of ZigBee coordinator
  2. Karaf output from zigbee fingerprint <IEEE address of your device>
    Use zigbee nodes to get the IEEE address
  3. debug log, see ZigBee - Bindings | openHAB
    .
1 Like

Just removing and scanning with the binding actually triggered the same exception, right after it’s discovered. Then, 20 seconds later, it turned Online, zigbee_device_initialised became true, and the device now works as expected.
I’m sure something could be improved, but if it works, I’m happy.

Thanks for quick and helpful reply!

2022-01-07 18:37:01.555 [INFO ] [ab.binding.zigbee.discovery.ZigBeeDiscoveryService] - A4C1387A8941B81A: Starting ZigBee device discovery
2022-01-07 18:37:02.804 [WARN ] [com.zsmartsystems.zigbee.ZigBeeExecutors          ] - Uncaught exception in thread NotificationService-thread-104
java.lang.ClassCastException: class java.lang.Integer cannot be cast to class java.lang.Long (java.lang.Integer and java.lang.Long are in module java.base of loader 'bootstrap')
	at com.zsmartsystems.zigbee.serialization.DefaultSerializer.appendZigBeeType(DefaultSerializer.java:209) ~[?:?]
	at com.zsmartsystems.zigbee.zcl.field.AttributeReportingConfigurationRecord.serialize(AttributeReportingConfigurationRecord.java:361) ~[?:?]
	at com.zsmartsystems.zigbee.zcl.ZclFieldSerializer.serialize(ZclFieldSerializer.java:38) ~[?:?]
	at com.zsmartsystems.zigbee.zcl.clusters.general.ConfigureReportingCommand.serialize(ConfigureReportingCommand.java:107) ~[?:?]
	at com.zsmartsystems.zigbee.ZigBeeNetworkManager.sendCommand(ZigBeeNetworkManager.java:905) ~[?:?]
	at com.zsmartsystems.zigbee.transaction.ZigBeeTransactionManager.send(ZigBeeTransactionManager.java:443) ~[?:?]
	at com.zsmartsystems.zigbee.transaction.ZigBeeTransactionManager.sendNextTransaction(ZigBeeTransactionManager.java:681) ~[?:?]
	at com.zsmartsystems.zigbee.transaction.ZigBeeTransactionManager.transactionComplete(ZigBeeTransactionManager.java:540) ~[?:?]
	at com.zsmartsystems.zigbee.transaction.ZigBeeTransaction.completeTransaction(ZigBeeTransaction.java:435) ~[?:?]
	at com.zsmartsystems.zigbee.transaction.ZigBeeTransaction.commandReceived(ZigBeeTransaction.java:387) ~[?:?]
	at com.zsmartsystems.zigbee.transaction.ZigBeeTransactionManager$2.run(ZigBeeTransactionManager.java:557) ~[?:?]
	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) [?:?]
==> /var/log/openhab/events.log <==
2022-01-07 18:37:54.684 [INFO ] [openhab.event.InboxRemovedEvent                   ] - Discovery Result with UID 'zigbee:device:usb:a4c1387a8941b81a' has been removed.
2022-01-07 18:37:54.693 [INFO ] [openhab.event.ThingStatusInfoChangedEvent         ] - Thing 'zigbee:device:usb:a4c1387a8941b81a' changed from UNINITIALIZED to INITIALIZING
2022-01-07 18:37:54.700 [INFO ] [openhab.event.ThingStatusInfoChangedEvent         ] - Thing 'zigbee:device:usb:a4c1387a8941b81a' changed from INITIALIZING to UNKNOWN
2022-01-07 18:37:56.708 [INFO ] [openhab.event.FirmwareStatusInfoEvent             ] - Firmware status of thing zigbee:device:usb:a4c1387a8941b81a changed to UNKNOWN.
2022-01-07 18:38:27.007 [INFO ] [openhab.event.ThingStatusInfoChangedEvent         ] - Thing 'zigbee:device:usb:a4c1387a8941b81a' changed from UNKNOWN to ONLINE

Maybe @chris can take a look at the problem.

I would need to see a debug log showing the problem - I need to see what data is being sent from the device that is causing the exception to understand what is going on. If you can provide this, I’ll see if I can fix it.

Please refer to the binding docs for how to configure debug logging.

With debug log enabled, issuing karaf command zigbee nodes printed An unexpected error occurred during execution. and generated the following java exception in the log, and nothing else:

2022-01-20 09:55:43.923 [ERROR] [org.openhab.core.io.console.ConsoleInterpreter    ] - An error occurred while executing the console command.
java.lang.NullPointerException: null
	at com.zsmartsystems.zigbee.ZigBeeDeviceType.getByValue(ZigBeeDeviceType.java:648) ~[?:?]
	at com.zsmartsystems.zigbee.console.ZigBeeConsoleNodeListCommand.printNode(ZigBeeConsoleNodeListCommand.java:96) ~[?:?]
	at com.zsmartsystems.zigbee.console.ZigBeeConsoleNodeListCommand.process(ZigBeeConsoleNodeListCommand.java:71) ~[?:?]
	at org.openhab.binding.zigbee.console.internal.ZigBeeConsoleCommandExtension.handleZigbeeCommand(ZigBeeConsoleCommandExtension.java:149) ~[?:?]
	at org.openhab.binding.zigbee.console.internal.ZigBeeConsoleCommandExtension.handleCommand(ZigBeeConsoleCommandExtension.java:117) ~[?:?]
	at org.openhab.binding.zigbee.console.internal.ZigBeeConsoleCommandExtension.execute(ZigBeeConsoleCommandExtension.java:89) ~[?:?]
	at org.openhab.core.io.console.ConsoleInterpreter.execute(ConsoleInterpreter.java:55) [bundleFile:?]
	at org.openhab.core.io.console.karaf.internal.CommandWrapper.execute(CommandWrapper.java:78) [bundleFile:?]
	at org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:68) [bundleFile:4.3.2]
	at org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:86) [bundleFile:4.3.2]
	at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:599) [bundleFile:4.3.2]
	at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:526) [bundleFile:4.3.2]
	at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:415) [bundleFile:4.3.2]
	at org.apache.felix.gogo.runtime.Pipe.doCall(Pipe.java:416) [bundleFile:4.3.2]
	at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:229) [bundleFile:4.3.2]
	at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:59) [bundleFile:4.3.2]
	at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
	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) [?:?]

Starting from the beginning again (removing all ZB things, resetting devices), pressing Scan and adding a single wall plug.

Log of exception during Scan:
openhab.log (514.3 KB)

The Java exception is on line 612 [2022-01-20 10:31:00.933], same as above.
Afterwards, zigbee nodes crashes same as above.

This is a POPP ZB Stick, zigbee:ember_controller, and a Tuya wall plug. There should be no other devices on the network.

Sorry - I missed this (If you don’t reply to me, then I’m not notified).

Hopefully I’ve fixed this with this PR -:

I see loads of other errors in your log from this device which I’m not sure I can do a lot about as it’s from a non-standard cluster and seems to not conform to the standards :frowning:

1 Like

Thank you chris!
Of the many errors you saw, could that explain any of these 2 issues I’m having with them?

  1. When toggling the device on and off, sometimes the command is delayed some 5-10 seconds, sometimes it doesn’t switch at all (3 meters line of sight).
  2. As a consequence, the device switch status is sometimes constantly different from the item status, i.e. plug is OFF while item switch is ON.
  • Do you think your PR would affect those 2 issues? (I don’t know how to test before release. Else I should return them, but it’s China, so …)
  • Can you think of a workaround? Like autoupdate=“false” + retry logic. (Differing item state is why I switched to 2-way communication in the first place :wink: )