The following rule fades some lights to off over a 15 minute period. Sometimes I need to cancel the lowering/fading of the lights midway through. I thought that calling cancel timed actions (from another rule) would do the trick, but it doesn’t stop the lights from fading to off.
I use a virtual switch as a required expression in my fade rule that will cancel pending actions when the Required Expression becomes false. Basically, it would be two rules:
First Rule
Required Expression: Cancel fade switch is off (cancel pending actions when Required Expression is False)
Triggers: whatever triggers you are using for the fade rule
Actions: your current fade action
Second Rule
Trigger: Cancel fade switch is on
Action: set lamps to whatever you desire when canceling the first rule
Whenever you manually press the cancel switch, these two rules would work together. They would cancel the fade and set the lights to whatever state you need/prefer them to be in.
@JB10 Is that second rule necessary if I just want the lights to stop fading (and remain on at whatever level they are set to when the cancel fade switch is turned on)?
Apart from the very helpful solution provided above (thanks, @JB10 !), I would like to better understand how Fade over time works.
It appears to me that Cancel Timed Actions does not stop the Fade command. Is that true, or is there something wrong with my rules posted at the top of this topic?
If you look into your logs, you'll see exactly how fade over time works. When that action happens, the hub will do some math. The hub every 10 seconds will send a setLevel command to the lamp for 15 minutes. Each 10 seconds will have a level (99%, 98%, 97%, etc...assuming you are starting at 100%) until a 0% setLevel command is given at the 15th minute.
Also, I did find another way of doing this via the "Stop Dimmer Fade" command. What are the triggers to your rule? Depending on the triggers, it might be possible to write one rule.
Ok. I've got an idea that might work, but have never used it before. The other suggestion I know works, but this one might let you use just one rule. Try this:
Triggers: Virtual Switch on; Virtual Switch off
Actions: If lamp on and virtual switch on, fade lights
Else: stop dimmer fade
End-If
Turn off Virtual Switch (delayed 15 minutes)
What this will do is turn your switch into a toggle of sorts. When you turn on the switch, it will start to fade the lights. If you turn off the virtual switch within the 15 minutes, it will stop the dimmer fade of the rule. The rule will then reset the virtual switch to off so that you can either fade again or do nothing since the lights are already off.
The other idea that would work is to not use switches, but buttons instead since they are stateless. You would need just two buttons:
Triggers: Button 1; Button 2
Action: If lamp on and button 1 pressed, fade the lights
Else: stop dimmer fade
Button 1 would fade the lights. Button 2 would stop the fade. Buttons are convenient since they are stateless and always ready to go. You would not need to worry about turning them on or off. Just push.
Glad it's working for you. Only thing to watch out for is using change as the trigger. It is possible to get the virtual switch out of sync. With that said, if it does not matter to you, then the rule should work.