Multiple Device Timers


#1

1) Give a description of the problem

I’m not sure I fully understand the async concepts and where to put them. I’m also just curious if there’s a simpler way to do this. My only “concern” with my piston would be if someone presses a button right as another fan is scheduled to turn off.

2) What is the expected behaviour?

I want my bathroom fans to turn off after 5 minutes and add 5 more minutes if the on button is pressed again. I was able to accomplish this by creating a time table with off times for each of my fans that get’s updated when a device on button get’s pressed. Then it schedules an off time for each fan that’s running.

3) What is happening/not happening?

For the most part it’s working now but I just put async everywhere on that part of the script but not sure if I need it on all or which ones.

I’m also not sure if there’s an easier way to do this that doesn’t require setting every device each time any device get’s changed-- this may be the only way to do this as a single piston.

I’ve tried every setting I could think of with the cancellation policies on different places and such but it always either cancels the timers for the other fans or doesn’t update existing timer. It seems like there is no option to “Update” an existing timer or set multiple timers separately for the same piston. I’ve also tried allowing the piston to run multiple times but there’s no way to specify 1 time per device that I’m aware of so it just run every time the button is pressed-- even if the device already has a running timer.

4) Post a Green Snapshot of the pistonimage

5) Attach logs after turning logging level to Full
|+1ms|╔Received event [Bathroom Fan].button = up with a delay of 54ms|
|—|---|
|+60ms|║RunTime Analysis CS > 16ms > PS > 6ms > PE > 38ms > CE|
|+63ms|║Runtime (41111 bytes) successfully initialized in 6ms (v0.3.113.20210203) (61ms)|
|+64ms|║╔Execution stage started|
|+84ms|║║Comparison (enum) on is (string) on = true (1ms)|
|+86ms|║║Condition #2 evaluated true (18ms)|
|+87ms|║║Condition group #1 evaluated true (state did not change) (19ms)|
|+95ms|║║Comparison (datetime) 1639932309876 is_greater_than (datetime) 1639934973645 = false (2ms)|
|+96ms|║║Condition #25 evaluated false (7ms)|
|+98ms|║║Condition group #39 evaluated false (state did not change) (8ms)|
|+100ms|║║Cancelling statement #40’s schedules…|
|+196ms|║║Executed virtual command setVariable (88ms)|
|+208ms|║║Comparison (datetime) 1639935033655 is_greater_than (datetime) 1639934973758 = true (2ms)|
|+210ms|║║Condition #48 evaluated true (7ms)|
|+211ms|║║Condition group #47 evaluated true (state did not change) (8ms)|
|+214ms|║║Cancelling statement #44’s schedules…|
|+221ms|║║Executed virtual command [Bathroom Fan].waitForTime (2ms)|
|+223ms|║║Requesting a wake up for Sun, Dec 19 2021 @ 11:30:33 AM CST (in 59.882s)|
|+236ms|║║Comparison (datetime) 1639935010673 is_greater_than (datetime) 1639934973786 = true (2ms)|
|+238ms|║║Condition #48 evaluated true (6ms)|
|+239ms|║║Condition group #47 evaluated true (state did not change) (7ms)|
|+241ms|║║Cancelling statement #44’s schedules…|
|+249ms|║║Executed virtual command [Guest Bathroom Fan].waitForTime (2ms)|
|+250ms|║║Requesting a wake up for Sun, Dec 19 2021 @ 11:30:10 AM CST (in 36.873s)|
|+256ms|║╚Execution stage complete. (192ms)|
|+258ms|║Setting up scheduled job for Sun, Dec 19 2021 @ 11:30:10 AM CST (in 36s), with 1 more job pending|
|+270ms|╚Event processed successfully (269ms)|

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