Delay for Intrusion Alert in SHM - Success!

intrusionalert
shm

(El Zurdo) #1

I had to bang my head against this for a while, but I successfully applied a 20-second delay before Smart Home Monitor will issue an intruder alert. It required tweaking a couple of SmartApps, as I explain below. But the result works. And I’m pretty proud of it–even if it is a Rube Goldberg sequence. Here is a basic summary for those of you equipped to handle it. (Specific implementation details are further below):

(1) All of the Open/Close sensors are configured to trigger a Virtual Switch (“S1”)
(2) S1 shuts off after 20 seconds (you could set any number of seconds)
(3) When S1 turns off, it triggers another Virtual Switch (“S2”)
(4) S2 activates motion on a Virtual Motion Sensor
(5) SHM alarm monitors for motion on only the Virtual Motion Sensor
(6) Both S2 and Virtual Motion Sensor turn off/reset after a few minutes.

Note that if you wanted a “real” motion sensor to also trigger a SHM intruder alert, you could run a parallel automation so that the motion sensors would also turn on S1 in step 1.

I needed this because we’re using a smart lock. We have it configured using IFTTT integration so that when it locks, it arms the SHM system, and when it unlocks, it disarms the SHM system. I will post separately about how we did that. (We wanted to use the lock’s keypad for arm/disarm because we spend a lot of time at our neighbors’ homes–we would register as “present” even if we’re in someone else’s backyard).

But the trouble is that when unlocking and opening the front door using the lock’s keypad, we would sometimes trigger the alarm. I guess the disarm routine hadn’t completed by the time the open/close sensor was triggered. Needed a short buffer to prevent false alarms.

Step 1: (All of the Open/Close sensors are configured to trigger a Virtual Switch (“S1”))

Create a virtual switch in the developer environment (“IDE”). Go to the IDE --> login --> My Locations --> Home (or wherever) --> My Devices --> New Device --> Name [S1 or whatever you want] --> Label [same] --> Zigbee Id [blank] --> [Device Network Id [whatever you want] --> Type [Simulated Switch] --> Location [home (or wherever] --> Hub [wherever] --> Group [blank] --> Create.

In the App, configure the open/close sensors to turn S1 on and off. You can do this in either Automatons/Routines or in the SmartApp for Lights & Switches --> Smart Lights --> New Lighting Automation.

Step 2: (S1 shuts off after 20 seconds (you could set any number of seconds))

I used the Power Allowance SmartApp Template, but I had to modify it to run in seconds rather than minutes.In the IDE, go to My SmartApps–> New SmartApp --> From Template --> All Categories --> Power Allowance. Copy that code. The click the “From Code” tab at the top and paste the code into the box. Every place in the code that you see the word, minutes, change it to “seconds.” And delete the multiplier of “* 60” a few lines from the bottom. Click Create --> Save --> Publish --> To Me.

In the app, go to Marketplace --> SmartApps --> My Apps (at the bottom) --> Power Allowance. Set the trigger switch to be S1, and set it to turn off in 20 seconds.

Credit to the community: I got this daisy-chain idea from user JDRoberts at this thread: Delay the State of a Switch?.

Step 3: (When S1 turns off, it triggers another Virtual Switch (“S2”))

In the IDE, create another virtual switch. Same process as Step 1. Let’s call it S2.
In the App, go to Smart Apps --> Lights & Switches --> Smart Lights --> New Lighting Automation.Set it to control S2, and have it set to turn S2 on when S1 is turned off.

Step 4: (S2 activates motion on a Virtual Motion Sensor)

In the IDE, create a virtual motion sensor that will be used to trigger the alarm when S2 is turned on. Same basic steps as creating a virtual switch.

Then, also in the IDE, create another smartapp from code using the “trigger a motion sensor” stuff found at the bottom of this thread: How to trigger an event on another device (possibly virtual?).

But this code is not perfect for these purposes. As written, this code only turns motion on for a very brief second before immediately resetting, which is not long enough to trigger the alarm. And if you remove the ability reset entirely, it you can’t reset your motion event on the virtual motion sensor (see Step 6). So you need to modify the code. From line 59 until the end, here are my changes–paste them over what is in the version you copy from github:

def installed() {
log.debug “Installed with settings: ${settings}”

on()
off()

}

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

unsubscribe()
on()
    off()

}

def on() {
log.debug "subscribe"
subscribe(theswitch, “switch.on”, onHandler)
}

def off() {
log.debug "subscribe"
subscribe(theswitch, “switch.off”, offHandler)
}

def onHandler(evt){
log.debug "onHandler called: $evt"
themotion.active()
}
def offHandler(evt){
log.debug "offHandler called: $evt"
themotion.inactive()
}

After making these changes, click Create --> Save --> Publish --> To Me.

Then go to the App on your device. Smart Apps --> Motion Sensor Activation. Set it the switch to S2 and the Sensor to be the Virtual Motion Sensor you created.

Step 5: (SHM alarm monitors for motion on only the Virtual Motion Sensor))

