Exporting a rule includes names of all rules

I exported a C7/ RM5.1 rule so that I could send it to another Hubitat user for them to import.

I looked at the json and saw it had the names of all my other rules in appData -> Rule# -> installedRules.

Are those required? Some of my rule names are kind of revealing and others odd to share.

I was going to test by just just nulling the whole installedRules, but no parser I could find was happy with all the \\" or \\* for me to gracefully try it.

I'm guessing this is because each rule caches the list of all rules internally so it can show them when you use actions like "Pause/Resume Rule." The output of the export really isn't intended to be edited, but it's also not necessarily valid JSON, so if you do take that route, any editor that tries to validate the contents isn't necessarily able to be trusted.

I am not aware of any way to avoid this (exports are essentially a dump of the app's internal data structures so they can be imported, cloned, or restored), though if you have a second hub and import the rule there before exporting again, it would probably get rid of it (assuming you don't care about those rule names). With one hub, this would also be the same effect as the extreme option of exporting, doing a soft reset, import, re-export, and then restore. But that's probably more work than it's worth normally...

1 Like

I was looking for a method to save (export) rules for reference in case I mess up/break a rule.

I exported all of the rules via selecting export at the RM level, not the rule itself. Select all of the rules and export to a file. Open the file in an editor, replace all \\ with \, then save. Then open in Firefox, Notepad++, or another JSON viewer. Updated file seems properly formatted.

Original thread & @Bob.ma's post: Why can't Rules be saved copied and shared like cooking recipes - #52 by Bob.ma

The fact that you saw something "invalid" in the output is not a problem, as these files are not guaranteed to be strict JSON, and it's likely that they will not import correctly after any "fix" to that. (You can see more in the post after the one you linked to in that topic.)

Manually editing them is bad idea and not supported, in any case.

1 Like

Download the Hubitat app