Rule Engine Problem

I have just encountered the following error creating a rule. It's happened twice now, and I receive the error above when I click on the actions to edit them. The error below has been logged.

Is this a new problem, as I've not seen the error before? Is there a way I can identify what the problem is and resolve it? Currently, I cant edit the rule as when I click to edit it, I just get the message above.

java.lang.StringIndexOutOfBoundsException: String index out of range: 7 on line 3773 (method selectActions)

@bravenel was advised to tag you by @rlithgow1

I need to see a screenshot of the rule before it throws the error.



I was inserting a command to set bulb colour just below the "Comment: Film" line, clicked done and the error appeared. Now every time I click the rule code I get the error.

Once it's broken like that, there is no way to recover it, except for restoring from a backup. With a very large rule like this, best thing to do is to first either create a clone, or download an export of it. Then you have an easy way to recover from a problem.

I can't really tell why it had this problem.

1 Like

Its unfortunate that i broke a rule in this way, set this ine up from scratch, which took a while an its broken too. Ive never had this happen before but twice today. Do you need any information to help debug?

Darren - I can't speak to your error itself, Bruce is the expert there.

However, I've written a couple large complex rules, and in one case (under a previous RM version) I ran into an error where the rule broke and had to be completely deleted and restarted as you have.

What I've found is it's easier for me to break large rules into smaller individual rules. Rules themselves don't always need a trigger, they can just be stand-alone and called to run from other rules. This way if you do run into an issue that breaks a rule, you don't need to completely start over from scratch. Particularly if you haven't cloned the rule or exported a backup as suggested.

You may also find that whatever is breaking the rule won't have the same issue, Alternatively, you may be able to narrow down what is causing the rule to break, helping to identify if there is a larger rule machine issue.

In your case, I would make separate rules for each of the light settings (OFF/WARM/BRIGHT/TV/FILM/DUSK), and put your conditionals in a master rule.

Other benefits - it makes it easier to adjust individual settings if you want to go back and change them, without changing the main rule each time. You can also can use the settings in other rules.

Many find it's a personal programming preference, just one that works best for me. Often it helps me break down complex logic into smaller, simpler, steps.

2 Likes