Go back to the SHM Dashboard, Click the little gear to enter the Configure settings–>Security. Set your monitoring modes to use only the Virtual Motion Sensor(s) you have created. Note that if you are using real motion sensors and want them to have the same delay, you can just create another lighting/switch automation to turn on S1, only one that is triggered by your chosen motion sensors.

Step 6: (Both S2 and Virtual Motion Sensor turn off/reset after a few minutes.)
This is one of the reasons why we changed the code–the motion needs to be active for long enough to trigger the alarm, but it needs to also turn off after a certain amount of time. The code was modified to turn the motion back off when the switch is deactivated. You could also code a delay directly into the smartapp, but I’m not a coder and don’t know how to do that. Instead, I applied another automation in SmartApps You could use the Power Allowance App that you created (operating on a number of seconds), or you could use Smart Apps --> Lights & Switches --> Smart Lights --> New Lighting Automation and use the “Power Allowance” trigger that is built in there. Remember that this latter version is operating on a number of minutes. Set it for something like 3 minutes. After that amount of time, the S2 virtual switch will turn off and the virtual motion sensor will deactivate.

Edit–credit to the original author of the code:

  • Copyright 2015 James Houghton
  • 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:
  • [I am a new user an cannot link–but there was a link here to Apache 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.

And while we’re at it, I’ll say same goes for my modified/derivative version-- copyright 2016 by Peter Surdo. Apache 2.0 License terms apply.


Smart home monitor exit/enter delay
Can I delay a Home Monitor "intrusion alert?"
Smart Home Monitor delay
Sound effect before alarm goes off (20 seconds)
Smart Home Monitor - Feature Requests
Can you delay Siren Alarm after sensor trigger
Connect wired alarm system sensors to SmartThings with a NodeMCU ESP8266 [deprecated]
[RELEASE] Honeywell / Ademco Vista 20P Integration
(Robin) #2

Or you could just leave SHM actions blank and setup a rule (using rule machine or CORE).

Example:

If SHM is armed and contact sensor opens then activate alarm after x delay (cancel on truth change).

In the above setup I switch a Fibaro relay on / off which in turn has rules to sound the siren etc. The relay is hard wired to a Fibaro universal sensor which transmits an alarm frame, making all the lights flash (Fibaro dimmer 2 units).

I also use a Fibaro button to toggle the relay which acts as a panic button.


Front door opens and alarm goes off
(El Zurdo) #3

Thanks. That seems more elegant.

At least now all the threads about setting a delay have two answers right here.

I am new to ST, but I did try to find rules engine and had the impression it wasn’t available anymore.I’m going to go play with Core next, I guess.


(Robin) #4

Rule machine is no longer available. It still works for those or us that had it before it was shelved, but no one can share the code anymore without breaching the licence owned by @bravenel

I haven’t dabbled with CORE yet but from what I hear it works just as well and is essentially the same thing…

This is a great community so please feel free to ask questions instead of spending ages trying to figure it out on your own.


(El Zurdo) #5

Turns out a new version of CoRE was released earlier today.


(Jason "The Enabler" as deemed so by @Smart) #6

@El.Zurdo
Welcome to the community and the addiction!
I just want to say awesome job jumping in full force and finding a solution to the problem, and then taking the time to write up a detailed report to share with others to use.

If you have questions, feel free to ask… This community is asked finding new ways to take ST to the next level. And if you can’t find it in a search, ask, it’s probably been asked already, but the forum has a horrible search function.

Rule machine was an outstanding tool that filled s bad need in the ST environment. There were a lot of growing pains after the V2 release and the developer had a falling out. He then decided to abandon the project and left.

@ady624 stepped in and repaired the void caused by the rule machine developer. He created a rule engine that makes rule machine look like a cute little toy.

So, if you’re looking to do some amazing things, jump in there and see what home automation can really do!


(Robin) #7

I have now dabbled with CoRE and though very complicated I take back the above statement. It does not work just as well… It works much better and has tons more features compared to the old Rule Machine… kudos to @ady624, Fantastic App!!!


(Ryan) #8

Has anyone done this with CoRE? I’m just getting started with it and cant get the logic right.


(Eric Plummer) #9

well i tried to follow the directions, was unsuccessful. It trips the alarm every-time. I even went back and did it again. Looks like it turns on s1, then after delay s2 and immediately virtual motion. alarm trips.
There were some settings that were unclear like to turn it off again. in the smart lighting. etc.

help would be appreciated.


(Robin) #10

Just setup a CoRE piston that looks like this:

No need to over complicate it.


Anyone managed ENTRY & EXIT delays
Smart alarm entry delay not working
Activate siren if switch/light left on for X minutes
Wired Zone Delay without SmartAlarm
Next project, Geo arm/disarm and light?
Front door opens and alarm goes off
(Eric Plummer) #11

Thanks for the instruction seems easy but how does it integrate with shm as I use scout to monitor.


(Robin) #12

Just add an extra action in CoRE to open and then close a virtual contact sensor… Then setup SHM to monitor the same.

Contact sensor options are a little hidden in CoRE, you can find them within “control any device” on the first page of a new action.


“I’m Back” timing against intrusion alerts for opening garage?
Entry delay for Intrusion alert
(Robin) #13

It never ceases to amaze me that companies like Scout offer remote monitoring and police call outs for SHM!!

In the UK, in response to all the false alarms, the police will refuse to attend an alarm activation unless a certified (wired) system was installed by a certified installer… Even then the system has to be included on a national register of authorised alarms. The emergency operator will ask for the reference number prior to dispatching the Police.

If a certified system then triggers 3 false alarms, the installer gets fined and the system is struck off the list until it is re-configured and re-certified!!

As far as I’m aware… SHM would never get certification in the UK for several reasons, but mainly due to the types of sensors it uses and the frequent false alarms.

In any case, I have a handheld device that can jam the frequencies ST uses, it’s not it’s intended purpose (and I won’t advertise it on here) but it works!

I could also just cut the power or data cables entering the building… Bypassing SHM is far too easy, it’s a toy not a reliable alarm.


(Chris ) #14

My cables are buried and I have 2 back ups… Cellular and sat phone.

Just to be safe a 4hr battery back up on critical components plus the generator that’s wired in.


(Amauri Viguera) #15

Depending on where you live in the US, it can be just as bad. One of my coworkers had that issue with his setup, where after a few false alarms he got a pretty stern warning from the local precinct.


(El Zurdo) #16

I haven’t had this problem. Sounds like your system isn’t disarming by the time virtual motion is triggered. Make sure you’re set for “S1 On --> S1 Off after daley, triggering S2 to come on --> S2 turns on virtual motion.” That’s your delay. As for disarming, make sure that the routine disarms the monitor at the same time that S1 turns on. And maybe try different delays to see if disarm is getting hung up or something. I’m currently set for a 5-second delay and our alarm gets a false alarm every once in a great while.


(El Zurdo) #17

Yup. The Smart Home Monitor that plugs into Scout will monitor for open sensors or motion. You can use the dummy contact in Core. Or, if you already have the virtual motion sensor installed from the DME setup in the original post, you can use the “Motion Sensor Activation” smart app to have the siren or some other triggered switch to turn it on.


(Shaun) #18

Thank you for this! Is there anyway to pass through CoRE a variable of the name of which contact sensor originally tripped? It seems like in this setup, SHM would only show the virtual contact as the point of intrusion. I only ask as an alternative to setting every intrusion sensor up with its own virtual equivalent.


(Robin) #19

There is no easy way to pass this kind of info directly to SHM from CoRE… As you correctly stated you will need to setup multiple virtual devices to achieve this.


(Shaun) #20

Thanks again! This is ok because I only really need the delay for my front door to eliminate someone entering the correct access code but SHM triggering an intrusion before recognizing the code is correct.