Announcement

Collapse
No announcement yet.

Else statements?

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

    #16
    Originally posted by sirmeili View Post

    How do you handle multiple triggers? (OR IFs). Do you say if any of them are triggered but their conditions not met then run the Else?

    I think it adds a level of complexity to the event system that would confuse new users, especially if they don't have a programming background.
    I would have a global else block that could if populated always run and a per trigger else block (eg 2 triggers 2 else blocks plus the global). Hide the enabling in the advanced field to handle new users. Each block has conditions just like the trigger block. Conditions have to be true for the actions to run. It’s actually a very simple extension to what’s there.

    Comment


      #17
      Originally posted by bsobel View Post
      Nothing. Else as I described is actually easy to add. None of your events would have else clauses unless you added them. Perfectly compatible.
      Originally posted by bsobel
      The general approach to an else is if the trigger fires but the conditions don't match, run the else (which ideally could have its own conditions). This way the invocation is known and doesn't break the world with infinite loops, etc.....
      I understand what you are saying as it would relate to a single Condition, but many if not the vast majority of my Events are dependent on multiple Conditions and quite a few are based upon non binary virtual devices. Would the Else be based on all or any Conditions being False?. What if one of the Conditions is based upon a multiple choice Virtual Device like Summer, Fall, Winter, Spring - there likely would be no Else. I can only think of a handful of events that would work with an Else based upon all Conditions being False and only a few more based upon one Condition being false and that would have to be on a specific Condition.

      While in a very narrow set of circumstances your proposal might save a step, for the vast majority it wouldn't work.
      HS4 Pro, 4.2.19.0 Windows 10 pro, Supermicro LP Xeon

      Comment


        #18
        Originally posted by rprade View Post
        I understand what you are saying as it would relate to a single Condition, but many if not the vast majority of my Events are dependent on multiple Conditions and quite a few are based upon non binary virtual devices. Would the Else be based on all or any Conditions being False?. What if one of the Conditions is based upon a multiple choice Virtual Device like Summer, Fall, Winter, Spring - there likely would be no Else. I can only think of a handful of events that would work with an Else based upon all Conditions being False and only a few more based upon one Condition being false and that would have to be on a specific Condition.

        While in a very narrow set of circumstances your proposal might save a step, for the vast majority it wouldn't work.
        I expanded a bit in the previous comment about global else block and per trigger. For either the trigger firing but any of the conditions not would run the else block. I’m not suggesting it would work for every case you can come up with, but coming from the ISY I know there are plenty of cases where it would. You could of course due this with additional events, it’s more for organization. That and the event editor is the slowest thing in the world once you have a few thousand devices. But that’s a different issue.

        Comment


          #19
          This is a common request from new users. It appears to arise partly from an unfamiliarity with how HS is structured and partly because the lack of an ELSE option in an event seems like an annoying oversight.
          First, the HS structure part:
          An HS event requires a TRIGGER, something that defines a point in time.
          "IF A is On, AND IF B is On" does not satisfy that criterion, and so it is not possible to construct an HS event beginning with that statement.
          It could be changed, to
          "IF A Changes and becomes On
          AND IF B is On
          OR IF B Changes and becomes On
          AND IF A is On"
          assuming that is what is required.
          On the other hand, you may actually have something else in mind. That is, something else entirely is the trigger and you want one thing to happen if both A and B are on and another thing to happen if only one or neither of them is on.
          HS forces you to be crystal clear about what it is you want to happen, and in the process, forces you to break up your logic into discrete Events.
          Of course, there are circumstances where an ELSE in an event makes perfect sense.
          If A changes and becomes On
          AND IF B is On
          Do X
          ELSE
          Do W
          There are likely many places where that structure would save some key strokes.
          Once you become familiar with how the HS event engine is structured and become conversant with building events, you will probably find, as most of us have, that the missing ELSE isn't really that annoying after all, and is actually pretty well handled in most cases without being an explicit option.
          In those cases were complex logic is genuinely necessary, HS provides the option to write a script, which can handle virtually any logic sequence you require.

          I'd recommend that you work with HS for a while. It has a steep learning curve, and it will seem rather foreign coming from another platform, but it has a way of growing on people. I have not found any situation that it cannot handle, and I suspect that the discipline in logic that the event structure forces on us is one of the reasons that it works as well as it does.
          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


            #20
            I agree that the way events work it would not really be feasible to have an Else statement related to an If statement if the 'if' statement is also the trigger for the event. I think the only way it could work is if there was a way to specify a triggering condition (or multiple triggering conditions using 'or') and allow an if/else mechanism inside of the event logic as shown above.

            I know that with scripts you can do a great many things, but sometimes it would be nice to just create an event that does one of two things depending on some condition. For example, I recently wanted to create an event which would either turn a device off, or just dim it, based on the value of a virtual device. The actual trigger of the event was just turning off one of my z-wave switches. Instead of doing something like this:

            Code:
            when switch changes and becomes off
                if virtual-device has a value of 'daylight'
                   turn off light
               else
                   dim light
            I had to create two events, one for the 'daylight' condition, and one for 'not daylight'. It wasn't a big deal, but it creates more events than I would like. I need to spend more time learning the scripting options. I've never been a big fan of Visual Basic so I've resisted doing anything major with scripts.

            I'm not complaining about the lack of else, but I also wouldn't complain if there was some way to have an else either. :-)

            Comment


              #21
              Originally posted by jhowe View Post
              I agree that the way events work it would not really be feasible to have an Else statement related to an If statement if the 'if' statement is also the trigger for the event. I think the only way it could work is if there was a way to specify a triggering condition (or multiple triggering conditions using 'or') and allow an if/else mechanism inside of the event logic as shown above.

              I know that with scripts you can do a great many things, but sometimes it would be nice to just create an event that does one of two things depending on some condition. For example, I recently wanted to create an event which would either turn a device off, or just dim it, based on the value of a virtual device. The actual trigger of the event was just turning off one of my z-wave switches. Instead of doing something like this:

              Code:
              when switch changes and becomes off
              if virtual-device has a value of 'daylight'
              turn off light
              else
              dim light
              I had to create two events, one for the 'daylight' condition, and one for 'not daylight'. It wasn't a big deal, but it creates more events than I would like. I need to spend more time learning the scripting options. I've never been a big fan of Visual Basic so I've resisted doing anything major with scripts.

              I'm not complaining about the lack of else, but I also wouldn't complain if there was some way to have an else either. :-)
              For your specific example, I actually use virtual devices (VD).... for instance my kitchen lights have a VD called "Kitchen automatic lights - ON" and I set the value there. Then in my event I just set the kitchen lights to the value of the VD (I use the plugin EasyTrigger for this).

              I do have to have additional events to change the VD to specific values, but I just have one event that modifies a lot of these types of devices based on another VD for day state (Morning, Day, Evening, Night) an other triggers/conditions.

              Edit: adding an image for clarification:
              Click image for larger version

