Editing rule deletes predicates when Conditional Action removed

I reported this in the previous version here, last post in the threa, but it had only happened once.

I just updated a RM5 rule and after I finished updating the actions and was about to hit done to save it I noticed that all my predicates were gone. The slider was set indicating the rule was using predicates but they were not listed.

Since this version allows you to select the conditions from the condition manager it was easy to correct. All my predicates were in the condition manager so I just had to add them back.

I have had this happen to me as well a few times in Rule 5.0. The "conditions" get set to null or disappear somehow.

2 Likes

Okay thanks at least it is not just me.

@bravenel I was able to duplicate this with a simple test rule. The first screenshot shows the rule.

I then added a predicate condition, the same condition in the action list. See next screenshot.

I then deleted the if condition in actions and when I exited the action editor the predicate condition had been deleted as well. See third screenshot. I created a simple rule this morning for something else and this happened. So I created this test rule to see if I could duplicate.

This is expected behavior. When you delete an action that defines a Condition, and have used that Condition somewhere else, it's going to vanish. I put some effort into preventing Predicate Conditions from allowing you to select a pre-existing condition, but evidently there are still ways around that. Use separate conditions for Predicate Conditions and any Conditional action you intend to later remove. Or, define the Predicate Conditions first, and don't remove them.

Okay but not very intuitive. I thought the condition manger maintain all the conditions, and once defined they remained there. Also basing that off RM4.X editor as rules that I changed many times during development maintained every condition I created whether I still used them or not.

Also in the case of the test rule above, the condition still existed in the condition manager. I just had to go edit the predicate and select the condition. So it did not actually delete the condition.

It is what it is, however.

This topic has been discussed several times since the Release of Rule 5.0, so here goes again:

There were innumerable complaints about the In Use By section of devices. Create a Condition in RM for some device, and it remained In Use By indefinitely, even after the Conditional Action had been removed (talk about not very intuitive). So, changes were made to fix this, including that if you remove a Conditional Action that defined a Condition, that Condition is removed too.

This is a bunch of chasing wild geese. Why do you want to edit rules so extensively, and remove things, and then wonder why the rule broke? It will probably always be possible to break rules through editing, and it would take an inordinate amount of effort to protect against this in all situations.

I can see how deleting the condition is useful if a conditional action is removed. However, if the condition is still in use by a predicate, then it is still in use.

If I delete a condition while editing Actions and that condition is also in use under Predicates, maybe a check/warning that the condition can't be removed?

I have no idea how the code is written, but from an end-user's perspective, it would maybe not be a bad idea to have the conditions section be part of the main view of the rule, so you'd see:

Define Predicate Conditions
Select Triggers
Select Actions
Manage/Create Conditions

OK, but this would take extensive effort to track where every condition is in use, new data structures just for that purpose, lots of code. And for what? To prevent you from messing up a rule through editing it. 'Tis a fools errand imo.

Instead, what we plan to do with all apps is make changing them easily reversible. If you break it, just don't save it.

People get confused by the existence of the Manage Conditions section already, and this would make that confusion much worse. The confusion is this: I created a Condition, why isn't my rule doing what it says (without having put it into a Conditional Action, as if having a Condition means something all by itself).

That's not what I meant. I just meant check IN the particular rule app itself if the condition is used in THAT rule. Certainly checking it against all rules would be way too much

That's exactly what I was referring to.

Point taken. We can put that under "user error" :slight_smile:

This was not an extensive change. I had just seen this happen a few times now, and thought it was a bug. Up until today I had not seen a reason as I had been moving some fairly large rules over from RM4 to 5 to use the predicates and Hub variables and it seemed to be happening randomly.

This morning I was creating a new rule that was fairly simple and I used RM5, as we should do for new rules. After creating the rule I realized I wanted to use the condition as a predicate instead of a condition in the rule. So I changed it and that is when I realized what was happening. I tend to just start writing and wing it, I don't flowchart or plan out my rules, so I will create and then delete stuff. perhaps not the best way but it works for me..

Actually, you can put it under the trials and tribulations of creating an app the magnitude of Rule Machine. It's not perfect, never will be. I'd rather we put our energies into adding capabilities than protecting users from editing mistakes.

Two releases ago, you could not even use an existing Condition in Predicate Conditions, only new ones. Perhaps I should go back to that. Sharing conditions is a potential problem if you are later going to edit the rule in such a way that those conditions might be changed or removed. It's easy enough to create a new condition. For Predicate Conditions, I strongly recommend that you create new conditions, and only use them in the Predicate Conditions. I strongly recommend against re-using any conditions in Predicate Conditions.

I know I think I reported that as a problem. Anyway I get it and now that I know I will try to remember.

Of coarse knowing and remembering with me these days is not necessarily synonymous.

It was entirely intentional.

I'm for it. Gets rid of confusion

I know this has been beaten to death but today I went back to edit a rule I started a week or so ago. It was initially created in the current version but probably a few releases back. The rule had 3 conditions in it, that I decided should be predicates.

I was careful this time. I did not delete the conditions in actions and when I created the predicates I did not use the conditions already available I re-did each one.

I then went to the actions and deleted the rule actions that used the conditions. The condition manger showed six conditions, all three original conditions duplicated. Three I created in the action editor and three I created in the predicate editor.

When I exited the action editor all my predicates had been deleted.

So to be safe I just deleted every condition and re-did the predicates. So apparently you need to be very sure about what you want as predicates or conditions before you start.

Going forward, conditions for Predicates and conditions for actions will be kept entirely separate.

3 Likes

Release 2.2.8.156 is out and fixes this problem.

5 Likes