My wife and I have varying schedules in the evening. Sometimes we both have to work late, and sometimes we go out to dinner or go straight to some other function from work. And then again, some days, one of us arrives home early.
When you have air conditioning or heat pumps, as we do, you'd like to be able to tell your system what time you will be home so it can set thermostat settings such that the house will be reasonably comfortable when you arrive. There's two parts to this. First the system has to know what time you will be home, and it has to be done in a way that automation code can trigger on.
The solution is to employ a user setting. You can set a user setting and then use that in place of a hard-coded time in a TIMED event trigger. The trick is to be able to set the user setting in a way that's quick and convenient -- something you can do in a second or two on your way out the door, or over the phone. You don't want to have to start up PC Access every morning just to tell the system what time you will be home.
I decided that if I had a limited number of possible settings, I could create a range of buttons to set the possible values. What I decided to do was allow exact hours from 2:00 PM to 9:00 PM; that pretty much covers the range for our lifestyle. I wrote some button code that looks like this:
etc., up to 9:00 PM. Button "Home at 2:00" is button 2 in my configuration; button "Home at 3:00" is button 3, and so forth. This makes it easy to set using a console; you press "3{hour}#" on your way out, and it sets it to that hour. For example, if I press "37#", it runs button 7, which sets the arrive time to 7:00 PM. This also works via phone access, from any phone. So if I'm at work and plans change, I can call the OPII and change it. Additionally, I have a page on the 5.7e that has a button for each of the hour settings, and each one runs the corresponding button on the OPII. ("At Home Hour" is a flag. Its sole purpose is to allow the 5.7e page to display the current setting, since the current 5.7e firmware can't access user settings. No other code looks at this flag.)
Notice that there are three user settings being set by each block of the button code: "Arrive Time 60 minutes before", "Arrive Time 30 minutes before", and "Arrive Time 0 minutes before". The last is set to the actual selected arrive time, and the other two are set to earlier times correspondingly. The thermostat management code uses these to anticipate when to change the setpoints based on the outdoor temperature:
This way, if it's really cold or really hot outside, the HVAC units start earlier so that the house is reasonably comfortable when we get home. ("Evening Thermostat Settings" is a button that sets thermostat setpoints based on a number of conditions.)
Because I'll probably not remember tomorrow that I changed the at-home time today, I have one more piece of code which, once the at-home actions have been taken, resets the time setting to a default value:
"Arrive Time Hold" is a flag that is tied to a switch icon on the 5.7e arrive-time page. If I know we are going to be arriving at an unusual time for several days in a row, I can turn on the flag and it will hold the set arrive time until I turn it off. "House is unoccupied" is a flag that we set (using a different page on the 5.7e) when we're going to be gone for one night or more; by having the code check this, we can set the arrive time before we leave, and it will apply that arrival time to our return day, rather than to the day after we leave. We tend to stay out later and do more things outside after work in the summer, so "Home Time Reset Summer" is a button that checks to see if the date is between June 1 and September 30. If so, it resets the default time to 6:00 PM:
When you have air conditioning or heat pumps, as we do, you'd like to be able to tell your system what time you will be home so it can set thermostat settings such that the house will be reasonably comfortable when you arrive. There's two parts to this. First the system has to know what time you will be home, and it has to be done in a way that automation code can trigger on.
The solution is to employ a user setting. You can set a user setting and then use that in place of a hard-coded time in a TIMED event trigger. The trick is to be able to set the user setting in a way that's quick and convenient -- something you can do in a second or two on your way out the door, or over the phone. You don't want to have to start up PC Access every morning just to tell the system what time you will be home.
I decided that if I had a limited number of possible settings, I could create a range of buttons to set the possible values. What I decided to do was allow exact hours from 2:00 PM to 9:00 PM; that pretty much covers the range for our lifestyle. I wrote some button code that looks like this:
Code:
65. WHEN Home at 2:00
THEN SET Arrive Time 60 minutes before TO 1:00 PM
THEN SET Arrive Time 30 minutes before TO 1:30 PM
THEN SET Arrive Time 0 minutes before TO 2:00 PM
THEN SET At Home Hour TO 2
66. WHEN Home at 3:00
THEN SET Arrive Time 60 minutes before TO 2:00 PM
THEN SET Arrive Time 30 minutes before TO 2:30 PM
THEN SET Arrive Time 0 minutes before TO 3:00 PM
THEN SET At Home Hour TO 3
etc., up to 9:00 PM. Button "Home at 2:00" is button 2 in my configuration; button "Home at 3:00" is button 3, and so forth. This makes it easy to set using a console; you press "3{hour}#" on your way out, and it sets it to that hour. For example, if I press "37#", it runs button 7, which sets the arrive time to 7:00 PM. This also works via phone access, from any phone. So if I'm at work and plans change, I can call the OPII and change it. Additionally, I have a page on the 5.7e that has a button for each of the hour settings, and each one runs the corresponding button on the OPII. ("At Home Hour" is a flag. Its sole purpose is to allow the 5.7e page to display the current setting, since the current 5.7e firmware can't access user settings. No other code looks at this flag.)
Notice that there are three user settings being set by each block of the button code: "Arrive Time 60 minutes before", "Arrive Time 30 minutes before", and "Arrive Time 0 minutes before". The last is set to the actual selected arrive time, and the other two are set to earlier times correspondingly. The thermostat management code uses these to anticipate when to change the setpoints based on the outdoor temperature:
Code:
28. TIMED Arrive Time 60 minutes before MTWTFSS
AND IF Outdoor Temp Sensor CURRENT READING IS LESS THAN 25
OR
AND IF Outdoor Temp Sensor CURRENT READING IS GREATER THAN 95
THEN RUN Evening Thermostat Settings
29. TIMED Arrive Time 30 minutes before MTWTFSS
AND IF Outdoor Temp Sensor CURRENT READING IS LESS THAN 38
OR
AND IF Outdoor Temp Sensor CURRENT READING IS GREATER THAN 85
THEN RUN Evening Thermostat Settings
30. TIMED Arrive Time 0 minutes before MTWTFSS
THEN RUN Evening Thermostat Settings
This way, if it's really cold or really hot outside, the HVAC units start earlier so that the house is reasonably comfortable when we get home. ("Evening Thermostat Settings" is a button that sets thermostat setpoints based on a number of conditions.)
Because I'll probably not remember tomorrow that I changed the at-home time today, I have one more piece of code which, once the at-home actions have been taken, resets the time setting to a default value:
Code:
31. TIMED Arrive Time 0 minutes before MTWTFSS
AND IF Arrive Time Hold OFF
AND IF House is unoccupied CURRENT VALUE IS 0
THEN RUN Home at 5:00
THEN RUN Home Time Reset Summer
"Arrive Time Hold" is a flag that is tied to a switch icon on the 5.7e arrive-time page. If I know we are going to be arriving at an unusual time for several days in a row, I can turn on the flag and it will hold the set arrive time until I turn it off. "House is unoccupied" is a flag that we set (using a different page on the 5.7e) when we're going to be gone for one night or more; by having the code check this, we can set the arrive time before we leave, and it will apply that arrival time to our return day, rather than to the day after we leave. We tend to stay out later and do more things outside after work in the summer, so "Home Time Reset Summer" is a button that checks to see if the date is between June 1 and September 30. If so, it resets the default time to 6:00 PM:
Code:
58. WHEN Home Time Reset Summer
AND IF DATE IS GREATER THAN 5/31
AND IF DATE IS LESS THAN 10/1
THEN RUN Home at 6:00