If Time X Is Before Time Y


#1

I’m trying to create a poor-man’s ‘double-tap’ piston, but seem to have run into something that’s working against me. I have the the time limit set to two seconds right now, but for the life of me I can’t figure out why this statement is evaluating false:

11/23/2017, 2:23:26 AM +163ms
+1ms ╔Received event [Family Room Main Lights].switch = off with a delay of 71ms
+122ms ║RunTime Analysis CS > 19ms > PS > 41ms > PE > 62ms > CE
+130ms ║Runtime (40126 bytes) successfully initialized in 41ms (v0.2.0fe.20171109) (129ms)
+131ms ║╔Execution stage started
+147ms ║║Comparison (enum) off changes_to (string) on = false (0ms)
+148ms ║║Cancelling condition #6’s schedules…
+149ms ║║Condition #6 evaluated false (14ms)
+150ms ║║Cancelling condition #1’s schedules…
+150ms ║║Condition group #1 evaluated false (state changed) (15ms)
+161ms ║║Comparison (enum) off changes = true (0ms)
+162ms ║║Cancelling condition #13’s schedules…
+163ms ║║Condition #13 evaluated true (11ms)
+167ms ║║Comparison (datetime) 1511421806327 is_before (datetime) 1511421807918 = false (2ms)
+168ms ║║Condition #14 evaluated false (4ms)
+169ms ║║Condition group #8 evaluated false (state did not change) (16ms)
+170ms ║║Cancelling statement #9’s schedules…
+175ms ║║Executed virtual command setVariable (3ms)
+178ms ║╚Execution stage complete. (47ms)
+185ms ╚Event processed successfully (184ms)

Any help here would be appreciated.


#2

Without posting your piston, it’s going to be difficult for people to advise.
Please post and I’m sure you will get a solution.


#3

I deleted it once I couldn’t get the IF statement to produce the correct outcome. I thought that was more of a webCoRe thing in my original post; I didn’t think I could write a piston that would make that evaluate as false.

It wasn’t a terribly complex piston though, it was:

If switch turns on, set variable ‘timestamp’ to $now + 4000.

If the same switch turns off AND $now is before ‘timestamp’ (essentially capturing an on-off cycle in 4 seconds, at least that was the goal)… then turn on all first floor lights.

All the parameters in the log satisfied the IF statement, but it evaluated false.


#4

Here’s a recreation of it… I think it took me about as much time as it did to type it above! :slight_smile:


#5

Is this what you are trying to achieve?


#6

Yeah, that should work too… never used the “was” comparison before so that didn’t even cross my mind. Thanks!

I’m still curious about that one statement evaluations though:

+167ms ║║Comparison (datetime) 1511421806327 is_before (datetime) 1511421807918 = false (2ms)

Reading the numbers, the first one is 1.6 seconds before the second, isn’t it? Is there some padding built into webCoRE so pistons looking for time comparisons within hours aren’t tripped up by interface delays?


#7

I really don’t know.
I just know my way around the functions that webCoRE can provide.
How it all works is a mystery to me. Sorry.