So I got this working I'm pretty sure but I'm wondering if there's a better way to do what I want with a custom app I haven't found or even consolidating it into one rule. I'm a programmer so I understand the logic, but I'm still wrapping my head around using the functionality of RM.
Basically I have a switch that controls a fan and I want to turn it on and have it turn off after 15 mins but if I press it up again it will be 30...again would be 45, etc and if I manually turn the switch off then it turns off and resets everything. I'm currently using 2 rules due to the multiple triggers (button 1 vs 2). The private boolean is basically my "is this the first time it was pressed up/initially turned on" variable.
OK...I set button 1 or button 2 as trigger and used conditional action to see which button was pushed and if 1 do the on actions and if 2 do the off actions. That got me down to 1 rule. I'm still thinking about working on the "adding delay to whatever delay is left" but since I don't need that it's not at the top of my list. However, I'm not quite understanding the
part. Could you point me in the right direction of what you mean?
The Private Boolean is only used to determine if a delay is already set.
Instead of looking at a private Boolean you can just look at the value of delay. If it is > 0, then a delay has already been set.
When the delay is over just set delay to 0. I would also use a wait for event Elapsed time using the delay variable, instead of delays. Then you don't need to add the cancel delay. With the wait for event it will automatically get canceled on a new trigger. Your method works fine it's just the way I would do it.
IF delay = 0 then
Set Delay
ELSE
Add delay
ENDIF
set
wait for event elapsed time delay min
fan off
set delay = 0
Now I see the efficiency of using the wait for event vs delay and the automatic cancellation. Just need to attempt the "extra credit" but I like this much better so thank you very much.