SHM Delay Replacement


#1

1) Give a description of the problem
General logic review of the two REPEAT loops on line 79 and 148. Being the secondary grouping in their respective IF statements that has both WAIT and Asynchronous timing issues, would the use of the REPEAT function be the best use case and if so, is it implemented ‘properly’?

2) What is the expected behaviour?
The loops are repeated until specific switches are turned on.

**4) Post a Green Snapshot of the piston![image|45x37]

5) Attach logs after turning logging level to Full

11/26/2020, 7:39:03 AM +74ms
+0ms ╔Received event [Indian Trail].test = 1606397943073 with a delay of 0ms
+76ms ║Calculating (string) You must leave within + (string) 60 >> (string) You must leave within 60
+79ms ║Calculating (string) You must leave within 60 + (string) seconds or DISARM the alarm! >> (string) You must leave within 60 seconds or DISARM the alarm!
+82ms ║RunTime Analysis CS > 23ms > PS > 3ms > PE > 57ms > CE
+86ms ║Runtime (63161 bytes) successfully initialized in 3ms (v0.3.110.20191009) (84ms)
+87ms ║╔Execution stage started
+110ms ║║Condition #28 evaluated false (18ms)
+111ms ║║Condition group #25 evaluated false (state did not change) (20ms)
+122ms ║║Condition #44 evaluated false (7ms)
+123ms ║║Condition group #43 evaluated false (state did not change) (9ms)
+135ms ║║Condition #99 evaluated false (8ms)
+138ms ║║Condition group #98 evaluated false (state did not change) (10ms)
+149ms ║║Comparison (enum) off is (string) on = false (1ms)
+150ms ║║Condition #64 evaluated false (10ms)
+151ms ║║Condition group #63 evaluated false (state did not change) (11ms)
+163ms ║║Comparison (enum) off is (string) on = false (1ms)
+165ms ║║Condition #104 evaluated false (11ms)
+166ms ║║Condition group #103 evaluated false (state did not change) (12ms)
+173ms ║║Comparison (boolean) false changes_to (boolean) true = false (1ms)
+175ms ║║Condition #85 evaluated false (5ms)
+176ms ║║Condition group #84 evaluated false (state did not change) (7ms)
+198ms ║╚Execution stage complete. (112ms)
+207ms ╚Event processed successfully (207ms)

#2

Great additions. I’m curious on the async and the repeat loops. I’ve never used those…will need to dig into it.


#3

Hey guys -

I took at look at what you guys were doing - as I’ve always been unhappy with the STHM solution from Samsung. I started with the piston that Jason edited as I like(d) the idea of defining all of the variables at the top and then using them in the piston - but because webcore doesn’t really work like a traditional programming language, that proved to be somewhat of a fools errand (for instance, the variables you initialize re-initialize every the piston executes, so you your triggers never change state)…and I ended up at almost exactly what Brent posted originally…go figure.

Anyway - I made some tweaks to the code - as I wanted some cases to fire an alarm instantly (like - alarm armed as away and a motion detector is tripped… no reason to delay…or alarm is armed in stay and a glass break sensor is tripped), but delayed for some (like the garage door opens when alarm armed away - so you can come inside and put down groceries and disarm the alarm…that sort of thing…and then I essentially just gave up on STHM and did the alarm siren control & notifications myself in the piston…that’s all STHM was doing for me anyway. Anyway - I had a bunch of automations originally, like Brent mentioned in his post on the Smartthings forum, but I turned all of those off - and built that logic in as well…anyway - what I ended up with is a stand alone smartthings alarm logic that doesn’t use STHM at all.

I paired mine with actiontiles to control the virtual “arm stay” “arm away” and “disarm” switches, and put a password on those tiles so when you try to arm or disarm the alarm from the panel, it pops up the keypad. I also paired it with Fully Kiosk Browser to lock everything down and do the TTS/Sounds at the panel as well.

I didn’t have any buzzers in my system, so I removed those…

Anyway - take a look - I tried to update the comments (thanks for commenting so well) … if it’s useful - use it :).

Legend for devices (from anonymized piston):
Switch 7 = Disarm Virtual Switch
Switch 1 = Siren
Switch 2 = Arm Away Virtual Switch
Switch 3 = Arm Stay Virtual Switch
Unknown Device 1 = Kindle Fire HD8 (At the Garage Door)
Unknown Device 2 = Kindle Fire HD8 (in Master Bedroom)
Contact Sensor 1, 2, 5 = most of the contact sensors (all except the (for me) garage entry door to the house - I wanted that one to have the delay)
Motion Sensor 1, 3 = Actual motion Sensors
Motion Sensor 2, 4 = Glass Break sensors (treated like motion sensors)
Contact Sensor 3 = the one door I want to delay firing the alarm in away state when it gets tripped (again - for me - my garage entry door).
Contact Sensor 4 = “Simulated Contact Sensor” (left over from STHM piston) - used to display status (set to open when disarmed and set to closed when armed in any state).

Anyway - enjoy!
Zach