Name:	2019-01-03_16-47-43.png
Views:	233
Size:	42.9 KB
ID:	1272069

              Comment


                #22
                Originally posted by jhowe View Post
                I agree that the way events work it would not really be feasible to have an Else statement related to an If statement if the 'if' statement is also the trigger for the event. I think the only way it could work is if there was a way to specify a triggering condition (or multiple triggering conditions using 'or') and allow an if/else mechanism inside of the event logic as shown above.

                I know that with scripts you can do a great many things, but sometimes it would be nice to just create an event that does one of two things depending on some condition. For example, I recently wanted to create an event which would either turn a device off, or just dim it, based on the value of a virtual device. The actual trigger of the event was just turning off one of my z-wave switches. Instead of doing something like this:

                Code:
                when switch changes and becomes off
                if virtual-device has a value of 'daylight'
                turn off light
                else
                dim light
                I had to create two events, one for the 'daylight' condition, and one for 'not daylight'. It wasn't a big deal, but it creates more events than I would like. I need to spend more time learning the scripting options. I've never been a big fan of Visual Basic so I've resisted doing anything major with scripts.

                I'm not complaining about the lack of else, but I also wouldn't complain if there was some way to have an else either. :-)
                I just learned not so long ago that creating that type of script is not that hard .. So what i wonder now... :

                What will stress the pc ressources less ? A list of events (many) or that type (1) of script ?

                Comment


                  #23
                  It is my opinion that Events only cause excessive stress when editing or adding them and this is only due to the method HS used for storing then and the way the Event Management page updates are handled. Once an Event is in the database and the queues it only uses resources when it runs, if the Event is Triggered, but Conditions prevent it from running there is negligible, if any, impact on resources. As far as an event running or a script running, in most cases it is likely you would still need an Event to launch the script.
                  HS4 Pro, 4.2.19.0 Windows 10 pro, Supermicro LP Xeon

                  Comment


                    #24
                    Originally posted by rprade View Post
                    It is my opinion that Events only cause excessive stress when editing or adding them and this is only due to the method HS used for storing then and the way the Event Management page updates are handled. Once an Event is in the database and the queues it only uses resources when it runs, if the Event is Triggered, but Conditions prevent it from running there is negligible, if any, impact on resources. As far as an event running or a script running, in most cases it is likely you would still need an Event to launch the script.
                    Agreed, best I can tell scripts are recompiled every time (which is incredibly silly), so you always have more overhead with a script (but much more decision/flow control).

                    Comment


                      #25
                      Originally posted by bsobel View Post

                      Agreed, best I can tell scripts are recompiled every time (which is incredibly silly), so you always have more overhead with a script (but much more decision/flow control).
                      From what I understood is that they were compiled the first time they run and not recompiled until the script was changed, or HS restarted. Supposedly the same for asp/aspx pages which is why they load slow the first time you open them, but are then much faster to reload if you open them again.
                      HS 4.2.8.0: 2134 Devices 1252 Events
                      Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

                      Comment


                        #26
                        Originally posted by sparkman View Post

                        From what I understood is that they were compiled the first time they run and not recompiled until the script was changed, or HS restarted. Supposedly the same for asp/aspx pages which is why they load slow the first time you open them, but are then much faster to reload if you open them again.
                        I will have to go double check, when working on the VBNC problem I certainly saw it was launched each time to compile. It might have a cache it uses internally...

                        Comment


                          #27
                          I'm always satisfied with the HS3 events procedures until I get to working with webCORE, and then I remember how antiquated the HS3 system is. Here is a simple example of sending status of a Zigbee water leak sensor to a HS3 virtual device that represents the sensor:

                          Click image for larger version

