Jump to content

I need some guidance understanding ISY programming logic ...


Broyd

Recommended Posts

Posted

UI and firmware both at 5.3.0.

The program: I am having trouble figuring out the ISY logic interpretation in this program.

 

 

Sunrise - [ID 0024][Parent 003D]

If
        'South - MS - Dawn Dusk' is switched Off
    And From     6:00:00AM
        To       9:30:00AM (same day)
 
Then
        $Sunset.Flag  = 0
        Send Notification to 'Broyd' content 'Sunrise Now'
        Wait  1 minute
        Send Notification to 'Broyd' content 'Sunrise Now'
 
Else
        $Sunset.Flag  = 0
        Send Notification to 'Broyd.Email' content 'Sunrise Now'
        Wait  1 minute
        Send Notification to 'Broyd.Email' content 'Sunrise Now'
 
Motion Sensor dawn/dusk detector is switched OFF at Sunrise

============

My question: I am having trouble figuring out the ISY logic interpretation in this program.


First: (Just in case you were wondering) The justification for this program is to verify the functioning
of both TEXT messages (Broyd) and email messages (Broyd.Email) for important notifications
such as leak detection. I have had trouble in the past with notifications and this program
lets me weed out problems before I need to receive a more serious notification.
And I don't want to be awakened by a TEXT message that is accompanied by a loud tune
so I switch between a text and an email ...

 

My UNDERSTANDING: of ISY logic ... hmmm ...

The IF statement contains TWO conditions coupled with AND ...

- as an independent condition, the first condition is a CONTROL statement
  that is triggered ONLY ONCE when the dawn/dusk sensor is switched OFF
  (this happens in the morning)
 
- as an independent condition, the second condition is triggered TWICE,
  once at 6AM and again at 9:30AM

- BUT the AND operator couples these two conditions such that if the dawn/dusk sensor is
  switched OFF AND the time is within the time between 6AM and 9:30AM then the program
  runs the THEN clause. But if the dawn/dusk sensor is switched off AND the time
  is outside the time window, then the program runs the ELSE clause.
 
What happens:

- My dawn/dusk sensor switched OFF this morning at 5:21AM and I received two emails,
  that is, the ELSE clause was run once at 5:20:47AM and another at 5:21:47AM.
  This is exactly what I expected to happen.
 
BUT ... and now we get to the bit that is confusing me ...

- I get 4 more Emails (the ELSE clause is run 4 more times), at 6:00AM, 6:01AM.
  9:30AM and 9:31AM

It seems to me that my two IF conditions are actually being coupled with an OR operator.

What I need to understand:

So why does this program even run at 6AM and 9:30AM? Why does the IF statement
not take into account that the dark/dusk sensor was only switched off at 5:20AM,
not at 6 or 9:30AM, namely the first condition in the IF statement?

 

Thanks for your insights ...

(BTW: I can fix the program easily enough to run the way I want, but what I want to

do is understand the why.)

Posted

The program is evaluated (run) when something in the 'if' part is triggered.

at 5:21ish, the dusk/dawn sensor is triggered, the program is run and the if statement evaluates to FALSE (sensor switched off is TRUE but time range is FALSE) so the ELSE clause is executed.

at 6:00am the program is run again and the if statement evaluates to FALSE (sensor switched off is FALSE but time range is TRUE) so, again, the ELSE clause is executed.

