You guys really need to make a way to share Rules

I agree with @jwjr. A simple text based import/export of rules would be great!

1 Like

There is much more to this than meets the eye. Are you thinking of this as a way to share rules with other users? What is your goal?

If I could dump rules into a text editor, perform a find/replace on a device and change it in the file and re-upload it would be very helpful.

This gets around having to use the web-based editor to modify existing conditional statements, which can be very tedious.

2 Likes

If a text editor is "too complicated", just a way to use our favorite text editor and inject the result as a new rule.

Agree, I don't mean for HE to add another online web interface. That is a lot of work.

I would assume that all these rules boil down to some type of script/configuration/language which is running under the hood. Just peel back a layer an let users see this detail.

This assumption is false. There is quite a bit more complexity than you are aware of. Even if a rule were written out, substituting devices would not be just a simple thing to accomplish. The effort for a user would be just as tedious, in a different and more obscure way, more prone to error, harder to document, etc. So, it would require yet another online interface to make it easy to use.

Best analogy would be going from a high level language, to editing binary object code or assembly language code. It's all there, but not in a form easy to see and edit.

I appreciate you responding, but your explanation sounds like you are intentionally trying to keep from sharing what "is" HE.

I'm a programmer by trade, my day job is dealing with all sorts of languages on embedded devices. Many with hard real-time control and web interfaces. So this platform is very intriguing to me, but the interface to the rules engine--not so much.

Are the rules stored in a database in HE? Or just straight custom data structures? What is the scheduler you use to run?

1 Like

Take a look at the developer documentation. OK, it's sparse for Hubitat. Take a look at the "classic" ST SmartApp developer docs instead: Groovy With SmartThings ā€” SmartThings Classic Developer Documentation

RM is closed-source, so we don't really know how it works, but it originated on SmartThings and the runtime environment is nearly compatible. You could write something like Rule Machine yourself if you wanted to. Perhaps try it and imagine the difficulty. :slight_smile: Everything you choose in the UI is saved as a "setting" (presumably implemented as a Map, but that's an implementation detail we again don't know). Check out the cogs/gear icon after you create a rule and look at all the settings it generates. The difficulty, presumably, stems from getting a way to import and export rules in such a way that all of these would get set properly in a new rule. I'm not aware of any SmartThings or Hubitat app that has such a capability and certainly not one as complex as Rule Machine (the only app that comes close to this on ST is webCoRE, and that doesn't really work in the same way--it makes intermediary JSON that, aside from slowing things down and something I can guarantee Hubitat isn't interested in doing--does help a little with sharing). Rules are stored and executed like any other app because that's what they are.

If you find yourself needing the flexibility Rule Machine offers but want some re-usability, since you're a programmer, perhaps yo could consider writing a custom app instead. Apps are written in Groovy within the (very reasonable) limits of the Hubitat sandbox and the (very helpful) additions it runs on top of behind the scenes (e.g., again the implementation details aren't open, but apps are almost certainly all instances of some inherited class that provides the Hubitat-specific methods that are documented). You could also look at the wealth of community-created apps or consider whether a built-in app can suit your needs before choosing RM. And when choosing RM, don't be afraid to use multiple rules and keep things per-rule simple.

Our app UI is rather clunky. This is something we basically inherited due to an effort to be mostly compatible with SmartThings SmartApps and DTHs. We have plans to greatly improve the UI, but for now, it is what it is. Rule Machine is clearly a complex app, and it has pushed the capabilities of the app ui to their creaky limits. I understand you'd like a nice clean script you could play with, but you'll just have to trust me when I say that won't be forthcoming per se. We may very well create a method to share Rules, but that won't encourage by its very nature editing of a complex json file. When sharing a rule, one would have to deal with device replacements, and that would pretty much require a UI to handle it. This too is planned, but to support the desire users have to take a person's rule, and substitute their own devices in it. That's not the same use case as editing a rule script.

Everything in Hubitat is stored in a database.

Quartz.

7 Likes

For me it would be a very good way to document all of my rules rather than taking screen shots. What I'd eventually hope for is a method to export not just rules, but every app and device to a text file so that the entire setup could be easily recreated from scratch if necessary. For new users that made a lot of mistakes on the initial setup, it would provide documentation to where it's be easy to start over and just use the portions that they need.

I've been having a play with Node Red on Home Assistant on a Pi mainly for a Harmony Hub interfacing system using a virtual Hue Bridge. That really is a great way to create and edit rules and I find the visual aspect of it very helpful to see what's going one. It allows super easy copy & paste of individual nodes or complete flows. Each node of the logic has the last event and timestamp it processed under it so debugging is very easy as you can see exactly what is happening as the rule runs. If there was any way RM could become a Node Red style interface it would be perfection IMO.

1 Like

Is there an export/import text format for rules?

No. That is the reason for this thread really.

2 Likes

I cannot agree strongly enough.

We really need this, I have some very long rules for my Hue dimmer switches, and having to clone and change devices for each switch I deploy is a nightmare!

How do we prioritize this feature request?

4 Likes

I can imagine an ā€œexploded viewā€ of a rule with the whole thing presented in a flat list with it in ā€œmad libsā€ mode highlighting each device that needs to be selected before the imported rule can run.

I think this will end up being a paid application in the future.

It's not so much a "what would it look like" problem so much as it is a "they have to live within the UI framework and App framework that exists within HE or undertake a massive effort of rewriting the whole thing." I believe that's pretty much the roadblock

1 Like

To add to what @dman2306 wrote, here's Bruce's description of the issues with "sharing" RM rules:

Also want to point out that there are ways to share automations that use Hubitat devices (for example, if one were using Node-RED instead of Rule Machine, or webCoRE for that matter).

4 Likes

I remember at a previous job Iā€™d ask an engineer ā€œis this possible?ā€ And theyā€™d say ā€œof course, itā€™s a small matter of codeā€

Then weā€™d laugh and talk about if that meant 5 mins or 3 years. Anything is possible. Just depends on how much time and priority it has.

1 Like