Merge branch 'master' of ssh://plrg.eecs.uci.edu/home/git/smartthings-infrastructure
[smartthings-infrastructure.git] / Thermostat / Thermostat.groovy
index b3f68b41f9319a1d231934393d4214fb46c80e7a..41a351cd2470043f10445ba3d10787c18649b8f4 100644 (file)
@@ -72,7 +72,7 @@ public class Thermostat {
                if (this.coolingSetpoint != coolingSetpoint) {
                        this.latestCoolingSetPoint = coolingSetpoint
                        this.coolingSetpoint = coolingSetpoint
-                       this.currentCoolingSetpoint = currentCoolingSetpoint
+                       this.currentCoolingSetpoint = coolingSetpoint
                        println("Cooling set point for the thermostat with id:$id is changed to $coolingSetpoint!")
                        sendEvent([name: "coolingSetpoint", value: "$coolingSetpoint", deviceId: this.id, descriptionText: "",
                                   displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
@@ -87,7 +87,7 @@ public class Thermostat {
                if (this.heatingSetpoint != heatingSetpoint) {
                        this.latestHeatingSetPoint = heatingSetpoint
                        this.heatingSetpoint = heatingSetpoint
-                       this.currentHeatingSetpoint = currentHeatingSetpoint
+                       this.currentHeatingSetpoint = heatingSetpoint
                        println("Heating set point for the thermostat with id:$id is changed to $heatingSetpoint!")
                        sendEvent([name: "heatingSetpoint", value: "$heatingSetpoint", deviceId: this.id, descriptionText: "",
                                   displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
@@ -116,7 +116,7 @@ public class Thermostat {
                if (this.thermostatMode != thermostatMode) {
                        this.thermostatLatestMode =thermostatMode
                        this.thermostatMode = thermostatMode
-                       this.currentThermostatMode = currentThermostatMode
+                       this.currentThermostatMode = thermostatMode
                        println("Mode of the thermostat with id:$id is changed to $thermostatMode!")
                        sendEvent([name: "thermostatMode", value: "$thermostatMode", deviceId: this.id, descriptionText: "",
                                   displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
@@ -129,7 +129,7 @@ public class Thermostat {
                        this.thermostatMode = "cool"
                        this.currentThermostatMode = "cool"
                        println("Mode of the thermostat with id:$id is changed to cool!")
-                       sendEvent([name: "cool", value: "cool", deviceId: this.id, descriptionText: "",
+                       sendEvent([name: "thermostatMode", value: "cool", deviceId: this.id, descriptionText: "",
                                   displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
        }
@@ -140,7 +140,7 @@ public class Thermostat {
                        this.thermostatMode = "heat"
                        this.currentThermostatMode = "heat"
                        println("Mode of the thermostat with id:$id is changed to heat!")
-                       sendEvent([name: "heat", value: "heat", deviceId: this.id, descriptionText: "",
+                       sendEvent([name: "thermostatMode", value: "heat", deviceId: this.id, descriptionText: "",
                                   displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
        }
@@ -151,7 +151,18 @@ public class Thermostat {
                        this.thermostatMode = "auto"
                        this.currentThermostatMode = "auto"
                        println("Mode of the thermostat with id:$id is changed to auto!")
-                       sendEvent([name: "auto", value: "auto", deviceId: this.id, descriptionText: "",
+                       sendEvent([name: "thermostatMode", value: "auto", deviceId: this.id, descriptionText: "",
+                                  displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+               }
+       }
+       
+       def emergencyHeat() {
+               if (this.thermostatMode != "emergencyHeat") {
+                       this.thermostatLatestMode = "emergencyHeat"
+                       this.thermostatMode = "emergencyHeat"
+                       this.currentThermostatMode = "emergencyHeat"
+                       println("Mode of the thermostat with id:$id is changed to emergencyHeat!")
+                       sendEvent([name: "thermostatMode", value: "emergencyHeat", deviceId: this.id, descriptionText: "",
                                   displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
        }
@@ -162,7 +173,7 @@ public class Thermostat {
                        this.thermostatMode = "off"
                        this.currentThermostatMode = "off"
                        println("Mode of the thermostat with id:$id is changed to off!")
-                       sendEvent([name: "off", value: "off", deviceId: this.id, descriptionText: "",
+                       sendEvent([name: "thermostatMode", value: "off", deviceId: this.id, descriptionText: "",
                                   displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
                }
        }