I went thru tons of forum threads and mostly all were good but either for whatever reason did not work for me or are based off the now sunset SmartThings mobile app (classic).
It took some tries and retries but finally I have a working version with some “help” from external units to achieve my objective. Here’s what and how I was able to do it.
Prerequisites / caveats: All of this is based off iPhone (I don’t know how it’ll work in Android but should be similar). Secondly, one needs Alexa (Amazon) to be installed in each mobile phone whose presence is required to be tracked. The location service must be set to “Always” for Alexa and it should be always running in the background. Oh and yes: webcore.
Step 1: Using the Groovy IDE I created 4 virtual switches and placed them in its own group - Virtual. They are vDad, vMom, vSon, vDaughter.
Step 2: In Dad’s phone I created 2 routines. These routines are individually created in each phone. This is because Alexa routine only allows one to track “This Device”.
Step 3: In Alexa I carefully play around and ensure by “Home” I have a really well defined area on the map. The good part is definition of “home” can vary for each member! Thus, for my 2 children the “Home” defined is relatively a very condensed space around my home while for my wife & I its relatively bigger.
Routine 1: Dad coming home
Trigger: When Dad's Device arrive home
Alexa Will: vDad = ON
Routine 2: Dad leaving home
Trigger: When Dad's Device leaves home
Alexa Will: vDad = OFF
These 2 routines are embed by creating them in each device. Thus, we need up have 2x4 = 8 routines.
One may wonder why Alexa when SmartThings itself has member locations. Try as much as I could that darn thing never ever worked as envisaged. One day it does work, next day it doesn’t. Ditto with Webcore Presence sensors also. Extremely unreliable. I reverted to Alexa as it’s been 200% stable. I also found stable was Tile app and its tracking
Step 4: In SmartThings Automation I created few scripts. They are listed below:
1. If Location Home = Home , SHM = Disarmed.
2. If Location Night = Home , SHM = Armed (Stay).
3. If Location Away = Home , SHM = Armed (Away)
This was required because after trying to play around directly with SHM, i.e. trying to set them it never worked perfectly.
Step 5: In Webcore and NOT in SmartThings I ended up creating the Goodbye and Welcome routines. I did not need the native automation because once again I saw very strange behavior, i.e. one day works next day doesn’t.
Piston #1 = Welcome
settings
disable automatic piston state;
end settings;
execute
if
Any of vDad's, vMom's, vDaughter's or vSon's switch changes to on
then
Set location mode to Home *(only while Away, or Night)* ;
end if;
end execute;
Piston #2: Goodbye
settings
disable automatic piston state;
end settings;
execute
if
Any of vDad's, vMom's, vDaughter's or vSon's switch changes to off
then
if
All of vDad's, vMom's, vDaughter's or vSon's switch are off
then
Set location mode to Away;
end if;
end if;
end execute;
The point here is - when trying to do this in the new app via an automation, setting the location mode is flaky at best. Thus switched to webcore. Also you’ll see in goodbye there’s an IF condition. I found webcore working best when there’s a “CHANGE” trigger
At this point I can safely say for the last +30 days this (above) has worked 100% of the time’
STEP 5: Good Night and Good Morning
For good night routine I used Smart Lighting smart app to create a script which keeps setting a virtual switch “Family Present” to On by checking for movement on specific motion sensors between time X to Y in the evening. If no movement for 30 min., then switches off the virtual switch. Smart Lighting programs are great since they keep resetting the timer every time there’s movement.
Then via a smart automation all I do is to set location = Night, if Family Present = OFF.
For good morning routine - it’s mostly the reverse. i.e. via a smart automation time between X and Y in the morning if motion is detected then flip the Family Present to ON. set location = HOME.
As you’ll observe here - I didn’t need Smart Lighting for Good Morning since I immediately make the home disarmed if there’s movement. However one can make that fancy too mirroring good night.
STEP 6: EXTRAS!! EXTRAS!! EXTRAS!!
All of the above works fine and dandy but I always had an issue where if the member’s phone died/not present/etc. then this won’t work and a lot of bad things will happen. For you see, I happen to have a Jerry-rigged 150 dB siren which goes off if security breached. That entire thing is controlled via SmartThing’s own response if a security event is triggered with a gap (delay) of a minute.
So here’s what I did in addition
Created another virtual open/close called vTickTock
Then, added this piston via webcore:
settings disable automatic piston state; end settings;
define
integer BlinkDurationOn = 5;
integer TimesOn = 10;
integer BlinkDurationOff = 3;
end define;
execute
if
Any of Back Door Open Close's, Front Door Open Close's, or Side Door Open Close's contact changes to open
then
with vtickTock do
Open *(only while Daytime, Away, or Night)* ;
end with;
end if;
while
All of Back Door Open Close's, Front Door Open Close's, and Side Door Open Close's contact are closed
and
vtickTock's contact is open
do
with vtickTock do
Close *(only while Home)* ;
end with;
end while;
end execute;
Then in Alexa, I created a routine which if it finds vTickTock to be opened, starts doing “tick tock” (Under sounds in Routine@Alexa). I had to manually add the tick tock at least 20 times. This is important since there’s a delay of a minute (in SmartThings before Siren kicks in). Thus, wanted to have a repetitive tick tock for at least approx. a minute. Only way to do that is to keep adding the tick-tock sound again and again in the Alexa routine. I calculated this and had to add it 18 times.
BTW: Anytime home is moved to HOME mode, the ticking stops since the sensor closes. Movement to HOME mode is done via the smart app (by whoever enters the phone) or via a secret phase to Alexa.
I know if I had a chime or something might have been easier but I wanted to keep devices to minimum. Also by using the messaging feature of Alexa routine I am able to generate this tick tock across all my Alexa devices simultaneously.
I have tested this with my children who regularly forget their phones, etc. I had a chimer before (Ring) but this works 100 times better. They call me to curse me but always end up moving the home into HOME mode before that. I have some secret message they utter to Alexa and home gets disarmed
So - I now have a working version of goodbye, welcome, good night and good morning. I also have a reminder routine just in case something fails or home does not get disarmed automatically. All of which is working perfectly for +30 days now. I also have the final routine which is triggered if there’s really an issue, i.e. the siren comes on
Final piston - is intruder alert, i.e. my strobe, siren all goes off.
For siren - as and when its triggered I have integration with IFTTT. There I have registered to generate a phone call to me as and when Siren get’s tripped.
Then also using webcore when siren gets tripped I have a piston which flashes all my lights in 2 groups. i.e. few lights in the front portion of my home goes on when back portion is off and vice versa. Couple this with the 150 dB siren + strobe (outdoor) Lights and the IFTTT generated phone calls I have the intruder side covered.
while
Siren's switch is on
do
with {group1Devices} do
Flash on {group1FlashOn} seconds / off {group1FlashOff} seconds for {counter} times *(only while Away, or Night)* ;
end with;
with {group2Devices} do
Flash on {group2FlashOn} seconds / off {Group2FlashOff} seconds for {counter} times *(only while Away, or Night)* ;
end with;
end while;
end execute;
Group 1 and Group 2 are set of lights spread across my home into 2 groups. They have different flash ON/OFF timings and counter can even be just 1 since as long as siren is ON this piston will trigger
STEP 7 : Work in progress. I am looking to see how I can leverage IFTTT to see if I can ping and get status of the hub. If I am not able to ping the hub for (say) XX seconds : call me. I want to do this to account for a scenario where someone cuts my Internet connection. Will post once I have a working version.
STEP 8: Normal (Home) mode notifications
I have 3 exit doors and each has it’s own open/close sensor. Every time door is opened, I have an Alexa routine detecting it (since open/close sensor opens) and does a nice sound. My children love it since we keep changing it - currently its Halloween based!! LOL
Final thing: My children are of an age they can stay comfortably home without us. The issue I had there was how to arm when we’re not home and only they are - either together or alone.
For this, using the Groovy IDE I created a special location mode: DAYTIME and then added a smartapp routine which is
If DAYTIME ; SHM = Armed (Stay)
To activate this once again via webcore I have this routine.
settings disable automatic piston state; end settings;
define
integer dAlone = 30;
integer sAlone = 30;
integer pAway = 60;
end define;
execute
while
vSon's switch stays on for {sAlone} minutes
and
All of vDad's and vMom's switch stay off for {pAway} minutes
and
vDaughter's switch stays on for {dAlone} minutes
and
All of Back Door Open Close's, Front Door Open Close's, and Side Door Open Close's contact stay closed for {sAlone} minutes
do
Send PUSH notification "Switching on DAYTIME (ARMED) mode" and store in Messages *(only while Home)* ;
Set location mode to Daytime *(only while Home)* ;
end while;
end execute;
The while condition is repeated with various options to account for just son / just daughter, etc.
Note: If doing this - carefully evaluate impact to other goodbye/welcome/etc. routines/pistons due to this new location mode = daytime