Merge pull request #1934 from SmartThingsCommunity/multi-sensor-accel-fix

DVCSMP-2573: Acceleration axis validation (Multi sensor DTH)
This commit is contained in:
Stephen Stack
2017-04-25 15:11:54 -05:00
committed by GitHub

View File

@@ -192,6 +192,10 @@ private List<Map> parseAxis(List<Map> attrData) {
def y = hexToSignedInt(attrData.find { it.attrInt == 0x0013 }?.value)
def z = hexToSignedInt(attrData.find { it.attrInt == 0x0014 }?.value)
if ([x, y ,z].any { it == null }) {
return []
}
def xyzResults = [:]
if (device.getDataValue("manufacturer") == "SmartThings") {
// This mapping matches the current behavior of the Device Handler for the Centralite sensors
@@ -372,6 +376,10 @@ def updated() {
}
private hexToSignedInt(hexVal) {
if (!hexVal) {
return null
}
def unsignedVal = hexToInt(hexVal)
unsignedVal > 32767 ? unsignedVal - 65536 : unsignedVal
}