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

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

You can. The part you are trying to edit is called a condition (an expression is some combination of one or more conditions and operators), and you can do that if you back up a page (hit "Done Editing Expression" -- don't use your browser's Back button) and go to the "Manage Conditions" page.

Note that this will affect any expression where you have used this condition, possibly not just this one, in the event that you have referenced this same condition in multiple places (one advantage of this approach).

4 Likes

Wow! Clearly I need more education on this Rule Machine! I see that you're right and I can make edits there, thanks!

Still have to wrap my head around "conditions".

In simple terms, conditions are just states, whereas triggers are events.

Trigger = XY switch turns on
Condition = XY switch is on

As Robert says above, the Manage Conditions section really shines in cases where you're using the same condition multiple times w/in a rule... When you need to make a tweak to that condition, then you just have to do it that one place (instead of digging around multiple places w/in the guts of the rule).