Announcement

Collapse
No announcement yet.

What do IF, OR IF, AND IF mean?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #16
    I will have to look for the Up/Down town arrows..... Think there was a song for that one


    Devoir

    Comment


      #17
      Originally posted by randy View Post
      As described under Triggers, Triggers are first preceded by IF and Conditions are always preceded by AND IF.

      Now that simple triggers (IF) and conditions (AND IF) have been covered, there is a third option the secondary trigger (OR IF). I think this one confuses a lot of users until they get the concept. If you remember IF or OR IF always means it is a Trigger. AND IF always means it is a Condition. The easiest way to cover this is to go step by step.

      When you first start creating an event, the first element is ALWAYS a trigger and therefore will always begin with "IF". As we've covered before a trigger is the element that gets the gets the event started, The best triggers are always a "moment in time", that will occur only once such as specific time of day or a device such as a switch or motion detector changing value. These trigger items are placed in the event queue and will be processed when the definition of the trigger is true.

      Below is a simple trigger "If the time is 12:00AM".





      Now if you press the add button to the right of the trigger line, you will be presented with a new line, presumably for a condition. But you will note that there are two choices, the first being "AND IF", which is always a condition. The second choice is "OR IF" which will always represent an additional trigger.





      If you choose "AND IF" you you will be given choices of conditions that will apply to the trigger, which will further refine the elements that need to be TRUE in order for an event to perform its assigned action(s). You will note that the condition immediately follows the trigger, with no space between the two lines.





      On the other hand if you choose "OR IF" you will get the first clue that something is different because HomeSeer will add some gray space between the "IF" trigger and the second "OR IF" trigger.





      If you choose the second trigger and collapse the line, you see two separate elements. This is a very important visual clue to a very important distinction relating to secondary or additional triggers.





      Below there have been conditions added to each of the two triggers. Again, by the way they are grouped, you should be able to visualize how they are evaluated by HomeSeer's Event Engine. Here we will cause an Action to be executed At Midnight on Weekend Days or at 11:00 PM on Weekdays





      Below we have created an event consisting of five different triggers and a condition for each one. This event will turn a light on at 6:00 PM on Monday, an hour later on Tuesday, an hour later on Wednesday and so on. The condition under each trigger (IF-OR IF) applies only to the trigger at the top of the group the condition is in. One group has absolutely no bearing on any other group in the event. If any one of the groups are true, the Event will run and execute the Action(s) of the Event. If none of them are true the Event will not run.





      Below we have added an additional condition to each group to check if the light is actually OFF before the Action is allowed to turn it on. The reason the condition had to be added to each group is that conditions are limited in their scope to the trigger immediately above them. If you want a condition to be applied to all triggers, it must be added to each individually or included in group conditions. A statement of group conditions still must follow each trigger to which they apply, so the benefit is only realized when there are two or more group conditions applying to each trigger. More about that in another thread.




      So, looking at how they are grouped and understanding that there can be only one Action or set of actions, the simplest way to look at the OR IF is that it is a means of creating a number of individual events which share a common Action or set of Actions.





      The logic is simple and straight forward and really adds to the power of HomeSeer, but it is imperative that as you are designing an event you realize that the multiple trigger/condition groups within an event, have absolutely NO bearing on one another, they simply share Action(s). It is NOT an IF, THEN, ELSE logic, there is no ELSE. It is simply an IF, OR IF, OR IF logic. Sometimes for the sake of tracing event triggers within the log, it makes much more sense to create five complete events as opposed a single one with 5 triggers. You have to make that choice.
      So what is wrong with my events? It's like AND IF statement is ignored. Hotge events get run as soon as the IF statement is satisfied..
      Attached Files

      Comment


        #18
        I’ve not seen an instance of Conditions being ignored in an event that is self-triggered. If the event is run from a voice command or manually from the Event management screen, Conditions are ALWAYS ignored. If an Event is called from another Event, Conditions are ignored unless expressly told to honor them in the calling Event.
        HS4 Pro, 4.2.19.16 Windows 10 pro, Supermicro LP Xeon

        Comment


          #19
          Originally posted by randy View Post
          I’ve not seen an instance of Conditions being ignored in an event that is self-triggered. If the event is run from a voice command or manually from the Event management screen, Conditions are ALWAYS ignored. If an Event is called from another Event, Conditions are ignored unless expressly told to honor them in the calling Event.
          Ok thanks for responding so quickly. I've tried multiple boards with no resolution unfortunately. Think I'll trying calling homeseer support, even if I have to pay..

          Thanks again

          Comment


            #20
            Are you sure that the value Lights Tracker Control is either an ON or OFF? Take a look at the status/value pairs and also the properties of the device to see just what the value actually is. ON might be 100 or 255, Off could be 0. But if the actual value is 99 or 1 then it won't fire. '

            Post the actual status/value pairs you have defined and also the properties for the Advanced/Properties for the actual device ref so we can see just what the actual numerical value is?

            Comment


              #21
              I think it's right? I tried telling the AND IF to look at both ON or by Value. same results... On version HS4 Pro 4.2.8.0

              Attached Files

              Comment


                #22
                Originally posted by randy View Post
                I’ve not seen an instance of Conditions being ignored in an event that is self-triggered. If the event is run from a voice command or manually from the Event management screen, Conditions are ALWAYS ignored. If an Event is called from another Event, Conditions are ignored unless expressly told to honor them in the calling Event.
                Indeed! For new users all of this is really quite confusing.

                a) OR IFs are completely decoupled from any other IF/OR IF
                b) AND IFs are conditions, i.e. something that has been and still has that condition. The "IF" is making HS checking on something and then it checks if other conditions are being met. You can't really have two things happening at the exact same time like LUX going below x and having somebody press a button. Those events might be close (less than a second apart) but they just don't happen at the exact same time.
                c) manually triggered events by default ignore conditions.

                Coming back to an old topic, I wish HS would finally implement the conditional actions which would allow us to have an if then else. It would make life so much easier.

                Comment


                  #23
                  Originally posted by devoir View Post
                  I will have to look for the Up/Down town arrows..... Think there was a song for that one


                  Devoir
                  Wasn't it a musical with Frank Sinatra and Gene Kelly?


                  Jim Speiser
                  38-year veteran of Home Automation
                  Still don't know squat

                  Comment


                    #24
                    Not ever have used HS3 - I like the way it shows the events compared to HS4. With HS4, it just does not look like event 1a, 1b, 1c and 1d. It's just all bunched together.

                    Click image for larger version

Name:	Screenshot 2022-07-29 114415.png
Views:	152
Size:	51.6 KB
ID:	1559735

                    Comment


                      #25
                      It would be nice if those 2 "AND IF" columns where indented to the right a little.
                      HS4Pro on a Raspberry Pi4
                      54 Z-Wave Nodes / 21 Zigbee Devices / 108 Events / 767 Devices
                      Plugins: Z-Wave / Zigbee Plus / EasyTrigger / AK Weather / OMNI

                      HSTouch Clients: 1 Android

                      Comment


                        #26
                        Originally posted by rmasonjr View Post
                        It would be nice if those 2 "AND IF" columns where indented to the right a little.
                        +1
                        "if I have seen further [than others], it is by standing on the shoulders of giants." --Sir Isaac Newton (1675)

                        Comment


                          #27
                          Originally posted by Marty_B View Post
                          I just wanted to thank you for this write up. It helped me out tremendously. I have used Homeseer for years and never really understood the logic order and grouping in events as most of my events are pretty simple. Thanks again.
                          Same here… Old HS2 and HS3 user, new HS4 user. Thanks Randy for all of the above clarity.

                          Comment

                          Working...
                          X