1 //Create a class for thermostat device
3 import Timer.SimulatedTimer
5 public class Thermostats{
11 //When we have only one device
12 private String id = "thermostatID0"
13 private String label = "thermostat0"
14 private String displayName = "thermostat0"
15 private int temperature = 66
16 private int currentCoolingSetpoint = 70
17 private int currentHeatingSetpoint = 50
18 private int coolingSetpoint = 70
19 private int thermostatSetpoint = 60
20 private int heatingSetpoint = 50
21 private coolingSetpointRange = [70, 90]
22 private thermostatSetpointRange = [50, 70]
23 private heatingSetpointRange = [20, 50]
24 private supportedThermostatFanModes = ["auto", "fanCirculate", "circulate", "fanOn", "on"]
25 private supportedThermostatModes = ["auto", "cool", "emergencyHeat", "heat", "off"]
26 private String thermostatOperatingState = "cooling"
27 private String thermostatFanMode = "auto"
28 private String thermostatMode = "auto"
30 Thermostats(Closure sendEvent, int deviceNumbers) {
31 this.sendEvent = sendEvent
32 this.timers = new SimulatedTimer()
33 this.deviceNumbers = deviceNumbers
36 thermostats.add(new Thermostat(sendEvent, id, label, displayName, this.temperature, this.currentCoolingSetpoint,
37 this.currentHeatingSetpoint, this.coolingSetpoint, this.thermostatSetpoint, this.heatingSetpoint, this.coolingSetpointRange,
38 this.thermostatSetpointRange, this.heatingSetpointRange, this.supportedThermostatFanModes, this.supportedThermostatModes,
39 this.thermostatOperatingState, this.thermostatFanMode, this.thermostatMode))
42 //Methods for closures
43 def count(Closure Input) {
44 thermostats.count(Input)
49 def each(Closure Input) {
50 thermostats.each(Input)
52 def find(Closure Input) {
53 thermostats.find(Input)
55 def collect(Closure Input) {
56 thermostats.collect(Input)
60 def setCoolingSetpoint(int coolingSetpoint) {
61 thermostats[0].setCoolingSetpoint(coolingSetpoint)
64 def setHeatingSetpoint(int heatingSetpoint) {
65 thermostats[0].setHeatingSetpoint(heatingSetpoint)
72 def setThermostatFanMode(String thermostatFanMode) {
73 thermostats[0].setThermostatFanMode(thermostatFanMode)
76 def setThermostatMode(String thermostatMode) {
77 thermostats[0].setThermostatMode(thermostatMode)