Pool access alarm rule

I have 1 pushbutton, 1 door contact sensor, and 1 siren. I just can't figure out how to make a Rule Machine rule to do what I want here.

If the door has been open for 5 seconds I want the siren to go off. But, if someone pushes the button before the 5 seconds has expired, I want the 5 second timer to START over. Like the button just keeps extending the time before the siren can go off.

So, if the door has been open >= 5 seconds, and the button hasn't been pushed in last 5 seconds....siren goes off.

How can I achieve this?

There are likely many ways to do this, but what I would do is:

Pressing the button will re-trigger the rule which will cancel the “Wait for event” and therefore re-start the timer.

If the door is closed when the 5-second is reached, nothing will happen. Otherwise, the siren will sound. (May require a siren off event depending on the type of siren…)

To make the siren turn off when the button is pressed, the first command could be to turn off the siren.

1 Like

Thank you. I don't know how to implement what you show above. I can make basic rules, but never fooled with virtual anything on the hub.

Ok, I implemented it with a user app. My brain just can't work with the rules for some reason (don't laugh).

definition(
name: "Alarm After Door Open 5s, defeat with Button",
namespace: "your.namespace",
author: "Your Name",
description: "Trigger an alarm after Door Contact 1 has been open for 5 seconds, unless the Third Reality Smart Button is pressed",
category: "Convenience",
iconUrl: "",
iconX2Url: ""
)

preferences {
section("Select Devices") {
input "doorContact1", "capability.contactSensor", title: "Door Contact 1", required: true
input "alarm1", "capability.alarm", title: "Alarm 1", required: true
input "button1", "capability.pushableButton", title: "Third Reality Smart Button", required: true
}
}

def installed() {
subscribe(doorContact1, "contact.open", contactOpenHandler)
subscribe(doorContact1, "contact.closed", contactClosedHandler)
subscribe(button1, "pushed", buttonPushedHandler)
}

def updated() {
unsubscribe()
subscribe(doorContact1, "contact.open", contactOpenHandler)
subscribe(doorContact1, "contact.closed", contactClosedHandler)
subscribe(button1, "pushed", buttonPushedHandler)
}

def contactOpenHandler(evt) {
log.debug "Door Contact 1 opened"
runIn(5, triggerAlarm)
}

def contactClosedHandler(evt) {
log.debug "Door Contact 1 closed"
unschedule(triggerAlarm)
alarm1.off()
}

def buttonPushedHandler(evt) {
log.debug "Third Reality Smart Button pushed"
unschedule(triggerAlarm)
alarm1.off()
}

def triggerAlarm() {
log.debug "Triggering Alarm 1"
alarm1.on()
}

The virtual devices in my example are just what I used, but you would replace them with the actual devices. However, if yo are more comfortable with an app, that works too! I won’t be able to help with that though… there are others with the required knowledge on the forum.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.