Unexpected format()'ing of zwave.configurationV1.configurationSet class when configurationValue argument contains Byte or Long

Naively, I would expect each of the following four expressions, in device driver code, to evaluate to the same value, namely the string "7004010100000000"

  1. zwave.configurationV1.configurationSet(configurationValue: [0 as Byte ]*4, parameterNumber: 1, size: 1).format()
  2. zwave.configurationV1.configurationSet(configurationValue: [0 as Short ]*4, parameterNumber: 1, size: 1).format()
  3. zwave.configurationV1.configurationSet(configurationValue: [0 as Integer ]*4, parameterNumber: 1, size: 1).format()
  4. zwave.configurationV1.configurationSet(configurationValue: [0 as Long ]*4, parameterNumber: 1, size: 1).format()

What I actually observe is that expressions 2 and 3 do evaluate to the expected value, but expressions 1 and 4 evaluate to the string "70040101". The format() method of the zwave.configurationV1.configurationSet class seems to be behaving incorrectly (or, at least, unexpectedly) in the case where the elements in the configurationValue list are Byte's or Long's . The particular values in the configurationValue list in the expressions above are just an example -- the same unexpected behavior seems to occur regardless of the values -- the type is what's important.

This unexpected behavior thwarted my attempts to set the configuration registers of a zwave device. The workaround was to explicitly cast the members of the configurationValue list to Short's before passing the list to the zwave.configurationV1.configurationSet constructor.

configurationValue is a

List<Short>

FWIW, the expected type is a List<Short> (see: ZWave Classes - Hubitat Documentation), but Groovy normally handles this pretty well and as expected if the values are in range of the target type, so maybe Hubitat is doing something odd here where this doesn't work. @bcopeland could probably say for sure. Otherwise, I'd be explicit with Short since that is what's documented.

EDIT: And he did say. :smiley:

3 Likes

:joy: That has bitten me too many times.. I always explicitly type these days..

3 Likes