Location Mode and Presence


#1

1) Give a description of the problem
I copied the location mode presence piston posted here. I don’t want as many home modes and have the Sleep location mode variable (I have that setup fine on another piston activated from a button press).

2) What is the expected behavior?
I just want the location mode to change to Home - Night after the nightTime set and stay that way until dawn or I change it via other piston. I can’t seem to set the string to work.

3) What is happening/not happening?
location does not change at the set time of nightTime (9:10 pm)

**4) Post a Green Snapshot of the piston!

5) Attach any logs (From ST IDE and by turning logging level to Full)
6/25/2018, 9:10:19 PM +110ms
+1ms ╔Received event [Home].time = 1529986220000 with a delay of -890ms
+164ms ║RunTime Analysis CS > 22ms > PS > 46ms > PE > 95ms > CE
+167ms ║Runtime (50098 bytes) successfully initialized in 46ms (v0.3.104.20180323) (164ms)
+168ms ║╔Execution stage started
+207ms ║║Comparison (enum) not present is (string) present = false (1ms)
+209ms ║║Comparison (enum) present is (string) present = true (2ms)
+212ms ║║Condition #7 evaluated true (36ms)
+213ms ║║Condition group #3 evaluated true (state did not change) (37ms)
+222ms ║║Comparison (string) :98e02b92acaedf3784a1b7b80fa10be0: is_any_of (string) :53ec8adb24bdb8f8ec461927abece7bb:,:70d58461493f158c824651856d284512:,:4074c3be11ccebfcad11eadf55f6a09f:,:61dffc7d52a074ac4b84f7c908135973:,:c9254decba624cafce734afb409e17b0:,:98e02b92acaedf3784a1b7b80fa10be0:,:2734a280e943026d16a9e76dab389d3c: = true (4ms)
+223ms ║║Condition #146 evaluated true (8ms)
+224ms ║║Condition group #8 evaluated true (state did not change) (10ms)
+225ms ║║Cancelling statement #8’s schedules…
+526ms ║║Calculating (time) 76200000 > (time) 63000000 >> (boolean) true
+529ms ║║Invalid ternary operator. Ternary operator’s syntax is ( condition ? trueValue : falseValue ). Please check your syntax and try again.
+530ms ║║Calculating (boolean) true ? (string) Home - Night >> (boolean)
+537ms ║║Calculating (time) 76200000 < (time) 76200000 >> (boolean) false
+543ms ║║Calculating (time) 76200000 < (time) 63000000 >> (boolean) false
+550ms ║║Calculating (time) 76200000 < (time) 19380000 >> (boolean) false
+560ms ║║Error setting location mode. Mode ‘false’ does not exist.
+560ms ║║Executed virtual command setLocationMode (7ms)
+564ms ║║Cancelling statement #63’s schedules…
+571ms ║║Calculating (string) Home - Evening + (string) was initiated on >> (string) Home - Evening was initiated on
+575ms ║║Calculating (string) Home - Evening was initiated on + (string) Mon, Jun 25 2018 @ 9:10:19 PM PDT >> (string) Home - Evening was initiated on Mon, Jun 25 2018 @ 9:10:19 PM PDT
+577ms ║║Executed virtual command setState (1ms)
+585ms ║║Comparison (time) 76219690 happens_daily_at (time) 18000000 = false (1ms)
+587ms ║║Condition #136 evaluated false (6ms)
+588ms ║║Cancelling statement #136’s schedules…
+593ms ║║Requesting time schedule wake up at Tue, Jun 26 2018 @ 5:00:20 AM PDT
+601ms ║║Comparison (time) 76219707 happens_daily_at (time) 19380000 = false (0ms)
+603ms ║║Condition #138 evaluated false (6ms)
+604ms ║║Cancelling statement #138’s schedules…
+611ms ║║Requesting time schedule wake up at Tue, Jun 26 2018 @ 5:23:20 AM PDT
+617ms ║║Comparison (time) 76219723 happens_daily_at (time) 63000000 = false (0ms)
+619ms ║║Condition #139 evaluated false (6ms)
+620ms ║║Cancelling statement #139’s schedules…
+626ms ║║Requesting time schedule wake up at Tue, Jun 26 2018 @ 5:30:20 PM PDT
+633ms ║║Comparison (time) 76219739 happens_daily_at (time) 76200000 = true (1ms)
+634ms ║║Time restriction check passed
+636ms ║║Cancelling condition #140’s schedules…
+636ms ║║Condition #140 evaluated true (8ms)
+638ms ║║Cancelling statement #140’s schedules…
+643ms ║║Requesting time schedule wake up at Tue, Jun 26 2018 @ 9:10:20 PM PDT
+646ms ║║Cancelling condition #135’s schedules…
+646ms ║║Condition group #135 evaluated true (state changed) (66ms)
+652ms ║╚Execution stage complete. (485ms)
+655ms ║Setting up scheduled job for Tue, Jun 26 2018 @ 5:00:20 AM PDT (in 28200.236s), with 3 more jobs pending
+663ms ╚Event processed successfully (663ms)


#2

Your calculation which sets the variable “timeOfDayHome” doesn’t evaluate correctly. This means it ends up returning false which isn’t a location mode so the piston fails. I’ve never tried nesting Ternary operators, try using an “if()” function and see if that solves it.


#3

I was able figure out the acceleration to make the variable to evaluate correctly. Thanks!