mirror of
https://github.com/mtan93/SmartThingsPublic.git
synced 2026-03-15 05:10:50 +00:00
Compare commits
3 Commits
MSA-884-4
...
plantlink-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
69a6fc4f9e | ||
|
|
d82a387c68 | ||
|
|
20d660e236 |
@@ -30,7 +30,6 @@ metadata {
|
||||
command "lowerSetpoint"
|
||||
command "resumeProgram"
|
||||
command "switchMode"
|
||||
command "switchFanMode"
|
||||
|
||||
attribute "thermostatSetpoint","number"
|
||||
attribute "thermostatStatus","string"
|
||||
@@ -64,9 +63,10 @@ metadata {
|
||||
state "updating", label:"Working", icon: "st.secondary.secondary"
|
||||
}
|
||||
standardTile("fanMode", "device.thermostatFanMode", inactiveLabel: false, decoration: "flat") {
|
||||
state "auto", action:"switchFanMode", nextState: "updating", icon: "st.thermostat.fan-auto"
|
||||
state "on", action:"switchFanMode", nextState: "updating", icon: "st.thermostat.fan-on"
|
||||
state "updating", label:"Working", icon: "st.secondary.secondary"
|
||||
state "auto", label:'Fan: ${currentValue}', action:"switchFanMode", nextState: "on"
|
||||
state "on", label:'Fan: ${currentValue}', action:"switchFanMode", nextState: "off"
|
||||
state "off", label:'Fan: ${currentValue}', action:"switchFanMode", nextState: "circulate"
|
||||
state "circulate", label:'Fan: ${currentValue}', action:"switchFanMode", nextState: "auto"
|
||||
}
|
||||
standardTile("upButtonControl", "device.thermostatSetpoint", inactiveLabel: false, decoration: "flat") {
|
||||
state "setpoint", action:"raiseSetpoint", icon:"st.thermostat.thermostat-up"
|
||||
@@ -96,14 +96,14 @@ metadata {
|
||||
state "default", action:"refresh.refresh", icon:"st.secondary.refresh"
|
||||
}
|
||||
standardTile("resumeProgram", "device.resumeProgram", inactiveLabel: false, decoration: "flat") {
|
||||
state "resume", action:"resumeProgram", nextState: "updating", label:'Resume', icon:"st.samsung.da.oven_ic_send"
|
||||
state "resume", action:"resumeProgram", nextState: "updating", label:'Resume Schedule', icon:"st.samsung.da.oven_ic_send"
|
||||
state "updating", label:"Working", icon: "st.secondary.secondary"
|
||||
}
|
||||
valueTile("humidity", "device.humidity", decoration: "flat") {
|
||||
state "humidity", label:'${currentValue}%'
|
||||
state "humidity", label:'${currentValue}% humidity'
|
||||
}
|
||||
main "temperature"
|
||||
details(["temperature", "upButtonControl", "thermostatSetpoint", "currentStatus", "downButtonControl", "mode", "fanMode","resumeProgram", "humidity", "refresh"])
|
||||
details(["temperature", "upButtonControl", "thermostatSetpoint", "currentStatus", "downButtonControl", "mode", "resumeProgram", "refresh", "humidity"])
|
||||
}
|
||||
|
||||
preferences {
|
||||
@@ -154,9 +154,6 @@ def generateEvent(Map results) {
|
||||
} else if (name=="heatMode" || name=="coolMode" || name=="autoMode" || name=="auxHeatMode"){
|
||||
isChange = isStateChange(device, name, value.toString())
|
||||
event << [value: value.toString(), isStateChange: isChange, displayed: false]
|
||||
} else if (name=="thermostatFanMode"){
|
||||
isChange = isStateChange(device, name, value.toString())
|
||||
event << [value: value.toString(), isStateChange: isChange, displayed: false]
|
||||
} else if (name=="humidity") {
|
||||
isChange = isStateChange(device, name, value.toString())
|
||||
event << [value: value.toString(), isStateChange: isChange, displayed: false, unit: "%"]
|
||||
@@ -306,7 +303,7 @@ def modes() {
|
||||
}
|
||||
|
||||
def fanModes() {
|
||||
["on", "auto"]
|
||||
["off", "on", "auto", "circulate"]
|
||||
}
|
||||
|
||||
def switchMode() {
|
||||
@@ -335,15 +332,17 @@ def switchFanMode() {
|
||||
def returnCommand
|
||||
|
||||
switch (currentFanMode) {
|
||||
case "on":
|
||||
returnCommand = switchToFanMode("auto")
|
||||
case "fanAuto":
|
||||
returnCommand = switchToFanMode("fanOn")
|
||||
break
|
||||
case "auto":
|
||||
returnCommand = switchToFanMode("on")
|
||||
case "fanOn":
|
||||
returnCommand = switchToFanMode("fanCirculate")
|
||||
break
|
||||
case "fanCirculate":
|
||||
returnCommand = switchToFanMode("fanAuto")
|
||||
break
|
||||
|
||||
}
|
||||
if(!currentFanMode) { returnCommand = switchToFanMode("auto") }
|
||||
if(!currentFanMode) { returnCommand = switchToFanMode("fanOn") }
|
||||
returnCommand
|
||||
}
|
||||
|
||||
@@ -352,20 +351,25 @@ def switchToFanMode(nextMode) {
|
||||
log.debug "switching to fan mode: $nextMode"
|
||||
def returnCommand
|
||||
|
||||
if(nextMode == "auto") {
|
||||
if(!fanModes.contains("auto")) {
|
||||
if(nextMode == "fanAuto") {
|
||||
if(!fanModes.contains("fanAuto")) {
|
||||
returnCommand = fanAuto()
|
||||
} else {
|
||||
returnCommand = switchToFanMode("on")
|
||||
returnCommand = switchToFanMode("fanOn")
|
||||
}
|
||||
} else if(nextMode == "on") {
|
||||
if(!fanModes.contains("on")) {
|
||||
} else if(nextMode == "fanOn") {
|
||||
if(!fanModes.contains("fanOn")) {
|
||||
returnCommand = fanOn()
|
||||
} else {
|
||||
returnCommand = switchToFanMode("auto")
|
||||
returnCommand = switchToFanMode("fanCirculate")
|
||||
}
|
||||
} else if(nextMode == "fanCirculate") {
|
||||
if(!fanModes.contains("fanCirculate")) {
|
||||
returnCommand = fanCirculate()
|
||||
} else {
|
||||
returnCommand = switchToFanMode("fanAuto")
|
||||
}
|
||||
}
|
||||
|
||||
returnCommand
|
||||
}
|
||||
|
||||
@@ -375,10 +379,13 @@ def getDataByName(String name) {
|
||||
|
||||
def setThermostatMode(String value) {
|
||||
log.debug "setThermostatMode({$value})"
|
||||
|
||||
}
|
||||
|
||||
def setThermostatFanMode(String value) {
|
||||
|
||||
log.debug "setThermostatFanMode({$value})"
|
||||
|
||||
}
|
||||
|
||||
def generateModeEvent(mode) {
|
||||
@@ -465,48 +472,23 @@ def auto() {
|
||||
|
||||
def fanOn() {
|
||||
log.debug "fanOn"
|
||||
String fanMode = "on"
|
||||
def heatingSetpoint = device.currentValue("heatingSetpoint")
|
||||
def coolingSetpoint = device.currentValue("coolingSetpoint")
|
||||
def deviceId = device.deviceNetworkId.split(/\./).last()
|
||||
|
||||
def sendHoldType = holdType ? (holdType=="Temporary")? "nextTransition" : (holdType=="Permanent")? "indefinite" : "indefinite" : "indefinite"
|
||||
|
||||
def coolingValue = location.temperatureScale == "C"? convertCtoF(coolingSetpoint) : coolingSetpoint
|
||||
def heatingValue = location.temperatureScale == "C"? convertCtoF(heatingSetpoint) : heatingSetpoint
|
||||
|
||||
if (parent.setFanMode(this, heatingValue, coolingValue, deviceId, sendHoldType, fanMode)) {
|
||||
generateFanModeEvent(fanMode)
|
||||
} else {
|
||||
log.debug "Error setting new mode."
|
||||
def currentFanMode = device.currentState("thermostatFanMode")?.value
|
||||
generateModeEvent(currentFanMode) // reset the tile back
|
||||
}
|
||||
// parent.setFanMode (this,"on")
|
||||
}
|
||||
|
||||
def fanAuto() {
|
||||
log.debug "fanAuto"
|
||||
String fanMode = "auto"
|
||||
def heatingSetpoint = device.currentValue("heatingSetpoint")
|
||||
def coolingSetpoint = device.currentValue("coolingSetpoint")
|
||||
def deviceId = device.deviceNetworkId.split(/\./).last()
|
||||
|
||||
def sendHoldType = holdType ? (holdType=="Temporary")? "nextTransition" : (holdType=="Permanent")? "indefinite" : "indefinite" : "indefinite"
|
||||
|
||||
def coolingValue = location.temperatureScale == "C"? convertCtoF(coolingSetpoint) : coolingSetpoint
|
||||
def heatingValue = location.temperatureScale == "C"? convertCtoF(heatingSetpoint) : heatingSetpoint
|
||||
|
||||
if (parent.setFanMode(this, heatingValue, coolingValue, deviceId, sendHoldType, fanMode)) {
|
||||
generateFanModeEvent(fanMode)
|
||||
} else {
|
||||
log.debug "Error setting new mode."
|
||||
def currentFanMode = device.currentState("thermostatFanMode")?.value
|
||||
generateModeEvent(currentFanMode) // reset the tile back
|
||||
}
|
||||
// parent.setFanMode (this,"auto")
|
||||
}
|
||||
|
||||
def fanCirculate() {
|
||||
log.debug "fanCirculate"
|
||||
// parent.setFanMode (this,"circulate")
|
||||
}
|
||||
|
||||
|
||||
def fanOff() {
|
||||
log.debug "fanOff"
|
||||
// parent.setFanMode (this,"off")
|
||||
}
|
||||
|
||||
def generateSetpointEvent() {
|
||||
|
||||
|
||||
@@ -422,8 +422,7 @@ def pollChildren(child = null) {
|
||||
heatingSetpoint: stat.runtime.desiredHeat / 10,
|
||||
coolingSetpoint: stat.runtime.desiredCool / 10,
|
||||
thermostatMode: stat.settings.hvacMode,
|
||||
humidity: stat.runtime.actualHumidity,
|
||||
thermostatFanMode: stat.runtime.desiredFanMode
|
||||
humidity: stat.runtime.actualHumidity
|
||||
]
|
||||
|
||||
if (location.temperatureScale == "F")
|
||||
@@ -677,19 +676,9 @@ def setHold(child, heating, cooling, deviceId, sendHoldType) {
|
||||
|
||||
int h = heating * 10
|
||||
int c = cooling * 10
|
||||
|
||||
|
||||
def jsonRequestBody = '{"selection":{"selectionType":"thermostats","selectionMatch":"' + deviceId + '","includeRuntime":true},"functions": [{ "type": "setHold", "params": { "coolHoldTemp": '+c+',"heatHoldTemp": '+h+', "holdType": '+sendHoldType+' } } ]}'
|
||||
|
||||
def result = sendJson(child, jsonRequestBody)
|
||||
return result
|
||||
}
|
||||
|
||||
def setFanMode(child, heating, cooling, deviceId, sendHoldType, fanMode) {
|
||||
|
||||
int h = heating * 10
|
||||
int c = cooling * 10
|
||||
|
||||
|
||||
def jsonRequestBody = '{"selection":{"selectionType":"thermostats","selectionMatch":"' + deviceId + '","includeRuntime":true},"functions": [{ "type": "setHold", "params": { "coolHoldTemp": '+c+',"heatHoldTemp": '+h+', "holdType": '+sendHoldType+', "fan": '+fanMode+' } } ]}'
|
||||
def result = sendJson(child, jsonRequestBody)
|
||||
return result
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user