Hi There,
I’ve spent countless hours trying to test/understand the Zigbee DataType class, and I’m at the point of ire and absolute frustration.
I cannot find a single usage example of it except in other platforms who have updated their own class to support extra stuff (like hubitat).
My problem is simple, I have a variable with a hex value of 21 and I want to get the getLength of type 21 which is DataType UINT16 (length should return 2)
The examples in the ‘old’ docs are just bad to explain how to properly use them in an example,
If I do this inside a method:
def testvalue = 0x21
def testUnknown = DataType.getLength(testvalue.UINT8)
log.warn "result of test is: ${testUnknown}"
you get:
groovy.lang.MissingPropertyException: No such property: UINT8 for class: java.lang.Integer @line…
(Same thing, but for java.lang string if I do a Integer.toHexString(value) first)
If I do, what the documentation says to do (which makes no sense):
DataType.getLength(DataType.UINT8)
you get: java.lang.NullPointerException: Cannot get property ‘UINT8’ on null object @line …
(if i replace the first DataType., with the testvalue variable (or even hex as string value), same error)
So the question is simple, WHAT exactly is the getLength() method is expecting??? how exactly can I just derive that the length is (value) if I priorly know the hex code for the DataType ZCL numeric value???
Has anybody actually used getLength() somewhere? can you provide an example on how to use it?