Virtual thermostat that wont turn on when door open

(Clinton Zimmerman) #1

Has anybody or can anybody make an app that could help me in my sitution
I have a heater in my garage. i currentlly monitor my garage door sensor so when the temp falls below 40 degree my smart outlet turns on which turns on the heater. I dont want the heater running if the garage door is open.

(Clinton Zimmerman) #2

nobody has thought of this???

(Eric R) #3

What device are you using to know if the garage door is open?

(Eric R) #4

This will work if you are using a contact sensor. If you need something else, let me know and I can change it.

 *  Virtual Thermostat - Door Closed
 *  Copyright 2015 Eric Roberts
 *  Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 *  in compliance with the License. You may obtain a copy of the License at:
 *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
 *  on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
 *  for the specific language governing permissions and limitations under the License.
    name: "Virtual Thermostat - Door Closed",
    namespace: "baldeagle072",
    author: "Eric Roberts",
    description: "Will only run heater if the door is closed.",
    category: "Green Living",
    iconUrl: "",
    iconX2Url: "",
    iconX3Url: "")

preferences {
	section("Thermostat options") {
    	input "temperatureSensor", "capability.temperatureMeasurement", title: "Temperature Sensor", required: true, multiple: false
        input "heater", "capability.switch", title: "Heater to turn on", required: true, multiple: true
        input "setTemp", "number", title: "Don't go below this temperature", required: true
    section("Don't heat if this door is open") {
		input "door", "capability.contactSensor", title: "Door to Monitor", required: true, multiple:false

def installed() {
	log.debug "Installed with settings: ${settings}"


def updated() {
	log.debug "Updated with settings: ${settings}"


def initialize() {
	subscribe(temperatureSensor, "temperature", eventHandler)
    subscribe(door, "contact", eventHandler)

def eventHandler(evt) {
	if (door.latestValue("contact") == "closed") {
    	if (temperatureSensor.latestValue("temperature") < setTemp) {
        } else if (temperatureSensor.latestValue("temperature") > setTemp + 1.0) {
    } else {

(Clinton Zimmerman) #5

sorry haven’t had time lately to get on here and mess with my smarthings. I use a multiswitch for the garage door sensor. I also use a multiswitch for the man door in my garage. I dont want the heater or AC to run if either are open. I have the heater/AC plugged into a smart outlet

(Jonathan) #6

This is exactly what i have been looking for! Unfortunately I am still very new at this and once I installed it in my in the smartApps but then when I go to the phone to set it up I can’t find it. Am I not looking in the right place? I pasted the code as a new app. I ran the simulator saved and published. I see the app “baldeagle072 : Virtual Thermostat - Door Closed Published Green Living” in the list of smartApps"

Thank you for your help!

(Stuart Buchanan) #7

Did you ever use rule machine? If so then that has all the pieces of the puzzle. Just created a rule with the following conditions Temp Sensor < 40 AND contact sensor = closed. Action for true = turn on heater, action for false = turn off heater.

If you didn’t have rule machine then ignore the above as the app is currently withdrawn. I do a similar thing with my air conditioning in my conservatory where If the back doors are open for longer than X minutes then turn off the heating/cooling. However 5 rules are needed in total to do this and also protect the compressor from turning on & off too quickly