4 * Copyright 2014 Brian Steere
6 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
7 * in compliance with the License. You may obtain a copy of the License at:
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
12 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
13 * for the specific language governing permissions and limitations under the License.
17 name: "Whole House Fan",
19 author: "Brian Steere",
20 description: "Toggle a whole house fan (switch) when: Outside is cooler than inside, Inside is above x temp, Thermostat is off",
21 category: "Green Living",
22 iconUrl: "https://s3.amazonaws.com/smartapp-icons/Developers/whole-house-fan.png",
23 iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Developers/whole-house-fan%402x.png"
29 input "outTemp", "capability.temperatureMeasurement", title: "Outdoor Thermometer", required: true
33 input "inTemp", "capability.temperatureMeasurement", title: "Indoor Thermometer", required: true
34 input "minTemp", "number", title: "Minimum Indoor Temperature"
35 input "fans", "capability.switch", title: "Vent Fan", multiple: true, required: true
38 section("Thermostat") {
39 input "thermostat", "capability.thermostat", title: "Thermostat"
42 section("Windows/Doors") {
43 paragraph "[Optional] Only turn on the fan if at least one of these is open"
44 input "checkContacts", "enum", title: "Check windows/doors", options: ['Yes', 'No'], required: true
45 input "contacts", "capability.contactSensor", title: "Windows/Doors", multiple: true, required: false
50 log.debug "Installed with settings: ${settings}"
56 log.debug "Updated with settings: ${settings}"
63 state.fanRunning = false;
65 subscribe(outTemp, "temperature", "checkThings");
66 subscribe(inTemp, "temperature", "checkThings");
67 subscribe(thermostat, "thermostatMode", "checkThings");
68 subscribe(contacts, "contact", "checkThings");
71 def checkThings(evt) {
72 def outsideTemp = settings.outTemp.currentTemperature
73 def insideTemp = settings.inTemp.currentTemperature
74 def thermostatMode = settings.thermostat.currentThermostatMode
75 def somethingOpen = settings.checkContacts == 'No' || settings.contacts?.find { it.currentContact == 'open' }
77 log.debug "Inside: $insideTemp, Outside: $outsideTemp, Thermostat: $thermostatMode, Something Open: $somethingOpen"
81 if(thermostatMode != 'off') {
82 log.debug "Not running due to thermostat mode"
86 if(insideTemp < outsideTemp) {
87 log.debug "Not running due to insideTemp > outdoorTemp"
91 if(insideTemp < settings.minTemp) {
92 log.debug "Not running due to insideTemp < minTemp"
97 log.debug "Not running due to nothing open"
101 if(shouldRun && !state.fanRunning) {
103 state.fanRunning = true;
104 } else if(!shouldRun && state.fanRunning) {
106 state.fanRunning = false;