Skip to content

Commit 7aa8be4

Browse files
committed
ICP-448 Thermostat resource works weirdly.
Mapping between ST and SC fails at times due to improper implementation of capability attributes. Some violates the attribute types, others are not initialized to a valid value, most due to not having one. However, mapping requires right type and values. This PR fixes Ecobee thermostats attributes.
1 parent 1f09a22 commit 7aa8be4

File tree

1 file changed

+41
-19
lines changed

1 file changed

+41
-19
lines changed

devicetypes/smartthings/ecobee-thermostat.src/ecobee-thermostat.groovy

Lines changed: 41 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ metadata {
3232
command "switchMode"
3333
command "switchFanMode"
3434

35-
attribute "thermostatSetpoint", "number"
35+
attribute "displayThermostatSetpoint", "string" // Added to be able to show "Auto"/"Off" keeping attribute thermostatSetpoint a number
3636
attribute "thermostatStatus", "string"
3737
attribute "maxHeatingSetpoint", "number"
3838
attribute "minHeatingSetpoint", "number"
@@ -70,7 +70,7 @@ metadata {
7070
state "heat", action:"switchMode", nextState: "updating", icon: "st.thermostat.heat"
7171
state "cool", action:"switchMode", nextState: "updating", icon: "st.thermostat.cool"
7272
state "auto", action:"switchMode", nextState: "updating", icon: "st.thermostat.auto"
73-
state "auxHeatOnly", action:"switchMode", icon: "st.thermostat.emergency-heat"
73+
state "emergency heat", label:"auxHeatOnly", action:"switchMode", icon: "st.thermostat.emergency-heat" // emergency heat = auxHeatOnly
7474
state "updating", label:"Working", icon: "st.secondary.secondary"
7575
}
7676
standardTile("fanMode", "device.thermostatFanMode", inactiveLabel: false, decoration: "flat") {
@@ -81,8 +81,8 @@ metadata {
8181
standardTile("upButtonControl", "device.thermostatSetpoint", inactiveLabel: false, decoration: "flat") {
8282
state "setpoint", action:"raiseSetpoint", icon:"st.thermostat.thermostat-up"
8383
}
84-
valueTile("thermostatSetpoint", "device.thermostatSetpoint", width: 1, height: 1, decoration: "flat") {
85-
state "thermostatSetpoint", label:'${currentValue}'
84+
valueTile("displayThermostatSetpoint", "device.displayThermostatSetpoint", width: 1, height: 1, decoration: "flat") {
85+
state "displayThermostatSetpoint", label:'${currentValue}'
8686
}
8787
valueTile("currentStatus", "device.thermostatStatus", height: 1, width: 2, decoration: "flat") {
8888
state "thermostatStatus", label:'${currentValue}', backgroundColor:"#ffffff"
@@ -113,7 +113,7 @@ metadata {
113113
state "humidity", label:'${currentValue}%'
114114
}
115115
main "temperature"
116-
details(["temperature", "upButtonControl", "thermostatSetpoint", "currentStatus", "downButtonControl", "mode", "fanMode","humidity", "resumeProgram", "refresh"])
116+
details(["temperature", "upButtonControl", "displayThermostatSetpoint", "currentStatus", "downButtonControl", "mode", "fanMode","humidity", "resumeProgram", "refresh"])
117117
}
118118

119119
preferences {
@@ -452,10 +452,10 @@ def emergencyHeat() {
452452
}
453453

454454
def auxHeatOnly() {
455-
log.debug "auxHeatOnly"
455+
log.debug "auxHeatOnly = emergency heat"
456456
def deviceId = device.deviceNetworkId.split(/\./).last()
457457
if (parent.setMode ("auxHeatOnly", deviceId))
458-
generateModeEvent("auxHeatOnly")
458+
generateModeEvent("emergency heat") // emergency heat = auxHeatOnly
459459
else {
460460
log.debug "Error setting new mode."
461461
def currentMode = device.currentState("thermostatMode")?.value
@@ -574,17 +574,23 @@ def generateSetpointEvent() {
574574
sendEvent("name":"heatingSetpoint", "value":heatingSetpoint, "unit":location.temperatureScale)
575575
sendEvent("name":"coolingSetpoint", "value":coolingSetpoint, "unit":location.temperatureScale)
576576

577+
def averageSetpoint = roundC((heatingSetpoint + coolingSetpoint) / 2)
577578
if (mode == "heat") {
578579
sendEvent("name":"thermostatSetpoint", "value":heatingSetpoint, "unit":location.temperatureScale)
580+
sendEvent("name":"displayThermostatSetpoint", "value":heatingSetpoint, "unit":location.temperatureScale, displayed: false)
579581
}
580582
else if (mode == "cool") {
581583
sendEvent("name":"thermostatSetpoint", "value":coolingSetpoint, "unit":location.temperatureScale)
584+
sendEvent("name":"displayThermostatSetpoint", "value":coolingSetpoint, "unit":location.temperatureScale, displayed: false)
582585
} else if (mode == "auto") {
583-
sendEvent("name":"thermostatSetpoint", "value":"Auto")
586+
sendEvent("name":"thermostatSetpoint", "value":averageSetpoint, "unit":location.temperatureScale)
587+
sendEvent("name":"displayThermostatSetpoint", "value":"Auto", displayed: false)
584588
} else if (mode == "off") {
585-
sendEvent("name":"thermostatSetpoint", "value":"Off")
586-
} else if (mode == "auxHeatOnly") {
589+
sendEvent("name":"thermostatSetpoint", "value":averageSetpoint, "unit":location.temperatureScale)
590+
sendEvent("name":"displayThermostatSetpoint", "value":"Off", displayed: false)
591+
} else if (mode == "emergency heat") { // emergency heat = auxHeatOnly
587592
sendEvent("name":"thermostatSetpoint", "value":heatingSetpoint, "unit":location.temperatureScale)
593+
sendEvent("name":"displayThermostatSetpoint", "value":heatingSetpoint, "unit":location.temperatureScale, displayed: false)
588594
}
589595
}
590596

@@ -621,13 +627,14 @@ void raiseSetpoint() {
621627
targetvalue = thermostatSetpoint ? thermostatSetpoint : 0
622628
targetvalue = location.temperatureScale == "F"? targetvalue + 1 : targetvalue + 0.5
623629

624-
if ((mode == "heat" || mode == "auxHeatOnly") && targetvalue > maxHeatingSetpoint) {
630+
if ((mode == "heat" || mode == "emergency heat") && targetvalue > maxHeatingSetpoint) { // emergency heat = auxHeatOnly
625631
targetvalue = maxHeatingSetpoint
626632
} else if (mode == "cool" && targetvalue > maxCoolingSetpoint) {
627633
targetvalue = maxCoolingSetpoint
628634
}
629635

630636
sendEvent("name":"thermostatSetpoint", "value":targetvalue, "unit":location.temperatureScale, displayed: false)
637+
sendEvent("name":"displayThermostatSetpoint", "value":targetvalue, "unit":location.temperatureScale, displayed: false)
631638
log.info "In mode $mode raiseSetpoint() to $targetvalue"
632639

633640
runIn(3, "alterSetpoint", [data: [value:targetvalue], overwrite: true]) //when user click button this runIn will be overwrite
@@ -666,13 +673,14 @@ void lowerSetpoint() {
666673
targetvalue = thermostatSetpoint ? thermostatSetpoint : 0
667674
targetvalue = location.temperatureScale == "F"? targetvalue - 1 : targetvalue - 0.5
668675

669-
if ((mode == "heat" || mode == "auxHeatOnly") && targetvalue < minHeatingSetpoint) {
676+
if ((mode == "heat" || mode == "emergency heat") && targetvalue < minHeatingSetpoint) { // emergency heat = auxHeatOnly
670677
targetvalue = minHeatingSetpoint
671678
} else if (mode == "cool" && targetvalue < minCoolingSetpoint) {
672679
targetvalue = minCoolingSetpoint
673680
}
674681

675682
sendEvent("name":"thermostatSetpoint", "value":targetvalue, "unit":location.temperatureScale, displayed: false)
683+
sendEvent("name":"displayThermostatSetpoint", "value":targetvalue, "unit":location.temperatureScale, displayed: false)
676684
log.info "In mode $mode lowerSetpoint() to $targetvalue"
677685

678686
runIn(3, "alterSetpoint", [data: [value:targetvalue], overwrite: true]) //when user click button this runIn will be overwrite
@@ -706,7 +714,7 @@ void alterSetpoint(temp) {
706714
}
707715

708716
//step1: check thermostatMode, enforce limits before sending request to cloud
709-
if (mode == "heat" || mode == "auxHeatOnly"){
717+
if (mode == "heat" || mode == "emergency heat"){ // emergency heat = auxHeatOnly
710718
if (temp.value > coolingSetpoint){
711719
targetHeatingSetpoint = temp.value
712720
targetCoolingSetpoint = temp.value
@@ -735,15 +743,18 @@ void alterSetpoint(temp) {
735743

736744
if (parent.setHold(heatingValue, coolingValue, deviceId, sendHoldType)) {
737745
sendEvent("name": "thermostatSetpoint", "value": temp.value, displayed: false)
746+
sendEvent("name": "displayThermostatSetpoint", "value": temp.value, displayed: false)
738747
sendEvent("name": "heatingSetpoint", "value": targetHeatingSetpoint, "unit": location.temperatureScale)
739748
sendEvent("name": "coolingSetpoint", "value": targetCoolingSetpoint, "unit": location.temperatureScale)
740749
log.debug "alterSetpoint in mode $mode succeed change setpoint to= ${temp.value}"
741750
} else {
742751
log.error "Error alterSetpoint()"
743-
if (mode == "heat" || mode == "auxHeatOnly"){
752+
if (mode == "heat" || mode == "emergency heat"){ // emergency heat = auxHeatOnly
744753
sendEvent("name": "thermostatSetpoint", "value": heatingSetpoint.toString(), displayed: false)
754+
sendEvent("name": "displayThermostatSetpoint", "value": heatingSetpoint.toString(), displayed: false)
745755
} else if (mode == "cool") {
746756
sendEvent("name": "thermostatSetpoint", "value": coolingSetpoint.toString(), displayed: false)
757+
sendEvent("name": "displayThermostatSetpoint", "value": heatingSetpoint.toString(), displayed: false)
747758
}
748759
}
749760

@@ -759,6 +770,7 @@ def generateStatusEvent() {
759770
def coolingSetpoint = device.currentValue("coolingSetpoint")
760771
def temperature = device.currentValue("temperature")
761772
def statusText
773+
def operatingState = "idle"
762774

763775
log.debug "Generate Status Event for Mode = ${mode}"
764776
log.debug "Temperature = ${temperature}"
@@ -767,27 +779,37 @@ def generateStatusEvent() {
767779
log.debug "HVAC Mode = ${mode}"
768780

769781
if (mode == "heat") {
770-
if (temperature >= heatingSetpoint)
782+
if (temperature >= heatingSetpoint) {
771783
statusText = "Right Now: Idle"
772-
else
784+
} else {
773785
statusText = "Heating to ${heatingSetpoint} ${location.temperatureScale}"
786+
operatingState = "heating"
787+
}
774788
} else if (mode == "cool") {
775-
if (temperature <= coolingSetpoint)
789+
if (temperature <= coolingSetpoint) {
776790
statusText = "Right Now: Idle"
777-
else
791+
} else {
778792
statusText = "Cooling to ${coolingSetpoint} ${location.temperatureScale}"
793+
operatingState = "cooling"
794+
}
779795
} else if (mode == "auto") {
780796
statusText = "Right Now: Auto"
797+
if (temperature < heatingSetpoint) {
798+
operatingState = "heating"
799+
} else if (temperature > coolingSetpoint) {
800+
operatingState = "cooling"
801+
}
781802
} else if (mode == "off") {
782803
statusText = "Right Now: Off"
783-
} else if (mode == "auxHeatOnly") {
804+
} else if (mode == "emergency heat") { // emergency heat = auxHeatOnly
784805
statusText = "Emergency Heat"
785806
} else {
786807
statusText = "?"
787808
}
788809

789810
log.debug "Generate Status Event = ${statusText}"
790811
sendEvent("name":"thermostatStatus", "value":statusText, "description":statusText, displayed: true)
812+
sendEvent("name":"thermostatOperatingState", "value":operatingState, "description":operatingState, displayed: false)
791813
}
792814

793815
def generateActivityFeedsEvent(notificationMessage) {

0 commit comments

Comments
 (0)