CT-30 Thermostat mode switching


(Danny C) #1

What kind of changes would I need to make to this Automatic Mode switching app from the shared apps to make it work with my CT-30 thermostats?

/**
 *  Thermostat Mode:  Heat/Cool Switcher
 *
 *  To automatically switch Thermostat Modes 
 *  (as Honeywell 8320 has lobotomy in that area)
 *  (and we need both here in any given day sometimes)
 *
 *  Author: George Chast
 * 
 */
preferences {
	section("Choose thermostat... ") {
		input "thermostat", "capability.thermostat", multiple: true
	}
}
def installed(){
    subscribeToEvents()
}
def updated(){
	unsubscribe()
    subscribeToEvents()
}
def subscribeToEvents(){
	subscribe(thermostat, "heatingSetpoint", heatingSetpointHandler)
	subscribe(thermostat, "coolingSetpoint", coolingSetpointHandler)
	subscribe(thermostat, "temperature", temperatureHandler)
	subscribe(location, "location",changedLocationMode)
	subscribe(app, appTouch)
}
def heatingSetpointHandler(evt){
	log.debug "heatingSetpoint: $evt, $settings"
	setThermoMode()
}
def coolingSetpointHandler(evt){
	log.debug "coolingSetpoint: $evt, $settings"
	setThermoMode()
}
def temperatureHandler(evt){
	log.debug "currentTemperature: $evt, $settings"
	setThermoMode()
}
def changedLocationMode(evt) {
	log.debug "changedLocationMode: $evt, $settings"
	setThermoMode()
}
def appTouch(evt){
	log.debug "appTouch: $evt, $settings"
	setThermoMode()
}
// catchall
def event(evt) {
	log.debug "value: $evt.value, event: $evt, settings: $settings, handlerName: ${evt.handlerName}"
}
//setMode
def setThermoMode() {
	// if temperature is above coolingSetpoint and ThermostatModeSet is not MODE_COOL
	// if temperature is below heatingSetpoint adn ThermostatModeSet is not MODE_HEAT
	thermostat.poll()
	def coolpt = thermostat.currentCoolingSetpoint
    def temp = thermostat.currentTemperature
    def heatpt = thermostat.currentHeatingSetpoint
    def mode0 = thermostat.currentThermostatMode
    //def tempGap = 1
    def waitTime = 120000	 // 2 minutes in milliseconds
	log.trace("evaluate:, mode: $tm -- temp: $ct, heat: $thermostat.currentHeatingSetpoint, cool: $thermostat.currentCoolingSetpoint -- "  +
			"sensor: $currentTemp, heat: $heatingSetpoint, cool: $coolingSetpoint")
	log.debug "---------------------------------"
    log.debug "---------setThermoMode, $settings"
    log.debug "coolingSetpoint: $coolpt"
    log.debug "temperature    : $temp"
    log.debug "heatingSetpoint: $heatpt"
    //log.debug "Gap            : $gap"
    log.debug "thermostatMode : $mode0"
    log.debug "Wait Time      : $waitTime"
    log.debug "Last Flipped   : $state.lastChanged"
    if (( state.lastChange == null) ||  ((state.lastChange != null) && (state.lastChange + waitTime<now() ) )) {
        if ((temp > coolpt ) && (mode0 != "cool")) {
            log.debug "--changing to Cool"
            thermostat.setThermostatMode("cool")
            state.lastChanged = now()
            log.debug "Now: $state.lastChanged"
        }
        if ((temp < heatpt)&& (mode0 != "heat")) {
            log.debug "--changing to Heat"
            thermostat.setThermostatMode("heat")
            state.lastChanged = now()
            log.debug "Now: $state.lastChanged"
        }
    }
	thermostat.poll()
}

(Kyle F) #2

Following along as I also have the CT-30 and am interested in doing the same.