Door left open for 1 minute, sound the alarm!


(Noah Selling) #1

Hi, new here and looking for help coding the following. It seems straight forward but so far it’s making this install much more complicated.

If my door is left open for 1 minute, sound the siren. The door has a contact sensor on it but I cant figure out how to enter the 1 minute delay.

I’m helping a friend with a store and this is the last piece to his puzzle. Right now it’s set to sound the siren when the door is opened and it’s not going well for his employees as you can imagine.

Thanks in advance for any help.


(Patrick Stuart [@pstuart]) #2

Well, first of all, why not post what you already have? We can help from there.

Essentially the blocks of code for the smartApp are this:

user inputs the door / contact sensor
user input the alarm

subscribe to that input and wire up an event function to fire on contact.open

Event will fire on open and start a timer, a runIn 60 seconds and another event that will fire after 60 seconds

Timer event, should check if door / contact is closed (latestValue, fyi) and if not, sound the subscribed alarm.

Probably should also subscribe to door close event, and if alarm is active, turn alarm off.

Hope that helps. If you want someone to write the code for you, just ask, I’m sure someone will, but if you want help writing the code yourself, just post what you got and we can help.


(Noah Selling) #3

Thank you very much for your response Patrick.

Clearly i started my request incorrectly and most likely in the wrong forum.

I a looking for someone to write this for me. I am looking into learning to code on my own but right now is not the right scenario for me to be tinkering. I do that on my own system.


(Patrick Stuart [@pstuart]) #4

Well, then we need to know the alarm type and what capabilities it has along with the door / contact sensor.

Assuming these both are available to choose, it shouldn’t be too hard to knock out a SmartApp that does this. I am quite surprised this doesn’t exist already (maybe it does, I didn’t look).

I’m a bit backed up on projects to do free coding. But maybe someone else has some time to donate to the cause.

Maybe I can knock this out during one of my upcoming live coding sessions. Would be fun to over engineer a simple app :smile:


(Noah Selling) #5

Sounds great and again thank you. Should I begin a new topic in a different board?

I have the SmartSense Open/Closed sensor connected to a Fortress Siren Strobe Alarm. It’s on the rear of the office and If it’s left open for 1 minute or more I would like the siren/strobe to activate. I have looked all over the forums and have not been able to locate anything like this albeit a boring use it seems quite basic.


(John S) #6

There is an “Alert me if the door is left open too long” action under Doors - rather than sending a push notification/SMS, we just need it to trip an alarm.

Edit: “Left It Open” template is the starting point. Just need to add the Alarm selection/trigger instead of SMS/Alert.


(jotto) #7

I would suggest trying SmartAlarm - You will have to self install (instructions to install are fairly straightforward).

This should give you options you have listed above, contact sensor setup to sound alarm with delay (you choose 30sec/60/90 delay).

http://statusbits.github.io/smartalarm/


(Patrick Stuart [@pstuart]) #8

Good catch, that is a great template. I don’t have anything with the capability of alarm, so not sure how that works in the real world.

Looking at that template, it just needs to add the function to turn off the alarm when door closed, if on.


(Noah Selling) #9

That’s as perfect as I have seen but as Patrick said I need to ability for the siren to stop once the door is closed. Great find though, Thanks a lot


(jotto) #10

Ahh sorry missed that you wanted the alarm to stop once the door was closed.


(Noah Selling) #11

Totally my fault. I truthfully forgot to mention it. Still getting used to truly representing all of the needs before posting.