I'm trying to work with a string that is a concatenation of positive bytes.
The string is: Zigbee Msg# 334A780F22EE0100
Where I would like to be able to test and get value for each byte:
33 4A 78 0F 22 EE 01 00
However I can't seem to address an individual element in the byte array.
Below is my code. You can see the last three "log.info" shows my latest attempts. I'm starting to think there may be something special of this type of array.
Does anyone see where I'm going wrong?
Thanks
def parse(String description){
log.info "Raw Description#$description"
// Map map = [:]
def event = zigbee.getEvent(description)
//if (event) sendEvent(event)
if (description?.startsWith('read attr -')){
def descMap = zigbee.parseDescriptionAsMap(description)
if (descMap.cluster == "0014" && descMap.attrId == "000E"){ // zigbee spec 0x000C= read analog cluster 0x0055 = present value
ZigbeeHexMap = descMap.value
log.info "Zigbee Msg# $ZigbeeHexMap"
byte[] xarray = hubitat.helper.HexUtils.hexStringToByteArray(ZigbeeHexMap)
log.info "fullarray= $xarray"
log.info "byteA= $xarray(3)"
log.info "byteB= $xarray[3]"
log.info "byteB= $xarray:3"
}
}
} // --- parse ---