From 2d22b5a384a7e747e45dd6b9b48076100930927f Mon Sep 17 00:00:00 2001 From: Tom Manley Date: Mon, 2 Nov 2015 09:51:03 -0600 Subject: [PATCH] Fix 'Low Battery Handler' exception caused by non-integer battery events ZigBee locks report battery percentage remaining in .5% increments. However the Low Battery Handler Smart App in Hello Home expects it to be an integer. --- devicetypes/smartthings/zigbee-lock.src/zigbee-lock.groovy | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/devicetypes/smartthings/zigbee-lock.src/zigbee-lock.groovy b/devicetypes/smartthings/zigbee-lock.src/zigbee-lock.groovy index 20384e2..0e46ebf 100644 --- a/devicetypes/smartthings/zigbee-lock.src/zigbee-lock.groovy +++ b/devicetypes/smartthings/zigbee-lock.src/zigbee-lock.groovy @@ -139,8 +139,7 @@ private Map parseReportAttributeMessage(String description) { Map resultMap = [:] if (descMap.clusterInt == CLUSTER_POWER && descMap.attrInt == POWER_ATTR_BATTERY_PERCENTAGE_REMAINING) { resultMap.name = "battery" - // BatteryPercentageRemaining is specified in .5% increments - resultMap.value = Integer.parseInt(descMap.value, 16) / 2 + resultMap.value = Math.round(Integer.parseInt(descMap.value, 16) / 2) log.info "parseReportAttributeMessage() --- battery: ${resultMap.value}" } else if (descMap.clusterInt == CLUSTER_DOORLOCK && descMap.attrInt == DOORLOCK_ATTR_LOCKSTATE) {