//Create a class for thermostat device package Thermostat import SmartThing.SmartThings //Importing mutable integer class import MutableInteger.MutableInteger class Thermostats extends SmartThings { List thermostats = new ArrayList() Thermostats(Closure sendEvent, boolean init) { // Only initialize one time since we only have one device for each capability thermostats = smartThings // Initialization StringBuilder id = new StringBuilder("thermostatID0") StringBuilder label = new StringBuilder("thermostat") StringBuilder displayName = new StringBuilder("thermostat0") StringBuilder climateName = new StringBuilder("climateName") StringBuilder thermostatOperatingState = new StringBuilder() StringBuilder thermostatFanMode = new StringBuilder() StringBuilder thermostatMode = new StringBuilder() MutableInteger temperature = new MutableInteger() MutableInteger coolingSetpoint = new MutableInteger() MutableInteger heatingSetpoint = new MutableInteger() MutableInteger thermostatSetpoint = new MutableInteger() if (init) { temperature.setValue(60) coolingSetpoint.setValue(70) heatingSetpoint.setValue(35) thermostatSetpoint.setValue(50) thermostatOperatingState.append("off") thermostatFanMode.append("off") thermostatMode.append("off") } else { temperature.setValue(66) coolingSetpoint.setValue(80) heatingSetpoint.setValue(50) thermostatSetpoint.setValue(60) thermostatOperatingState.append("heating") thermostatFanMode.append("circulate") thermostatMode.append("auto") } thermostats.add(new Thermostat(sendEvent, id, label, displayName, temperature, coolingSetpoint, heatingSetpoint, thermostatSetpoint, thermostatOperatingState, thermostatFanMode, thermostatMode, climateName)) } // Methods to set values def setCoolingSetpoint(int coolingSetpoint) { thermostats[0].setCoolingSetpoint(coolingSetpoint) } def setCoolingSetpoint(String coolingSetpoint) { setCoolingSetpoint(coolingSetpoint.toInteger()) } def setHeatingSetpoint(int heatingSetpoint) { thermostats[0].setHeatingSetpoint(heatingSetpoint) } def setHeatingSetpoint(String heatingSetpoint) { setHeatingSetpoint(heatingSetpoint.toInteger()) } def setThermostatFanMode(String thermostatFanMode) { thermostats[0].setThermostatFanMode(thermostatFanMode) } def setThermostatMode(String thermostatMode) { thermostats[0].setThermostatMode(thermostatMode) } def setClimate(String info, String givenClimateName) { thermostats[0].setClimate(info, givenClimateName) } def setHold(String info1, int coolingSetpoint, int heatingSetpoint, String info2, String info3) { setCoolingSetpoint(coolingSetpoint) setHeatingSetpoint(heatingSetpoint) } def cool() { thermostats[0].cool() } def heat() { thermostats[0].heat() } def auto() { thermostats[0].auto() } def emergencyHeat() { thermostats[0].emergencyHeat() } def off() { thermostats[0].off() } // Methods to return values def getCurrentTemperature() { List tmpValues = new ArrayList() tmpValues.add(thermostats[0].getCurrentTemperature()) return tmpValues } def getCurrentCoolingSetpoint() { List tmpValues = new ArrayList() tmpValues.add(thermostats[0].getCurrentCoolingSetpoint()) return tmpValues } def getCurrentHeatingSetpoint() { List tmpValues = new ArrayList() tmpValues.add(thermostats[0].getCurrentHeatingSetpoint()) return tmpValues } def getCurrentThermostatSetPoint() { List tmpValues = new ArrayList() tmpValues.add(thermostats[0].getCurrentThermostatSetPoint()) return tmpValues } def getCurrentThermostatOperatingState() { List tmpValues = new ArrayList() tmpValues.add(thermostats[0].getCurrentThermostatOperatingState()) return tmpValues } def getCurrentThermostatFanMode() { List tmpValues = new ArrayList() tmpValues.add(thermostats[0].getCurrentThermostatFanMode()) return tmpValues } def getCurrentThermostatMode() { List tmpValues = new ArrayList() tmpValues.add(thermostats[0].getCurrentThermostatMode()) return tmpValues } def getCurrentClimateName() { List tmpValues = new ArrayList() tmpValues.add(thermostats[0].getCurrentClimateName()) return tmpValues } }