@Robin Does this new Piston look correct?
Advance Piston not working as intended
Maybe… hard to tell without testing…
Suggest you setup a couple of simulated presence sensors to save you having to test physically.
If you use the ‘on event’ function and IS it separates things and may work better.
‘On event’ is an advanced trigger option… click options and then ‘show advanced statements’.
Now when you click ‘add a statement’ you get loads more choices, including ‘on event’
Gotcha, Thank you for the assistance.
On a side note my wife got home today and Smartthings picked up that she was present but the house didn’t switch from Away - Day to Home - Day for some reason. Not sure why though, any ideas?
Here is the latest log, she got home at 13:58
’11/29/2017, 1:58:10 PM +565ms
+1ms ╔Received event [Kaitlyn].presence = present with a delay of 102ms
+169ms ║RunTime Analysis CS > 22ms > PS > 36ms > PE > 112ms > CE
+182ms ║Runtime (54179 bytes) successfully initialized in 36ms (v0.2.0fe.20171109) (181ms)
+183ms ║╔Execution stage started
+242ms ║║Comparison (time) 50290754 is_between (time) 18000000 … (time) 1511957280000 = false (7ms)
+243ms ║║Condition #2 evaluated false (54ms)
+244ms ║║Cancelling statement #2’s schedules…
+251ms ║║Requesting time schedule wake up at Thu, Nov 30 2017 @ 5:00:00 AM EST
+253ms ║║Condition group #1 evaluated false (state did not change) (64ms)
+269ms ║║Comparison (time) 50290822 is_between (time) 1511957280000 … (time) 1511991840000 = true (9ms)
+270ms ║║Time restriction check passed
+272ms ║║Condition #12 evaluated true (15ms)
+273ms ║║Cancelling statement #12’s schedules…
+281ms ║║Requesting time schedule wake up at Wed, Nov 29 2017 @ 4:44:00 PM EST
+283ms ║║Condition group #11 evaluated true (state did not change) (27ms)
+293ms ║║Comparison (enum) not present is (string) present = false (2ms)
+295ms ║║Comparison (enum) present is (string) present = true (1ms)
+297ms ║║Cancelling condition #17’s schedules…
+298ms ║║Condition #17 evaluated true (13ms)
+299ms ║║Cancelling condition #13’s schedules…
+300ms ║║Condition group #13 evaluated true (state changed) (14ms)
+302ms ║║Cancelling statement #18’s schedules…
+314ms ║║Executed virtual command setAlarmSystemStatus (10ms)
+357ms ║║Executed virtual command setLocationMode (40ms)
+372ms ║║Comparison (time) 50290926 is_between (time) 1511991840000 … (time) 73800000 = false (8ms)
+374ms ║║Condition #80 evaluated false (12ms)
+375ms ║║Cancelling statement #80’s schedules…
+381ms ║║Requesting time schedule wake up at Wed, Nov 29 2017 @ 4:44:00 PM EST
+384ms ║║Condition group #69 evaluated false (state did not change) (23ms)
+396ms ║║Comparison (time) 50290952 is_between (time) 73800000 … (time) 82800000 = false (7ms)
+397ms ║║Condition #22 evaluated false (10ms)
+399ms ║║Cancelling statement #22’s schedules…
+403ms ║║Requesting time schedule wake up at Wed, Nov 29 2017 @ 8:30:00 PM EST
+405ms ║║Condition group #21 evaluated false (state did not change) (19ms)
+417ms ║║Comparison (time) 50290974 is_between (time) 82800000 … (time) 18000000 = false (7ms)
+419ms ║║Condition #32 evaluated false (11ms)
+420ms ║║Cancelling statement #32’s schedules…
+425ms ║║Requesting time schedule wake up at Wed, Nov 29 2017 @ 11:00:00 PM EST
+428ms ║║Condition group #31 evaluated false (state did not change) (19ms)
+431ms ║║Cancelling statement #63’s schedules…
+437ms ║║Calculating (string) Home + (string) was initiated on >> (string) Home was initiated on
+440ms ║║Calculating (string) Home was initiated on + (string) Wed, Nov 29 2017 @ 1:58:10 PM EST >> (string) Home was initiated on Wed, Nov 29 2017 @ 1:58:10 PM EST
+442ms ║║Executed virtual command setState (0ms)
+449ms ║╚Execution stage complete. (266ms)
+453ms ║Setting up scheduled job for Wed, Nov 29 2017 @ 4:44:00 PM EST (in 9948.983s), with 4 more jobs pending
+470ms ╚Event processed successfully (471ms)
11/29/2017, 1:57:11 PM +349ms
+1ms ╔Received event [Home].test = 1511981831342 with a delay of 7ms
+159ms ║RunTime Analysis CS > 13ms > PS > 30ms > PE > 116ms > CE
+171ms ║Runtime (54176 bytes) successfully initialized in 30ms (v0.2.0fe.20171109) (169ms)
+172ms ║╔Execution stage started
+228ms ║║Comparison (time) 50231527 is_between (time) 18000000 … (time) 1511957280000 = false (9ms)
+229ms ║║Condition #2 evaluated false (51ms)
+230ms ║║Cancelling statement #2’s schedules…
+241ms ║║Requesting time schedule wake up at Thu, Nov 30 2017 @ 5:00:00 AM EST
+244ms ║║Condition group #1 evaluated false (state did not change) (66ms)
+258ms ║║Comparison (time) 50231595 is_between (time) 1511957280000 … (time) 1511991840000 = true (8ms)
+259ms ║║Time restriction check passed
+261ms ║║Condition #12 evaluated true (14ms)
+263ms ║║Cancelling statement #12’s schedules…
+271ms ║║Requesting time schedule wake up at Wed, Nov 29 2017 @ 4:44:00 PM EST
+274ms ║║Condition group #11 evaluated true (state did not change) (28ms)
+285ms ║║Comparison (enum) not present is (string) present = false (1ms)
+288ms ║║Comparison (enum) not present is (string) present = false (1ms)
+289ms ║║Condition #17 evaluated false (13ms)
+290ms ║║Condition group #13 evaluated false (state did not change) (14ms)
+304ms ║║Comparison (enum) not present is (string) not present = true (2ms)
+306ms ║║Comparison (enum) not present is (string) not present = true (2ms)
+308ms ║║Comparison (enum) not present is (string) not present = true (1ms)
+310ms ║║Condition #85 evaluated true (17ms)
+310ms ║║Condition group #14 evaluated true (state did not change) (18ms)
+311ms ║║Cancelling statement #14’s schedules…
+334ms ║║Executed virtual command [Bathroom Fan, Bathroom Heat, Bathroom Light, Bedroom Light, Bedroom Light 2, Bedroom Scentsy, Dining Room Light, Flood Lights, Hallway Light, Kitchen Lights, Living Room Lights, Living Room Scentsy, Mud Room Light, Nursery Lamp, Nursery Light, TV Lightstrip].wait (4ms)
+336ms ║║Requesting a wake up for Wed, Nov 29 2017 @ 2:02:11 PM EST (in 300.0s)
+354ms ║╚Execution stage complete. (182ms)
+359ms ║Setting up scheduled job for Wed, Nov 29 2017 @ 2:02:11 PM EST (in 299.982s), with 5 more jobs pending
+374ms ╚Event processed successfully (374ms)
11/29/2017, 7:12:58 AM +140ms
+0ms ╔Received event [Home].time = 1511957579873 with a delay of -1734ms
+173ms ║RunTime Analysis CS > 25ms > PS > 31ms > PE > 117ms > CE
+185ms ║Runtime (54165 bytes) successfully initialized in 31ms (v0.2.0fe.20171109) (183ms)
+186ms ║╔Execution stage started
+281ms ║║Executed virtual command [Bathroom Fan, Bathroom Heat, Bathroom Light, Bedroom Light, Bedroom Light 2, Bedroom Scentsy, Dining Room Light, Flood Lights, Hallway Light, Kitchen Lights, Living Room Lights, Living Room Scentsy, Mud Room Light, Nursery Lamp, Nursery Light, TV Lightstrip].setAlarmSystemStatus (43ms)
+334ms ║║Executed virtual command [Bathroom Fan, Bathroom Heat, Bathroom Light, Bedroom Light, Bedroom Light 2, Bedroom Scentsy, Dining Room Light, Flood Lights, Hallway Light, Kitchen Lights, Living Room Lights, Living Room Scentsy, Mud Room Light, Nursery Lamp, Nursery Light, TV Lightstrip].setLocationMode (51ms)
+339ms ║║Skipped execution of physical command [Bathroom Fan].off([]) because it would make no change to the device. (3ms)
+340ms ║║Executed [Bathroom Fan].off (5ms)
+459ms ║║Executed physical command [Bathroom Heat].off() (116ms)
+460ms ║║Executed [Bathroom Heat].off (118ms)
+466ms ║║Skipped execution of physical command [Bathroom Light].off([]) because it would make no change to the device. (3ms)
+466ms ║║Executed [Bathroom Light].off (5ms)
+477ms ║║Executed physical command [Bedroom Light].off() (9ms)
+478ms ║║Executed [Bedroom Light].off (9ms)
+487ms ║║Executed physical command [Bedroom Light 2].off() (7ms)
+488ms ║║Executed [Bedroom Light 2].off (9ms)
+493ms ║║Skipped execution of physical command [Bedroom Scentsy].off([]) because it would make no change to the device. (3ms)
+494ms ║║Executed [Bedroom Scentsy].off (4ms)
+498ms ║║Skipped execution of physical command [Dining Room Light].off([]) because it would make no change to the device. (2ms)
+499ms ║║Executed [Dining Room Light].off (4ms)
+505ms ║║Skipped execution of physical command [Flood Lights].off([]) because it would make no change to the device. (3ms)
+506ms ║║Executed [Flood Lights].off (5ms)
+511ms ║║Skipped execution of physical command [Hallway Light].off([]) because it would make no change to the device. (3ms)
+512ms ║║Executed [Hallway Light].off (5ms)
+530ms ║║Executed physical command [Kitchen Lights].off() (15ms)
+530ms ║║Executed [Kitchen Lights].off (16ms)
+535ms ║║Skipped execution of physical command [Living Room Lights].off([]) because it would make no change to the device. (3ms)
+536ms ║║Executed [Living Room Lights].off (4ms)
+541ms ║║Skipped execution of physical command [Living Room Scentsy].off([]) because it would make no change to the device. (2ms)
+541ms ║║Executed [Living Room Scentsy].off (4ms)
+546ms ║║Skipped execution of physical command [Mud Room Light].off([]) because it would make no change to the device. (3ms)
+547ms ║║Executed [Mud Room Light].off (5ms)
+551ms ║║Skipped execution of physical command [Nursery Lamp].off([]) because it would make no change to the device. (2ms)
+552ms ║║Executed [Nursery Lamp].off (4ms)
+557ms ║║Skipped execution of physical command [Nursery Light].off([]) because it would make no change to the device. (3ms)
+558ms ║║Executed [Nursery Light].off (5ms)
+563ms ║║Skipped execution of physical command [TV Lightstrip].off([]) because it would make no change to the device. (2ms)
+564ms ║║Executed [TV Lightstrip].off (4ms)
+622ms ║║Comparison (time) 25978708 is_between (time) 1511991840000 … (time) 73800000 = false (10ms)
+624ms ║║Condition #80 evaluated false (56ms)
+625ms ║║Cancelling statement #80’s schedules…
+633ms ║║Requesting time schedule wake up at Wed, Nov 29 2017 @ 4:44:00 PM EST
+635ms ║║Condition group #69 evaluated false (state did not change) (68ms)
+648ms ║║Comparison (time) 25978779 is_between (time) 73800000 … (time) 82800000 = false (7ms)
+649ms ║║Condition #22 evaluated false (11ms)
+651ms ║║Cancelling statement #22’s schedules…
+655ms ║║Requesting time schedule wake up at Wed, Nov 29 2017 @ 8:30:00 PM EST
+658ms ║║Condition group #21 evaluated false (state did not change) (19ms)
+670ms ║║Comparison (time) 25978801 is_between (time) 82800000 … (time) 18000000 = false (7ms)
+672ms ║║Condition #32 evaluated false (10ms)
+673ms ║║Cancelling statement #32’s schedules…
+678ms ║║Requesting time schedule wake up at Wed, Nov 29 2017 @ 11:00:00 PM EST
+680ms ║║Condition group #31 evaluated false (state did not change) (20ms)
+683ms ║║Cancelling statement #63’s schedules…
+689ms ║║Calculating (string) Home - Dawn + (string) was initiated on >> (string) Home - Dawn was initiated on
+692ms ║║Calculating (string) Home - Dawn was initiated on + (string) Wed, Nov 29 2017 @ 7:12:58 AM EST >> (string) Home - Dawn was initiated on Wed, Nov 29 2017 @ 7:12:58 AM EST
+695ms ║║Executed virtual command setState (1ms)
+701ms ║╚Execution stage complete. (516ms)
+705ms ║Setting up scheduled job for Wed, Nov 29 2017 @ 4:44:00 PM EST (in 34261.156s), with 4 more jobs pending
+723ms ╚Event processed successfully (722ms)
It’s being reported on the ST forum that modes are not reporting / changing properly, even with native apps like routines and smart lighting… haven’t seen issues myself but might be that.
Also, can you post your latest piston (green snapshot) as the version you posted at the top of this thread does not appear to be subscribing to the presence events whereas the logs look like it is.
Youre not subscribing to the presence sensors properly… anyway, your piston could be wayyyyyyy more efficient, I’ll knock something up.
@Robin that would be great, I pulled the Piston I have now from the Advance Samples page on the wiki and I always thought it seemed a bit complicated.
Try this (untested but should be good):
In addition to when presence toggles between any present and all away, the timers at the bottom will trigger the piston at the various times to move the mode along when presence hasn’t changed.
Edit, this only fires for presence change, not time. Fixed and more condensed piston in my next post.
@Robin Thank you! I will test this when I get home from work this evening and let you know how it works out.
Because I like a good challenge… here’s the same thing simplified even further :
Also, the example I showed in post 13 doesn’t fully work, ‘every day’ does not fire the whole piston, only what’s within that statement, whereas ‘time happens daily’ does fire the rest of the piston (which is what is needed).
So this example is subscribed to presence changes AND the 5 different times of day.
@Robin So I was trying to use your latest example but it is asking me for custom modes, didn’t know what it wanted so hit cancel and now not sure where to enter those values at? I also evaluate the “timeOfDayHome” variable and it is returning sleep at 8:30PM which isn’t correct, it should be “Home - Night”
Also I noticed that when in sleep mode it doesn’t currently set SHM to Armed/Stay like my original piston did, I’m sure that is an easy fix though
Latest update: Home - Night evaluated true at 10:26pm. Get up at 6:10AM this morning and mode is still on Sleep. Seems the time is off in the string variable somehow?
It appears the 20s delays I put in the timers wasn’t enough (needed to be over 1 minute)… $time24 is formatted as hh:mm whereas the specific times and presets are hh:mm:ss.
The 20 seconds past 5am trigger tests the ternary operator as follows: 05:00 (should be 05:00:20) <= 05:00:00 (should return false), with the missing ss on the left the ss on the right gets ignored, so its testing 05:00 <= 05:00 and incorrectly returns true which in turn returns the wrong mode.
Anyway, I’ve changed the logical operator to < (less than) which should solve the problem.
In regards to the import wizard asking you to select ‘custom modes’… just hit cancel, then go into lines 37 and 44 and select the variables ‘timeOfDayHome’ and ‘timeOfDayAway’ respectively, as shown in the screenshot.
@Robin Thanks for the quick responce, the only remaining issue I have with this Piston is it isn’t setting the SHM mode to Arm/STAY when sleep time arrives. Any chance that is a quick fix/add?
This should work:
Instead of set SHM to value Disarmed I used the following expression:
(timeOfDayHome == ‘Sleep’ ? ‘Armed/Stay’ : ‘Disarmed’)
This is the same as:
IF timeOfDayHome IS Sleep
THEN
Set SHM to Armed/Stay
Else
Set SHM to Disarmed
@Robin Awesome! Thank you so much for the assistance. I was going to post it in examples but seen you already did.
Also here is my notification Piston, that is now working correcly, I’m sure the logic could be cleaned up some but it works.
It could be shortened but it wouldn’t have enough effect on the efficiency.
Looks fine to me.