mirror of
https://github.com/mtan93/SmartThingsPublic.git
synced 2026-03-23 21:03:54 +00:00
Ecobee fanMode available - https://smartthings.atlassian.net/browse/DVCSMP-1501
https://smartthings.atlassian.net/browse/DVCSMP-1501
This commit is contained in:
@@ -30,6 +30,7 @@ metadata {
|
|||||||
command "lowerSetpoint"
|
command "lowerSetpoint"
|
||||||
command "resumeProgram"
|
command "resumeProgram"
|
||||||
command "switchMode"
|
command "switchMode"
|
||||||
|
command "switchFanMode"
|
||||||
|
|
||||||
attribute "thermostatSetpoint","number"
|
attribute "thermostatSetpoint","number"
|
||||||
attribute "thermostatStatus","string"
|
attribute "thermostatStatus","string"
|
||||||
@@ -63,10 +64,9 @@ metadata {
|
|||||||
state "updating", label:"Working", icon: "st.secondary.secondary"
|
state "updating", label:"Working", icon: "st.secondary.secondary"
|
||||||
}
|
}
|
||||||
standardTile("fanMode", "device.thermostatFanMode", inactiveLabel: false, decoration: "flat") {
|
standardTile("fanMode", "device.thermostatFanMode", inactiveLabel: false, decoration: "flat") {
|
||||||
state "auto", label:'Fan: ${currentValue}', action:"switchFanMode", nextState: "on"
|
state "auto", action:"switchFanMode", nextState: "updating", icon: "st.thermostat.fan-auto"
|
||||||
state "on", label:'Fan: ${currentValue}', action:"switchFanMode", nextState: "off"
|
state "on", action:"switchFanMode", nextState: "updating", icon: "st.thermostat.fan-on"
|
||||||
state "off", label:'Fan: ${currentValue}', action:"switchFanMode", nextState: "circulate"
|
state "updating", label:"Working", icon: "st.secondary.secondary"
|
||||||
state "circulate", label:'Fan: ${currentValue}', action:"switchFanMode", nextState: "auto"
|
|
||||||
}
|
}
|
||||||
standardTile("upButtonControl", "device.thermostatSetpoint", inactiveLabel: false, decoration: "flat") {
|
standardTile("upButtonControl", "device.thermostatSetpoint", inactiveLabel: false, decoration: "flat") {
|
||||||
state "setpoint", action:"raiseSetpoint", icon:"st.thermostat.thermostat-up"
|
state "setpoint", action:"raiseSetpoint", icon:"st.thermostat.thermostat-up"
|
||||||
@@ -96,14 +96,14 @@ metadata {
|
|||||||
state "default", action:"refresh.refresh", icon:"st.secondary.refresh"
|
state "default", action:"refresh.refresh", icon:"st.secondary.refresh"
|
||||||
}
|
}
|
||||||
standardTile("resumeProgram", "device.resumeProgram", inactiveLabel: false, decoration: "flat") {
|
standardTile("resumeProgram", "device.resumeProgram", inactiveLabel: false, decoration: "flat") {
|
||||||
state "resume", action:"resumeProgram", nextState: "updating", label:'Resume Schedule', icon:"st.samsung.da.oven_ic_send"
|
state "resume", action:"resumeProgram", nextState: "updating", label:'Resume', icon:"st.samsung.da.oven_ic_send"
|
||||||
state "updating", label:"Working", icon: "st.secondary.secondary"
|
state "updating", label:"Working", icon: "st.secondary.secondary"
|
||||||
}
|
}
|
||||||
valueTile("humidity", "device.humidity", decoration: "flat") {
|
valueTile("humidity", "device.humidity", decoration: "flat") {
|
||||||
state "humidity", label:'${currentValue}% humidity'
|
state "humidity", label:'${currentValue}%'
|
||||||
}
|
}
|
||||||
main "temperature"
|
main "temperature"
|
||||||
details(["temperature", "upButtonControl", "thermostatSetpoint", "currentStatus", "downButtonControl", "mode", "resumeProgram", "refresh", "humidity"])
|
details(["temperature", "upButtonControl", "thermostatSetpoint", "currentStatus", "downButtonControl", "mode", "fanMode","resumeProgram", "humidity", "refresh"])
|
||||||
}
|
}
|
||||||
|
|
||||||
preferences {
|
preferences {
|
||||||
@@ -154,6 +154,9 @@ def generateEvent(Map results) {
|
|||||||
} else if (name=="heatMode" || name=="coolMode" || name=="autoMode" || name=="auxHeatMode"){
|
} else if (name=="heatMode" || name=="coolMode" || name=="autoMode" || name=="auxHeatMode"){
|
||||||
isChange = isStateChange(device, name, value.toString())
|
isChange = isStateChange(device, name, value.toString())
|
||||||
event << [value: value.toString(), isStateChange: isChange, displayed: false]
|
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") {
|
} else if (name=="humidity") {
|
||||||
isChange = isStateChange(device, name, value.toString())
|
isChange = isStateChange(device, name, value.toString())
|
||||||
event << [value: value.toString(), isStateChange: isChange, displayed: false, unit: "%"]
|
event << [value: value.toString(), isStateChange: isChange, displayed: false, unit: "%"]
|
||||||
@@ -303,7 +306,7 @@ def modes() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def fanModes() {
|
def fanModes() {
|
||||||
["off", "on", "auto", "circulate"]
|
["on", "auto"]
|
||||||
}
|
}
|
||||||
|
|
||||||
def switchMode() {
|
def switchMode() {
|
||||||
@@ -332,17 +335,15 @@ def switchFanMode() {
|
|||||||
def returnCommand
|
def returnCommand
|
||||||
|
|
||||||
switch (currentFanMode) {
|
switch (currentFanMode) {
|
||||||
case "fanAuto":
|
case "on":
|
||||||
returnCommand = switchToFanMode("fanOn")
|
returnCommand = switchToFanMode("auto")
|
||||||
break
|
break
|
||||||
case "fanOn":
|
case "auto":
|
||||||
returnCommand = switchToFanMode("fanCirculate")
|
returnCommand = switchToFanMode("on")
|
||||||
break
|
|
||||||
case "fanCirculate":
|
|
||||||
returnCommand = switchToFanMode("fanAuto")
|
|
||||||
break
|
break
|
||||||
|
|
||||||
}
|
}
|
||||||
if(!currentFanMode) { returnCommand = switchToFanMode("fanOn") }
|
if(!currentFanMode) { returnCommand = switchToFanMode("auto") }
|
||||||
returnCommand
|
returnCommand
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -351,25 +352,20 @@ def switchToFanMode(nextMode) {
|
|||||||
log.debug "switching to fan mode: $nextMode"
|
log.debug "switching to fan mode: $nextMode"
|
||||||
def returnCommand
|
def returnCommand
|
||||||
|
|
||||||
if(nextMode == "fanAuto") {
|
if(nextMode == "auto") {
|
||||||
if(!fanModes.contains("fanAuto")) {
|
if(!fanModes.contains("auto")) {
|
||||||
returnCommand = fanAuto()
|
returnCommand = fanAuto()
|
||||||
} else {
|
} else {
|
||||||
returnCommand = switchToFanMode("fanOn")
|
returnCommand = switchToFanMode("on")
|
||||||
}
|
}
|
||||||
} else if(nextMode == "fanOn") {
|
} else if(nextMode == "on") {
|
||||||
if(!fanModes.contains("fanOn")) {
|
if(!fanModes.contains("on")) {
|
||||||
returnCommand = fanOn()
|
returnCommand = fanOn()
|
||||||
} else {
|
} else {
|
||||||
returnCommand = switchToFanMode("fanCirculate")
|
returnCommand = switchToFanMode("auto")
|
||||||
}
|
|
||||||
} else if(nextMode == "fanCirculate") {
|
|
||||||
if(!fanModes.contains("fanCirculate")) {
|
|
||||||
returnCommand = fanCirculate()
|
|
||||||
} else {
|
|
||||||
returnCommand = switchToFanMode("fanAuto")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
returnCommand
|
returnCommand
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -379,13 +375,10 @@ def getDataByName(String name) {
|
|||||||
|
|
||||||
def setThermostatMode(String value) {
|
def setThermostatMode(String value) {
|
||||||
log.debug "setThermostatMode({$value})"
|
log.debug "setThermostatMode({$value})"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def setThermostatFanMode(String value) {
|
def setThermostatFanMode(String value) {
|
||||||
|
|
||||||
log.debug "setThermostatFanMode({$value})"
|
log.debug "setThermostatFanMode({$value})"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def generateModeEvent(mode) {
|
def generateModeEvent(mode) {
|
||||||
@@ -472,23 +465,48 @@ def auto() {
|
|||||||
|
|
||||||
def fanOn() {
|
def fanOn() {
|
||||||
log.debug "fanOn"
|
log.debug "fanOn"
|
||||||
// parent.setFanMode (this,"on")
|
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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def fanAuto() {
|
def fanAuto() {
|
||||||
log.debug "fanAuto"
|
log.debug "fanAuto"
|
||||||
// parent.setFanMode (this,"auto")
|
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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def fanCirculate() {
|
|
||||||
log.debug "fanCirculate"
|
|
||||||
// parent.setFanMode (this,"circulate")
|
|
||||||
}
|
|
||||||
|
|
||||||
def fanOff() {
|
|
||||||
log.debug "fanOff"
|
|
||||||
// parent.setFanMode (this,"off")
|
|
||||||
}
|
|
||||||
|
|
||||||
def generateSetpointEvent() {
|
def generateSetpointEvent() {
|
||||||
|
|
||||||
|
|||||||
@@ -422,7 +422,8 @@ def pollChildren(child = null) {
|
|||||||
heatingSetpoint: stat.runtime.desiredHeat / 10,
|
heatingSetpoint: stat.runtime.desiredHeat / 10,
|
||||||
coolingSetpoint: stat.runtime.desiredCool / 10,
|
coolingSetpoint: stat.runtime.desiredCool / 10,
|
||||||
thermostatMode: stat.settings.hvacMode,
|
thermostatMode: stat.settings.hvacMode,
|
||||||
humidity: stat.runtime.actualHumidity
|
humidity: stat.runtime.actualHumidity,
|
||||||
|
thermostatFanMode: stat.runtime.desiredFanMode
|
||||||
]
|
]
|
||||||
|
|
||||||
if (location.temperatureScale == "F")
|
if (location.temperatureScale == "F")
|
||||||
@@ -676,9 +677,19 @@ def setHold(child, heating, cooling, deviceId, sendHoldType) {
|
|||||||
|
|
||||||
int h = heating * 10
|
int h = heating * 10
|
||||||
int c = cooling * 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 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)
|
def result = sendJson(child, jsonRequestBody)
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user