CT-100 Schedule

I just connected a CT-100 and I’m trying to figure out if I am missing something.

What I would like to do is to have a regular schedule that says Mon-Fri it’s 70 degrees from 7pm-11pm and from 7am-9am, and then the rest of the time it can go down to 65 degrees. I had this on my last cheap thermostat.

The thing I was looking for with Smartthings is that if I know I am coming home early, or working later, I can override that schedule and change the temp manually, but at the next scheduled time the schedule goes back into effect. That’s basically what happened on the old thermostat, but I had to be home to change it. I was hoping I could do that same thing from work as I was walking out the door. That way I didn’t have to wait until I got home to start the house warming up.

Is this doable on the CT-100 with Smartthings?

Thanks.

Ted

Sure can my friend, there’s an app called Extravagent Thermostat to setup the thermostat based on a weekday setting to leverage the 7 day or 5-2 feature of an existing thermostat.

Here’s the code from the IDE site:

Thank you very much for the information, but I have to admit my ignorance. How do I install that app? I must be missing something because I can’t figure out a way to install 3rd party apps into Smartthings on my phone.

I tried googling the term “Extravagent Thermostat” but couldn’t find what you are talking about.

Thanks again for your help. I’m a newbie to this. I haven’t coded anything in around 20 years since college, so having someone else’s code is a good thing.

Ted

Step 1.
Go to this site
https://graph.api.smartthings.com/ you need to create an account or use your existing ST credentials to login

Step 2.

Once logged in, click on MY SMARTAPPS at the top

Step 3.
Click on +NEW SMARTAPP

Step 4.
From the "From Form"
Fill the following fields as such:
Name: Extravagent Thermostat
Description: Extravagent Thermostat
Category: select My Apps

Step 5.
Click Create at the very bottom

Step 6.
From the next screen, delete the code and replace it with this one:

/**
 *  Extravagent Thermostat setting
 *     Allows you to set your thermostat to different temp during
 *     different days of the week
 *
 *  Author: Samer Theodossy
 */

// Automatically generated. Make future change here.
definition(
    name: "Extravagent Thermostat",
    namespace: "",
    author: "Samer Theodossy",
    description: "Programmable Thermostat",
    category: "My Apps",
    iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png",
    iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png",
    oauth: true)

preferences {
    section("Set these thermostats") {
        input "thermostat", "capability.thermostat", title: "Which?", multiple:true

    }
    
    section("To these temperatures") {
        input "heatingSetpoint", "decimal", title: "When Heating"
        input "coolingSetpoint", "decimal", title: "When Cooling"
    }
    
    section("Configuration") {
        input "dayOfWeek", "enum",
                        title: "Which day of the week?",
                        multiple: false,
                        metadata: [
                    values: [
                    'All Week',
                    'Monday to Friday',
                    'Saturday & Sunday',
                    'Monday',
                    'Tuesday',
                    'Wednesday',
                    'Thursday',
                    'Friday',
                    'Saturday',
                    'Sunday'
                ]
                        ]
        input "time", "time", title: "At this time"
        //input "newMode", "mode", title: "Change to this mode"
    }
    
    section( "Notifications" ) {
        input "sendPushMessage", "enum", title: "Send a push notification?", metadata:[values:["Yes", "No"]], required: false
        input "phoneNumber", "phone", title: "Send a text message?", required: false
    }
}

def installed() {
        // subscribe to these events
        subscribe(thermostat, "heatingSetpoint", heatingSetpointHandler)
        subscribe(thermostat, "coolingSetpoint", coolingSetpointHandler)
        subscribe(thermostat, "temperature", temperatureHandler)
        initialize()
}

def updated() {
        // we have had an update
        // remove everything and reinstall
        unschedule()
        subscribe(thermostat, "heatingSetpoint", heatingSetpointHandler)
        subscribe(thermostat, "coolingSetpoint", coolingSetpointHandler)
        subscribe(thermostat, "temperature", temperatureHandler)
        initialize()
}

def initialize() {
    
        log.debug "Scheduling Temp change for day " + dayOfWeek + " at time " + time
    
        schedule(time, setTheTemp)
}

def heatingSetpointHandler(evt)
{
    log.debug "heatingSetpoint: $evt, $settings"
}

def coolingSetpointHandler(evt)
{
    log.debug "coolingSetpoint: $evt, $settings"
}

def temperatureHandler(evt)
{
    log.debug "currentTemperature: $evt, $settings"
}

