4 * Author: dianoga7@3dgo.net
8 // Automatically generated. Make future change here.
10 name: "Thermostat Auto Off",
12 author: "dianoga7@3dgo.net",
13 description: "Automatically turn off thermostat when windows/doors open. Turn it back on when everything is closed up.",
14 category: "Green Living",
15 iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png",
16 iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience%402x.png",
22 input("thermostat", "capability.thermostat", title: "Thermostat")
25 section("Open/Close") {
26 input("sensors", "capability.contactSensor", title: "Sensors", multiple: true)
27 input("delay", "number", title: "Delay (seconds)")
32 log.debug "Installed with settings: ${settings}"
38 log.debug "Updated with settings: ${settings}"
47 subscribe(sensors, "contact", sensorChange)
50 def sensorChange(evt) {
51 log.debug "Desc: $evt.value , $state"
52 if(evt.value == 'open' && !state.changed) {
54 runIn(delay, 'turnOff')
55 } else if(evt.value == 'closed' && state.changed) {
58 for(sensor in sensors) {
59 if(sensor.id != evt.deviceId && sensor.currentValue('contact') == 'open') {
66 runIn(delay, 'restore')
72 log.debug "Turning off thermostat due to contact open"
73 state.thermostatMode = thermostat.currentValue("thermostatMode")
76 log.debug "State: $state"
80 log.debug "Setting thermostat to $state.thermostatMode"
81 thermostat.setThermostatMode(state.thermostatMode)