Name:	example1.png
Views:	229
Size:	303.2 KB
ID:	1272116

                          Notice I'm sending changed status (trigger) of the sensor IF changes to wet, or ELSE IF it changes to dry. Using the SAME event I'm also sending changes (additional trigger) for battery changes and temperature changes which are defined as dynamic variables. Takes maybe 2 minutes to set this event up. These were all selected from drop-down llsts and then webCORE builds the visual representation.

                          Here is one for a Zigbee multi-purpose sensor that is a bit more complicated but still very easy and quick to do:

                          Click image for larger version

Name:	example2.png
Views:	214
Size:	791.6 KB
ID:	1272117

                          I'd love to see HS4 have a more visual representation like this.

                          --Barry

                          Comment


                            #28
                            Here is a simple one for a presence sensor of my Android... Note all the different conditions and triggers available...

                            Click image for larger version

Name:	example3.png
Views:	220
Size:	366.9 KB
ID:	1272122

                            --Barry

                            Comment


                              #29
                              I think I have read most posts on the if then else debate. At a programmer. the If then else if really pretty simple. If "some statement that evaluates to true/false then "do this" else "
                              if is false for do this". Now you can normally nest if then else if then else statements so you can check another "value". The "Trigger" always be the first if then else. It works that way is all of the programming languages that I know of. So there is no possibility of looping as some have worried about as only the 1st if has a trigger.

                              Comment


                                #30
                                Originally posted by rprade View Post
                                I would also want to hear what happens to my 1400+ perfectly functioning Events if HomeSeer was to completely restructure Events to accommodate branching (after the initial Trigger) within the Event.
                                Let's say HomeSeer only has "AND" in the drop-down for conditions - adding an "OR" option has zero impact to you, it's just another option you COULD chose to select. Your existing events don't have an addition condition or, if they do, they obviously have the AND option which always existed. The addition of an OR option has zero impact on you other than if you chose to go edit any and add another condition and chose that options.

                                Likewise if the action drop-down had an "ELSE" in addition to "THEN" this still has no impact on you - your 1400 events are all configured with only a "THEN", there is no reason for them to suddenly have a panic attack.

                                In regards to the actual trigger point, the actual IF condition achieves that... if a device changes and becomes "xxx" THEN.... clicking + and adding an ELSE action would in my mind mean if device changes and becomes something OTHER than "xxx". To make this easier to understand for non-programmers adding an "ELSE" action could in brackets append a description such as "ELSE (if device changes and does NOT become "xxx" then)". This would then be self-documenting. If HomeSeer's back-end programming is extremely inflexible and would require a complete re-write, then that's how it could fake it... an ELSE would actually create a hidden behind-the-scenes IF that does the opposite logic, but in the GUI shows them grouped together and instead of showing the second IF it shows it as ELSE. Just the programmer in me speaking out loud

                                Comment

                                Working...
                                X