Time between two different time ranges


#1

1) Give a description of the problem
I am trying to dim my lights between 9pm and 6am or between 9pm and sunrise. I have tried many different permutations but it keeps working incorrectly. It could be unrelated to my code but I suspect I am just making a basic logic error

2) What is the expected behavior?
Evaluate to true when the current time is between either one the two ranges. The start time of the range is typically the same while the end time of the range will either be sunrise or a set time,

3) What is happening/not happening?
At this point I do not recall the exact behavior of the code as it is right now, but in all its permutations it was either working between start and midnight and not afterwards or between midnight and the end time but not before midnight. Or something along those lines… I am not typically up at night testing this. I think I am having issues with the fact the range spans across 2 days and I am therefore making an incorrect logic test. OR… it is due to me not knowing how to use time/datetime variable types

4) Post a Green Snapshot of the pistonimage

5) Attach any logs (From ST IDE and by turning logging level to Full)
(PASTE YOUR LOGS HERE BETWEEN THE MARKS)

10/23/2017, 7:51:24 AM +79ms
+1ms ╔Received event [Master Bathroom Light].switch = off with a delay of 1584ms
+538ms ║RunTime Analysis CS > 17ms > PS > 205ms > PE > 316ms > CE
+547ms ║Runtime (43213 bytes) successfully initialized in 205ms (v0.2.0fa.20171011) (545ms)
+548ms ║╔Execution stage started
+564ms ║║Comparison (enum) on is (string) on = true (5ms)
+565ms ║║Condition #20 evaluated true (12ms)
+566ms ║║Condition group #null evaluated true (state did not change) (14ms)
+580ms ║║Comparison (enum) off changes_to (string) on = false (0ms)
+582ms ║║Cancelling condition #3’s schedules…
+583ms ║║Condition #3 evaluated false (14ms)
+584ms ║║Cancelling condition #1’s schedules…
+585ms ║║Condition group #1 evaluated false (state changed) (16ms)
+587ms ║╚Execution stage complete. (39ms)
+594ms ╚Event processed successfully (594ms)
10/23/2017, 7:16:42 AM +825ms
+2ms ╔Received event [Master Bathroom Light].switch = on with a delay of 1051ms
+257ms ║RunTime Analysis CS > 16ms > PS > 120ms > PE > 121ms > CE
+266ms ║Runtime (43218 bytes) successfully initialized in 120ms (v0.2.0fa.20171011) (263ms)
+267ms ║╔Execution stage started
+282ms ║║Comparison (enum) on is (string) on = true (2ms)
+284ms ║║Condition #20 evaluated true (10ms)
+285ms ║║Condition group #null evaluated true (state did not change) (12ms)
+301ms ║║Comparison (enum) on changes_to (string) on = true (1ms)
+303ms ║║Cancelling condition #3’s schedules…
+304ms ║║Condition #3 evaluated true (17ms)
+305ms ║║Cancelling condition #1’s schedules…
+306ms ║║Condition group #1 evaluated true (state changed) (19ms)
+318ms ║║Comparison (time) 26203134 is_after (time) 75600000 = false (6ms)
+319ms ║║Condition #10 evaluated false (10ms)
+334ms ║║Comparison (time) 26203146 is_between (datetime) 1508734800000 … (time) 21600000 = false (7ms)
+336ms ║║Condition #21 evaluated false (14ms)
+384ms ║║Comparison (time) 26203162 is_between (datetime) 1508734800000 … (datetime) 1508762280000 = true (6ms)
+385ms ║║Time restriction check passed
+387ms ║║Condition #23 evaluated true (51ms)
+388ms ║║Condition group #22 evaluated true (state did not change) (67ms)
+389ms ║║Condition group #6 evaluated true (state did not change) (81ms)
+392ms ║║Cancelling statement #7’s schedules…
+408ms ║║Skipped execution of physical command [Master Bathroom Light].setLevel([10]) because it would make no change to the device. (3ms)
+409ms ║║Executed virtual command [Master Bathroom Light].fadeLevel (8ms)
+413ms ║╚Execution stage complete. (146ms)
+428ms ╚Event processed successfully (428ms)
10/23/2017, 7:16:39 AM +29ms
+1ms ╔Received event [Master Bathroom Light].switch = off with a delay of 1047ms
+255ms ║RunTime Analysis CS > 25ms > PS > 114ms > PE > 116ms > CE
+263ms ║Runtime (43218 bytes) successfully initialized in 114ms (v0.2.0fa.20171011) (261ms)
+264ms ║╔Execution stage started
+278ms ║║Comparison (enum) on is (string) on = true (1ms)
+279ms ║║Condition #20 evaluated true (10ms)
+280ms ║║Condition group #null evaluated true (state did not change) (11ms)
+296ms ║║Comparison (enum) off changes_to (string) on = false (1ms)
+298ms ║║Condition #3 evaluated false (16ms)
+299ms ║║Condition group #1 evaluated false (state did not change) (17ms)
+301ms ║╚Execution stage complete. (38ms)
+309ms ╚Event processed successfully (309ms)
10/23/2017, 7:16:36 AM +872ms
+1ms ╔Received event [Master Suite Toilet Light].switch = off with a delay of 1022ms
+204ms ║RunTime Analysis CS > 13ms > PS > 75ms > PE > 115ms > CE
+216ms ║Runtime (43214 bytes) successfully initialized in 75ms (v0.2.0fa.20171011) (214ms)
+217ms ║╔Execution stage started
+230ms ║║Comparison (enum) on is (string) on = true (2ms)
+232ms ║║Condition #20 evaluated true (10ms)
+233ms ║║Condition group #null evaluated true (state did not change) (11ms)
+247ms ║║Comparison (enum) off changes_to (string) on = false (1ms)
+249ms ║║Cancelling condition #3’s schedules…
+250ms ║║Condition #3 evaluated false (15ms)
+251ms ║║Cancelling condition #1’s schedules…
+252ms ║║Condition group #1 evaluated false (state changed) (17ms)
+254ms ║╚Execution stage complete. (37ms)
+268ms ╚Event processed successfully (268ms)
10/23/2017, 7:05:29 AM +93ms
+2ms ╔Received event [Master Suite Toilet Light].switch = on with a delay of 951ms
+239ms ║RunTime Analysis CS > 23ms > PS > 104ms > PE > 112ms > CE
+247ms ║Runtime (43215 bytes) successfully initialized in 104ms (v0.2.0fa.20171011) (244ms)
+248ms ║╔Execution stage started
+266ms ║║Comparison (enum) on is (string) on = true (2ms)
+267ms ║║Condition #20 evaluated true (13ms)
+268ms ║║Condition group #null evaluated true (state did not change) (15ms)
+284ms ║║Comparison (enum) on changes_to (string) on = true (1ms)
+286ms ║║Condition #3 evaluated true (15ms)
+287ms ║║Condition group #1 evaluated true (state did not change) (17ms)
+297ms ║║Comparison (time) 25529383 is_after (time) 75600000 = false (5ms)
+299ms ║║Condition #10 evaluated false (9ms)
+312ms ║║Comparison (time) 25529393 is_between (datetime) 1508734800000 … (time) 21600000 = false (7ms)
+314ms ║║Condition #21 evaluated false (13ms)
+360ms ║║Comparison (time) 25529408 is_between (datetime) 1508734800000 … (datetime) 1508762280000 = true (6ms)
+361ms ║║Time restriction check passed
+363ms ║║Condition #23 evaluated true (49ms)
+364ms ║║Condition group #22 evaluated true (state did not change) (64ms)
+365ms ║║Condition group #6 evaluated true (state did not change) (76ms)
+367ms ║║Cancelling statement #7’s schedules…
+385ms ║║Skipped execution of physical command [Master Suite Toilet Light].setLevel([10]) because it would make no change to the device. (5ms)
+385ms ║║Executed virtual command [Master Suite Toilet Light].fadeLevel (9ms)
+389ms ║╚Execution stage complete. (140ms)
+396ms ╚Event processed successfully (396ms)
10/23/2017, 7:05:11 AM +763ms
+2ms ╔Received event [Master Bathroom Light].switch = on with a delay of 958ms
+240ms ║RunTime Analysis CS > 23ms > PS > 101ms > PE > 116ms > CE
+249ms ║Runtime (43217 bytes) successfully initialized in 101ms (v0.2.0fa.20171011) (246ms)
+250ms ║╔Execution stage started
+264ms ║║Comparison (enum) on is (string) on = true (2ms)
+266ms ║║Condition #20 evaluated true (11ms)
+267ms ║║Condition group #null evaluated true (state did not change) (12ms)
+284ms ║║Comparison (enum) on changes_to (string) on = true (0ms)
+286ms ║║Cancelling condition #3’s schedules…
+287ms ║║Condition #3 evaluated true (18ms)
+288ms ║║Cancelling condition #1’s schedules…
+289ms ║║Condition group #1 evaluated true (state changed) (20ms)
+300ms ║║Comparison (time) 25512055 is_after (time) 75600000 = false (5ms)
+301ms ║║Condition #10 evaluated false (10ms)
+315ms ║║Comparison (time) 25512066 is_between (datetime) 1508734800000 … (time) 21600000 = false (7ms)
+317ms ║║Condition #21 evaluated false (13ms)
+364ms ║║Comparison (time) 25512081 is_between (datetime) 1508734800000 … (datetime) 1508762280000 = true (7ms)
+365ms ║║Time restriction check passed
+367ms ║║Condition #23 evaluated true (49ms)
+368ms ║║Condition group #22 evaluated true (state did not change) (65ms)
+369ms ║║Condition group #6 evaluated true (state did not change) (77ms)
+371ms ║║Cancelling statement #7’s schedules…
+388ms ║║Skipped execution of physical command [Master Bathroom Light].setLevel([10]) because it would make no change to the device. (4ms)
+389ms ║║Executed virtual command [Master Bathroom Light].fadeLevel (9ms)
+393ms ║╚Execution stage complete. (143ms)
+445ms ╚Event processed successfully (445ms)
10/23/2017, 6:30:50 AM +981ms
+2ms ╔Received event [Master Suite Toilet Light].switch = off with a delay of 1022ms
+240ms ║RunTime Analysis CS > 24ms > PS > 101ms > PE > 116ms > CE
+251ms ║Runtime (43217 bytes) successfully initialized in 101ms (v0.2.0fa.20171011) (247ms)
+252ms ║╔Execution stage started
+267ms ║║Comparison (enum) on is (string) on = true (2ms)
+269ms ║║Condition #20 evaluated true (11ms)
+270ms ║║Condition group #null evaluated true (state did not change) (12ms)
+287ms ║║Comparison (enum) off changes_to (string) on = false (1ms)
+289ms ║║Cancelling condition #3’s schedules…
+290ms ║║Condition #3 evaluated false (17ms)
+291ms ║║Cancelling condition #1’s schedules…
+292ms ║║Condition group #1 evaluated false (state changed) (20ms)
+294ms ║╚Execution stage complete. (43ms)
+301ms ╚Event processed successfully (301ms)
10/23/2017, 6:28:44 AM +72ms
+1ms ╔Received event [Master Suite Toilet Light].switch = on with a delay of 1031ms
+411ms ║RunTime Analysis CS > 22ms > PS > 271ms > PE > 119ms > CE
+419ms ║Runtime (43223 bytes) successfully initialized in 271ms (v0.2.0fa.20171011) (417ms)
+420ms ║╔Execution stage started
+436ms ║║Comparison (enum) on is (string) on = true (2ms)
+438ms ║║Condition #20 evaluated true (10ms)
+439ms ║║Condition group #null evaluated true (state did not change) (12ms)
+455ms ║║Comparison (enum) on changes_to (string) on = true (1ms)
+457ms ║║Cancelling condition #3’s schedules…
+457ms ║║Condition #3 evaluated true (16ms)
+459ms ║║Cancelling condition #1’s schedules…
+459ms ║║Condition group #1 evaluated true (state changed) (18ms)
+471ms ║║Comparison (time) 23324534 is_after (time) 75600000 = false (6ms)
+472ms ║║Cancelling condition #10’s schedules…
+473ms ║║Condition #10 evaluated false (11ms)
+491ms ║║Comparison (time) 23324550 is_between (datetime) 1508734800000 … (time) 21600000 = false (7ms)
+493ms ║║Condition #21 evaluated false (15ms)
+558ms ║║Comparison (time) 23324566 is_between (datetime) 1508734800000 … (datetime) 1508762280000 = true (6ms)
+559ms ║║Time restriction check passed
+561ms ║║Cancelling condition #23’s schedules…
+562ms ║║Condition #23 evaluated true (68ms)
+563ms ║║Cancelling condition #22’s schedules…
+564ms ║║Condition group #22 evaluated true (state changed) (87ms)
+565ms ║║Condition group #6 evaluated true (state did not change) (103ms)
+567ms ║║Cancelling statement #7’s schedules…
+585ms ║║Skipped execution of physical command [Master Suite Toilet Light].setLevel([10]) because it would make no change to the device. (4ms)
+586ms ║║Executed virtual command [Master Suite Toilet Light].fadeLevel (9ms)
+589ms ║╚Execution stage complete. (170ms)
+596ms ╚Event processed successfully (596ms)


#2

Do you by chance have location modes that correspond to the time slots you are trying to set?

Also there are presets for midnight/sunrise/sunset


#3

As modes I only have home, away and night I believe but I really don’t use them and did not intend to use them in this piston (if I did).

What I am trying to do is simply dim the lights if any of the lights I listed are turned on between 9pm and 6am (or sunrise if earlier). The hours may change over time, especially when my baby daughter moves to her own room… so sunrise is there to ensure that when the sun light comes in through the window, the light goes on at max intensity as well.


#4

Only reason I brought up modes is because you can limit tasks to certain modes. But since you don’t have that set up then I won’t get into that.

I would suggest using the preset values for time where you have variables like midnight/sunrise/sunset etc.


#5

I think my issues was mixing time and datetime variables.

I found a way to strip off the date from datetime variables. I wonder whether this will work:


#6

This seems to have fixed the issues: