Close shade after window changes to close


#1

Need some input, please.

This piston seems to work only after I close the window, re-open, then close again. I’m doing it within the time frame I set up, but it isn’t catching it on the first close. The goal is when it’s dark out and I close the window, the shade knows to close on that specific window.


#2

Can you set the logging level to ‘full’ and post the logs of when it doesn’t work as expected?


#3

A couple thoughts…

First you could really write your first Time condition as a Restriction and that might resolve things. That’s really what it is anyway. So you want to say “only when Time is between…”

The other thought would be (if you don’t make Time into a restriction) would be to flip the order of those statements so that the Trigger is first (contact changes to closed). It shouldn’t matter, but I’ve seen often enough where it does.


#4

Without logs, I think the problem you’re having is a “contact changes to” paired with a “wait 10 seconds” in your next statement. Inside webCoRE, the flow goes something like this:

You close your window within the time restriction, satisfying both your conditions, so your piston begins to execute your WITH statement.

When it reaches the WAIT 10 seconds, your piston sets a wake-up call for itself 10 seconds in the future.

Ten seconds later, you piston wakes up and checks your conditions again. Since “contact changes to closed” only evaluates true for ~10 seconds, it probably JUST misses the window, evaluates false, and your shade is not activated. This is also why if you open and close it a second time, it works… the “time to expire” is renewed on your “contact changes to closed”, so it evaluates true.

The easiest way around this is to change your “contact changes to closed” condition to “contact stays closed for 10 seconds”. Then if you find you want to extend the 10 seconds to something even longer, it can easily be done.


#5

Thanks for all the replies. After looking over Michicago’s explanation, I think I agree the timer might be the culprit. I just removed the time restriction, as there’s a delay anyways between when the window closes and the contact registers this. I put the logging on full just in case it doesn’t work. Thanks :slight_smile:

Update:

It didn’t work, even taking out the time requirement completely. Here’s the logs (the first one shows when I re-opened and closed, then it work):

3/15/2018, 7:10:37 PM +505ms
+1ms ╔Received event [Master Bedroom Window].contact = closed with a delay of 137ms
+109ms ║RunTime Analysis CS > 34ms > PS > 52ms > PE > 24ms > CE
+112ms ║Runtime (37142 bytes) successfully initialized in 52ms (v0.3.000.20180224) (109ms)
+113ms ║╔Execution stage started
+146ms ║║Comparison (time) 69037624 is_between (time) 1521165480000 … (time) 0 = true (9ms)
+147ms ║║Time restriction check passed
+149ms ║║Condition #5 evaluated true (30ms)
+153ms ║║Comparison (enum) closed changes_to (string) closed = true (1ms)
+155ms ║║Cancelling condition #6’s schedules…
+156ms ║║Condition #6 evaluated true (7ms)
+157ms ║║Cancelling condition #1’s schedules…
+158ms ║║Condition group #1 evaluated true (state changed) (39ms)
+160ms ║║Cancelling statement #2’s schedules…
+284ms ║║Executed physical command [Master Bedrm Shade Middle].close() (120ms)
+285ms ║║Executed [Master Bedrm Shade Middle].close (122ms)
+288ms ║╚Execution stage complete. (176ms)
+289ms ╚Event processed successfully (289ms)
3/15/2018, 7:10:31 PM +81ms
+2ms ╔Received event [Master Bedroom Window].contact = open with a delay of 156ms
+109ms ║RunTime Analysis CS > 33ms > PS > 54ms > PE > 22ms > CE
+112ms ║Runtime (37142 bytes) successfully initialized in 54ms (v0.3.000.20180224) (109ms)
+113ms ║╔Execution stage started
+145ms ║║Comparison (time) 69031200 is_between (time) 1521165480000 … (time) 0 = true (9ms)
+146ms ║║Time restriction check passed
+148ms ║║Condition #5 evaluated true (30ms)
+152ms ║║Comparison (enum) open changes_to (string) closed = false (1ms)
+154ms ║║Condition #6 evaluated false (4ms)
+154ms ║║Condition group #1 evaluated false (state did not change) (36ms)
+157ms ║╚Execution stage complete. (44ms)
+158ms ╚Event processed successfully (158ms)
3/15/2018, 7:09:55 PM +510ms
+1ms ╔Received event [Master Bedroom Window].contact = closed with a delay of 136ms
+105ms ║RunTime Analysis CS > 33ms > PS > 52ms > PE > 21ms > CE
+108ms ║Runtime (37145 bytes) successfully initialized in 52ms (v0.3.000.20180224) (105ms)
+109ms ║╔Execution stage started
+141ms ║║Comparison (time) 68995625 is_between (time) 1521165480000 … (time) 0 = true (8ms)
+142ms ║║Time restriction check passed
+144ms ║║Cancelling condition #5’s schedules…
+145ms ║║Condition #5 evaluated true (30ms)
+149ms ║║Comparison (enum) closed changes_to (string) closed = false (0ms)
+151ms ║║Condition #6 evaluated false (5ms)
+152ms ║║Condition group #1 evaluated false (state did not change) (37ms)
+154ms ║╚Execution stage complete. (46ms)
+155ms ╚Event processed successfully (155ms)


#6

I’ve had that happen to me before, too. Try swapping your conditions so your “contact changes to closed” is first…

Contact changes to closed
AND
Time is between…

Not sure why but it works.


#7

Thanks. Both you and Mike1616 were correct. I switched the statement and it has worked perfectly :slight_smile: