Physical Switch De-Bounce

I created a Rule to make an exhaust fan turn off after X amount of time. If the switch is toggled while the fan is still running it adds y amount of more time to the off delay. Trouble is unless I trigger on the physical switch on and stays on for 1 second, switching on racks up the on time plus one or two adds so the time out becomes X+Y+Y. I am sure this is due to the Leviton ZW4SF bouncing. I need clued in on how to debounce an input before sending down into the rule. I don't think I need a whole second delay which is the minimum "and stays on" is. I got it working but I need to remember to let it stay on for at least 1 second before toggling it off and on again. A little nit picky but maybe there is a secret for doing that I have not found yet.

Just curious why you are not using a doubleTapped button to add time. That is exactly what I do with my bathroom fan. Single press "on" turns on the fan and starts a timer, DoubleTapped "on" adds time to the timer.

1 Like

I don't know the Leviton ZW4SF but debounce is usually done at the hardware/firmware level, not on the hub, unless something else is going on driver wise and updating the correct states for events?

Would need screen shot of the events during such behavior to understand what is going on, also are you using built in driver or community driver (if that exists).

Because the z-wave switch I use sends nothing I can see unless off is selected first. On, wait a bit then on again is ignored. So On - Off - On and it adds the time. The question that On sends one to two on events. Hubitat is fast enough to queue them up.

So I asked Googles AI Gemini. It suggested a logic flow I had not thought of.
For this to work correctly, On has to stay on for longer than DeBounce and off can not stay off for longer than DeBounce. That is of course you want it off and TimeRemaining reset back to Zero.

This is what I have now. What changed were the trigger which was an off with a and stays off and an on with and stays on.
Then it added the top 4 lines in the rule.
While it it not exactly what I wanted, it works way better than the original.

I have 4 ZooZ 37s. With buttons controlling my Ceiling fans the fan light dim level and the zibgee bulbs in the lamps. I agree that those do work good. And with the use of hub variables, I was able to keep the ZooZ and the wired in wall switches/dimmers in sync. They control fan speed, light dim levels. Thank you for your suggestion.

Put the copy through Notepad++ to make it more readable. Also reversed the order to read it from top down. Snip it does not let me scroll during the selection which limits the image to what is on the screen.

11:15:36.014 info Event: Master Exhaust Fan switch on
11:15:36.027 info Triggered: Master Exhaust Fan physical changed
11:15:36.039 info Action: Cancel Delayed Actions --> delayed: DeBounce(0:00:00.5)
11:15:36.048 info Action: Delay DeBounce(0:00:00.5) (cancelable)
11:15:36.558 info Delay Over: Cancel Delayed Actions
11:15:36.616 info Delay Over: Delay DeBounce(0:00:00.5) (cancelable)
11:15:36.669 info Action: Track Switch: Master Exhaust Fan
11:15:36.682 info Action: IF (Master Exhaust Fan(on) is on(T) AND Variable TimeRemaining(0) <= 0(T) [TRUE]) THEN
11:15:36.686 info Action: Set TimeRemaining to 13
11:15:36.703 info Action: ELSE-IF (Master Exhaust Fan(on) is on(T) AND Variable TimeRemaining(13) > 0(T) AND Variable TimeRemaining(13) <= 54(T) [TRUE]) THEN (skipping)
11:15:36.707 info Action: Add 7 to TimeRemaining (skipped)
11:15:36.708 info Action: Stop Repeating Actions (skipped)
11:15:36.712 info Action: ELSE-IF (Master Exhaust Fan(on) is off(F) [FALSE]) THEN (skipped)
11:15:36.716 info Action: Set TimeRemaining to 0 (skipped)
11:15:36.718 info Action: END-IF
11:15:36.721 info Action: While (Variable TimeRemaining(13) > 0(T) [TRUE]) Repeat every 0:01:00 (stoppable) (repeating)
11:15:36.746 info Action: Repeating Actions While True
11:15:36.757 info Action: Set TimeRemaining to (TimeRemaining(13) - 1)
11:15:36.766 info Action: IF (Variable TimeRemaining(12) <= 0 FALSE) Off: Master Exhaust Fan (skipped)
11:15:36.768 info Action: END-REP (waiting for next)
11:15:42.800 info Event: Master Exhaust Fan switch off
11:15:42.814 info Triggered: Master Exhaust Fan physical changed
11:15:42.826 info Action: Cancel Delayed Actions --> delayed: DeBounce(0:00:00.5)
11:15:42.835 info Action: Delay DeBounce(0:00:00.5) (cancelable)
11:15:43.329 info Event: Master Exhaust Fan switch on
11:15:43.343 info Triggered: Master Exhaust Fan physical changed
11:15:43.393 info Action: Cancel Delayed Actions --> delayed: DeBounce(0:00:00.5)
11:15:43.402 info Action: Delay DeBounce(0:00:00.5) (cancelable)
11:15:43.444 info Delay Over: Cancel Delayed Actions
11:15:43.502 info Delay Over: Delay DeBounce(0:00:00.5) (cancelable)
11:15:43.517 info Action: Track Switch: Master Exhaust Fan
11:15:43.531 info Action: IF (Master Exhaust Fan(on) is on(T) AND Variable TimeRemaining(12) <= 0(F) [FALSE]) THEN (skipping)
11:15:43.535 info Action: Set TimeRemaining to 13 (skipped)
11:15:43.546 info Action: ELSE-IF (Master Exhaust Fan(on) is on(T) AND Variable TimeRemaining(12) > 0(T) AND Variable TimeRemaining(12) <= 54(T) [TRUE]) THEN
11:15:43.550 info Action: Add 7 to TimeRemaining
11:15:43.555 info Action: Stop Repeating Actions
11:15:43.572 info Action: Repetition stopped
11:15:43.645 info Action: ELSE-IF (Master Exhaust Fan(on) is off(F) [FALSE]) THEN (skipping)
11:15:43.649 info Action: Set TimeRemaining to 0 (skipped)
11:15:43.650 info Action: END-IF
11:15:43.654 info Action: While (Variable TimeRemaining(19) > 0(T) [TRUE]) Repeat every 0:01:00 (stoppable) (repeating)
11:15:43.679 info Action: Repeating Actions While True
11:15:43.689 info Action: Set TimeRemaining to (TimeRemaining(19) - 1)
11:15:43.698 info Action: IF (Variable TimeRemaining(18) <= 0 FALSE) Off: Master Exhaust Fan (skipped)
11:15:43.700 info Action: END-REP (waiting for next)
11:15:43.912 info Delay Over: Cancel Delayed Actions

And next time I will edit a post instead of deleting and reposting. I was not aware deleting a post leaves an artifact behind. I am now though.

Screenshots are always better if possible, if you are on windows, window key + S then select what you want and just CTRL-V in the edit window when replying. That way we can see where the info is in the columns instead of trying to figure out what is what.

Also those are the logs, can you post a screenshot of the events of the switch, then we will be able to really see what is going on. Not what the RM rule is doing, I have never seen a switch that needs debouncing on the hub, again, this is done on the hardware/firmware level and should never reach the hub, I think it's more of the way the driver is reporting events.

1 Like

Is this what you are referring to? The switch events? I can not see a bounce here. But in Rule Maker I get more than one action so I don't know what is doing it. In the logs I can see my DeBounce hitting twice. Those are un-commanded.

Exactly what I thought, you have something else going on that is causing the pseudo bounce. You will need to track down where/what is causing this, check all the triggered apps to see if any of these could cause this. Trun debug on anything and everything that is involved and track down what is triggering it.