Workaround App to use a Momentary Button in Rule Machine

As was revealed in another user post, Rule Machine has a bug in that you cannot select a Momentary Button in the rule action, as the Momentary devices will not show in the list to be selected.

Until that bug is fixed, I created this Push Momentary Button app to link a Pushable Button to a Momentary Button Device, so a Momentary button can be pressed in Rule Machine via a pushable button.

Click Here for App Code

  1. Copy the code to Apps Code
  2. Create a Virtual Button device in Hubitat with the built-in virtual driver
  3. Create an instance of the App - You can name it in settings
  4. Chose the Virtual Button Device you created, and your Momentary Device to control in settings
  5. Also in settings, choose a pushed button number to use from the virtual button device to trigger the momentary button device you selected.

You can create as many instances of the app as needed for the number of momentary button devices you have. You can use the same Virtual Button device for all of the instances, just use a different pushable button number for each instance and name the instance differently.

Then, in Rule Machine, instead of using the momentary button device in the rules (since you can't), you use the Virtual Button device, usings pushed(number) for the button number that corresponds to the momentary button you want to push, based on what you used for the button number in the app.

2 Likes

Perhaps you want to include a link to that post.

1 Like

Sorry about that...

Though @user7221 pointed out to me that Momentary Button drivers should just add the Switch capability, to make it selectable in Rule Machine as a switch, revealing the push() command as an option..

For any custom app that does not add the switch capability to the driver, this might be useful. Or just use Webcore, which will let you use a Momentary button that only has the Momentary capability without switch.

I'm slightly confused by the problem this solves..

What do you mean when you say "momentary button"? In my mind ALL buttons are momentary. They get pressed and then immediately return to their "unpressed" state.

Any "button" that isn't momentary is actually a "switch"..

I seem to misunderstand something..

1 Like

There is a capability called Momentary that sends a push() event, and that is all it does.

The more standard button is the Pushable Button, which sends a pushed(button number) event.

Then there is Double Tappable Button, that sends a doubleTapped(button number) event, and
a Holdable Button that sends the held(button number) event.

Pushable, Holdable, and Double Tappable are often combined into one button device, like with scene switches, or in-wall switches.

If a custom driver only provides a Momentary Button device, Rule Machine will not show the Momentary Button capability devices in the button list, but it will show devices for the other button types. Though it has been pointed out, most developers will include another capability, like switch or actuator to let push() be selected that way.

This only for if the custom driver implements only the Momentary capability, leaving you no way to select it in rule machine for an Action if the developer is not around to fix the driver to work with Rule Machine.

This workaround effectively bridges the Rule Machine bug by linking a Pushable Button to a Momentary Button Device, allowing seamless rule execution. Well-explained setup!