def setTheTemp() {
    
    def doChange = false
    Calendar localCalendar = Calendar.getInstance(TimeZone.getDefault());
    int currentDayOfWeek = localCalendar.get(Calendar.DAY_OF_WEEK);
    
    // Check the condition under which we want this to run now
    // This set allows the most flexibility.
    if(dayOfWeek == 'All Week'){
            doChange = true
    }
    else if((dayOfWeek == 'Monday' || dayOfWeek == 'Monday to Friday') && currentDayOfWeek == Calendar.instance.MONDAY){
            doChange = true
    }
    
    else if((dayOfWeek == 'Tuesday' || dayOfWeek == 'Monday to Friday') && currentDayOfWeek == Calendar.instance.TUESDAY){
            doChange = true
    }
    
    else if((dayOfWeek == 'Wednesday' || dayOfWeek == 'Monday to Friday') && currentDayOfWeek == Calendar.instance.WEDNESDAY){
            doChange = true
    }
    
    else if((dayOfWeek == 'Thursday' || dayOfWeek == 'Monday to Friday') && currentDayOfWeek == Calendar.instance.THURSDAY){
            doChange = true
    }
    
    else if((dayOfWeek == 'Friday' || dayOfWeek == 'Monday to Friday') && currentDayOfWeek == Calendar.instance.FRIDAY){
            doChange = true
    }
    
    else if((dayOfWeek == 'Saturday' || dayOfWeek == 'Saturday & Sunday') && currentDayOfWeek == Calendar.instance.SATURDAY){
            doChange = true
    }
    
    else if((dayOfWeek == 'Sunday' || dayOfWeek == 'Saturday & Sunday') && currentDayOfWeek == Calendar.instance.SUNDAY){
            doChange = true
    }
    
    
    
    // some debugging in order to make sure things are working correclty
    log.debug "Calendar DOW: " + currentDayOfWeek
    log.debug "SET DOW: " + dayOfWeek
    
    // If we have hit the condition to schedule this then lets do it
    if(doChange == true){
        log.debug "setTheTemp, location.mode = $location.mode, newMode = $newMode, location.modes = $location.modes"
        
        // We only want to allow this set of commands to run when we are in any mode other than "Away" 
        // If we are Away then we do not want to change it, this will take effect from the good night setting
        // or from another instance of this which will setup at 12:00 am to take effect everyday.
        if (location.mode != 'Away') {
            log.debug " Entering the set part"
            thermostat.setHeatingSetpoint(heatingSetpoint)
            thermostat.setCoolingSetpoint(coolingSetpoint)
            thermostat.poll()
            send "  heat set to  '${heatingSetpoint}' and cooling to  '${coolingSetpoint}'"
        }
    }
    else {
            log.debug "Temp change not scheduled for today."
    }
    log.debug "End of Fcn"
}

private send(msg) {
        if ( sendPushMessage != "No" ) {
                log.debug( "sending push message" )
                sendPush( msg )
        }

        if ( phoneNumber ) {
                log.debug( "sending text message" )
                sendSms( phoneNumber, msg )
        }

        log.debug msg
}

private getLabel() {
        app.label ?: "SamerTheodossy"
}


// catchall
def event(evt)
{
    log.debug "value: $evt.value, event: $evt, settings: $settings, handlerName: ${evt.handlerName}"
}

/*
def installed()
{
    subscribe(thermostat, "heatingSetpoint", heatingSetpointHandler)     // done
    subscribe(thermostat, "coolingSetpoint", coolingSetpointHandler)     // done
    subscribe(thermostat, "temperature", temperatureHandler)               // done
    subscribe(location)    
    subscribe(app)
}

def updated()
{
    unsubscribe()                                                         // done
    subscribe(thermostat, "heatingSetpoint", heatingSetpointHandler)     // done
    subscribe(thermostat, "coolingSetpoint", coolingSetpointHandler)     // done
    subscribe(thermostat, "temperature", temperatureHandler)              // done
    subscribe(location)
    subscribe(app)
}

// SAMER
// see if we can leverage this to make this much smarter
// this seems to be a location change event happening and can take some value already set ???
def changedLocationMode(evt)
{
    log.debug "changedLocationMode: $evt, $settings"

    thermostat.setHeatingSetpoint(heatingSetpoint)
    thermostat.setCoolingSetpoint(coolingSetpoint)
    thermostat.poll()
}

// SAMER
// Not sure what this is about appTouch. Is this when I change the mode myself ???
def appTouch(evt)
{
    log.debug "appTouch: $evt, $settings"

    thermostat.setHeatingSetpoint(heatingSetpoint)
    thermostat.setCoolingSetpoint(coolingSetpoint)
    thermostat.poll()
}

*/

