I am new with the smartapps as I have just recently purchased a hub and it has been quite a few years since I have done any coding.
Basically I am looking at getting a notification when the garage door is open and then the interior door to the garage is open for more than 1 minutes. This is so the dogs don’t get out, but I don’t want to get the notification if i just open and close the door. Later I will probably add a way to get a sound notification.
But what I am looking at doing is adding a delay to the following code that I am trying to modify to suit my needs. Any help in pointing me in the right direction would be great.
preferences {
section (“When this door opens/is open…”) {
input “door1”, “capability.contactSensor”, title: “Which garage door?”, required: true
}
section (“And this door opens/is open…”) {
input “door2”, “capability.contactSensor”, title: “Which interior door?”, required: true
}
section( "Notifications" ) {
input "sendPushMessage", "enum", title: "Send a push notification?", metadata:[values:["Yes","No"]], required:false
input "phone1", "phone", title: "Send a text message?", required: false
input "msg", "text", title: "What is your message?", required: false
}
}
def installed() {
log.debug “Installed with settings: ${settings}”
initialize()
}
def updated() {
log.debug “Updated with settings: ${settings}”
unsubscribe()
initialize()
}
def initialize() {
subscribe(door1, “contact.open”, door1Handler)
subscribe(door2, “contact.open”, door2Handler)
}
def door1Handler(evt) {
def door2Current = door2.currentContact
log.debug “door2 current status is $door2Current”
if (door2.currentContact == "open") {
send(msg)
}
}
def door2Handler(evt) {
def door1Current = door1.currentContact
log.debug “door1 current status is $door1Current”
if (door1.currentContact == “open”) {
send(msg)
}
}
private send(msg) {
if ( sendPushMessage != “No” ) {
log.debug( “sending push message” )
sendPush( msg )
}
if ( phone1 ) {
log.debug( "sending text message" )
sendSms( phone1, msg )
}
log.debug msg
}
Thank you in advance for any help!