Else-if controls

How does one add else-if to a rule? I cannot find this. I can do and It-then, a separate else line, then a new if-then below it. So..

If-then
Else
If-then
End-if
End-if

The simple response is you need to look at including brackets in the set of actions. Let me know if a screenshot would make this clearer...

1 Like

The Else-If option appears in the conditional actions once an “IF” was added to the rule:

7 Likes

Ok. I didn’t see it in the list, but I never added brackets. Is this documented somewhere?

The documentation link above includes RM 5.1 documentation:

3 Likes

Pardon my ignorance as I don't usually use Rule Machine but am building out rules for someone who does. Bit of a learning curve :slight_smile:

I'm looking for the ELSE-IF Expression THEN to restore the window blinds to position 50 if the existing conditions have passed.

I'm this far:

When I attempt to create the restore Action I don't have ELSE-IF Expression THEN in my options.

What am I missing here, please? I'm sure it's simple but this is the very first complex rule I'm building out.

You need and IF action before you can have an ELSE-IF

IF... THEN
   Some action
ELSE-IF...
   Some other action
ELSE-IF...
   More action
ELSE...
   Even more action
END-IF
1 Like

I guess I'm not understanding where to see the IF... I may not be providing the correct info. This is the main page of this rule:

EDIT: I'm attempting to use this video tutorial.

Adding my first Condition my screen doesn't look like his, ie there's no IF etc above my work...


...as there is in his:

The trigger is an event that starts the actions happening. It's not an IF this happens, it's a when this happens. For example, if we look at a door opening as the trigger, the action could be IF the current time is between sunrise and sunset THEN turn on the foyer light. ELSE-IF the current time is between sunset and sunrise then turn on the foyer and front porch lights. IF-THEN-ELSE is a way to define different actions based upon some defined conditions.

2 Likes

The section that says Manage and Create Conditions is only a repository where your expressions are stored and modified. They do nothing unless they are used in the actions section of the rule. In the Actions for MAYO it's sunny tilt office blinds, Create a new action and selection Conditional Actions. There you will find IF Expression THEN. Note that you will also find Simple Conditional Action which is a single action only (no ELSE or ELSE-IF possible) with only a single condition allowed.

1 Like

Correct, understand that.

In following the video I've created the Trigger:

  • Sun Azimuth changes

I've created the following Conditions:

  • Sun Azimuth greater than 133
  • Sun Azimuth less than 215
  • Between sunrise and sunset
  • Illuminance greater than 6

I've created an Action:

  • Set the two blinds to position 20

And then the video and I diverge because, in attempting to add the ELSE-IF, there's no option to do so in the Conditional Actions dropdown as there is in the video:

Please post a screen shot of your current rule


You haven't defined a conditional action in the Actions for... section.

Please start here
Create New Action
Selection Conditional Actions - IF Expression THEN
When defining the IF-THEN you can use existing conditions and pull one, or eventually multiple, from the Manage Conditions section.
Lets start with this...
IF (Sun Azimuth azimuth > 133) THEN
ELSE-IF (Sun Azimuth azimuth < 215) THEN
ELSE
END-IF
When typing this I realized there may need to be some additional logic as 300 is greater than 133 but not less than 215. But lets start with how to define an IF-THEN-ELSE-IF first then get to the logic.

2 Likes

Where am I finding the ELSE and END-IF?

EDIT: wow, ok, must do Done with IF Expression THEN and go back to the main rule menu and + END and END-IF.

1 Like

@pseudonym So taking this the rest of the way, the Action the ELSE takes is to restore the blinds to their original position:

...with the final rule looking like:

Yes?

Looks good to me!

So I've taken this a step further. The goal here is that, when this rule is done, and it's still before sunset, the blinds reopen.


I'm guessing the reason the ELSE shows [False] is because we're still within the IF.

The IF-THEN within the ELSE is corrupted. The IF((F) should have a condition defined but it's missing. Also, instead of using ELSE then another IF-THEN, conditional actions have an ELSE-IF you can use. It's only visible once you define the IF-THEN. I'd replace the ELSE with ELSE-IF and delete your last IF-THEN.

Effectively this:

EDIT: Then adding in a couple more Conditions for the post-sunny section:

Download the Hubitat app