Alternate betweeen buttons 1 and 2 while button 3 is pressed

I have a 2 button device that can send a total of 3 commands, each usable as button press triggers.
"Button 1 pressed", "button 2 pressed" and "either button released".
I need to use this as a dimmer for some devices that only respond once per button press. I can't hold a button until it reaches the correct level, I have to constantly click and release the button to get the job done.
Is there a way to make it so that, as long as I keep one of the buttons pressed, hubitat quickly alternates between pressing that button, releasing it, presing the other button, release it and so on?

You could do this with a rule (or set of rules) and a repeat, but I'd back up a bit: what device are you actually controlling (like the one that "only responds once per button press")? Does it support the "Start Level Change" and "Stop Level Change" commands? You'd see this on the device page in Hubitat. If not, are you using a custom driver that could be re-worked to include these commands if the device itself can do something like that? If not, what kind of device is it? Lots of Z-Wave or Zigbee devices--and the networks themselves--won't do well with sending a bunch of commands super-fast, and RM will for the most part prevent you from doing anything under 1 second, too, so I think more information here might help someone provide alternative ideas that might work better.

I'm also curious what your button device is and why there are only three commands for two buttons, but that's really just me being curious, unlike the above that could have an impact on the real automation. :slight_smile:

It's an IKEA symfonisk dimmer with a custom driver. I have several.
There are no drivers that will show it as a real dimmer, so I'm using a driver that binds your turning left and right as holding down buttons 1 and 2 and your stop turning as button 3.
The custom driver has been abandoned by the maker, so there is no hope of any fixes on that end.
The devices I want to connect are some IR blasters that do not support "Start Level Change" and "Stop Level Change" commands. They are made to basically accept a single command, ignore everything after that, wait for a "reset" command, accept the next single command, wait for another "reset" command and so on.
I need it to go fast for things like volume adjustment and channel surfing, where you'll need to go both fast and slow, but only in very short bursts.

I wouldn't say there's no hope of a "fix" on the driver end since the code is open and anyone could modify it, but I understand the issue. :slight_smile: These devices are a bit odd.

To get the repeat and the ability to stop it with a separate button action, I'd use one of two ideas. One is Rule Machine with a "Button" trigger--a separate rule for each button event. Create the repeat where you need it, then in the other rule (the one triggered on the button event that you want to stop the repeat), use a "Cancel Rule Timers" action and choose for it to act on the other rule. This is an option you'll see when using this option.

Usually I'd recommend a "Button Device" trigger in Rule Machine, but each "Actions" section (for each button event) is intended to be independent from the others, so you can't use a "Stop Repeat" action in one set of actions to affect an active repeat in another set of actions. That's why the above workaround is needed: separate rules, and you can call "Cancel Rule Timers" on the other rule. (Actually, I wonder whether you can use "Cancel Rule Timers" on the same button rule and have it work, but I haven't tested to see if that also affects only the current actions...). Alternatively, someone in this thread found a workaround using a local variable, which may also work:

If you haven't used repeats in Rule Machine before, there are are few threads about how to create various kinds of repeating actions. This is one of my favorites, despite the fact that it's ostensibly about repeated notifications--but the general idea of how to "stop" a repeat is the same regardless of what you actually put in the body of the repeat, so it's more broadly applicable than that:

(But again, the caveat that you need separate rules or the above workaround since you can't use "Stop Repeat" in the same rule/actions section is a difference from what you'll see in that post, given that you're working with different button events/actions sections or different rules entirely.)

Thank you.
I'll give it a shot and reply here if it worked or not and what failed if something did. I am new to hubitat (only had it for about a month or so) and I never got to mess with anything due to lack of time.