From e98a04a1b4a61aa2c58465b4fd57565f66abed15 Mon Sep 17 00:00:00 2001 From: Tom Manley Date: Mon, 4 Jan 2016 15:21:55 -0600 Subject: [PATCH 1/3] multi: Fix x,y,z parsing error The previous axis value parsing code was very fragile. For example, this code block: def unsignedY = hexToInt(part.split("13")[1].trim()) would fail when `part` was "13xx13", where "xx" is any value. The split assumed the value "13" was present only once in the string, and everything after the "13" was the value. When "13" was part of the value this code would interpret only "xx" as the value, instead of "xx13". The new parsing code is not fragile like this. It knows exactly what bytes of the string are X, Y, and Z and parses the values correctly. --- .../smartsense-multi-sensor.groovy | 70 +++++++------------ 1 file changed, 27 insertions(+), 43 deletions(-) diff --git a/devicetypes/smartthings/smartsense-multi-sensor.src/smartsense-multi-sensor.groovy b/devicetypes/smartthings/smartsense-multi-sensor.src/smartsense-multi-sensor.groovy index 8dd6c94..5771b85 100644 --- a/devicetypes/smartthings/smartsense-multi-sensor.src/smartsense-multi-sensor.groovy +++ b/devicetypes/smartthings/smartsense-multi-sensor.src/smartsense-multi-sensor.groovy @@ -478,50 +478,34 @@ def enrollResponse() { ] } - private Map parseAxis(String description) { - log.debug "parseAxis" - def xyzResults = [x: 0, y: 0, z: 0] - def parts = description.split("2900") - parts[0] = "12" + parts[0] - parts.each { part -> - part = part.trim() - if (part.startsWith("12")) { - def unsignedX = hexToInt(part.split("12")[1].trim()) - def signedX = unsignedX > 32767 ? unsignedX - 65536 : unsignedX - xyzResults.x = signedX - log.debug "X Part: ${signedX}" - } - // Y and the Z axes are interchanged between SmartThings's implementation and Centralite's implementation - else if (part.startsWith("13")) { - def unsignedY = hexToInt(part.split("13")[1].trim()) - def signedY = unsignedY > 32767 ? unsignedY - 65536 : unsignedY - if (device.getDataValue("manufacturer") == "SmartThings") { - xyzResults.z = -signedY - log.debug "Z Part: ${xyzResults.z}" - if (garageSensor == "Yes") - garageEvent(xyzResults.z) - } - else { - xyzResults.y = signedY - log.debug "Y Part: ${signedY}" - } - } - else if (part.startsWith("14")) { - def unsignedZ = hexToInt(part.split("14")[1].trim()) - def signedZ = unsignedZ > 32767 ? unsignedZ - 65536 : unsignedZ - if (device.getDataValue("manufacturer") == "SmartThings") { - xyzResults.y = signedZ - log.debug "Y Part: ${signedZ}" - } else { - xyzResults.z = signedZ - log.debug "Z Part: ${signedZ}" - if (garageSensor == "Yes") - garageEvent(signedZ) - - } - } - } + def hexToSignedInt = { hexVal -> + def unsignedVal = hexToInt(hexVal) + unsignedVal > 32767 ? unsignedVal - 65536 : unsignedVal + } + + def z = hexToSignedInt(description[0..3]) + def y = hexToSignedInt(description[10..13]) + def x = hexToSignedInt(description[20..23]) + def xyzResults = [x: x, y: y, z: z] + + if (device.getDataValue("manufacturer") == "SmartThings") { + // This mapping matches the current behavior of the Device Handler for the Centralite sensors + xyzResults.x = z + xyzResults.y = y + xyzResults.z = -x + } else { + // The axises reported by the Device Handler differ from the axises reported by the sensor + // This may change in the future + xyzResults.x = z + xyzResults.y = x + xyzResults.z = y + } + + log.debug "parseAxis -- ${xyzResults}" + + if (garageSensor == "Yes") + garageEvent(xyzResults.z) getXyzResult(xyzResults, description) } From c1c2431299bf9b5eea9ebafcb08d818d3eda30c2 Mon Sep 17 00:00:00 2001 From: Tom Manley Date: Mon, 4 Jan 2016 15:56:12 -0600 Subject: [PATCH 2/3] multi: Adjust threshold multiplier to prevent motion detection while idle The previous threshold multiplier was found to be too low so motion was being detected while the sensor was idle. This new value of 630 seems to produce better results. --- .../smartsense-multi-sensor.groovy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/devicetypes/smartthings/smartsense-multi-sensor.src/smartsense-multi-sensor.groovy b/devicetypes/smartthings/smartsense-multi-sensor.src/smartsense-multi-sensor.groovy index 5771b85..b950034 100644 --- a/devicetypes/smartthings/smartsense-multi-sensor.src/smartsense-multi-sensor.groovy +++ b/devicetypes/smartthings/smartsense-multi-sensor.src/smartsense-multi-sensor.groovy @@ -381,7 +381,7 @@ def getTemperature(value) { log.debug "Refreshing Values for manufacturer: SmartThings " refreshCmds = refreshCmds + [ - /* These values of Motion Threshold Multiplier(01) and Motion Threshold (D200) + /* These values of Motion Threshold Multiplier(01) and Motion Threshold (7602) seem to be giving pretty accurate results for the XYZ co-ordinates for this manufacturer. Separating these out in a separate if-else because I do not want to touch Centralite part as of now. @@ -392,7 +392,7 @@ def getTemperature(value) { "send 0x${device.deviceNetworkId} 1 1", "delay 400", "zcl mfg-code ${manufacturerCode}", "delay 200", - "zcl global write 0xFC02 2 0x21 {D200}", "delay 200", + "zcl global write 0xFC02 2 0x21 {7602}", "delay 200", "send 0x${device.deviceNetworkId} 1 1", "delay 400", ] From fe505ddc9fc153fea0bd50665160a39a3459fb30 Mon Sep 17 00:00:00 2001 From: Yaima Valdivia Date: Wed, 6 Jan 2016 15:24:47 -0800 Subject: [PATCH 3/3] Removed degree sign from tile https://smartthings.atlassian.net/browse/DVCSMP-1318 --- .../smartthings/ecobee-thermostat.src/ecobee-thermostat.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devicetypes/smartthings/ecobee-thermostat.src/ecobee-thermostat.groovy b/devicetypes/smartthings/ecobee-thermostat.src/ecobee-thermostat.groovy index f28323b..b439a63 100644 --- a/devicetypes/smartthings/ecobee-thermostat.src/ecobee-thermostat.groovy +++ b/devicetypes/smartthings/ecobee-thermostat.src/ecobee-thermostat.groovy @@ -67,7 +67,7 @@ metadata { state "setpoint", action:"raiseSetpoint", icon:"st.thermostat.thermostat-up" } valueTile("thermostatSetpoint", "device.thermostatSetpoint", width: 1, height: 1, decoration: "flat") { - state "thermostatSetpoint", label:'${currentValue}°' + state "thermostatSetpoint", label:'${currentValue}' } valueTile("currentStatus", "device.thermostatStatus", height: 1, width: 2, decoration: "flat") { state "thermostatStatus", label:'${currentValue}', backgroundColor:"#ffffff"