Does Hubitat have “functions” or “routines”?

Wondering if there is an easy way to do some common tasks/set or tasks or checks from multiple apps/integrations without having to repeat the logic over and over everywhere?

1 Like

You can have Rule Machine rules that have no defined trigger and call them as needed, e.g from other rules.

6 Likes

This can also be accomplished in Groovy Apps/Drivers. It sound like you’d like reusable code, correct? If so, some of the much more skilled developers, like @bertabcd1234, can probably point you to the proper Hubitat Developer documentation that describe how to implement reusable code.

5 Likes

I suppose depending upon what you are doing, you could clone rules, and change the devices within the cloned rule. That doesn't prevent multiple similar rules, but does help to not have to rewrite things and click through all those triggers and conditions.

4 Likes

If you use WebCore you can call common routines and pass args.
You can't return args like a function but it cleans up the code and debugging considerably.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.