Announcement

Collapse
No announcement yet.

IF-THEN-ELSE Action

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

    IF-THEN-ELSE Action

    The possibility of doing a "IF-THEN-ELSE" in an event is one of the most requested thing for HS3. So I thought about how to implement this as a new EasyTrigger action, I coded a quick proof of concept and so far it seems it could work but would be severely limited.

    Basically the IF-THEN-ELSE action would be limited to conditions and actions from EasyTrigger itself.
    The native HS3 conditions and actions would not be available, I may be able to add specific actions and conditions from my other plugins but I'm not 100% sure this will work, and I can't guarantee that conditions and actions from other plugins will ever work.


    Click image for larger version  Name:	ifthenelse.png Views:	1 Size:	122.8 KB ID:	1278492

    This is just a proof of concept to give you an idea but there is still a lot of work to make this work properly.

    I'm also worried that it will add some more confusion to the event engine which is already confusing enough for new users.
    Given the amount of work it would ask and the limitations it would suffer, I'm not 100% it's worth the shot.

    What do you think?

    #2
    My first home automation system was a Stargate for more than 20 years, which not only did if-then-else programming, but multiple nests of it - excellent at creating elegant and effective events. So my brain is forever wired for if-then-else logic. The fact that HS can't do it has been frustrating for me. So I would probably love the feature.

    As you suggest, I suppose the usefulness depends on the number of EasyTrigger conditions and actions available. So far, EasyTrigger has been very useful, so I would think there are enough to make if-then-else useful. If any more conditions and actions become available (other plugins), then it gets even better - but how feasible is that? Anyway, I'm one guy, and it's your hard work.
    Mark

    Comment


      #3
      I would not worry about 'new user confusion' this is not who that is for anyway.

      ITE could be a very, very loved and highly used feature if there is enough usable conditions/actions. For those of us with complex logic, it could make things FAR less complicated to do and require far fewer Events.

      If you think it is worth the effort, I suspect it will get a lot of use!
      ... especially if we can add multiple IF (using and or) conditions

      Comment


        #4
        Originally posted by Ltek View Post
        I would not worry about 'new user confusion' this is not who that is for anyway.

        ITE could be a very, very loved and highly used feature if there is enough usable conditions/actions. For those of us with complex logic, it could make things FAR less complicated to do and require far fewer Events.

        If you think it is worth the effort, I suspect it will get a lot of use!
        ... especially if we can add multiple IF (using and or) conditions
        I couldn’t say better!

        I would love to see that feature.

        Comment


          #5
          yes I would love to have this feature, This would be my go to method to make simple events and after having an ISY for over 5 years, i think it would help new ISY users like me adapt,

          Comment


            #6
            I have not done heavy plugin work focused on events since HS1, but back then I sucked all the HS event info into a database and then manipulated to serve my objectives. I believe Jon00 has an event for matter that likely does something similar. While it is a duplication of what HS has, it may be possible to cherrypick the 80% and do the event logic using this info and the HSevent callbacks.

            i tend to have distributed logic so my HS events are usually pretty simple and do not need nested or I/T/E capability, but I do recognize it as a natural expectation to describe an event condition. For more complex situations I would typically just use a script rather than some arcane logic using virtual devices that represent partial logic expression results.

            Comment


              #7
              Originally posted by ocyberbum View Post
              yes I would love to have this feature, This would be my go to method to make simple events and after having an ISY for over 5 years, i think it would help new ISY users like me adapt,
              Just curious, will you keep both system. Or are transitioning from isy to hs3?

              If you keep both, would you mind to say me what are the advantage of isy that you do not see on hs3? thanks

              Comment


                #8
                Originally posted by Michael McSharry View Post
                I have not done heavy plugin work focused on events since HS1, but back then I sucked all the HS event info into a database and then manipulated to serve my objectives. I believe Jon00 has an event for matter that likely does something similar. While it is a duplication of what HS has, it may be possible to cherrypick the 80% and do the event logic using this info and the HSevent callbacks.

                i tend to have distributed logic so my HS events are usually pretty simple and do not need nested or I/T/E capability, but I do recognize it as a natural expectation to describe an event condition. For more complex situations I would typically just use a script rather than some arcane logic using virtual devices that represent partial logic expression results.
                I think you are right.

                Take myself as an example (lol) :

                I am able to read a script and know what it does ( most of the time). I also understand the logic of else , if else ,while ,.. etc... So , while I learn how to script better ( if I ever do), that feature will be a really nice add on.

                off topic: Personally i want to learn coding from the basics and not go directly to scripting ( ex: starting learning from a c++ book). So that may be a long term goal on my spare time lol..

                Comment


                  #9
                  Originally posted by spud View Post
                  I may be able to add specific actions and conditions from my other plugins but I'm not 100% sure this will work, and I can't guarantee that conditions and actions from other plugins will ever work.
                  Adding this to you other plugin would be great ( I know you said it would maybe not possible). Easytrigger is a classic if i could say it like that, so if other author want to add if then else logic to their plugin they will have to contact you.


                  NB: If you make this first available to easytriger's trigger, I think you will need to add all the basic trigger from hs3 to easytrigger ?

                  Comment


                    #10
                    Originally posted by MattL0 View Post

                    Just curious, will you keep both system. Or are transitioning from isy to hs3?

                    If you keep both, would you mind to say me what are the advantage of isy that you do not see on hs3? thanks
                    I decided to use HS3 only, figured it would be simpler to have It all in one.. The ISY handles Insteon devices and Polling a lot better, but HS3 has a better interface and HS3 plugins, life360,Harmony,Blueiris etc make it my choice since the ISY lacked development for new Z-Wave devices and integration plugins but I miss my simple If, then, Else interface/Scenes. I liked it showed if an event was active,, I like the flexibility HS3 events give me for complex setups but to create an Event that says IF its nighttime, THEN Turn on Lights, ELSE Turn them Off, requires a on and off event to be created, oddly I found I could create events better if I just set the IF to Manually Triggered and then set OR IF to Nighttime, Then turn off lights and it works, I guess I have a lot to learn!

                    Comment


                      #11
                      I really love this and I think it will be quite attractive to people old and new to HS. "If then else" is a lot more straightforward than the tangle of many virtual devices and "If - Or" statements now available. Not being a programmer, myself, I don't know if a "case" statement would be possible or not. (I may be speculating on the nearly impossible, I just don't know what is involved.) But, a case statement would be great, too...



                      HomeSeer Version: HS4 Pro Edition 4.2.19.0 (Windows - Running as a Service)
                      Home Assistant 2024.3
                      Operating System: Microsoft Windows 11 Pro - Desktop
                      Z-Wave Devices via two Z-Net G3s
                      Zigbee Devices via RaspBee on RPi 3b+
                      WiFi Devices via Internal Router.

                      Enabled Plug-Ins
                      AK GoogleCalendar 4.0.4.16,AK HomeAssistant 4.0.1.23,AK SmartDevice 4.0.5.1,AK Weather 4.0.5.181,AmbientWeather 3.0.1.9,Big6 3.44.0.0,BLBackup 2.0.64.0,BLGData 3.0.55.0,BLLock 3.0.39.0,BLUPS 2.0.26.0,Device History 4.5.1.1,EasyTrigger 3.0.0.76,Harmony Hub 4.0.14.0,HSBuddy 4.51.303.0,JowiHue 4.1.4.0,LG ThinQ 4.0.26.0,ONVIF Events 1.0.0.5,SDJ-Health 3.1.1.9,TPLinkSmartHome4 2022.12.30.0,UltraCID3 3.0.6681.34300,Z-Wave 4.1.3.0

                      Comment


                        #12
                        Originally posted by ocyberbum View Post

                        I decided to use HS3 only, figured it would be simpler to have It all in one.. The ISY handles Insteon devices and Polling a lot better, but HS3 has a better interface and HS3 plugins, life360,Harmony,Blueiris etc make it my choice since the ISY lacked development for new Z-Wave devices and integration plugins but I miss my simple If, then, Else interface/Scenes. I liked it showed if an event was active,, I like the flexibility HS3 events give me for complex setups but to create an Event that says IF its nighttime, THEN Turn on Lights, ELSE Turn them Off, requires a on and off event to be created, oddly I found I could create events better if I just set the IF to Manually Triggered and then set OR IF to Nighttime, Then turn off lights and it works, I guess I have a lot to learn!
                        thank you

                        Comment


                          #13
                          I'd suggest an alternate (or enhanced) implementation which may be more flexible / logical since you would not be limited to Easy Trigger Actions in response to the If / Then.

                          What I would propose is an If ... then ... Else where the Action is a call to another event. I.e., If Condition X then Run Event Y else Run Event Z. Perhaps with a "wait until called event finishes" option. This would give more flexibility in the Actions that can be run and might be less confusing to the user who may not otherwise understand why the Actions are limited. The downside is this approach increases the number of Events, but it does so in a manner that seems to maintain an easy way to trace the flow of what is happening.

                          Alternatively, if you go ahead with the If ... Then ... Else as you've proposed -- i.e., where the Actions are (generally) Easy Trigger actions -- I'd suggest also including the ability to run other Events as another option for the reasons I mention.

                          Thanks.

                          Comment


                            #14
                            I would love this! IF - THEN - ELSE should have been added to HS3 in the first place...but Rich knows best ; )

                            Comment


                              #15
                              Originally posted by MattL0 View Post

                              NB: If you make this first available to easytriger's trigger, I think you will need to add all the basic trigger from hs3 to easytrigger ?
                              I would make this first available to easytrigger's conditions and actions, not triggers. The IF in a IF-THEN-ELSE action would always be a condition not a trigger.
                              But yes I think I would need to add some native basic condition like "A device's value is...", but I don't plan to re-code all of them.

                              Comment

                              Working...
                              X