Step 7.
Click SAVE at the top and then click PUBLISH

Step 8.
From the SmartThings app on your phone, click on the big + sign scroll to the right to "My Apps " you should see the app that you just created “Extravagent Thermostat”

Step 9.
Click and install it and that’s it!

1 Like

BTW this code no longer works after the platform upgrade. The problem is with the line schedule(time, setTheTemp)
setTheTemp reports a Date that about a month earlier to the current date, so it ends up scheduling it in the past and event never fires.

You will need to make changes to your code to handle time, instead of time use

timeToday(time, location.timeZone)

and it should solve your problem. See this thread:

I must be missing something with this. I can install this app fine and I can open it on my phone. But how to I setup an actual daily on off schedule with this? I’d like my Mon-Fri to be heat at 6:00am and set temp to 65, then set that back to 58 at 7:00am? Then I’d want to do that again at 4:00pm set to 65 and then set to 58 at 10:00pm? Is this not the purpose of this app? Any advise will be much appreciated.

This is a very powerful app but slightly confusion app. Think of this as the individual thermostat controller. In a traditional thermostat you will be given a set of choices, like 4 programs a day, either 1 for each day of the week or 1 for Mon-Fri and 1 for weekends. On the otherhand this one you can setup as many as you like but each will be setup as an APP. So if you have 6 schedules on Monday, 4 for Tuesday, 2 for Wednesday, 1 for Thu/Friday and 2 for Sat and 2 for Sun, you will have to setup a grand total of 18 apps. i.e. one app for each schedule. I hope that makes sense. That way it’s powerful as in you can create any number of schedules but for each schedule it will have to be 1 new app installed. (don’t forget to correct the bug in the timeToday calculation I pointed out above).

If you prefer a more traditional thermostat, try this:

Actually this code has other bugs, it will only run the schedule ONCE! It’s not setup to do repeat schedules. @veni you may want to relook at your apps, there are bugs in it:

  1. It won’t schedule every week/every day since the schedule is only called once
  2. It won’t run on the time scheduled due to a change in the way ST platofrm handles the time variable input by user, it will only schedule to run on the day the app was installed, instead you should use the timeToday function with local timezone.

OK, which code has the bug in it?
I scrapped the CT-100 one and implemented the one you referenced above (5-2 Day). The 5-2 is exactly what I’m looking for.

Okay for those who want this unlimited change thermostat with individual customizations, I’ve fixed the code and here it is:

/**
 *  Individual Change Thermostat
 *  Allows you to set single/multiple thermostats to different temp during different days of the week unlimited number of times (one app instance for each change)
 *
 *  Taken from : Samer Theodossy
 *  Update - 2014-11-20
 */

// Automatically generated. Make future change here.
definition(
    name: "Individual Change Thermostat",
    namespace: "rboy",
    author: "RBoy",
    description: "Setup unlimited adjustments to the thermostat(s), install this app once for each change you want to make",
    category: "Green Living",
    iconUrl: "https://s3.amazonaws.com/smartapp-icons/GreenLiving/Cat-GreenLiving.png",
    iconX2Url: "https://s3.amazonaws.com/smartapp-icons/GreenLiving/Cat-GreenLiving@2x.png",
    iconX3Url: "https://s3.amazonaws.com/smartapp-icons/GreenLiving/Cat-GreenLiving@3x.png"
    )

preferences {
    section("Set these thermostats") {
        input "thermostat", "capability.thermostat", title: "Which?", multiple:true

    }

    section("To these temperatures") {
        input "heatingSetpoint", "decimal", title: "When Heating"
        input "coolingSetpoint", "decimal", title: "When Cooling"
    }

    section("Configuration") {
        input "dayOfWeek", "enum",
                        title: "Which day of the week?",
                        multiple: false,
                        metadata: [
                    values: [
                    'All Week',
                    'Monday to Friday',
                    'Saturday & Sunday',
                    'Monday',
                    'Tuesday',
                    'Wednesday',
                    'Thursday',
                    'Friday',
                    'Saturday',
                    'Sunday'
                ]
                        ]
        input "time", "time", title: "At this time"
    }

    section( "Notifications" ) {
        input "sendPushMessage", "enum", title: "Send a push notification?", metadata:[values:["No", "Yes"]]
        input "phoneNumber", "phone", title: "Send a text message?", required: false
    }
}

def installed() {
        // subscribe to these events
        initialize()
}

