mirror of
https://github.com/mtan93/SmartThingsPublic.git
synced 2026-03-31 14:13:11 +01:00
Merge pull request #421 from SmartThingsCommunity/master
Merging Ecobee and SmartSense code
This commit is contained in:
@@ -67,7 +67,7 @@ metadata {
|
|||||||
state "setpoint", action:"raiseSetpoint", icon:"st.thermostat.thermostat-up"
|
state "setpoint", action:"raiseSetpoint", icon:"st.thermostat.thermostat-up"
|
||||||
}
|
}
|
||||||
valueTile("thermostatSetpoint", "device.thermostatSetpoint", width: 1, height: 1, decoration: "flat") {
|
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") {
|
valueTile("currentStatus", "device.thermostatStatus", height: 1, width: 2, decoration: "flat") {
|
||||||
state "thermostatStatus", label:'${currentValue}', backgroundColor:"#ffffff"
|
state "thermostatStatus", label:'${currentValue}', backgroundColor:"#ffffff"
|
||||||
|
|||||||
@@ -381,7 +381,7 @@ def getTemperature(value) {
|
|||||||
log.debug "Refreshing Values for manufacturer: SmartThings "
|
log.debug "Refreshing Values for manufacturer: SmartThings "
|
||||||
refreshCmds = refreshCmds + [
|
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.
|
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
|
Separating these out in a separate if-else because I do not want to touch Centralite part
|
||||||
as of now.
|
as of now.
|
||||||
@@ -392,7 +392,7 @@ def getTemperature(value) {
|
|||||||
"send 0x${device.deviceNetworkId} 1 1", "delay 400",
|
"send 0x${device.deviceNetworkId} 1 1", "delay 400",
|
||||||
|
|
||||||
"zcl mfg-code ${manufacturerCode}", "delay 200",
|
"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",
|
"send 0x${device.deviceNetworkId} 1 1", "delay 400",
|
||||||
|
|
||||||
]
|
]
|
||||||
@@ -478,50 +478,34 @@ def enrollResponse() {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Map parseAxis(String description) {
|
private Map parseAxis(String description) {
|
||||||
log.debug "parseAxis"
|
def hexToSignedInt = { hexVal ->
|
||||||
def xyzResults = [x: 0, y: 0, z: 0]
|
def unsignedVal = hexToInt(hexVal)
|
||||||
def parts = description.split("2900")
|
unsignedVal > 32767 ? unsignedVal - 65536 : unsignedVal
|
||||||
parts[0] = "12" + parts[0]
|
}
|
||||||
parts.each { part ->
|
|
||||||
part = part.trim()
|
def z = hexToSignedInt(description[0..3])
|
||||||
if (part.startsWith("12")) {
|
def y = hexToSignedInt(description[10..13])
|
||||||
def unsignedX = hexToInt(part.split("12")[1].trim())
|
def x = hexToSignedInt(description[20..23])
|
||||||
def signedX = unsignedX > 32767 ? unsignedX - 65536 : unsignedX
|
def xyzResults = [x: x, y: y, z: z]
|
||||||
xyzResults.x = signedX
|
|
||||||
log.debug "X Part: ${signedX}"
|
if (device.getDataValue("manufacturer") == "SmartThings") {
|
||||||
}
|
// This mapping matches the current behavior of the Device Handler for the Centralite sensors
|
||||||
// Y and the Z axes are interchanged between SmartThings's implementation and Centralite's implementation
|
xyzResults.x = z
|
||||||
else if (part.startsWith("13")) {
|
xyzResults.y = y
|
||||||
def unsignedY = hexToInt(part.split("13")[1].trim())
|
xyzResults.z = -x
|
||||||
def signedY = unsignedY > 32767 ? unsignedY - 65536 : unsignedY
|
} else {
|
||||||
if (device.getDataValue("manufacturer") == "SmartThings") {
|
// The axises reported by the Device Handler differ from the axises reported by the sensor
|
||||||
xyzResults.z = -signedY
|
// This may change in the future
|
||||||
log.debug "Z Part: ${xyzResults.z}"
|
xyzResults.x = z
|
||||||
if (garageSensor == "Yes")
|
xyzResults.y = x
|
||||||
garageEvent(xyzResults.z)
|
xyzResults.z = y
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
xyzResults.y = signedY
|
log.debug "parseAxis -- ${xyzResults}"
|
||||||
log.debug "Y Part: ${signedY}"
|
|
||||||
}
|
if (garageSensor == "Yes")
|
||||||
}
|
garageEvent(xyzResults.z)
|
||||||
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)
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
getXyzResult(xyzResults, description)
|
getXyzResult(xyzResults, description)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user