at 9:30am the program is run again and the if statement evaluates to FALSE (sensor switched off is FALSE but time range is TRUE (maybe) so, again, the ELSE clause is executed.

The confusion is that the condition is re-evaluated when any of the conditions change, not when all the conditions are TRUE.  The conditions control which part of the program is executed (THEN or ELSE), not if the program is run.

It sounds like what you might need two programs to accomplish this because you're trying to do a nested condition, but the ISY can't do that. You want:

if sensor switch off then
	if time in range
		send text
	else
		send email

On the ISY you can simulate that with:

if sensor switched off and time in range then
	send text

if sensor switched off and time outside range then
	send email

 

  • Like 2
Posted (edited)

As discussed many (many, many, many...) times before the Else clause is not that useful in ISY programs because of the fact that the trigger conditions for the program and the boolean logic in the if are all wrapped together and can't be separated. This has caused much confusion over the 12 or so years I have been on these forums. This is a classic example where you need two programs to get the "expected" or "desired" behavior (I understand this is just a test program). First program is enabled, and contains the "trigger" condition:

If
        'South - MS - Dawn Dusk' is switched Off
Then
        Run Program SunRiseNotifications (If)
Else
    <--- No Action ---> 

The second program, SunRiseNotifications, is disabled and contains the conditions you want to test in the if, but not necessarily trigger the program(s):

If
        From     6:00:00AM
        To       9:30:00AM (same day)
Then
        $Sunset.Flag  = 0
        Send Notification to 'Broyd' content 'Sunrise Now'
        Wait  1 minute
        Send Notification to 'Broyd' content 'Sunrise Now'
 
Else
        $Sunset.Flag  = 0
        Send Notification to 'Broyd.Email' content 'Sunrise Now'
        Wait  1 minute
        Send Notification to 'Broyd.Email' content 'Sunrise Now'

Edited by Goose66
  • Like 3
Posted

I think bpwwer provided a robust response.


I disagree thate ELSE clauses are universally not useful.

the reason you get so may emails is, besides the fact that your program is triggered three times ( 5:21, 6:00, 9:30, all false) is that you also have one-minute waits, followed by a second email.  From your program, I expect an email at dusk, dusk + one minute, 6:00, 6:01, 9:30, and 9:31.

 

Posted

Thank all 3 of you very much for taking the time to provide me with such detailed responses. Much appreciated. I asked for an understanding of ISY programming logic and you provided excellent and complete detailed descriptions of what is happening; more than sufficient to understand things, especially the 'time within' logic. I couldn't have gotten better advice! And thanks Goose66 for your programming example; I will use it to alter my programming setup.

I am bothered a little bit though; it kinda 'sticks in my craw' ... that there seems to be no difference to the way the IF statement works whether the operand I used, 'And' is changed to 'Or'. I'll switch it today and see what results I get tomorrow morning :). I expect that the ISY response will be the same. But that would be ok, it would be the way it is.

I realize the number of text and/or emails I get is because of the double notifies ... I did this because occasionally I do not get every notify and this logic is an attempt to get at least one. This has worked for me on a number of occasions.

Posted
2 hours ago, Broyd said:

 

I am bothered a little bit though; it kinda 'sticks in my craw' ... that there seems to be no difference to the way the IF statement works whether the operand I used, 'And' is changed to 'Or'. I'll switch it today and see what results I get tomorrow morning :). I expect that the ISY response will be the same. But that would be ok, it would be the way it is.

 

And & Or does work differently depending on what you are trying to accomplish. 

For example, If you wanted to turn on a kpl button whenever a light in your kitchen is on (let's say you have 3 sets of lights), you would use "Or" for your program.

Ie: if light 1, or light 2, or light 3 is turned on THEN do whatever 

If you wanted that kpl light to turn off when all lights in the kitchen are off then you would use "And"

Ie: if light 1, and light 2, and light 3 are off THEN do whatever.

Just remember when it comes to Or Else statements, it works great for basic stuff such as simple on/off timers (turn your outside lights on at sunset off at sunrise).

Anything beyond that, you're better off splitting your programs....especially if you'll have multiple programs controlling the same devices. 

 

 

Posted
3 hours ago, Broyd said:

I am bothered a little bit though; it kinda 'sticks in my craw' ... that there seems to be no difference to the way the IF statement works whether the operand I used, 'And' is changed to 'Or'. I'll switch it today and see what results I get tomorrow morning :). I expect that the ISY response will be the same. But that would be ok, it would be the way it is.

in your example above the specific difference is:

If
        'South - MS - Dawn Dusk' is switched Off
    And From     6:00:00AM
        To       9:30:00AM (same day)

If Sunrise is at 5:21 this will run and evaluate to false because it's not in the time window, it's also false at 6:00am and 9:30 because "AND South - MS - Dawn Dusk is already off"

For this to evaluate TRUE South - MS - Dawn Dusk must switch off between 6 and 9:30 AM, but it still runs false at 6 and 9:30

 

If
        'South - MS - Dawn Dusk' is switched Off
    OR From     6:00:00AM
        To       9:30:00AM (same day)

 

At 5:21 AM this will be true, it will also be true at 6AM and false at 9:30

this will also be true if sunrise is between 6am and 9:30am

 

  • Like 1
Posted
3 hours ago, lilyoyo1 said:

And & Or does work differently depending on what you are trying to accomplish. 

For example, If you wanted to turn on a kpl button whenever a light in your kitchen is on (let's say you have 3 sets of lights), you would use "Or" for your program.

Ie: if light 1, or light 2, or light 3 is turned on THEN do whatever 

If you wanted that kpl light to turn off when all lights in the kitchen are off then you would use "And"

Ie: if light 1, and light 2, and light 3 are off THEN do whatever.

Just remember when it comes to Or Else statements, it works great for basic stuff such as simple on/off timers (turn your outside lights on at sunset off at sunrise).

Anything beyond that, you're better off splitting your programs....especially if you'll have multiple programs controlling the same devices. 

 

 

...and one cannot use AND between three control/switched conditions. Only one control/switched condition line can ever be true at one time, and the combined result will always be False. To use AND (in this instance) one must use status conditions.

Posted (edited)
15 minutes ago, larryllix said:

...and one cannot use AND between three control/switched conditions. Only one control/switched condition line can ever be true at one time, and the combined result will always be False. To use AND (in this instance) one must use status conditions.

I wasnt trying to be specific in writing a program which is why i wrote it that way (doesnt even have anything to do with what op wanted). I was simply showing how AND & OR functioned. However you are correct. If this were a proper example, one would need to use status

Edited by lilyoyo1
Posted
2 minutes ago, Broyd said:

Is the from - to time construct a control or status condition? Thanks :)

Its neither but if you wanted to be technical about it, then it would be a status condition. Status about the state of the device. This can be changed via multiple avenues such as voice, app, another device.

Control is the physical control of a device. ie: you manually press the button on a switch.

Zwave does add a wrinkle to this because...its zwave. Who knows why zwave does the way zwave does. Some devices will use status even though you are manually controlling the device.

IF time is from sunset to sunrise

THEN

Set Light on

OR ELSE

Set Light off

Posted
9 hours ago, Broyd said:

I am bothered a little bit though; it kinda 'sticks in my craw' ... that there seems to be no difference to the way the IF statement works whether the operand I used, 'And' is changed to 'Or'. I'll switch it today and see what results I get tomorrow morning :). I expect that the ISY response will be the same. But that would be ok, it would be the way it is.

Confirming MrBill...Changing the "and" to "or", all other statements being unchanged, will result in a different result.  At 6am, it will trigger and now run TRUE (ran false before.). At sunrise, it will also now run true (ran false before.)

In case it was not mentioned before, control conditions are true ONLY at the moment the device (light sensor, in this case) sends the expected command.  At all other times, control conditions are false.  Compare that to "status" conditions.  Status conditions trigger programs whenever a device changes state (for any reason) and will remain true for as long as that device remains in the stated state (off, in this case).  

 

  • Like 1
Posted
5 hours ago, Broyd said:

Is the from - to time construct a control or status condition?

It acts exactly like a status condition.  When it changes from FALSE (time not between) to TRUE (time between) it triggers the IF to be evaluated.  Likewise when it changes from TRUE (time between) to FALSE (time not between) it triggers the IF to be evaluated.  And at all times it will either be TRUE or FALSE depending on the time.

Posted (edited)
12 hours ago, Broyd said:

Is the from - to time construct a control or status condition? Thanks :)

It is both.

It will trigger program evaluation at both of it's node times, evaluating  as True to run Then,  and as False to run Else.
It is also a status that is True between the times, and False outside the time framing.

When used in a program that is disabled it becomes only a status condition.

ISY will only make available whichever construct each conditional offers.

Edited by larryllix
  • Like 1
Posted

Once again, thanks to all of you. I am sure now of how And - Or work. And based on all of your replies, I have done my own testing; nothing works better than seeing the results for yourself. And I know what to expect from the time within construct now. Appreciated :)

  • Like 2
Guest
This topic is now closed to further replies.

×
×
  • Create New...