Virtual thermostat that wont turn on when door open

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.

nobody has thought of this???

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

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:
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  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.
 *
 */
definition(
    name: "Virtual Thermostat - Door Closed",
    namespace: "baldeagle072",
    author: "Eric Roberts",
    description: "Will only run heater if the door is closed.",
    category: "Green Living",
    iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png",
    iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png",
    iconX3Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png")


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}"

	initialize()
}

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

	unsubscribe()
	initialize()
}

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

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

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

This is exactly what i have been looking for! Unfortunately I am still very new at this and once I installed it in my graph.api.smartthings.com 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!

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