[Released] Rule 4.0

Trigger Event: Gate changed
Actions, IF gate open -THEN
your actions
ELSE
Cancel Delayed actions
Stop Repeating actions
END-IF

1 Like

Thank you very much for the props. It’s a great community to be a part of and contribute towards!!

2 Likes

First rule 4.0 I tried to create needed presence and found this myself a bit ago. Came here to see what I could find on it. Guess I'll wait for the hotfix. :smile: I think I'm going to like RM 4.0.

I hate to harp on something, but I still have a question on "nested" if statements. Will this action work? It allowed me to save it and it appears correct to me...but obviously if it won't I'll come up with something else.

This is the conversion of 2 RM 3.0 rules into one 4.0 Rule. If we can also add nested IF's, that will reduce my "rules" by an even larger number.

Yes, you can nest IF-THENs to your heart's content.

3 Likes

Thanks @bravenel. And is that the right way to do it, have one END-IF for the nested IF then an ELSE-IF for the top level IF? It is nice that it indents itself automatically without having to do it manually.

IF-THEN, ELSE-IF... ELSE, END-IF all need to be matched up into a single block. Within any segment of that block, you can have other IF-THEN-ELSE-ENDIF blocks. ELSE-IF and ELSE are optional, and there can be as many ELSE-IFs as you want but only one ELSE. There must be an END-IF to close the block.

And the screenshot i posted looks right?

It looks fine except for my bug with the indents for Delay Per Mode being off.

Well, I meant more my rule than your code. I only have control over one out of two of those. :stuck_out_tongue: Thanks!!!

Currently in RM 3 if we do not close and "if" statement with an "end if" it works fine. Now with nested rules is it mandatory to use a "end if" for each "if' ??

Yes. Otherwise it won't know where one stops and the other continues! The auto-indentation shows the nesting.

If we forget to use a end if will it allow us to save?

Yes, it will. If you had this:

 IF THEN
    IF THEN
        IF THEN 
            actions

And left off all of the END-IFs, it would work as you expect.

So then when the end if is needed? Before you mentioned is mandatory

IF THEN
    IF THEN
          actions
    ELSE
          more actions
    ENDIF
    yet more actions
ELSE 
     some alternate actions
END-IF

That last one could be left off, but not the one for the inner IF-THEN block if there are to be actions after it.

Kind of confusing when and when not. But if a end if is missing will it warn us?

No, that's not the issue in and of itself. Think of IF-THEN and END-IF as bookends that make a complete thing. Like parentheses must be a matched pair. You wouldn't write a sentence with a left parentheses and not the right one, and then have more words in the sentence -- how would you know which were parenthetical and which weren't? Plus, your English teacher would give you bad marks if you left off the closing parenthesis. IF-THEN and END-IF are like that.

It's bad form to leave off an END-IF.

2 Likes

Ok but I see that anyways the ifs will work without end ifs sometimes. I guess to be safe would be better to close an if with an end if. I have first to give a try. Thanks

1 Like

The hot fix release is out: Hub Update 2.1.2

This fixes the two bugs reported earlier.