Commit #10: more classes
[smartthings-infrastructure.git] / Thermostat / Thermostats.groovy
index 994506677a68aa31bb30c8b1227cce9aa22b4eb5..cc955d17e74849d1c73c6b8c333f8827c6c13180 100644 (file)
@@ -125,11 +125,49 @@ public class Thermostats{
 
        //By Model Checker
        def setValue(LinkedHashMap eventDataMap) {
-               if (eventDataMap["value"] != thermostats[0].thermostatMode) {
-                       thermostats[0].setValue(eventDataMap["value"])
-                       this.thermostatMode = thermostats[0].thermostatMode
-                       this.currentThermostatMode = thermostats[0].currentThermostatMode
-                       sendEvent(eventDataMap)
+               if (eventDataMap["name"] == "temperature") {
+                       if (eventDataMap["value"] != thermostats[0].temperature) {
+                               thermostats[0].setValue(eventDataMap["value"], "temperature")
+                               this.temperature = thermostats[0].temperature
+                               sendEvent(eventDataMap)
+                       }
+               } else if (eventDataMap["name"] == "heatingSetpoint") {
+                       if (eventDataMap["value"] != thermostats[0].heatingSetpoint) {
+                               thermostats[0].setValue(eventDataMap["value"], "heatingSetpoint")
+                               this.heatingSetpoint = thermostats[0].heatingSetpoint
+                               sendEvent(eventDataMap)
+                       }
+               } else if (eventDataMap["name"] == "coolingSetpoint") {
+                       if (eventDataMap["value"] != thermostats[0].coolingSetpoint) {
+                               thermostats[0].setValue(eventDataMap["value"], "coolingSetpoint")
+                               this.coolingSetpoint = thermostats[0].coolingSetpoint
+                               sendEvent(eventDataMap)
+                       }
+               } else if (eventDataMap["name"] == "thermostatSetpoint") {
+                       if (eventDataMap["value"] != thermostats[0].thermostatSetpoint) {
+                               thermostats[0].setValue(eventDataMap["value"], "thermostatSetpoint")
+                               this.thermostatSetpoint = thermostats[0].thermostatSetpoint
+                               sendEvent(eventDataMap)
+                       }
+               } else if (eventDataMap["name"] == "thermostatMode") {
+                       if (eventDataMap["value"] != thermostats[0].thermostatMode) {
+                               thermostats[0].setValue(eventDataMap["value"], "thermostatMode")
+                               this.thermostatMode = thermostats[0].thermostatMode
+                               this.currentThermostatMode = thermostats[0].currentThermostatMode
+                               sendEvent(eventDataMap)
+                       }
+               } else if (eventDataMap["name"] == "thermostatFanMode") {
+                       if (eventDataMap["value"] != thermostats[0].thermostatFanMode) {
+                               thermostats[0].setValue(eventDataMap["value"], "thermostatFanMode")
+                               this.thermostatFanMode = thermostats[0].thermostatFanMode
+                               sendEvent(eventDataMap)
+                       }
+               } else if (eventDataMap["name"] == "thermostatOperatingState") {
+                       if (eventDataMap["value"] != thermostats[0].thermostatOperatingState) {
+                               thermostats[0].setValue(eventDataMap["value"], "thermostatOperatingState")
+                               this.thermostatOperatingState = thermostats[0].thermostatOperatingState
+                               sendEvent(eventDataMap)
+                       }
                }
        }