Announcement

Collapse
No announcement yet.

[Newbie] Two IFs and an AND

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

    [Newbie] Two IFs and an AND

    Hello everyone,
    I'm just starting out with HS3 (coming over from another HA platform). I'm so far very impressed with what I see.
    I've been reading through this sub forum - especially the What do IF/OR-IF/AND-IF threads some more threads from the master list.

    But I am having trouble with what sounds like a simple event... merging two IFs and an AND without redundant programming.

    ( IF (Condition-A) OR IF( Condition-B) ) AND IF (Condition-C) ) then do something.

    The below WORKS, but seems to need a redundant statement.

    Click image for larger version  Name:	1.png Views:	1 Size:	39.0 KB ID:	1277754

    Is this the correct way to do it?
    Is there a better way to do it?

    I ask, because I've developed a habit of creating a "disable" event for lot of my events, to either help debug, or when everything starts falling apart, "hit the switch" to stop automation from running.

    So, a lot of my previous events are of the form

    ( IF (A is true) OR if (B is true) OR if (C is true) OR if (D is true) )
    AND IF ( NOT DISABLE_SCRIPT)
    Then { Do something}

    With the HS3 interface, it looks like i would have to do a lot (what seems to be redundant statements) to get the same effect.

    IF (A is true)
    AND IF ( NOT DISABLE_SCRIPT)

    OR if (B is true)
    AND IF ( NOT DISABLE_SCRIPT)

    OR if (C is true)
    AND IF ( NOT DISABLE_SCRIPT)

    OR if (D is true)
    AND IF ( NOT DISABLE_SCRIPT)


    Then { Do something}

    What am I missing? Any help would be appreciated!
    Thanks!
    Last edited by computernut; January 21, 2019, 01:19 PM. Reason: Adding C,D events

    #2
    The first AND IF applies to the first IF and the second AND IF to the second OR IF. Yes, that's the correct way to do it.
    HS 4.2.8.0: 2134 Devices 1252 Events
    Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

    Comment


      #3
      Thanks sparkman!
      Is there a better optimized (or a HS3 tribal knowledge / best known method) to handle something like what I am trying to do? (multiple IFs that can be grouped for a single AND)

      Comment


        #4
        The only alternative (aside from writing a script) that I can think of would be to have the first event run a second event, with the advanced option that the conditions for the second event are true. So the first event would have triggers like If A is true, etc. The second event (the{Do something} event) would have a manual trigger and your common condition(s).
        Mike____________________________________________________________ __________________
        HS3 Pro Edition 3.0.0.548, NUC i3

        HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF | RFXCOM | Vantage Pro | Green-Eye | Edgeport/8 | Way2Call | Ecobee3 | EtherRain | Ubiquiti

        Comment


          #5
          hmm... that is something I had hoped could be avoided.
          Thank you both for your responses!

          I am liking the rest of the software quite a lot at the moment.

          Comment


            #6
            Originally posted by computernut View Post
            Thanks sparkman!
            Is there a better optimized (or a HS3 tribal knowledge / best known method) to handle something like what I am trying to do? (multiple IFs that can be grouped for a single AND)
            HS decided to make it possible for each Trigger to have different Conditions, yet share common actions. This gives great flexibility at the expense of a few seconds adding Conditions to each Trigger. Not too bad as compared to limiting the flexibility by having all Triggers share common Conditions. The vast majority of Events will have a single trigger. Out of 1450 Events on my system, I would bet that less than 10% have multiple triggers. Of that 10%, more than half will have different conditions applied to each trigger. I use that flexibility frequently. Without it, Events like these would be impossible.

            Click image for larger version

Name:	Capture.PNG
Views:	103
Size:	55.1 KB
ID:	1277896

            Click image for larger version

Name:	Capture1.PNG
Views:	111
Size:	68.9 KB
ID:	1277897
            HS4 Pro, 4.2.19.0 Windows 10 pro, Supermicro LP Xeon

            Comment


              #7
              Originally posted by computernut View Post
              hmm... that is something I had hoped could be avoided.
              While I understand how the constraint can be frustrating, as Randy noted, it does add power and versatility.

              Most of us who have used HS for some time have been able to accommodate its quirks, and for me at least, find that they are not very serious compared to the overall benefits. (Yes, it does take more keystrokes to create some events, but I don't have very many like that, and once the events are done, they continue working for years.) For situations where there is complex logic or many combinations of conditions, I find that a script can be a powerful and easy way to augment the HS event engine.

              Mike____________________________________________________________ __________________
              HS3 Pro Edition 3.0.0.548, NUC i3

              HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF | RFXCOM | Vantage Pro | Green-Eye | Edgeport/8 | Way2Call | Ecobee3 | EtherRain | Ubiquiti

              Comment


                #8
                Oh, don't get me wrong. I'm comfortable writing code. I just don't want to keep jumping in between the GUI and a script.

                I'm a little surprised that this doesn't seem to have come up before. I would have assumed a logic tree of ((A OR B OR C) AND (D)) wasn't that uncommon. But like you said, its a quirk of the system.

                I just have to get used to the quirks, and see if I can come up with a design pattern that allows me to get my existing practice of having a kill-switch along with the HS3 event system.

                Besides, I spend a large portion of $dayjob writing code , so one less place of writing code would be welcome

                Thanks for all the support. The HS3 community has so far been extremely helpful.

                Comment


                  #9
                  One other idea for a "kill" switch you can consider: There are scripting calls - hs.DisableEvent() and hs.EnableEvent() - that would let you disable/enable a group of events.
                  Mike____________________________________________________________ __________________
                  HS3 Pro Edition 3.0.0.548, NUC i3

                  HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF | RFXCOM | Vantage Pro | Green-Eye | Edgeport/8 | Way2Call | Ecobee3 | EtherRain | Ubiquiti

                  Comment


                    #10
                    Originally posted by Uncle Michael View Post
                    One other idea for a "kill" switch you can consider: There are scripting calls - hs.DisableEvent() and hs.EnableEvent() - that would let you disable/enable a group of events.
                    This

                    or the same feature with spud easytriger plugin

                    Comment


                      #11
                      Originally posted by Uncle Michael View Post
                      One other idea for a "kill" switch you can consider: There are scripting calls - hs.DisableEvent() and hs.EnableEvent() - that would let you disable/enable a group of events.

                      can those be set by id , instead of event name?

                      EDIT ::


                      ok was able to get it with &hs.DisableEventByRef ("EVEN_ID")

                      Comment

                      Working...
                      X