mirror of
https://github.com/mtan93/SmartThingsPublic.git
synced 2026-03-19 13:20:53 +00:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
edc98e4840 | ||
|
|
fb2c2cb2a7 | ||
|
|
62aeb0533d | ||
|
|
01fae3dcd4 | ||
|
|
6c125fe80f | ||
|
|
5728f08770 | ||
|
|
f073df0a57 | ||
|
|
6c5b93da87 |
@@ -204,11 +204,11 @@ private getThermostatDescriptionText(name, value, linkText) {
|
|||||||
|
|
||||||
void setHeatingSetpoint(setpoint) {
|
void setHeatingSetpoint(setpoint) {
|
||||||
log.debug "***heating setpoint $setpoint"
|
log.debug "***heating setpoint $setpoint"
|
||||||
def heatingSetpoint = setpoint.toDouble()
|
def heatingSetpoint = setpoint
|
||||||
def coolingSetpoint = device.currentValue("coolingSetpoint").toDouble()
|
def coolingSetpoint = device.currentValue("coolingSetpoint")
|
||||||
def deviceId = device.deviceNetworkId.split(/\./).last()
|
def deviceId = device.deviceNetworkId.split(/\./).last()
|
||||||
def maxHeatingSetpoint = device.currentValue("maxHeatingSetpoint").toDouble()
|
def maxHeatingSetpoint = device.currentValue("maxHeatingSetpoint")
|
||||||
def minHeatingSetpoint = device.currentValue("minHeatingSetpoint").toDouble()
|
def minHeatingSetpoint = device.currentValue("minHeatingSetpoint")
|
||||||
|
|
||||||
//enforce limits of heatingSetpoint
|
//enforce limits of heatingSetpoint
|
||||||
if (heatingSetpoint > maxHeatingSetpoint) {
|
if (heatingSetpoint > maxHeatingSetpoint) {
|
||||||
@@ -241,11 +241,11 @@ void setHeatingSetpoint(setpoint) {
|
|||||||
|
|
||||||
void setCoolingSetpoint(setpoint) {
|
void setCoolingSetpoint(setpoint) {
|
||||||
log.debug "***cooling setpoint $setpoint"
|
log.debug "***cooling setpoint $setpoint"
|
||||||
def heatingSetpoint = device.currentValue("heatingSetpoint").toDouble()
|
def heatingSetpoint = device.currentValue("heatingSetpoint")
|
||||||
def coolingSetpoint = setpoint.toDouble()
|
def coolingSetpoint = setpoint
|
||||||
def deviceId = device.deviceNetworkId.split(/\./).last()
|
def deviceId = device.deviceNetworkId.split(/\./).last()
|
||||||
def maxCoolingSetpoint = device.currentValue("maxCoolingSetpoint").toDouble()
|
def maxCoolingSetpoint = device.currentValue("maxCoolingSetpoint")
|
||||||
def minCoolingSetpoint = device.currentValue("minCoolingSetpoint").toDouble()
|
def minCoolingSetpoint = device.currentValue("minCoolingSetpoint")
|
||||||
|
|
||||||
|
|
||||||
if (coolingSetpoint > maxCoolingSetpoint) {
|
if (coolingSetpoint > maxCoolingSetpoint) {
|
||||||
@@ -505,9 +505,6 @@ def fanAuto() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def generateSetpointEvent() {
|
def generateSetpointEvent() {
|
||||||
|
|
||||||
log.debug "Generate SetPoint Event"
|
log.debug "Generate SetPoint Event"
|
||||||
@@ -536,6 +533,7 @@ def generateSetpointEvent() {
|
|||||||
coolingSetpoint = roundC(coolingSetpoint)
|
coolingSetpoint = roundC(coolingSetpoint)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sendEvent("name":"maxHeatingSetpoint", "value":maxHeatingSetpoint, "unit":location.temperatureScale)
|
sendEvent("name":"maxHeatingSetpoint", "value":maxHeatingSetpoint, "unit":location.temperatureScale)
|
||||||
sendEvent("name":"maxCoolingSetpoint", "value":maxCoolingSetpoint, "unit":location.temperatureScale)
|
sendEvent("name":"maxCoolingSetpoint", "value":maxCoolingSetpoint, "unit":location.temperatureScale)
|
||||||
sendEvent("name":"minHeatingSetpoint", "value":minHeatingSetpoint, "unit":location.temperatureScale)
|
sendEvent("name":"minHeatingSetpoint", "value":minHeatingSetpoint, "unit":location.temperatureScale)
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ metadata {
|
|||||||
fingerprint inClusters: "0000,0001,0003,0402,0500,0020,0B05", outClusters: "0019", manufacturer: "CentraLite", model: "3305"
|
fingerprint inClusters: "0000,0001,0003,0402,0500,0020,0B05", outClusters: "0019", manufacturer: "CentraLite", model: "3305"
|
||||||
fingerprint inClusters: "0000,0001,0003,0402,0500,0020,0B05", outClusters: "0019", manufacturer: "CentraLite", model: "3325"
|
fingerprint inClusters: "0000,0001,0003,0402,0500,0020,0B05", outClusters: "0019", manufacturer: "CentraLite", model: "3325"
|
||||||
fingerprint inClusters: "0000,0001,0003,0402,0500,0020,0B05", outClusters: "0019", manufacturer: "CentraLite", model: "3326"
|
fingerprint inClusters: "0000,0001,0003,0402,0500,0020,0B05", outClusters: "0019", manufacturer: "CentraLite", model: "3326"
|
||||||
|
fingerprint inClusters: "0000,0001,0003,0402,0500,0020,0B05", outClusters: "0019", manufacturer: "CentraLite", model: "3326-L", deviceJoinName: "Iris Motion Sensor"
|
||||||
fingerprint inClusters: "0000,0001,0003,000F,0020,0402,0500", outClusters: "0019", manufacturer: "SmartThings", model: "motionv4", deviceJoinName: "Motion Sensor"
|
fingerprint inClusters: "0000,0001,0003,000F,0020,0402,0500", outClusters: "0019", manufacturer: "SmartThings", model: "motionv4", deviceJoinName: "Motion Sensor"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,17 +16,18 @@
|
|||||||
|
|
||||||
metadata {
|
metadata {
|
||||||
definition (name: "SmartSense Open/Closed Sensor", namespace: "smartthings", author: "SmartThings") {
|
definition (name: "SmartSense Open/Closed Sensor", namespace: "smartthings", author: "SmartThings") {
|
||||||
capability "Battery"
|
capability "Battery"
|
||||||
capability "Configuration"
|
capability "Configuration"
|
||||||
capability "Contact Sensor"
|
capability "Contact Sensor"
|
||||||
capability "Refresh"
|
capability "Refresh"
|
||||||
capability "Temperature Measurement"
|
capability "Temperature Measurement"
|
||||||
|
|
||||||
command "enrollResponse"
|
command "enrollResponse"
|
||||||
|
|
||||||
|
|
||||||
fingerprint inClusters: "0000,0001,0003,0402,0500,0020,0B05", outClusters: "0019", manufacturer: "CentraLite", model: "3300-S"
|
fingerprint inClusters: "0000,0001,0003,0402,0500,0020,0B05", outClusters: "0019", manufacturer: "CentraLite", model: "3300-S"
|
||||||
fingerprint inClusters: "0000,0001,0003,0402,0500,0020,0B05", outClusters: "0019", manufacturer: "CentraLite", model: "3300"
|
fingerprint inClusters: "0000,0001,0003,0402,0500,0020,0B05", outClusters: "0019", manufacturer: "CentraLite", model: "3300"
|
||||||
|
fingerprint inClusters: "0000,0001,0003,0020,0402,0500,0B05", outClusters: "0019", manufacturer: "CentraLite", model: "3320-L", deviceJoinName: "Iris Contact Sensor"
|
||||||
}
|
}
|
||||||
|
|
||||||
simulator {
|
simulator {
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ metadata {
|
|||||||
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0702"
|
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0702"
|
||||||
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0702, 0B05", outClusters: "0003, 000A, 0019", manufacturer: "Jasco Products", model: "45853", deviceJoinName: "GE ZigBee Plug-In Switch"
|
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0702, 0B05", outClusters: "0003, 000A, 0019", manufacturer: "Jasco Products", model: "45853", deviceJoinName: "GE ZigBee Plug-In Switch"
|
||||||
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0702, 0B05", outClusters: "000A, 0019", manufacturer: "Jasco Products", model: "45856", deviceJoinName: "GE ZigBee In-Wall Switch"
|
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0702, 0B05", outClusters: "000A, 0019", manufacturer: "Jasco Products", model: "45856", deviceJoinName: "GE ZigBee In-Wall Switch"
|
||||||
|
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 000F, 0B04", outClusters: "0019", manufacturer: "SmartThings", model: "outletv4", deviceJoinName: "Outlet"
|
||||||
}
|
}
|
||||||
|
|
||||||
tiles(scale: 2) {
|
tiles(scale: 2) {
|
||||||
|
|||||||
@@ -257,21 +257,16 @@ def getEcobeeThermostats() {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.debug "http status: ${resp.status}"
|
log.debug "http status: ${resp.status}"
|
||||||
//refresh the auth token
|
|
||||||
if (resp.data.status.code == 14) {
|
|
||||||
log.debug "Storing the failed action to try later"
|
|
||||||
atomicState.action = "getEcobeeThermostats"
|
|
||||||
log.debug "Refreshing your auth_token!"
|
|
||||||
refreshAuthToken()
|
|
||||||
} else {
|
|
||||||
log.error "Authentication error, invalid authentication method, lack of credentials, etc."
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch(Exception e) {
|
} catch (groovyx.net.http.HttpResponseException e) {
|
||||||
log.debug "___exception getEcobeeThermostats(): " + e
|
log.trace "Exception polling children: " + e.response.data.status
|
||||||
refreshAuthToken()
|
if (e.response.data.status.code == 14) {
|
||||||
}
|
atomicState.action = "getEcobeeThermostats"
|
||||||
|
log.debug "Refreshing your auth_token!"
|
||||||
|
refreshAuthToken()
|
||||||
|
}
|
||||||
|
}
|
||||||
atomicState.thermostats = stats
|
atomicState.thermostats = stats
|
||||||
return stats
|
return stats
|
||||||
}
|
}
|
||||||
@@ -450,23 +445,15 @@ def pollChildren(child = null) {
|
|||||||
}
|
}
|
||||||
result = true
|
result = true
|
||||||
log.debug "updated ${atomicState.thermostats?.size()} stats: ${atomicState.thermostats}"
|
log.debug "updated ${atomicState.thermostats?.size()} stats: ${atomicState.thermostats}"
|
||||||
} else {
|
|
||||||
log.error "polling children & got http status ${resp.status}"
|
|
||||||
|
|
||||||
//refresh the auth token
|
|
||||||
if (resp.data.status.code == 14) {
|
|
||||||
atomicState.action = "pollChildren"
|
|
||||||
log.debug "Refreshing your auth_token!"
|
|
||||||
refreshAuthToken()
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
log.error "Authentication error, invalid authentication method, lack of credentials, etc."
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch(Exception e) {
|
} catch (groovyx.net.http.HttpResponseException e) {
|
||||||
log.debug "___exception polling children: " + e
|
log.trace "Exception polling children: " + e.response.data.status
|
||||||
refreshAuthToken()
|
if (e.response.data.status.code == 14) {
|
||||||
|
atomicState.action = "pollChildren"
|
||||||
|
log.debug "Refreshing your auth_token!"
|
||||||
|
refreshAuthToken()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
@@ -642,16 +629,14 @@ private refreshAuthToken() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
atomicState.action = ""
|
atomicState.action = ""
|
||||||
} else {
|
|
||||||
log.debug "refresh failed ${resp.status} : ${resp.status.code}"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (groovyx.net.http.HttpResponseException e) {
|
} catch (groovyx.net.http.HttpResponseException e) {
|
||||||
log.error "refreshAuthToken() >> Error: e.statusCode ${e.statusCode}"
|
log.error "refreshAuthToken() >> Error: e.statusCode ${e.statusCode}"
|
||||||
def reAttemptPeriod = 300 // in sec
|
def reAttemptPeriod = 300 // in sec
|
||||||
if (e.statusCode != 401) { //this issue might comes from exceed 20sec app execution, connectivity issue etc.
|
if (e.statusCode != 401) { // this issue might comes from exceed 20sec app execution, connectivity issue etc.
|
||||||
runIn(reAttemptPeriod, "refreshAuthToken")
|
runIn(reAttemptPeriod, "refreshAuthToken")
|
||||||
} else if (e.statusCode == 401) { //refresh token is expired
|
} else if (e.statusCode == 401) { // unauthorized
|
||||||
atomicState.reAttempt = atomicState.reAttempt + 1
|
atomicState.reAttempt = atomicState.reAttempt + 1
|
||||||
log.warn "reAttempt refreshAuthToken to try = ${atomicState.reAttempt}"
|
log.warn "reAttempt refreshAuthToken to try = ${atomicState.reAttempt}"
|
||||||
if (atomicState.reAttempt <= 3) {
|
if (atomicState.reAttempt <= 3) {
|
||||||
@@ -724,29 +709,21 @@ def sendJson(child = null, String jsonBody) {
|
|||||||
log.debug "Error return code = ${resp.data.status.code}"
|
log.debug "Error return code = ${resp.data.status.code}"
|
||||||
debugEvent("Error return code = ${resp.data.status.code}")
|
debugEvent("Error return code = ${resp.data.status.code}")
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
log.error "sent Json & got http status ${resp.status} - ${resp.status.code}"
|
|
||||||
debugEvent ("sent Json & got http status ${resp.status} - ${resp.status.code}")
|
|
||||||
|
|
||||||
//refresh the auth token
|
|
||||||
if (resp.status.code == 14) {
|
|
||||||
log.debug "Refreshing your auth_token!"
|
|
||||||
debugEvent ("Refreshing OAUTH Token")
|
|
||||||
refreshAuthToken()
|
|
||||||
return false
|
|
||||||
} else {
|
|
||||||
debugEvent ("Authentication error, invalid authentication method, lack of credentials, etc.")
|
|
||||||
log.error "Authentication error, invalid authentication method, lack of credentials, etc."
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch(Exception e) {
|
} catch (groovyx.net.http.HttpResponseException e) {
|
||||||
log.debug "Exception Sending Json: " + e
|
log.trace "Exception Sending Json: " + e.response.data.status
|
||||||
debugEvent ("Exception Sending JSON: " + e)
|
debugEvent ("sent Json & got http status ${e.statusCode} - ${e.response.data.status.code}")
|
||||||
refreshAuthToken()
|
if (e.response.data.status.code == 14) {
|
||||||
return false
|
atomicState.action = "pollChildren"
|
||||||
}
|
log.debug "Refreshing your auth_token!"
|
||||||
|
refreshAuthToken()
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
debugEvent("Authentication error, invalid authentication method, lack of credentials, etc.")
|
||||||
|
log.error "Authentication error, invalid authentication method, lack of credentials, etc."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (returnStatus == 0)
|
if (returnStatus == 0)
|
||||||
return true
|
return true
|
||||||
|
|||||||
Reference in New Issue
Block a user