Originally posted by sirmeili
View Post
Announcement
Collapse
No announcement yet.
Else statements?
Collapse
X
-
-
Originally posted by bsobel View PostNothing. 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 bsobelThe 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.....
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.16 Windows 10 pro, Supermicro LP Xeon
Comment
-
Originally posted by rprade View PostI 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.
Comment
-
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.Of course, there are circumstances where an ELSE in an event makes perfect sense.
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.If A changes and becomes OnAND IF B is OnDo XELSEDo WThere are likely many places where that structure would save some key strokes.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.
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.
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
-
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'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
-
Originally posted by jhowe View PostI 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'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 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:
Comment
-
Guest
Originally posted by jhowe View PostI 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'm not complaining about the lack of else, but I also wouldn't complain if there was some way to have an else either. :-)
What will stress the pc ressources less ? A list of events (many) or that type (1) of script ?
Comment
-
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.16 Windows 10 pro, Supermicro LP Xeon
Comment
-
Originally posted by rprade View PostIt 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.
Comment
-
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).HS 4.2.8.0: 2134 Devices 1252 Events
Z-Wave 3.0.10.0: 133 Nodes on one Z-Net
Comment
-
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.
Comment
-
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:
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:
I'd love to see HS4 have a more visual representation like this.
--Barry
- Likes 1
Comment
-
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
-
Originally posted by rprade View PostI 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.
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
Comment