Control ac through zxt-120 after door open for 10 minutes?

Hi folks only came online yesterday I have setup my hub and have a door sensor and zxt-120 working my daikin AC split system on a device handler, I am trying to make s smartapp that will
check if the door sendor is open for 10 minutes and then turn off my AC through the zxt-120
I am quite new to this only 15 hours on this but I do underatnd things quite quickly so any help would be great thank you

Welcome! :sunglasses: Your best bet will probably be to use webcore. This is essentially a scripting language for SmartThings and can handle all kinds of stacked conditionals, including time duration.

Setting it up is a little complicated, but there are lots of docs and people who will be glad to help if you have any questions. And once you get into it you’ll find you can do almost anything with it. :sunglasses:

I have this working now on one door sensor, I can easily add multiple thermostats and turn them off, BUT how can I change the code so that if any door sensor is open for x minutes it shuts off the ac, any help would be appreciated.

the code I am using that works fine on 1 sensor and 1 thermostat.

name: “Left It Open”,
namespace: “smartthings”,
author: “SmartThings”,
description: “Notifies you when you have left a door or window open longer that a specified amount of time.”,
category: “Convenience”,
iconUrl: “”,
iconX2Url: “

preferences {
section("Choose thermostat… ") {
input “thermostat1”, “capability.thermostat”, title: “Choose Thermostat 1”

section(“Monitor this door or window”) {
input “contact”, “capability.contactSensor”, title: “Choose Door Sensor”

section(“And notify me if it’s open for more than this many minutes (default 10)”) {
input “openThreshold”, “number”, description: “Number of minutes”, required: false

section(“Delay between notifications (default 10 minutes”) {
input “frequency”, “number”, title: “Number of minutes”, description: “”, required: false


def installed() {
log.trace "installed()"

def updated() {
log.trace "updated()"

def subscribe() {
subscribe(contact, “”, doorOpen)
subscribe(contact, “contact.closed”, doorClosed)

def doorOpen(evt) {
log.trace "doorOpen($ $evt.value)"
def delay = (openThreshold != null && openThreshold != “”) ? openThreshold * 60 : 600
runIn(delay, doorOpenTooLong, [overwrite: true])

def doorClosed(evt) {
log.trace "doorClosed($ $evt.value)"

def doorOpenTooLong() {
def contactState = contact.currentState(“contact”)
def freq = (frequency != null && frequency != “”) ? frequency * 60 : 600

if (contactState.value == “open”) {
def elapsed = now() - contactState.rawDateCreated.time
def threshold = ((openThreshold != null && openThreshold != “”) ? openThreshold * 60000 : 60000) - 1000
if (elapsed >= threshold) {
log.debug "Contact has stayed open long enough since last check ($elapsed ms): calling sendMessage()"
runIn(freq, doorOpenTooLong, [overwrite: false])
} else {
log.debug “Contact has not stayed open long enough since last check ($elapsed ms): doing nothing”
} else {
log.warn “doorOpenTooLong() called but contact is closed: doing nothing”

void sendMessage() {
def minutes = (openThreshold != null && openThreshold != “”) ? openThreshold : 10
def msg = "${contact.displayName} has been left open for ${minutes} minutes." msg
if (location.contactBookEnabled) {
sendNotificationToContacts(msg, recipients)
} else {
if (phone) {
sendSms phone, msg
} else {
sendPush msg