Setting modes based on time of day and presence

mode
presence

#62

that was on purpose - i want evening mode to kick in a bit before sunset so outside lights etc come on a bit earlier.

Still, the piston fired correctly at the time of evening, but it set mode to “Home Day”. that’s the issue.


#63

there’s nothing in your piston to make it fire at ‘evening time’… that’s not even a specified time in your piston.

If you want it to fire early, just change the sunset variable to sunset less 20 minutes and leave the schedule to run 20 seconds after the sunset variable (rather than the sunset preset).

You cannot adjust the presets in the variable definitions however, so you’ll need to use an expression:

addMinutes($sunset,-20)


#64

my apologies - i meant when the time hits “sunset” - I have this scheduled to run at 20 mins prior.

However, last night when that time hit it set mode as “Home Day” instead of “Home Evening” which is what i have in the time24 rule. i must have something wrong there as it’s setting home day ?

i’ll update sunset to be addMinutes($sunset,-20) as you’ve suggested. ( i had put the - 20 down the bottom under time happens at.


#65

Hi Robin thanks for your help, I’ve move the scheduling section down to the bottom and this morning it didn’t trigger home-dawn at all it went straight from sleep to home-day at sunrise. Although when I went to bed at just after midnight the variable for DawnTime was 05:30:00.
I think what is happening is the mode changes correctly to dawn but then it re-evaluates the mode based on timeofdayhome which tells it that the time is now still < dawntime so it should be in sleep mode, it changes back to sleep mode and we miss dawn mode completely. i think i would need different expressions for wakeup is before sunrise and after sunrise.
Out of curiosity what happens to the original piston if dawnTime is after sunrise or if nighttime is after sunset?

25/09/2018, 05:30:29 +751ms
+0ms	╔Received event [Home].mode = Sleep with a delay of 74ms
+9989ms	║RunTime Analysis CS > 19ms > PS > 9828ms > PE > 141ms > CE
+9990ms	║Piston waited at a semaphore for 9770ms
+9993ms	║Runtime (59239 bytes) successfully initialized in 9828ms (v0.3.108.20180906) (9992ms)
+9994ms	║╔Execution stage started
+10006ms	║║Comparison (string) :9ed33657c6130d8602b092ce335983cb: is_not_any_of (string) :7429bcb2a229229d6f1c1e6659102d4a:,:318fa7d6b2e7e746b1695c546858196d: = true (3ms)
+10008ms	║║Condition #151 evaluated true (7ms)
+10009ms	║║Condition group #3 evaluated true (state did not change) (9ms)
+10024ms	║║Comparison (enum) present is (string) present = true (2ms)
+10027ms	║║Condition #7 evaluated true (16ms)
+10028ms	║║Condition group #3 evaluated true (state did not change) (18ms)
+10031ms	║║Cancelling statement #8's schedules...
+10051ms	║║Executed virtual command setAlarmSystemStatus (16ms)
+10118ms	║║Calculating (time) 19800000 < (time) 86340000 >> (boolean) true
+10127ms	║║Calculating (time) 19800000 < (time) 72180000 >> (boolean) true
+10136ms	║║Calculating (time) 19800000 < (time) 68580000 >> (boolean) true
+10145ms	║║Calculating (time) 19800000 < (time) 25260000 >> (boolean) true
+10153ms	║║Calculating (time) 19800000 < (time) 21660000 >> (boolean) true
+10190ms	║║Executed virtual command setLocationMode (33ms)
+10194ms	║║Cancelling statement #63's schedules...
+10202ms	║║Calculating (string) Sleep + (string) was initiated on >> (string) Sleep was initiated on
+10206ms	║║Calculating (string) Sleep was initiated on + (string) Tue, Sep 25 2018 @ 5:30:39 AM BST >> (string) Sleep was initiated on Tue, Sep 25 2018 @ 5:30:39 AM BST
+10209ms	║║Executed virtual command setState (1ms)
+10217ms	║║Comparison (boolean) false changes_to (boolean) true = false (0ms)
+10218ms	║║Condition #142 evaluated false (5ms)
+10220ms	║║Condition group #141 evaluated false (state did not change) (7ms)
+10224ms	║║Comparison (string) :9ed33657c6130d8602b092ce335983cb: changes_to (string) :46cc155878d3427fe608e136b52dbd53: = false (1ms)
+10226ms	║║Condition #168 evaluated false (5ms)
+10227ms	║║Condition group #167 evaluated false (state did not change) (6ms)
+10244ms	║║Comparison (enum) present is (string) present = true (2ms)
+10246ms	║║Condition #147 evaluated true (14ms)
+10252ms	║║Comparison (string) :9ed33657c6130d8602b092ce335983cb: changes_away_from_any_of (string) :7429bcb2a229229d6f1c1e6659102d4a:,:318fa7d6b2e7e746b1695c546858196d: = false (3ms)
+10254ms	║║Condition #148 evaluated false (7ms)
+10255ms	║║Condition group #146 evaluated false (state did not change) (25ms)
+10263ms	║║Comparison (string) :9ed33657c6130d8602b092ce335983cb: changes_to (string) :9ed33657c6130d8602b092ce335983cb: = true (1ms)
+10265ms	║║Cancelling condition #171's schedules...
+10266ms	║║Condition #171 evaluated true (7ms)
+10267ms	║║Cancelling condition #154's schedules...
+10269ms	║║Condition group #154 evaluated true (state changed) (10ms)
+10281ms	║║Comparison (enum) on is (string) on = true (2ms)
+10283ms	║║Condition #165 evaluated true (10ms)
+10290ms	║║Comparison (string) Tuesday is (string) Sunday = false (2ms)
+10292ms	║║Condition #166 evaluated false (8ms)
+10293ms	║║Condition group #164 evaluated false (state did not change) (21ms)
+10307ms	║║Comparison (time) 19800000 is_before (time) 1537855260000 = true (8ms)
+10309ms	║║Condition #172 evaluated true (14ms)
+10317ms	║║Comparison (string) Tuesday is_any_of (string) Monday, Tuesday, Wednesday, Thursday = true (3ms)
+10319ms	║║Condition #156 evaluated true (9ms)
+10321ms	║║Condition group #173 evaluated true (state did not change) (25ms)
+10322ms	║║Condition group #162 evaluated true (state did not change) (51ms)
+10323ms	║║Cancelling statement #162's schedules...
+10332ms	║║Executed virtual command setVariable (4ms)
+10340ms	║║Comparison (time) 19840087 happens_daily_at (time) 19800000 = false (1ms)
+10342ms	║║Condition #136 evaluated false (5ms)
+10343ms	║║Cancelling statement #136's schedules...
+10349ms	║║Requesting time schedule wake up at Wed, Sep 26 2018 @ 5:30:20 AM BST
+10356ms	║║Comparison (time) 19840103 happens_daily_at (time) 1537855260000 = false (0ms)
+10358ms	║║Condition #137 evaluated false (5ms)
+10359ms	║║Cancelling statement #137's schedules...
+10365ms	║║Requesting time schedule wake up at Tue, Sep 25 2018 @ 7:01:20 AM BST
+10372ms	║║Comparison (time) 19840119 happens_daily_at (time) 1537898580000 = false (1ms)
+10374ms	║║Condition #138 evaluated false (5ms)
+10375ms	║║Cancelling statement #138's schedules...
+10382ms	║║Requesting time schedule wake up at Tue, Sep 25 2018 @ 7:03:20 PM BST
+10395ms	║║Comparison (time) 19840136 happens_daily_at (time) 72180000 = false (1ms)
+10397ms	║║Condition #139 evaluated false (12ms)
+10398ms	║║Cancelling statement #139's schedules...
+10410ms	║║Requesting time schedule wake up at Tue, Sep 25 2018 @ 8:03:20 PM BST
+10418ms	║║Comparison (time) 19840165 happens_daily_at (time) 86340000 = false (0ms)
+10419ms	║║Condition #140 evaluated false (6ms)
+10421ms	║║Cancelling statement #140's schedules...
+10427ms	║║Requesting time schedule wake up at Tue, Sep 25 2018 @ 11:59:20 PM BST
+10430ms	║║Condition group #135 evaluated false (state did not change) (95ms)
+10436ms	║╚Execution stage complete. (442ms)
+10441ms	║Setting up scheduled job for Tue, Sep 25 2018 @ 7:01:20 AM BST (in 5439.809s), with 4 more jobs pending
+10453ms	╚Event processed successfully (10452ms)
25/09/2018, 05:30:20 +563ms
+0ms	╔Received event [Home].mode = Home - Dawn with a delay of 145ms
+8905ms	║RunTime Analysis CS > 17ms > PS > 8829ms > PE > 59ms > CE
+8906ms	║Piston waited at a semaphore for 8771ms
+8909ms	║Runtime (59207 bytes) successfully initialized in 8829ms (v0.3.108.20180906) (8908ms)
+8910ms	║╔Execution stage started
+8921ms	║║Comparison (string) :22e263f6fea9d0017b40c2a0afbed100: is_not_any_of (string) :7429bcb2a229229d6f1c1e6659102d4a:,:318fa7d6b2e7e746b1695c546858196d: = true (3ms)
+8923ms	║║Condition #151 evaluated true (7ms)
+8924ms	║║Condition group #3 evaluated true (state did not change) (9ms)
+8939ms	║║Comparison (enum) present is (string) present = true (1ms)
+8941ms	║║Condition #7 evaluated true (14ms)
+8942ms	║║Condition group #3 evaluated true (state did not change) (17ms)
+8945ms	║║Cancelling statement #8's schedules...
+8966ms	║║Executed virtual command setAlarmSystemStatus (18ms)
+9038ms	║║Calculating (time) 19800000 < (time) 86340000 >> (boolean) true
+9047ms	║║Calculating (time) 19800000 < (time) 72180000 >> (boolean) true
+9057ms	║║Calculating (time) 19800000 < (time) 68580000 >> (boolean) true
+9066ms	║║Calculating (time) 19800000 < (time) 25260000 >> (boolean) true
+9074ms	║║Calculating (time) 19800000 < (time) 21660000 >> (boolean) true
+9124ms	║║Executed virtual command setLocationMode (46ms)
+9128ms	║║Cancelling statement #63's schedules...
+9136ms	║║Calculating (string) Home - Dawn + (string) was initiated on >> (string) Home - Dawn was initiated on
+9140ms	║║Calculating (string) Home - Dawn was initiated on + (string) Tue, Sep 25 2018 @ 5:30:29 AM BST >> (string) Home - Dawn was initiated on Tue, Sep 25 2018 @ 5:30:29 AM BST
+9143ms	║║Executed virtual command setState (1ms)
+9150ms	║║Comparison (boolean) false changes_to (boolean) true = false (1ms)
+9152ms	║║Condition #142 evaluated false (5ms)
+9153ms	║║Condition group #141 evaluated false (state did not change) (7ms)
+9158ms	║║Comparison (string) :22e263f6fea9d0017b40c2a0afbed100: changes_to (string) :46cc155878d3427fe608e136b52dbd53: = false (1ms)
+9160ms	║║Condition #168 evaluated false (4ms)
+9161ms	║║Condition group #167 evaluated false (state did not change) (7ms)
+9176ms	║║Comparison (enum) present is (string) present = true (2ms)
+9178ms	║║Condition #147 evaluated true (14ms)
+9185ms	║║Comparison (string) :22e263f6fea9d0017b40c2a0afbed100: changes_away_from_any_of (string) :7429bcb2a229229d6f1c1e6659102d4a:,:318fa7d6b2e7e746b1695c546858196d: = false (3ms)
+9187ms	║║Condition #148 evaluated false (7ms)
+9188ms	║║Condition group #146 evaluated false (state did not change) (23ms)
+9195ms	║║Comparison (string) :22e263f6fea9d0017b40c2a0afbed100: changes_to (string) :9ed33657c6130d8602b092ce335983cb: = false (0ms)
+9196ms	║║Condition #171 evaluated false (5ms)
+9198ms	║║Condition group #154 evaluated false (state did not change) (6ms)
+9200ms	║║Cancelling statement #157's schedules...
+9209ms	║║Calculating (decimal) 0.0 - (decimal) 1.0 >> (decimal) -1.0
+9216ms	║║Executed virtual command setVariable (2ms)
+9224ms	║║Comparison (time) 19829783 happens_daily_at (time) 21660000 = false (1ms)
+9226ms	║║Cancelling condition #136's schedules...
+9227ms	║║Condition #136 evaluated false (8ms)
+9228ms	║║Cancelling statement #136's schedules...
+9234ms	║║Requesting time schedule wake up at Tue, Sep 25 2018 @ 6:01:20 AM BST
+9241ms	║║Comparison (time) 19829800 happens_daily_at (time) 1537855260000 = false (1ms)
+9243ms	║║Condition #137 evaluated false (5ms)
+9244ms	║║Cancelling statement #137's schedules...
+9250ms	║║Requesting time schedule wake up at Tue, Sep 25 2018 @ 7:01:20 AM BST
+9257ms	║║Comparison (time) 19829816 happens_daily_at (time) 1537898580000 = false (1ms)
+9259ms	║║Condition #138 evaluated false (6ms)
+9261ms	║║Cancelling statement #138's schedules...
+9267ms	║║Requesting time schedule wake up at Tue, Sep 25 2018 @ 7:03:20 PM BST
+9281ms	║║Comparison (time) 19829833 happens_daily_at (time) 72180000 = false (0ms)
+9282ms	║║Condition #139 evaluated false (12ms)
+9284ms	║║Cancelling statement #139's schedules...
+9296ms	║║Requesting time schedule wake up at Tue, Sep 25 2018 @ 8:03:20 PM BST
+9303ms	║║Comparison (time) 19829862 happens_daily_at (time) 86340000 = false (1ms)
+9305ms	║║Condition #140 evaluated false (5ms)
+9307ms	║║Cancelling statement #140's schedules...
+9312ms	║║Requesting time schedule wake up at Tue, Sep 25 2018 @ 11:59:20 PM BST
+9316ms	║║Cancelling condition #135's schedules...
+9317ms	║║Condition group #135 evaluated false (state changed) (97ms)
+9323ms	║╚Execution stage complete. (414ms)
+9327ms	║Setting up scheduled job for Tue, Sep 25 2018 @ 6:01:20 AM BST (in 1850.111s), with 4 more jobs pending
+9337ms	╚Event processed successfully (9337ms)
25/09/2018, 05:30:19 +91ms
+1ms	╔Received event [Home].time = 1537849820000 with a delay of -909ms
+226ms	║RunTime Analysis CS > 52ms > PS > 109ms > PE > 64ms > CE
+230ms	║Runtime (59140 bytes) successfully initialized in 109ms (v0.3.108.20180906) (228ms)
+231ms	║╔Execution stage started
+249ms	║║Comparison (string) :9ed33657c6130d8602b092ce335983cb: is_not_any_of (string) :7429bcb2a229229d6f1c1e6659102d4a:,:318fa7d6b2e7e746b1695c546858196d: = true (4ms)
+251ms	║║Condition #151 evaluated true (9ms)
+253ms	║║Condition group #3 evaluated true (state did not change) (11ms)
+269ms	║║Comparison (enum) present is (string) present = true (2ms)
+272ms	║║Condition #7 evaluated true (16ms)
+274ms	║║Condition group #3 evaluated true (state did not change) (19ms)
+279ms	║║Cancelling statement #8's schedules...
+333ms	║║Executed virtual command setAlarmSystemStatus (49ms)
+433ms	║║Calculating (time) 19800000 < (time) 86340000 >> (boolean) true
+443ms	║║Calculating (time) 19800000 < (time) 72180000 >> (boolean) true
+453ms	║║Calculating (time) 19800000 < (time) 68580000 >> (boolean) true
+462ms	║║Calculating (time) 19800000 < (time) 25260000 >> (boolean) true
+472ms	║║Calculating (time) 19800000 < (time) 19800000 >> (boolean) false
+1419ms	║║Executed virtual command setLocationMode (942ms)
+1424ms	║║Cancelling statement #63's schedules...
+1436ms	║║Calculating (string) Sleep + (string) was initiated on >> (string) Sleep was initiated on
+1442ms	║║Calculating (string) Sleep was initiated on + (string) Tue, Sep 25 2018 @ 5:30:20 AM BST >> (string) Sleep was initiated on Tue, Sep 25 2018 @ 5:30:20 AM BST
+1447ms	║║Executed virtual command setState (1ms)
+1457ms	║║Comparison (boolean) false changes_to (boolean) true = false (1ms)
+1459ms	║║Condition #142 evaluated false (8ms)
+1461ms	║║Condition group #141 evaluated false (state did not change) (9ms)
+1467ms	║║Comparison (string) :9ed33657c6130d8602b092ce335983cb: changes_to (string) :46cc155878d3427fe608e136b52dbd53: = false (0ms)
+1469ms	║║Condition #168 evaluated false (6ms)
+1471ms	║║Condition group #167 evaluated false (state did not change) (8ms)
+1491ms	║║Comparison (enum) present is (string) present = true (2ms)
+1494ms	║║Condition #147 evaluated true (17ms)
+1500ms	║║Comparison (string) :9ed33657c6130d8602b092ce335983cb: changes_away_from_any_of (string) :7429bcb2a229229d6f1c1e6659102d4a:,:318fa7d6b2e7e746b1695c546858196d: = false (1ms)
+1502ms	║║Condition #148 evaluated false (7ms)
+1504ms	║║Condition group #146 evaluated false (state did not change) (28ms)
+1512ms	║║Comparison (string) :9ed33657c6130d8602b092ce335983cb: changes_to (string) :9ed33657c6130d8602b092ce335983cb: = false (1ms)
+1515ms	║║Cancelling condition #171's schedules...
+1517ms	║║Condition #171 evaluated false (8ms)
+1519ms	║║Cancelling condition #154's schedules...
+1520ms	║║Condition group #154 evaluated false (state changed) (12ms)
+1523ms	║║Cancelling statement #157's schedules...
+1536ms	║║Calculating (decimal) 0.0 - (decimal) 1.0 >> (decimal) -1.0
+1545ms	║║Executed virtual command setVariable (3ms)
+1556ms	║║Comparison (time) 19820641 happens_daily_at (time) 21660000 = true (1ms)
+1559ms	║║Time restriction check passed
+1561ms	║║Cancelling condition #136's schedules...
+1562ms	║║Condition #136 evaluated true (12ms)
+1563ms	║║Cancelling statement #136's schedules...
+1570ms	║║Requesting time schedule wake up at Tue, Sep 25 2018 @ 6:01:20 AM BST
+1573ms	║║Cancelling condition #135's schedules...
+1575ms	║║Condition group #135 evaluated true (state changed) (25ms)
+1585ms	║╚Execution stage complete. (1354ms)
+1589ms	║Setting up scheduled job for Tue, Sep 25 2018 @ 6:01:20 AM BST (in 1859.321s), with 4 more jobs pending
+1598ms	╚Event processed successfully (1598ms)
24/09/2018, 23:59:19 +832ms
+0ms	╔Received event [Home].mode = Sleep with a delay of 90ms
+9406ms	║RunTime Analysis CS > 18ms > PS > 9325ms > PE > 63ms > CE
+9407ms	║Piston waited at a semaphore for 9269ms
+9410ms	║Runtime (59244 bytes) successfully initialized in 9325ms (v0.3.108.20180906) (9409ms)
+9411ms	║╔Execution stage started
+9422ms	║║Comparison (string) :9ed33657c6130d8602b092ce335983cb: is_not_any_of (string) :7429bcb2a229229d6f1c1e6659102d4a:,:318fa7d6b2e7e746b1695c546858196d: = true (3ms)
+9424ms	║║Condition #151 evaluated true (7ms)
+9425ms	║║Condition group #3 evaluated true (state did not change) (9ms)
+9440ms	║║Comparison (enum) present is (string) present = true (2ms)
+9442ms	║║Condition #7 evaluated true (15ms)
+9443ms	║║Condition group #3 evaluated true (state did not change) (17ms)
+9446ms	║║Cancelling statement #8's schedules...
+9459ms	║║Executed virtual command setAlarmSystemStatus (9ms)
+9523ms	║║Calculating (time) 86340000 < (time) 86340000 >> (boolean) false
+9533ms	║║Calculating (time) 86340000 < (time) 72300000 >> (boolean) false
+9542ms	║║Calculating (time) 86340000 < (time) 68700000 >> (boolean) false
+9551ms	║║Calculating (time) 86340000 < (time) 25140000 >> (boolean) false
+9560ms	║║Calculating (time) 86340000 < (time) 21540000 >> (boolean) false
+9589ms	║║Executed virtual command setLocationMode (24ms)
+9592ms	║║Cancelling statement #63's schedules...
+9600ms	║║Calculating (string) Sleep + (string) was initiated on >> (string) Sleep was initiated on
+9604ms	║║Calculating (string) Sleep was initiated on + (string) Mon, Sep 24 2018 @ 11:59:29 PM BST >> (string) Sleep was initiated on Mon, Sep 24 2018 @ 11:59:29 PM BST
+9607ms	║║Executed virtual command setState (1ms)
+9614ms	║║Comparison (boolean) false changes_to (boolean) true = false (1ms)
+9616ms	║║Condition #142 evaluated false (5ms)
+9617ms	║║Condition group #141 evaluated false (state did not change) (7ms)
+9622ms	║║Comparison (string) :9ed33657c6130d8602b092ce335983cb: changes_to (string) :46cc155878d3427fe608e136b52dbd53: = false (0ms)
+9623ms	║║Condition #168 evaluated false (5ms)
+9625ms	║║Condition group #167 evaluated false (state did not change) (6ms)
+9640ms	║║Comparison (enum) present is (string) present = true (2ms)
+9642ms	║║Condition #147 evaluated true (14ms)
+9648ms	║║Comparison (string) :9ed33657c6130d8602b092ce335983cb: changes_away_from_any_of (string) :7429bcb2a229229d6f1c1e6659102d4a:,:318fa7d6b2e7e746b1695c546858196d: = false (3ms)
+9650ms	║║Condition #148 evaluated false (7ms)
+9651ms	║║Condition group #146 evaluated false (state did not change) (24ms)
+9658ms	║║Comparison (string) :9ed33657c6130d8602b092ce335983cb: changes_to (string) :9ed33657c6130d8602b092ce335983cb: = true (0ms)
+9660ms	║║Cancelling condition #171's schedules...
+9661ms	║║Condition #171 evaluated true (6ms)
+9662ms	║║Cancelling condition #154's schedules...
+9663ms	║║Condition group #154 evaluated true (state changed) (9ms)
+9674ms	║║Comparison (enum) on is (string) on = true (2ms)
+9676ms	║║Condition #165 evaluated true (10ms)
+9683ms	║║Comparison (string) Monday is (string) Sunday = false (2ms)
+9685ms	║║Condition #166 evaluated false (8ms)
+9686ms	║║Condition group #164 evaluated false (state did not change) (20ms)
+9699ms	║║Comparison (time) 19800000 is_before (time) 1537768740000 = true (8ms)
+9701ms	║║Condition #172 evaluated true (13ms)
+9708ms	║║Comparison (string) Monday is_any_of (string) Monday, Tuesday, Wednesday, Thursday = true (2ms)
+9710ms	║║Condition #156 evaluated true (8ms)
+9712ms	║║Condition group #173 evaluated true (state did not change) (23ms)
+9713ms	║║Condition group #162 evaluated true (state did not change) (47ms)
+9714ms	║║Cancelling statement #162's schedules...
+9721ms	║║Executed virtual command setVariable (3ms)
+9729ms	║║Comparison (time) 86369557 happens_daily_at (time) 19800000 = false (1ms)
+9731ms	║║Condition #136 evaluated false (5ms)
+9732ms	║║Cancelling statement #136's schedules...
+9738ms	║║Requesting time schedule wake up at Tue, Sep 25 2018 @ 5:30:20 AM BST
+9744ms	║║Comparison (time) 86369573 happens_daily_at (time) 1537768740000 = false (1ms)
+9746ms	║║Condition #137 evaluated false (6ms)
+9748ms	║║Cancelling statement #137's schedules...
+9754ms	║║Requesting time schedule wake up at Tue, Sep 25 2018 @ 6:59:20 AM BST
+9760ms	║║Comparison (time) 86369589 happens_daily_at (time) 1537812300000 = false (1ms)

#66

i think i figured out what is happening in my case. (see above) i may have to adopt this route, though i still need flexible timings for the sleep mode as we go to bed at different times so kind of “last to bed turns off the lights”


#67

I actually use a custom Alexa routine for bedtime because my wife and I never go to bed at a fixed time. So, I created a custom routine in Alexa with a phrase of “Alexa, we’re going to bed now” that turns off all the lights, locks the doors, turns on various cameras and sets the thermostat.

The only thing I use webCoRE for in this instance is just to set the mode to “sleeping” and arm cameras and SHM.


#68

You may as well just keep it simple then, have Alexa turn off a simulated switch and have webCoRE respond to that switch by changing the mode.


#69

I thought about doing that too. I need to re-setup Ask Alexa as well. It’s on my very long list of things to do. LOL


#70

Based on my last reply any idea why it’s still firing home day mode when the time is after sunset ?

Id really appreciate your help.


#71

Your last reply said you would change the piston based on my recommendation… I can’t comment without seeing the updated piston.


#72

no problems appreciate it -

here’s the updated piston. I just added the expression to time happens statement.

Right now the piston sets mode to “Home Day” Correctly. But “Home Evening” should be set when sunset occurs (-20 mins now) but for some reason it is setting “Home Day”.

thank you


#73

what you have there is essentially the same as what you had before…

You need to add the expression to the sunset variable in the define section (top of the piston) not the happens daily part.

The happens daily part should be 20 seconds after variable sunset not the original 20 seconds after preset $sunset.


#74

got it thanks - updated below and it worked nicely !

Hopefully it runs Home Evening at 20 mins to sunset now.

thank you


#75

Hey All,

I havent been on here for a while. Im not sure whats happened, but since the ST hub upgrade (at some point in the past). This piston has stopped working for me. The mode just stays on Home-Morning. What could cause this? Where is best to start troubleshooting?


#76

Are you running the latest version of webCoRE? all 4 apps?


#77

Having a few issues with this and I’ve been staring at it for an hour and can’t figure out why. I tried adding something so that if we are both away overnight, it will automatically set the location mode to vacation instead of running through the morning, noon, evening, night.

What happened is last night at 11pm, while we were both home, it set the location mode to Away - Night. I figured I’d leave it until morning so I could test the vacation mode setting. At 2 minutes before 7:30 that if statement somehow evaluated as false so vacation mode was not set. Then at 7:30am it set the location mode to Home - Night.

I must have something off somewhere, but I’m just not seeing it.

Piston ran again at 12:00:20pm and set mode to Home - Morning.
($time24 < morning ? ‘Home - Night’ : ($time24 < afternoon ? ‘Home - Morning’ : ($time24 < evening ? ‘Home - Afternoon’ : ($time24 < night ? ‘Home - Evening’ : ‘Home - Night’))))
This expression is currently evaluating to Home - Afternoon. So I really have no clue why it’s setting Home - Morning.

Blockquote
1/13/2019, 12:00:20 PM +126ms
+1ms ╔Received event [47 Carsdale].time = 1547395220000 with a delay of 126ms
+671ms ║RunTime Analysis CS > 325ms > PS > 314ms > PE > 32ms > CE
+675ms ║Runtime (51480 bytes) successfully initialized in 314ms (v0.3.109.20181207) (672ms)
+676ms ║╔Execution stage started
+700ms ║║Comparison (enum) not present is (string) present = false (2ms)
+704ms ║║Comparison (enum) present is (string) present = true (2ms)
+705ms ║║Condition #7 evaluated true (21ms)
+712ms ║║Comparison (string) :a078bddfaa1ea31b2a58e6ee1a406477: is_not (string) :c7db4daaef8d8f12a541db3807b02850: = true (2ms)
+713ms ║║Condition #151 evaluated true (7ms)
+715ms ║║Condition group #3 evaluated true (state did not change) (31ms)
+718ms ║║Cancelling statement #8’s schedules…
+756ms ║║Calculating (time) 43200000 < (time) 82800000 >> (boolean) true
+766ms ║║Calculating (time) 43200000 < (time) 59400000 >> (boolean) true
+777ms ║║Calculating (time) 43200000 < (time) 43200000 >> (boolean) false
+786ms ║║Calculating (time) 43200000 < (time) 27000000 >> (boolean) false
+7675ms ║║Executed virtual command setLocationMode (6884ms)
+7701ms ║║Comparison (enum) not present is (string) not present = true (3ms)
+7706ms ║║Comparison (enum) present is (string) not present = false (2ms)
+7708ms ║║Condition #142 evaluated false (27ms)
+7709ms ║║Condition group #141 evaluated false (state did not change) (29ms)
+8275ms ║║Comparison (time) 43228394 happens_daily_at (time) 27000000 = false (1ms)
+8278ms ║║Condition #140 evaluated false (9ms)
+8280ms ║║Cancelling statement #140’s schedules…
+8291ms ║║Requesting time schedule wake up at Mon, Jan 14 2019 @ 7:30:20 AM AST
+8304ms ║║Comparison (time) 43228421 happens_daily_at (time) 43200000 = true (1ms)
+8306ms ║║Time restriction check passed
+8309ms ║║Cancelling condition #136’s schedules…
+8310ms ║║Condition #136 evaluated true (15ms)
+8312ms ║║Cancelling statement #136’s schedules…
+8325ms ║║Requesting time schedule wake up at Mon, Jan 14 2019 @ 12:00:20 PM AST
+8329ms ║║Cancelling condition #135’s schedules…
+8331ms ║║Condition group #135 evaluated true (state changed) (63ms)
+8335ms ║║Cancelling statement #63’s schedules…
+8346ms ║║Calculating (string) Home - Morning + (string) was initiated on >> (string) Home - Morning was initiated on
+8351ms ║║Calculating (string) Home - Morning was initiated on + (string) Sun, Jan 13 2019 @ 12:00:28 PM AST >> (string) Home - Morning was initiated on Sun, Jan 13 2019 @ 12:00:28 PM AST
+8356ms ║║Executed virtual command setState (1ms)
+8864ms ║╚Execution stage complete. (8189ms)
+8877ms ║Setting up scheduled job for Sun, Jan 13 2019 @ 4:30:20 PM AST (in 16190.998s), with 4 more jobs pending
+8900ms ╚Event processed successfully (8900ms)


#78

One thing I would do is adjust your Ternary operators slightly. Currently, if timeOfDayAway is false for the 4 checks, it falls back on Away - Night. Likewise, if timeOfDayHome is false for the 4 checks, it falls back on Home - Night. Personally, I like to insert some kind of error as my last resort so I know when the other checks fail. Such as:

($time24 < morning ? ‘Home - Night’ : ($time24 < afternoon ? ‘Home - Morning’ : ($time24 < evening ? ‘Home - Afternoon’ : ($time24 > night ? ‘Home - Night’ : ($time24 < night ? ‘Home - Evening’ : ‘ERROR’)))))

(notice I added a new check for 11pm - midnight)


#79

That’s not a bad idea. I’ve made that adjustment.

It still doesn’t explain why it’s setting location mode to Home - Morning at 12:00:20pm. It should clearly be evaluating as < evening and setting to Home - Afternoon


#80

Please turn on TRACE so we can see the grey numbers after each line of code. This helps when digging thru the logs to see what is happening.


#81

Like this?