Help me regain my trust of If-Then-Else

I converted all my rules over to 5.1 (OCD), but still don't trust the ELSE part of IF-THEN-ELSE.

My IF-THEN statements work perfectly, and I just add a second IF-THEN with a .not. or some other condition that gets me there.

My rules would be a lot simpler (cleaner, more efficient?) if I could just add that ELSE and remove most of the subsequent IF-THEN (with .not.) code, but I can't.

Every time I try, the rule fails to execute reliably. I go back to my two IF-THEN statements, and 100% solid. Hmmm.

First of all, has anyone else been struggling with this? Are there things to watch out for? Is this a bug?

I have not tried an ELSE since converting everything over to 5.1. Perhaps 5.1 has addressed the issue?

I use if/then/else all the time and have never found any bugs in its basic functioning. Doesn't mean there isn't a bug in a specific use case of course.

Can you post a screen shot of a rule that uses if/then/else and maybe describe what you're trying to do?

4 Likes

Can you post a screenshot of a rule with an ELSE that doesn't work?

3 Likes

Unfortunately, I've removed all my ELSE code in all my rules. The only way to give an example, is to try again.

If this works reliably for everyone, and it appears to be the case, then I should give it another go.

Thank you for the AMAZING instant response! This community is one of the reasons I switched to Hubitat!

3 Likes

I too use if-then-else with no problems. I'm on C7 so RM 5.1

2 Likes

So that we don't keep this discussion on the hypothetical level, a few screenshots of your existing Rules might be in order. Extra pairs of eyes never hurt, and you never know... someone might pipe up with something unexpected like, "Hey, you're missing an END-IF" or some other speck of housekeeping that's bollocksing up your workflow.

7 Likes

Here is an example where it makes me wonder. If that first IF-THEN is false, will RM check the ELSE portion?

1 Like

If the IF statement is false at the time the rule is triggered it will execute only the ELSE portion. So if you were to run the rule actions right now (bypassing the trigger) it would turn off CR Nanoleaf, Computer Room Fan, and Computer Room Lights.

2 Likes

A few in here and no issues.

2 Likes

!

1 Like

I've never noticed any problem with the else... BUT if you had some logical issues you didn't realize, I could see things happening that you didn't expect, especially if you have IF conditions with multiple pieces to the IF condition...

It might be quite possible to have two statements that can be true independently so that they both happen, but switching to else would mean that only one or the other but not both could ever happen.

3 Likes

Here is a rule that uses if/then, else-if/then, and endif:

It can and does work if the hardware cooperates.

3 Likes

I switched over all my applicable rules (that had double IF-THENs) to IF-THEN-ELSE. I'm very careful to terminate my IF-THENs with ENDIFs. I just put in the ELSE, and removed the redundant ENDIF and IF-THEN statements.

Let's see if things remain stable :-).

I just had to get over my fear of ELSE, and hear from the community that my fear of ELSE was groundless.

I will miss seeing the "TRUE" in one section and "FALSE" in the other which you get with two IF-THENs.

1 Like

Dang! That rule requires a master class in RM! LOL

2 Likes

depends what your trigger is .. you didnt show us.. it should be change.. it it is only active the else will never fire.

Hmmm. Here is the trigger code. I would not have guessed that the trigger would affect the ELSE....

1 Like

That's fine u have motion changed.

1 Like

Those triggers are most likely good since you used the *changed" as the trigger, some people misuse the True or False as the trigger instead, and expect a different outcome because the action part will never go to the else (flase) part because the trigger is set to run when true only.

2 Likes

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.