Merge branch 'master' of ssh://plrg.eecs.uci.edu/home/git/smartthings-infrastructure
[smartthings-infrastructure.git] / Thermostat / Thermostats.groovy
index 66957ddff3d8de686730634a06b58ce967ee6f94..d77af21e2a2d2cfe8095c53092df97abd594e7cb 100644 (file)
@@ -50,7 +50,11 @@ public class Thermostats{
                this.heatingSetpoint = initHeatingSetpoint
                
                def initThermostatSetpoint = Verify.getIntFromList(50, 60, 70)
+<<<<<<< HEAD
+               this.thermostatSetpoint = initThermostatSetpoint
+=======
                this.currentHeatingSetpoint = initThermostatSetpoint
+>>>>>>> e378d6a65b25030f8914dc97f04b81ddff351d9c
                
                def initFanMode = Verify.getInt(0,4)
                if (initFanMode == 0) {
@@ -108,15 +112,19 @@ public class Thermostats{
 
        //By Apps
        def setCoolingSetpoint(int coolingSetpoint) {
-               thermostats[0].setCoolingSetpoint(coolingSetpoint)
-               this.currentCoolingSetpoint = coolingSetpoint
-               this.coolingSetpoint = coolingSetpoint
+               if (coolingSetpoint != this.coolingSetpoint) {
+                       thermostats[0].setCoolingSetpoint(coolingSetpoint)
+                       this.currentCoolingSetpoint = coolingSetpoint
+                       this.coolingSetpoint = coolingSetpoint
+               }
        }
 
        def setHeatingSetpoint(int heatingSetpoint) {
-               thermostats[0].setHeatingSetpoint(heatingSetpoint)
-               this.currentHeatingSetpoint = heatingSetpoint
-               this.heatingSetpoint = heatingSetpoint
+               if (heatingSetpoint != this.heatingSetpoint) {
+                       thermostats[0].setHeatingSetpoint(heatingSetpoint)
+                       this.currentHeatingSetpoint = heatingSetpoint
+                       this.heatingSetpoint = heatingSetpoint
+               }
        }
 
        def setSchedule() {
@@ -124,51 +132,67 @@ public class Thermostats{
        }
 
        def setThermostatFanMode(String thermostatFanMode) {
-               thermostats[0].setThermostatFanMode(thermostatFanMode)
-               this.thermostatFanMode = thermostatFanMode
+               if (thermostatFanMode != this.thermostatFanMode) {
+                       thermostats[0].setThermostatFanMode(thermostatFanMode)
+                       this.thermostatFanMode = thermostatFanMode
+               }
        }
 
        def setThermostatMode(String thermostatMode) {
-               thermostats[0].setThermostatMode(thermostatMode)
-               this.thermostatMode = thermostatMode
-               this.currentThermostatMode = currentThermostatMode
+               if (thermostatMode != this.thermostatMode) {
+                       thermostats[0].setThermostatMode(thermostatMode)
+                       this.thermostatMode = thermostatMode
+                       this.currentThermostatMode = currentThermostatMode
+               }
        }
 
        def cool() {
-               thermostats[0].cool()
-               this.thermostatMode = "cool"
-               this.currentThermostatMode = "cool"
+               if (thermostatMode != "cool") {
+                       thermostats[0].cool()
+                       this.thermostatMode = "cool"
+                       this.currentThermostatMode = "cool"
+               }
        }
 
        def heat() {
-               thermostats[0].heat()
-               this.thermostatMode = "heat"
-               this.currentThermostatMode = "heat"
+               if (thermostatMode != "heat") {
+                       thermostats[0].heat()
+                       this.thermostatMode = "heat"
+                       this.currentThermostatMode = "heat"
+               }
        }
 
        def auto() {
-               thermostats[0].auto()
-               this.thermostatMode = "auto"
-               this.currentThermostatMode = "auto"
+               if (thermostatMode != "auto") {
+                       thermostats[0].auto()
+                       this.thermostatMode = "auto"
+                       this.currentThermostatMode = "auto"
+               }
        }
 
        def off() {
-               thermostats[0].off()
-               this.thermostatMode = "off"
-               this.currentThermostatMode = "off"
+               if (thermostatMode != "off") {
+                       thermostats[0].off()
+                       this.thermostatMode = "off"
+                       this.currentThermostatMode = "off"
+               }
        }
 
        def setClimate(String info, String givenClimateName) {
-               thermostats[0].setClimate(info, givenClimateName)
-               this.climateName = givenClimateName
+               if (givenClimateName != climateName) {
+                       thermostats[0].setClimate(info, givenClimateName)
+                       this.climateName = givenClimateName
+               }
        }
 
        def setHold(String info1, int coolingSetpoint, int heatingSetpoint, String info2, String info3) {
-               thermostats[0].setHold(info1, coolingSetpoint, heatingSetpoint, info2, info3)
-               this.currentCoolingSetpoint = coolingSetpoint
-               this.coolingSetpoint = coolingSetpoint
-               this.currentHeatingSetpoint = heatingSetpoint
-               this.heatingSetpoint = heatingSetpoint
+               if ((coolingSetpoint != this.coolingSetpoint) || (heatingSetpoint != this.heatingSetpoint)) {
+                       thermostats[0].setHold(info1, coolingSetpoint, heatingSetpoint, info2, info3)
+                       this.currentCoolingSetpoint = coolingSetpoint
+                       this.coolingSetpoint = coolingSetpoint
+                       this.currentHeatingSetpoint = heatingSetpoint
+                       this.heatingSetpoint = heatingSetpoint
+               }
        }
 
        //By Model Checker