I have a Zigbee sensor that is sending data to the hub. The source of the data appends a ! to the UART data to identify which part of the sensor is being sent. The ! could be a # for a different message.
So I need to remove the leading 21 from the "value:21313538" (from log - descMap.value= 21313538)
The below code yields an error message essentially saying the startsWith doesn't work with integers.
So my "descMap.value" is an integer (I think) so I'm at a loss on how to remove the leading "!" (aka 0x21)
dev:40172023-11-22 23:44:09.359debug Desc Map: [raw:7AFE010014100E00410421313538, dni:7AFE, endpoint:01, cluster:0014, size:10, attrId:000E, encoding:41, command:0A, value:21313538, clusterInt:20, attrInt:14]
dev:40172023-11-22 23:44:09.355debug Parse description= {read attr - raw: 7AFE010014100E00410421313538, dni: 7AFE, endpoint: 01, cluster: 0014, size: 10, attrId: 000E, encoding: 41, command: 0A, value: 0421313538}
if (description?.startsWith("read attr -")) {
def descMap = zigbee.parseDescriptionAsMap(description)
if (logEnable) log.debug " Desc Map: $descMap"
if (descMap.clusterInt == 20) log.info "clusterInt = 20"
if (descMap.clusterInt == 0x0014) log.info "clusterInt = 0x0014"
if (descMap?.attrID == 000E) log.info "attrID = 000E"
def echo = descMap.value
if (echo.startsWith (21)) log.info "value start = 21"
if (echo.startsWith ("21")) log.info "value start = 21 (in dbl quotes)"