def updated() {
        // we have had an update
        // remove everything and reinstall
        initialize()
}

def initialize() {
        unschedule()
		def scheduleTime = timeToday(time, location.timeZone)
        def timeNow = now() + (2*1000) // ST platform has resolution of 1 minutes, so be safe and check for 2 minutes) 
        log.debug "Current time is ${(new Date(timeNow)).format("EEE MMM dd yyyy HH:mm z", location.timeZone)}, scheduled check time is ${scheduleTime.format("EEE MMM dd yyyy HH:mm z", location.timeZone)}"
        if (scheduleTime.time < timeNow) { // If we have passed current time we're scheduled for next day
	        log.debug "Current scheduling check time $scheduleTime has passed, scheduling check for tomorrow"
        	scheduleTime = scheduleTime + 1 // Next day schedule
        }
        log.debug "Temp change schedule set for $dayOfWeek at time ${scheduleTime.format("HH:mm z", location.timeZone)} to $heatingSetpoint in heat and $coolingSetpoint in cool"
        log.debug "Scheduling next temp check at ${scheduleTime.format("EEE MMM dd yyyy HH:mm z", location.timeZone)}"
        schedule(scheduleTime, setTheTemp)
}

def setTheTemp() {
    def doChange = false
    Calendar localCalendar = Calendar.getInstance(TimeZone.getDefault());
    int currentDayOfWeek = localCalendar.get(Calendar.DAY_OF_WEEK);

    // some debugging in order to make sure things are working correclty
    log.debug "Calendar DOW: " + currentDayOfWeek
    log.debug "SET DOW: " + dayOfWeek

	// Check the condition under which we want this to run now
    // This set allows the most flexibility.
    if(dayOfWeek == 'All Week'){
            doChange = true
    }
    else if((dayOfWeek == 'Monday' || dayOfWeek == 'Monday to Friday') && currentDayOfWeek == Calendar.instance.MONDAY){
            doChange = true
    }

    else if((dayOfWeek == 'Tuesday' || dayOfWeek == 'Monday to Friday') && currentDayOfWeek == Calendar.instance.TUESDAY){
            doChange = true
    }

    else if((dayOfWeek == 'Wednesday' || dayOfWeek == 'Monday to Friday') && currentDayOfWeek == Calendar.instance.WEDNESDAY){
            doChange = true
    }

    else if((dayOfWeek == 'Thursday' || dayOfWeek == 'Monday to Friday') && currentDayOfWeek == Calendar.instance.THURSDAY){
            doChange = true
    }

    else if((dayOfWeek == 'Friday' || dayOfWeek == 'Monday to Friday') && currentDayOfWeek == Calendar.instance.FRIDAY){
            doChange = true
    }

    else if((dayOfWeek == 'Saturday' || dayOfWeek == 'Saturday & Sunday') && currentDayOfWeek == Calendar.instance.SATURDAY){
            doChange = true
    }

    else if((dayOfWeek == 'Sunday' || dayOfWeek == 'Saturday & Sunday') && currentDayOfWeek == Calendar.instance.SUNDAY){
            doChange = true
    }

    // If we have hit the condition to schedule this then lets do it
    if(doChange == true){
        log.debug "Setting temperature in $thermostat to $heatingSetpoint in heat and $coolingSetpoint in cool"
        thermostat.setHeatingSetpoint(heatingSetpoint)
        thermostat.setCoolingSetpoint(coolingSetpoint)
        send "$thermostat heat set to '${heatingSetpoint}' and cool to '${coolingSetpoint}'"
    }
    else {
        log.debug "Temp change not scheduled for today."
    }
    
    log.debug "Scheduling next check"
    
    initialize() // Setup the next check schedule
}

private send(msg) {
        if ( sendPushMessage != "No" ) {
            log.debug( "sending push message" )
            sendPush( msg )
        }

        if ( phoneNumber ) {
            log.debug( "sending text message" )
            sendSms( phoneNumber, msg )
        }

        log.debug msg
}
1 Like

You’re right, the App was not functioning as expected, but it’s worth mentioning that I’m not the the creator of this app. I been however using this App from another user; it’s a 7-day thermostat.

Yes that’s the one I rewrote here. The link you put has many bugs in it and also it’s not a 7 days thermostat but a 5-2 days thermostat (5 weekdays and 2 weekend days). The code won’t run properly because of the time bug that’s why I rewrote it to fix those issues:

Anyways I’ve started a new thread here with the fixed code and appropriate title to avoid overloading this thread: