Why is editing a rule so hard? (And backup/restore of rules, too)

Am I the only one who frequently finds himself unable to edit an existing rule? This is true even with rules created in RM 5.1. Oftentimes I have no edit button at all. Other times, I can start editing but what seems like it should be a simple change becomes a challenge.

While I'm at it, I have also had trouble backing up a rule. When I created some rules back in 2022, they saved as JSON files. Now my rules are saving in TXT format. I had a case where I broke a rule badly while editing it and I hadn't cloned it first (which I forgot I should do). So I restored my whole database to a backup from last week, then I tried to save the rule I had broken, but I only got TXT. I the restored my Friday database, and finally restored the rule that was broken. The rule came back, but the devices in the rule were not the same as they were when I backed them up. I got back generic versions of thee devices that gave NULL results. I had to manually go back and edit to repoint the correct devices.

Anyway, I'm probably missing something in my understanding. My problem is I love the power that Hubitat gives me, but if I don't mess with rules for a year, it's really tough to get back into it.

2 Likes

I am sorry for your troubles. Have you tried a soft reset? Your database may be messed up. I have rules I created over 5 years ago that are still running and I had to update them recently as I migrated and combined a few separate hubs. No issues with old rules.

2 Likes

Do you sometimes use the back button on the browser while editing rules? I use to do that all the time. This breaks/corrupts rules and then they can no longer be edited.

Since I was able to train myself not to do that anymore, I haven’t had issues.

5 Likes

I guess I need to look into the implications of and the procedures for a soft reset. Thanks @ritchierich!

As for using the back button, @Sebastien, I don't do that.

2 Likes

@ritchierich This looks like a generally safe and useful procedure, so thanks for suggesting it! Do you have any tips for doing this? I just did a manual backup, but is there anything else I should do? Have you heard of any soft resets going way wrong? I'm not trying to give myself a whole new project. :wink:

1 Like

I'd suggest following the soft reset process from the documentation, if anything comes up then it's worth noting in the documentation. Or if @ritchierich has anything to add to the documentation.....

1 Like

I have the same problem, especially when trying to edit a rule containing if/then/else. Usually I just delete the rule and start over.

2 Likes

Sorry busy day. I have done many soft resets and all have gone well so you should have no concerns.

Are you doing most of your rule editing from a phone/tablet or a PC? I've never had a problem editing rule via PC web browser. I loathe trying to use my phone to even do something as simple as disable a rule. It's so cumbersome. Using a PC web browser makes things a lot easier.

2 Likes

@ritchierich Thanks for the reassurance. I just did the soft reset. I'll check things out over the coming days, but a quick check of on of my rules DID give me an edit ability. So I'm hopeful!

Thanks again!

2 Likes

@rlithgow1 I don't think I ever tried to edit a rule from a cell phone. The screen size just doesn't lend itself to that use case, at least for me. I also don't use the browser back button, having learned that lesson in the first few weeks! I may have even learned about "soft reset" back then, but I can forget a LOT in a few short years! :wink:

Can I circle back to my other question about how to reliably back up individual rules that can reliably be restored? I thought the JSON backups would restore correctly, but I cannot find again how I got that format rather than simple TXT files.

If you backup a single rule it backs up as a JSON format. If you backup multiple rules then they are in text format, perhaps that is what you are seeing.

1 Like

@terminal3 Even for a single rule, I don't see any option for JSON file exports. But I have some from 2 years back that WERE json so there clearly has to be some way.

The format is the same no matter what the file extension ends up being (note that in any case, it also might not be valid JSON and is not intended for human editing).

If I revert to an older backup and then restore a single rule, shouldn't it just work? When I did it, it created some generic non-working devices. I then had to go back and try to edit it.

This just seems more complex than it should be.

In general, yes, assuming you mean revert, back up the rule, re-upgrade, and then import (not restore) the rule. Note that a local backup doesn't include your Z-Wave or Zigbee radio information, just the Hubitat devices themselves, so anything you have changed since then will not be reflected. An import of an app/rule is also different from a restore and should not be done unless the and device IDs are the exact same, otherwise you may indeed end up with possibly useless ones it will create for you that will need to be swapped out (and the "new" ones entirely removed to avoid confusion; a restore assumes they already exist, so this is apparently how it avoids entirely failing if not).

I believe that backups also do not backup File Manager files, but Jean May (@thebearmay) wrote a nice utility (in HPM) that can back up and restore File Manager files.

This doesn't address your issue exactly, but in the future I would clone the rule, and edit the cloned rule. Disable the old rule and is then "saved" (for lack of a better term) for reference or if you just want to revert back to the old one for some reason.

It also allows you to compare two versions of rules very easily by having the old and new open in two browser windows side by side.

That edit the cloned rule method has never failed me, but I do have to remember to clone the rule in the first place, which is the biggest flaw in this method.

4 Likes

So here if I want to edit the part comparing the forecast high temperature to a temperature of my choosing, notice that I can't actually edit that part. I'm offered only to "insert before Expression element" or "Delete Expression elements".

So is this element something that cannot just be edited, in the sense where I can pull it up and say change ">" to ">=". That's how I think of editing.

1 Like