I'm struggling with Lists. I've tried numerous syntax for the DescList(index) and this one gives me an output. However I do not understand why the line:
log.info "sData: ${sData}"
does not log "Outside Humidity =" as it did in the previous line.
Can anyone explain where I'm going wrong? And why a simple List does not seem to work as the groovy documentation suggests?
@Field static List<String> DescList = ['Outside Temp = ', 'Outside Humidity = ', 'Outside Dew Point = ','Pressure = ','Inside Temp = ', 'Inside Humidity = ', 'Alarm Status: ']
.
.
.
.
.
def handlerButton(evt) {
int index = 1
log.info "DescList_1 = ${DescList[index]}" // log.info => Outside Humidity =
String sData = {DescList(index)}
log.info "sData: ${sData}" // logs => user_app_hubitat__Testing_App_1768$_handlerButton_closure3@d38161
String xData = sData.getBytes("UTF-8").encodeHex()
xData = "01" + xData
log.info "xData: ${xData}"
BDlen = xData.length()/2 // rtns a BigDecimal because of the division.
String HexLen = hubitat.helper.HexUtils.integerToHexString(BDlen.intValue(), 1)
String HexDataString = HexLen + xData
log.info "full HEX string = $HexDataString"
UARTdriver.WriteAttr_(HexDataString)
}