Editing A Rule

Greetings,

Another thing I struggle with is modifying a rule..
In troubleshooting this very rule earlier in a different topic, I have 2 rules, one that turns on Christmas Lights and another that does the same thing with Halloween lights. It dawned on me that these rules may conflict with each other so I want to combine them.

The Christmas light rules is below. What I want to do is say:

If (Mode is Holiday) Then
Do these things
Or if (Mode is Halloween)
Do these things
Else
Do this
End If

I have tried to "Edit" this rule to add the OR but it always ends with Broken Rule.
Do I really have to delete the actions and enter them again from scratch?

Any suggestions?

You need to use an ELSE IF rather than OR.

OK, but can I add that now because that’s where I’m struggling?

Sorry. I am not at home right now to confirm the details but basically you need to edit the actions table. You do this by clicking on the greyed action area in the screenshot you supplied above. You can insert an ELSE IF conditional action somewhere between the existing IF statement and the existing ELSE statement.

Details on how to do this should be found in the rule machine documentation which can be accessed by clicking the blue question mark on the top of the rule page in the screenshot you provided.

Unfortunately i cannot provide much more detail without a screen in front of me.

1 Like

I have had cases where if a IF then was complete RM will not let you add a ELSEIF. When you click the + to add an action you would then click conditional action and then select ELSE IF. If the ELSE IF is not available then add a blank IF at the end and put a ELSEIF in that IF statement. You can then copy or Cut the ELSEIF and paste it where you need it and then delete the blank IF.

I have noticed similar behaviour. It seems to only offer the ELSE IF to be inserted if it deems the place you are inserting it to be logically correct. Regardless of the fact that you may want to re-order the actions later.

I cant figure out how to add a blank if statement - it only allows me to save if I complete the statement - this is so frustrating....

@harold.craswell man I am frustrated - I look at the help file and I cant figure this out... I have tried everything I can think of, crap in the amount of time I have spent messing around, I could have just deleted everything and started over..

Click the area you said just takes me in circles..

By the way, no worries on not being home..

When I click on the rule and select edit, this is the screen I get but I can do anything..

I just did a bit of checking. It seems that that you can only add an ELSE IF conditional action if it follows a valid IF conditional action.

So add a "dummy" IF statement at the bottom of the the actions table. Give it a valid condition ("time is 10:00 am", for example), and save it. Then, add another conditional action. This time you should be offered the additional choices of adding an ELSE IF, ELSE of END IF in the pull down list. Choose ELSE IF and provide a valid condition.

Once you have the ELSE IF statement you may move it to the correct position in your rule and delete the unnecessary dummy IF statement. Somewhat counter-intuitive but it will work.

It appears the authors of the rule machine thought rule editors would usually enter their rules in a linear fashion and did not account for easy rule editing in the user interface.

You should see something like this.

The screen you are showing seems to be one level beyond this. It looks like you are trying to edit the ELSE statement. If you see a screen like the one above, click on the green + sign beside the Create New Action line. Then you will be able to create a new conditional action. Your window should looks something like this:


Choose a conditional action IF expression THEN

Choose a conditional expression. Then click Done with IF expression THEN.

The if expression should now appear in the bottom of the rule table as below:

Note that you now have the options to add an ELSE or and END IF action. However you want an ELSE IF.

Click the plus sign again to create a new action and repeat the process, only this time you will be able to add an ELSE IF. Once you have your ELSE IF conditional action you will be able to use the buttons on the right of the table to move or copy and paste it into the correct place in your rule.

Not sure if this helps or is more confusing. It is late and I need an early start tomorrow. Hope this helps.

@harold.craswell Thank you - Whew that was a long road to travel for a seemingly quick edit..

Here is what the rule looks like now.. This is my first rule with ELSE-IF... Do I have it setup correctly?

There is a couple ways you can add the ELSEIF, Try copying your current IF and then paste it at end. Then you should be able to add an ELSEIF.

Also you could just delete your current IF and build it again. Your condition is already there so it would be pretty quick.

Glad to see it finally worked out. It really is not that difficult to do once you have been through it a time or two, but I agree it is a head scratcher for a newbie. I know exactly how frustrated you are. I am fairly new to Hubitat as well and I just recently went through the same scenario. There is a great three part video on the Hubitat YouTube site which walks through the intricacies of the Rule Machine App. It is worth taking 30 minutes to go through them. You can access it here: Rule Machine Tutorials

The IF... ELSE IF ... ELSE ... END IF control structure in your rule looks to be syntactically correct, but obviously I cannot comment on the correctness of the actions beyond that.

Now I can consolidate 3 rules into one and streamline my process.. Thank you all