byronomo Posted September 15, 2022 Share Posted September 15, 2022 I am not very experienced, so I'm guessing this question is incredibly basic (if not stupid). What is the difference between the two following approaches: When.........turns off If XXXX is True AND YYYY is True AND ZZZZ is True -->Turn on LIGHT A Else -->Stop When........turns off If XXXX is True AND YYYY is True AND ZZZZ is True -->Turn on LIGHT A Is there any functional or technical difference between these two if you are only looking to initiate an action if ALL of the conditional statements are true? Thanks in advance. Quote Link to comment Share on other sites More sharing options...
Cyknight Posted September 16, 2022 Share Posted September 16, 2022 Your stop command is completely redundant in your scenario to begin with. ELSE is used more in the sense of 'if not do this instead' IF light is on Turn light off ELSE turn light on This is an extremely basic example of course. ELSE is relatively new to Control4 as a command, and was put in to replace messy lines of IF statements. To take the above exmaple IF light is on Turn off light IF light is off Turn on light does the same thing. So does: If light is on Turn light off stop Turn light on Again in the above examples, being as simple as they are, there's no advantage, really, in one method or another. But when you get into much more complex options it becomes a lot cleaner to use WHEN front yard motion senses motion IF time is night time IF security is armed to away turn on front hallway light turn on garage lights send push notification notify someone's at the house ELSE IF security is armed to stay send push notification alert someone's approaching activate scene light alert low ELSE IF door is unlocked send push notification notify someone's here to visit Turn on porch light Here three sets of things could happen depending on various IF statements, and one thing always happens (porch lights turn on) SpencerT 1 Quote Link to comment Share on other sites More sharing options...
byronomo Posted September 16, 2022 Author Share Posted September 16, 2022 3 hours ago, Cyknight said: Your stop command is completely redundant in your scenario to begin with. ELSE is used more in the sense of 'if not do this instead' Thanks....I was able to follow/understand 98% of your response. Incredibly helpful! The one thing that I wanted to clarify in my example: Is it the "stop" command ONLY that is redundant or the "Else" AND the "Stop" command in my example. In other words, is my example #2 the functional equivalent of example #1? Quote Link to comment Share on other sites More sharing options...
Cyknight Posted September 16, 2022 Share Posted September 16, 2022 2 hours ago, byronomo said: Thanks....I was able to follow/understand 98% of your response. Incredibly helpful! The one thing that I wanted to clarify in my example: Is it the "stop" command ONLY that is redundant or the "Else" AND the "Stop" command in my example. In other words, is my example #2 the functional equivalent of example #1? In your original post, both the ELSE and stop statements are redundant, and yes both your examples would accomplish the same thing. In your example, ELSE isn't needed simply because there IS no other programming that you want to execute "if not the case" STOP is only needed to, and functions as, a hard stop - meaning once the systems reads STOP it will stop and not 'read' any further. See the third example I posted about three methods of accomplishing the same thing (toggle a light) Without the stop in there, it would turn the light off if was on ... and proceed to keep 'reading' the lines and turn it right back on. Quote Link to comment Share on other sites More sharing options...
byronomo Posted September 17, 2022 Author Share Posted September 17, 2022 Crystal clear now. Thank you so much!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.