How can I disable a piston timer from the switch itself?


#1

1) Give a description of the problem
I’d like to be able to cancel a switch timer if the switch is turned on, off, on quickly.

4) Post a Green Snapshot of the pistonimage

So this is the basic timer piston I have. There’s only one device in it right now, but there will be more. There are occasions where I’d like to disable the timer. The easiest way I can think of doing that is having the piston react if the light is turned on, off, on in rapid succession. However, I can’t wrap my mind around how to do that. Any ideas?


TCP and Cancel All Pending Tasks
#2

The easiest way I can think of would be

If light X was off for less than 5 seconds
Then cancel all pending tasks.

That way with one evaluation you can tell the light WAS on, then OFF for a brief period of time before being switched on again.


#3

Hmmm…

Where would I put that IF so that it worked for the $currentEventDevice?


#4

Would this work?


#5

That might. If it doesn’t, try changing your $device and timeoutdevices variables to $currentEventDevice.

A note about cancel all tasks: in my testing it cancelled all tasks setup by the statement. Meaning if I had 5 dimmers going through a fade statement, cancel all tasks stopped the fade for all 5 and there was no way to single out one device.


#6

Hmmm… That didn’t work. I also tried this, which didn’t work either.


#7

Hmm. Where is the second “on events from” block of code failing? Can you tell in the logs?


#8

It isn’t. It’s like webCoRE isn’t seeing the switch turn on and off so quickly.

12/15/2017, 4:13:18 PM +789ms
+1ms ╔Received event [Guest Bathroom Light].switch = off with a delay of 1091ms
+155ms ║RunTime Analysis CS > 17ms > PS > 29ms > PE > 110ms > CE
+158ms ║Runtime (38308 bytes) successfully initialized in 29ms (v0.2.100.20171211) (156ms)
+159ms ║╔Execution stage started
+170ms ║║Comparison (enum) off changes_to (string) on = false (1ms)
+172ms ║║Cancelling condition #3’s schedules…
+173ms ║║Condition #3 evaluated false (7ms)
+174ms ║║Cancelling condition #1’s schedules…
+174ms ║║Condition group #1 evaluated false (state changed) (10ms)
+208ms ║║Comparison (enum) off was (string) off = false (23ms)
+210ms ║║Condition #10 evaluated false (29ms)
+211ms ║║Condition group #7 evaluated false (state did not change) (31ms)
+294ms ║╚Execution stage complete. (134ms)
+319ms ╚Event processed successfully (319ms)
12/15/2017, 4:13:13 PM +326ms
+1ms ╔Received event [Home].time = 1513372394809 with a delay of -1483ms
+177ms ║RunTime Analysis CS > 15ms > PS > 29ms > PE > 133ms > CE
+180ms ║Runtime (38301 bytes) successfully initialized in 29ms (v0.2.100.20171211) (177ms)
+181ms ║╔Execution stage started
+235ms ║║Executed physical command [Guest Bathroom Light].off() (14ms)
+236ms ║║Executed [Guest Bathroom Light].off (16ms)
+349ms ║╚Execution stage complete. (169ms)
+374ms ╚Event processed successfully (374ms)
12/15/2017, 4:12:14 PM +632ms
+1ms ╔Received event [Guest Bathroom Light].switch = on with a delay of 1017ms
+151ms ║RunTime Analysis CS > 14ms > PS > 24ms > PE > 113ms > CE
+154ms ║Runtime (38313 bytes) successfully initialized in 24ms (v0.2.100.20171211) (151ms)
+155ms ║╔Execution stage started
+165ms ║║Comparison (enum) on changes_to (string) on = true (1ms)
+166ms ║║Cancelling condition #3’s schedules…
+167ms ║║Condition #3 evaluated true (7ms)
+168ms ║║Cancelling condition #1’s schedules…
+169ms ║║Condition group #1 evaluated true (state changed) (9ms)
+175ms ║║Executed virtual command [Guest Bathroom Light].wait (1ms)
+176ms ║║Requesting a wake up for Fri, Dec 15 2017 @ 4:13:14 PM EST (in 60.0s)
+218ms ║║Comparison (enum) on was (string) off = false (30ms)
+219ms ║║Condition #10 evaluated false (35ms)
+220ms ║║Condition group #7 evaluated false (state did not change) (37ms)
+297ms ║╚Execution stage complete. (143ms)
+318ms ║Setting up scheduled job for Fri, Dec 15 2017 @ 4:13:14 PM EST (in 59.859s)
+328ms ╚Event processed successfully (328ms)


#9

I had issues with that when I tried to mimic a double-tap feature. I’ll post up some thoughts on it later, getting some time with the kiddo now!


#10

Sorry it took me a while, but have a few minutes now. There are a few ways to tackle this, and while none of them are ideal, if you don’t disable the timer often one of these should work for you.

  1. Keep the on-off-on cycle and know when you do it, you need a good 4-5 count in the off position. If it fails or works intermittently, try a longer count in the off position until you see both off and on in the logs.
  2. Set your piston to cancel the timer if the light level is changed for a light.
  3. Create a ST routine or webCoRE dashboard tile that, when executed, disables your piston timer.

If any of those sound like a solution you can live with, I’ll help you get it written up and working.


#11

Try this:

Change ZZZ Dummy Switch to the name of your switch

Got it set to 15 seconds for testing, change that to minutes when you’re happy.

The 5000 is in ms so it’s 5 seconds


#12

previousAge, whoa!

I’m trying to do this with multiple devices. Based on your piston, this is what I did, but it’s not working.


#13

I don’t think system variables (i.e. $currentEventDevice) can be used within the expression like that… but local variables can… I’ll knock something up for you later.


#14

If you turned a light on (from off), wouldn’t that turn it off after 15 seconds?.. because it was off for more than 5 seconds? Or am I misreading how that works?


#15

Your’e reading it right… if you turn it on after it has been sitting for more than 5 seconds, the timer will start… and that’s what you wanted…

But if you turn it on>off>on (as per your original brief) with no gap greater than 5 seconds, that will cancel the timer.

I’m playing with putting variables into the previousAge([Device Name : Attribute]) and it wont work, for both system variables or local ones :sob:

I could have sworn it used to work as I once built a device name out of component strings and that worked… can’t access my old pistons though coz my tenants have the password.


#16

Nope… I cant quote device variables in previousAge…

@ady624… I’m sure this was working before, am I missing something???

@flyize for now you’re just gonna have to run multiple pistons I’m afraid


#17

@flyize

Can you test the following piston with one of your switches… I’m just getting 604800000 (7 days - max time ST keeps data) and i’m starting to think it might be related to my use of simulated devices not reporting properly…

If you are getting accurate times in the notification (in miliseconds) then we can go from there


#18

@flyize

right… problem lies with the expression, needs be previousAge([$currentEventDevice : switch]) not previousAge([$currentEventDevice : Switch])

Still doesn’t resolve your requirements though as $currentEventDevice changes on every execution, even with parallelism enabled.

Just keep it simple and do it with multiple pistons, unless someone else has any ideas?


#19

Thanks. Appreciate the time looking at this guys. I have a bunch of lights I’d like to setup this way, so if anyone has another idea for how to make it work for all in a single piston, I’d love to hear it.


#20

If the physical switch inputs are an option for disabling the fade, an ST subroutine or a tile on your webCoRE dashboard will work. Which of those would work for you? If neither, I’ll try to think of something else.