2 * Smart Home Ventilation
3 * Version 2.1.2 - 5/31/15
5 * Copyright 2015 Michael Struck
7 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
8 * in compliance with the License. You may obtain a copy of the License at:
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
13 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
14 * for the specific language governing permissions and limitations under the License.
19 name: "Smart Home Ventilation",
20 namespace: "MichaelStruck",
21 author: "Michael Struck",
22 description: "Allows for setting up various schedule scenarios for turning on and off home ventilation switches.",
23 category: "Convenience",
24 iconUrl: "https://raw.githubusercontent.com/MichaelStruck/SmartThings/master/Other-SmartApps/Smart-Home-Ventilation/HomeVent.png",
25 iconX2Url: "https://raw.githubusercontent.com/MichaelStruck/SmartThings/master/Other-SmartApps/Smart-Home-Ventilation/HomeVent@2x.png",
26 iconX3Url: "https://raw.githubusercontent.com/MichaelStruck/SmartThings/master/Other-SmartApps/Smart-Home-Ventilation/HomeVent@2x.png")
32 //----Scheduling Pages
33 page(name: "A_Scenario") {
35 input "timeOnA1", title: "Schedule 1 time to turn on", "time", required: false
36 input "timeOffA1", title: "Schedule 1 time to turn off", "time", required: false
39 input "timeOnA2", title: "Schedule 2 time to turn on", "time", required: false
40 input "timeOffA2", title: "Schedule 2 time to turn off", "time", required: false
43 input "timeOnA3", title: "Schedule 3 time to turn on", "time", required: false
44 input "timeOffA3", title: "Schedule 3 time to turn off", "time", required: false
47 input "timeOnA4", title: "Schedule 4 time to turn on", "time", required: false
48 input "timeOffA4", title: "Schedule 4 time to turn off", "time", required: false
51 input "titleA", title: "Assign a scenario name", "text", required: false
52 input "modeA", "mode", required: false, multiple: true, title: "Run in specific mode(s)", description: "Choose Modes"
53 input "daysA", "enum", multiple: true, title: "Run on specific day(s)", description: "Choose Days", required: false, options: ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
58 page(name: "pageAbout", title: "About ${textAppName()}") {
60 paragraph "${textVersion()}\n${textCopyright()}\n\n${textLicense()}\n"
62 section("Instructions") {
68 dynamicPage(name: "mainPage", title: "", install: true, uninstall: true) {
69 section("Select ventilation switches..."){
70 input "switches", title: "Switches", "capability.switch", multiple: true
72 section([mobileOnly:true], "Options") {
73 label(title: "Assign a name", required: false, defaultValue: "Smart Home Ventilation")
74 href "pageAbout", title: "About ${textAppName()}", description: "Tap to get application version, license and instructions"
79 // Install and initiate
82 log.debug "Installed with settings: ${settings}"
88 turnOffSwitch() //Turn off all switches if the schedules are changed while in mid-schedule
90 log.debug "Updated with settings: ${settings}"
95 schedule ("someTime", midNight)
96 subscribe(location, "mode", locationHandler)
102 def startProcess () {
114 def locationHandler(evt) {
116 state.modeChange = true
118 if (it.currentValue("switch")=="on"){
133 log.debug "Home ventilation switches are on."
136 def turnOffSwitch() {
138 if (it.currentValue("switch")=="on"){
142 log.debug "Home ventilation switches are off."
146 //Version/Copyright/Information/Help
148 private def textAppName() {
149 def text = "Smart Home Ventilation"
152 private def textVersion() {
153 def text = "Version 2.1.2 (05/31/2015)"
156 private def textCopyright() {
157 def text = "Copyright © 2015 Michael Struck"
160 private def textLicense() {
162 "Licensed under the Apache License, Version 2.0 (the 'License'); "+
163 "you may not use this file except in compliance with the License. "+
164 "You may obtain a copy of the License at"+
166 " http://www.apache.org/licenses/LICENSE-2.0"+
168 "Unless required by applicable law or agreed to in writing, software "+
169 "distributed under the License is distributed on an 'AS IS' BASIS, "+
170 "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. "+
171 "See the License for the specific language governing permissions and "+
172 "limitations under the License."
175 private def textHelp() {
177 "Within each scenario, choose a start and end time for the ventilation fan. You can have up to 4 different " +
178 "venting scenarios, and 4 schedules within each scenario. Each scenario can be restricted to specific modes or certain days of the week. It is recommended "+
179 "that each scenario does not overlap and run in separate modes (i.e. Home, Out of town, etc). Also note that you should " +
180 "avoid scheduling the ventilation fan at exactly midnight; the app resets itself at that time. It is suggested to start any new schedule " +
181 "at 12:15 am or later."