Time happens daily not firing


#1

Greetings guys, I set up a piston to turn on lights based on a global variable, but when it starts to evaluate the time it returns false even time is correct. Did anyone has similar problems? Thanks in advance for help.

1) Give a description of the problem
Time happens daily is not firing in the weekend condition, especially, according to the stack trace/log, the time comparison is evaluated to false rather than true.

Infact I have 2 very similar IF conditions, one is for weekday timed activity and one is for weekend, they are subscribing to the same time variable, @wakeUpTime. But when the same condition is evaluated at the weekend condition, it’s evaluated to false (+264ms) while weekday time is evaluated to true (+233ms). Logs attached below.

2) What is the expected behavior?
Time happen daily should evaluated to true.

3) What is happening/not happening?
Time evaluation is not evaluated correctly.

4) Post a Green Snapshot of the pistonimage

5) Attach any logs (From ST IDE and by turning logging level to Full)

3/25/2018, 7:04:59 AM +684ms
+0ms	╔Received event [Home].time = 1521975900000 with a delay of -316ms
+151ms	║RunTime Analysis CS > 18ms > PS > 43ms > PE > 90ms > CE
+154ms	║Runtime (50299 bytes) successfully initialized in 43ms (v0.3.104.20180323) (153ms)
+155ms	║╔Execution stage started
+213ms	║║Comparison (time) 25499846 happens_daily_at (datetime) 1522021020000 = false (5ms)
+214ms	║║Condition #12 evaluated false (52ms)
+221ms	║║Cancelling statement #12's schedules...
+225ms	║║Requesting time schedule wake up at Sun, Mar 25 2018 @ 7:17:00 PM EDT
+228ms	║║Condition group #1 evaluated false (state did not change) (65ms)
+233ms	║║Comparison (time) 25499913 happens_daily_at (time) 25500000 = true (0ms)
+240ms	║║Time restriction check failed
+241ms	║║Condition #10 evaluated false (12ms)
+242ms	║║Cancelling statement #10's schedules...
+247ms	║║Requesting time schedule wake up at Mon, Mar 26 2018 @ 7:05:00 AM EDT
+249ms	║║Condition group #7 evaluated false (state did not change) (20ms)
+252ms	║║Comparison (time) 25499935 happens_daily_at (time) 82800000 = false (0ms)
+254ms	║║Condition #28 evaluated false (4ms)
+255ms	║║Cancelling statement #28's schedules...
+257ms	║║Requesting time schedule wake up at Sun, Mar 25 2018 @ 11:00:00 PM EDT
+260ms	║║Condition group #25 evaluated false (state did not change) (10ms)
+264ms	║║Comparison (time) 25499945 happens_daily_at (time) 25500000 = false (0ms)
+266ms	║║Condition #41 evaluated false (4ms)
+267ms	║║Cancelling statement #41's schedules...
+271ms	║║Requesting time schedule wake up at Mon, Mar 26 2018 @ 7:05:00 AM EDT
+274ms	║║Condition group #40 evaluated false (state did not change) (14ms)
+278ms	║╚Execution stage complete. (123ms)
+280ms	║Setting up scheduled job for Sun, Mar 25 2018 @ 7:17:00 PM EDT (in 43920.036s), with 3 more jobs pending
+288ms	╚Event processed successfully (288ms)

REMOVE BELOW AFTER READING
If a solution is found for your question then please mark the post as the solution.


#2

Why did you go with using the ELSE IFs? Seems like using 4 separate IF blocks would be better. Or 4 Separate Timer blocks. :slight_smile:


#3

Does that mean all the conditions will be evaluated at the same time? I’m suspecting it being evaluated to false was because it got delayed and the time for true evaluation had passed.


#4

Anyone can help please? @ady624 is this behaviour expected or would it be a potential bug?


#5

I’ll do some tests tonight see what comes out, thank you :slight_smile:


#6

Thank you! I also did some test last night, turns out wherever there are more than one time subscriptions at the same time, only the first one will be evaluated to true.


#7

For the ELSE-IF construct that you’re using in your piston above:

if condition1
  do something1
else if condition2
  do something2
else if condition3
  do something3
...
else
  do this instead
endif

evaluation stops when the first true condition is encountered. So if none of the conditions above are true, the ELSE block (if it exists) is executed. If “condition1” is true, then “do something1” is executed; the rest of the conditions are not evaluated.

If you want all your conditions to evaluate, use separate IF-blocks, as @jkp mentioned above.


#8

Thanks for the explanation, I DID try putting them in separate if blocks, still it fails.

The thing is in my piston time evaluation is the first and also I have other conditions like day of week and hub mode. Evaluation of the time succeeded in the first condition, but the first condition as a whole failed as expected. When it came to the second time evaluation, that itself failed and this is where I don’t understand.


#9

@ady624 while you’re in there and in case it is related could you please review my pull request from a few months ago that addresses some issues with scheduling when there are day of week restrictions?

Basically regardless of the day of week restrictions, the piston is scheduled to wake every day. The scheduling condition will evaluate to false when the day of week restriction is not met but it can create some unexpected behavior in pistons that pair this with else conditions. I’m just not comfortable enough tweaking scheduling without a second opinion.


#10

So with seperate IF blocks failing, I tried to merge weekend rule with the weekday one with only when clause controlling day of week and time constraints. This time it works perfectly. But this is more like a workaround with the problem, this time subscription issue still exists.

Working pistion: