1 //Create a class for thermostat device
3 import SmartThing.SmartThings
5 class Thermostats extends SmartThings {
6 List thermostats = new ArrayList()
8 Thermostats(Closure sendEvent, boolean init) {
9 // Only initialize one time since we only have one device for each capability
10 thermostats = smartThings
13 String id = "thermostatID0"
14 String label = "thermostat"
15 String displayName = "thermostat"
16 String climateName "climateName"
17 String thermostatOperatingState
18 String thermostatFanMode
21 Integer coolingSetpoint
22 Integer heatingSetpoint
23 Integer thermostatSetpoint
29 thermostatSetpoint = 50
30 thermostatOperatingState = "off"
31 thermostatFanMode = "off"
32 thermostatMode = "off"
37 thermostatSetpoint = 60
38 thermostatOperatingState = "heating"
39 thermostatFanMode = "circulate"
40 thermostatMode = "auto"
43 thermostats.add(new Thermostat(sendEvent, id, label, displayName, temperature, coolingSetpoint,
44 heatingSetpoint, thermostatSetpoint, thermostatOperatingState,
45 thermostatFanMode, thermostatMode, climateName))
48 // Methods to set values
49 def setThermostatSetpoint(int thermostatSetpoint) {
50 thermostats[0].setThermostatSetpoint(thermostatSetpoint)
53 def setCoolingSetpoint(int coolingSetpoint) {
54 thermostats[0].setCoolingSetpoint(coolingSetpoint)
57 def setCoolingSetpoint(String coolingSetpoint) {
58 setCoolingSetpoint(coolingSetpoint.toInteger())
61 def setHeatingSetpoint(int heatingSetpoint) {
62 thermostats[0].setHeatingSetpoint(heatingSetpoint)
65 def setHeatingSetpoint(String heatingSetpoint) {
66 setHeatingSetpoint(heatingSetpoint.toInteger())
69 def setThermostatFanMode(String thermostatFanMode) {
70 thermostats[0].setThermostatFanMode(thermostatFanMode)
73 def setThermostatMode(String thermostatMode) {
74 thermostats[0].setThermostatMode(thermostatMode)
77 def setThermostatOperatingState(String thermostatOperatingState) {
78 thermostats[0].setThermostatOperatingState(thermostatOperatingState)
81 def setClimate(String info, String givenClimateName) {
82 thermostats[0].setClimate(info, givenClimateName)
85 def setHold(String info1, int coolingSetpoint, int heatingSetpoint, String info2, String info3) {
86 setCoolingSetpoint(coolingSetpoint)
87 setHeatingSetpoint(heatingSetpoint)
102 def emergencyHeat() {
103 thermostats[0].emergencyHeat()