Commit #8: New version of extractor with running the preferences method make things...
[smartthings-infrastructure.git] / Thermostat / Thermostat.groovy
1 //Create a class for thermostat device
2 package Thermostat
3 import Timer.SimulatedTimer
4
5 public class Thermostat {
6         private int id
7         private String label
8         private String displayName
9         private int temperature
10         private int currentCoolingSetpoint
11         private int currentHeatingSetpoint
12         private int coolingSetpoint
13         private int thermostatSetpoint
14         private int heatingSetpoint
15         private List coolingSetpointRange
16         private List thermostatSetpointRange
17         private List heatingSetpointRange
18         private List supportedThermostatFanModes
19         private List supportedThermostatModes
20         private String thermostatOperatingState
21         private String thermostatFanMode
22         private String thermostatMode
23         def sendEvent
24         def timers
25
26
27         Thermostat(Closure sendEvent, int id, String label, String displayName, int temperature, int currentCoolingSetpoint, int currentHeatingSetpoint, int coolingSetpoint, 
28                    int thermostatSetpoint, int heatingSetpoint, List coolingSetpointRange, List thermostatSetpointRange, List heatingSetpointRange, 
29                    List supportedThermostatFanModes, List supportedThermostatModes, String thermostatOperatingState, String thermostatFanMode, String thermostatMode) {
30                 this.id = id
31                 this.label = label
32                 this.sendEvent = sendEvent
33                 this.temperature = temperature
34                 this.currentCoolingSetpoint = currentCoolingSetpoint
35                 this.currentHeatingSetpoint = currentHeatingSetpoint
36                 this.coolingSetpoint = coolingSetpoint
37                 this.thermostatSetpoint = thermostatSetpoint
38                 this.heatingSetpoint = heatingSetpoint
39                 this.coolingSetpointRange = coolingSetpointRange
40                 this.thermostatSetpointRange = thermostatSetpointRange
41                 this.heatingSetpointRange = heatingSetpointRange
42                 this.supportedThermostatFanModes = supportedThermostatFanModes
43                 this.supportedThermostatModes = supportedThermostatModes
44                 this.thermostatOperatingState = thermostatOperatingState
45                 this.thermostatFanMode = thermostatFanMode
46                 this.thermostatMode = thermostatMode
47         }
48
49
50         //By Apps
51         def setCoolingSetpoint(int coolingSetpoint) {
52                 this.coolingSetpoint = coolingSetpoint
53                 this.currentCoolingSetpoint = currentCoolingSetpoint
54                 println("Cooling set point for the thermostat with id:$id is changed to $coolingSetpoint!")
55         }
56
57         def setHeatingSetpoint(int heatingSetpoint) {
58                 this.heatingSetpoint = heatingSetpoint
59                 this.currentHeatingSetpoint = currentHeatingSetpoint
60                 println("Heating set point for the thermostat with id:$id is changed to $heatingSetpoint!")
61         }
62
63         def setSchedule() {
64                 //Not implemented yet
65         }
66
67         def setThermostatFanMode(String thermostatFanMode) {
68                 this.thermostatFanMode = thermostatFanMode
69                 println("Fan mode of the thermostat with id:$id is changed to $thermostatFanMode!")
70         }
71
72         def setThermostatMode(String thermostatMode) {
73                 this.thermostatMode = thermostatMode
74                 println("Mode of the thermostat with id:$id is changed to $thermostatMode!")
75         }
76
77
78         //By Model Checker
79         /*def setValue(String value) {
80                 println("the door with id:$id is $value!")
81                 this.lockLatestValue = this.lockState
82                 this.lockState = value
83                 this.currentLock = value
84         }*/
85 }