Announcement

Collapse
No announcement yet.

What do IF, OR IF, AND IF mean?

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

  • What do IF, OR IF, AND IF mean?

    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.
    Last edited by rprade; December 27th, 2018, 06:01 PM.
    Randy Prade
    Aurora, CO
    Prades.net

    PHLocation - Pushover - EasyTrigger - UltraECM3 - Ultra1Wire3 - Arduino

  • #2
    Originally posted by rprade View Post
    ....It is simply an IF, OR IF, OR IF logic...
    I guess you actually refer to "IF, AND IF, OR IF" ?

    Also, I think this is good reference:
    Originally posted by sooty View Post
    Think of "OR IF" as a trigger and "AND IF" as a condition.

    Comment


    • #3
      Originally posted by rprade View Post
      ....It is simply an IF, OR IF, OR IF logic...
      Originally posted by larhedse View Post
      I guess you actually refer to "IF, AND IF, OR IF" ?
      No, I used "IF, OR IF, OR IF" for a very specific reason. They are Triggers. The only way to wrap your mind around the function of the HomeSeer Event Engine is to thoroughly understand the fundamental difference between Triggers and Conditions. Triggers are the launching point for any event. IF and OR IF are Triggers. One of them must be true before any Event can begin to run. AND IF statements are always Conditions, which are only evaluated if the Trigger is true. Conditions are simply boolean filters for Triggers. That would answer the question "Now why is there different number of choices depending on OR / AND?" you asked in this post. 12:00 PM is a Trigger or Condition, Monday is only a Condition. You cannot use Monday as a Trigger for an event, but you can trigger an Event at 12:00 AM on a Monday (using Monday as a Condition). You can turn a light on when a door opens at 12:00 AM (using the door opening as a trigger and 12:00 AM as a Condition). Understanding the most practical Trigger for an Event is very important to building a successful one. If it is nighttime and I close a door, closing the door is the Trigger and nighttime is the Condition.

      If you look at the statement "Events use simple "IF" "THEN" "ELSE" logic. They may contain multiple conditions in order to trigger the event:" in the HomeSeer help file, it simply isn't true, there is no ELSE. In most programming an ELSE is true when an IF is not. That will not work in HomeSeer's event logic, because any event has a fixed set of actions, regardless of how many (IF, OR IF) Triggers and their associated (AND IF) Conditions. A more accurate description would be: "Events use simple "IF" "AND IF" "THEN" logic".

      Think about "If the time is 9:00 PM". What would be the ELSE? If the ELSE is NOT 9:00 PM, it is true 23h, 59m, 59.999999s out of every day - definitely not useful as a trigger. Triggers in most cases are a "moment in time" and will not be true again until a device changes value or is set, a time of day, recurring trigger, etc.

      After a trigger occurs, HomeSeer does provide for ELSE functions before Actions are performed by nesting events. The logic of this is to have a single triggering event which in turn call other events that perform different actions based upon the conditions set in them. For example:

      Trigger Event
      IF the living room motion detector is set to motion
      AND IF the time is Nighttime
      AND IF the TV is On

      Then If the Event Conditions are True, Run Event Evening Lights
      Then If the Event Conditions are True, Run Event Night Lights

      Evening Lights Event
      IF this event is manually triggered
      AND IF the time is before 11:59PM
      (this is the IF)
      Then set living room lights to 50%


      Night Lights Event
      IF this event is manually triggered
      AND IF the time is after 12:00 AM
      (this is the ELSE)
      Then set living room lights to 25%


      The above series basically says - If I enter the living room while someone is watching TV at night before midnight, set the lights at 1/2 brightness, Else If I enter the the room at night after midnight set the lights to 1/4 brightness. Because there is a small flaw in the standard logic available, there is a one minute gap between 11:59 PM and midnight, so I would probably build this event with a virtual device. Each day starts and ends at midnight, so 12:00 AM is tomorrow. That said, for the purpose of illustration of nested events, this is a reasonable example.

      This is explained in this post.

      In an Event setting, Else just doesn't make sense. In HS2 I don't think there was a true distinction between Triggers and Conditions, because all events were evaluated on a recurring trigger basis.

      Originally posted by sooty View Post
      Think of "OR IF" as a trigger and "AND IF" as a condition.
      Originally posted by larhedse View Post
      Also, I think this is good reference:
      This just reiterates what I stated above. You might want to look at this post which directs you to a number of posts that attempt to explain the logic behind the Event Engine, primarily the usage and difference between Triggers and Conditions. This thread is linked in that table of contents post.
      Randy Prade
      Aurora, CO
      Prades.net

      PHLocation - Pushover - EasyTrigger - UltraECM3 - Ultra1Wire3 - Arduino

      Comment


      • #4
        what's the difference between nested events, eg. with 3 events.

        And two copy pasted events.. but with slightly different condition at the end?

        it seems to give the same result at the end


        Will it take less computer resources with nested event , since the event engine do not have to validate 2x the same sets of conditions each time?

        Comment


        • #5
          Originally posted by Summerguy View Post
          what's the difference between nested events, eg. with 3 events.

          And two copy pasted events.. but with slightly different condition at the end?

          it seems to give the same result at the end


          Will it take less computer resources with nested event , since the event engine do not have to validate 2x the same sets of conditions each time?
          I noticed that if you run another event through an event, it slows down if you add multiple events to run. If it is one event it seems to run quicker.

          Comment


          • #6
            Originally posted by djsaad1 View Post
            I noticed that if you run another event through an event, it slows down if you add multiple events to run. If it is one event it seems to run quicker.
            I don't find that to be the case. Here are log entries from my manually triggering an event that calls 35 other events. All 36 events ran in the same second. The first event is at the bottom. Only three of the called events were true.


            Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Work Programming 9:00 - No Setback
            Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Work Programming 9:00 - Cold - Weekend Setback
            Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Work Programming 9:00 - Cold - No Setback
            Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Work Programming 9:00 - Cold
            Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Work Programming 9:00 - Weekend Setback
            Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Work Programming 9:00
            Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Work Programming 8:30 - Weekend Setback
            Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Work Programming 8:30 - No Setback
            Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Work Programming 8:30 - Cold - Weekend Setback
            Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Work Programming 8:30 - Cold - No Setback
            Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Work Programming 8:30 - Cold
            Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Work Programming 8:30
            Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Work Programming 8:00 - Cold - Weekend Setback
            Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Work Programming 8:00 - Weekend Setback
            Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Work Programming 8:00 - Cold - No Setback
            Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Work Programming 8:00 - Cold
            Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Work Programming 8:00 - No Setback
            Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Work Programming 8:00
            Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Work Programming 7:30 - Cold - Weekend Setback
            Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Work Programming 7:30 - Weekend Setback
            Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Work Programming 7:30 - Cold - No Setback
            Apr-07 5:17:12 PM Event Event Trigger "Thermostat & DHW Programming Work Programming 7:30 - No Setback"
            Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Work Programming 7:30 - Cold
            Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Work Programming 7:30
            Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Work Programming 7:00 - Cold - Weekend Setback
            Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Work Programming 7:00 - Weekend Setback
            Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Work Programming 7:00 - Cold - No Setback
            Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Work Programming 7:00 - Cold
            Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Work Programming 7:00 - No Setback
            Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Work Programming 7:00
            Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Non-Work Programming - Cold - Weekend Setback
            Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Non-Work Programming - Cold
            Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Non-Work Programming - Weekend Setback
            Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Non-Work Programming
            Apr-07 5:17:12 PM Event Event Trigger "Thermostat & DHW Programming Non-vacation Programming - Bathrooms"
            Apr-07 5:17:12 PM Event Event Trigger "Thermostat & DHW Programming 3a)Thermostat Programming Check Home"
            Apr-07 5:17:12 PM Event Event Thermostat & DHW Programming 3a)Thermostat Programming Check Home triggered by the event page 'Run' button.
            Randy Prade
            Aurora, CO
            Prades.net

            PHLocation - Pushover - EasyTrigger - UltraECM3 - Ultra1Wire3 - Arduino

            Comment


            • #7
              Originally posted by rprade View Post
              I don't find that to be the case. Here are log entries from my manually triggering an event that calls 35 other events. All 36 events ran in the same second. The first event is at the bottom. Only three of the called events were true.


              Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Work Programming 9:00 - No Setback
              Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Work Programming 9:00 - Cold - Weekend Setback
              Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Work Programming 9:00 - Cold - No Setback
              Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Work Programming 9:00 - Cold
              Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Work Programming 9:00 - Weekend Setback
              Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Work Programming 9:00
              Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Work Programming 8:30 - Weekend Setback
              Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Work Programming 8:30 - No Setback
              Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Work Programming 8:30 - Cold - Weekend Setback
              Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Work Programming 8:30 - Cold - No Setback
              Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Work Programming 8:30 - Cold
              Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Work Programming 8:30
              Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Work Programming 8:00 - Cold - Weekend Setback
              Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Work Programming 8:00 - Weekend Setback
              Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Work Programming 8:00 - Cold - No Setback
              Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Work Programming 8:00 - Cold
              Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Work Programming 8:00 - No Setback
              Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Work Programming 8:00
              Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Work Programming 7:30 - Cold - Weekend Setback
              Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Work Programming 7:30 - Weekend Setback
              Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Work Programming 7:30 - Cold - No Setback
              Apr-07 5:17:12 PM Event Event Trigger "Thermostat & DHW Programming Work Programming 7:30 - No Setback"
              Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Work Programming 7:30 - Cold
              Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Work Programming 7:30
              Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Work Programming 7:00 - Cold - Weekend Setback
              Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Work Programming 7:00 - Weekend Setback
              Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Work Programming 7:00 - Cold - No Setback
              Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Work Programming 7:00 - Cold
              Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Work Programming 7:00 - No Setback
              Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Work Programming 7:00
              Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Non-Work Programming - Cold - Weekend Setback
              Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Non-Work Programming - Cold
              Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Non-Work Programming - Weekend Setback
              Apr-07 5:17:12 PM Event 'Run Event' action execution skipped, the conditions applied were not met: Thermostat & DHW Programming Non-Work Programming
              Apr-07 5:17:12 PM Event Event Trigger "Thermostat & DHW Programming Non-vacation Programming - Bathrooms"
              Apr-07 5:17:12 PM Event Event Trigger "Thermostat & DHW Programming 3a)Thermostat Programming Check Home"
              Apr-07 5:17:12 PM Event Event Thermostat & DHW Programming 3a)Thermostat Programming Check Home triggered by the event page 'Run' button.
              I must have had something wrong in one of my events then, I had 8 events turning off about 20 light switches and it was really slow compared to having all the switches in one event.

              Comment


              • #8
                Originally posted by djsaad1 View Post
                I must have had something wrong in one of my events then, I had 8 events turning off about 20 light switches and it was really slow compared to having all the switches in one event.
                What controller are you running. I run under Windows 10 on a Supermicro 1U compact server with a low power Xeon E3. I have read reports that the Pi based Zee does have a little trouble executing events quickly from time to time.
                Randy Prade
                Aurora, CO
                Prades.net

                PHLocation - Pushover - EasyTrigger - UltraECM3 - Ultra1Wire3 - Arduino

                Comment


                • #9
                  Originally posted by rprade View Post
                  What controller are you running. I run under Windows 10 on a Supermicro 1U compact server with a low power Xeon E3. I have read reports that the Pi based Zee does have a little trouble executing events quickly from time to time.
                  I am temporarily on a microsoft surface book i7 with windows 10 and a znet.

                  Comment


                  • #10
                    Originally posted by djsaad1 View Post
                    I am temporarily on a microsoft surface book i7 with windows 10 and a znet.
                    That should be enough hardware. A mobile i7 is only 2 cores with hyper threading, but my very busy system on a Xeon hangs below 10% CPU which would be about 25% of a mobile processor. You can watch the log and see what sequence things are happening in to identify any bottleneck.
                    Randy Prade
                    Aurora, CO
                    Prades.net

                    PHLocation - Pushover - EasyTrigger - UltraECM3 - Ultra1Wire3 - Arduino

                    Comment

                    Working...
                    X