Jump to content

why doesn't this program work properly?


someguy

Recommended Posts

Posted

why would this program make my lights continue to flash on and off? I was intending to have them flash once to tell me that it is 10:00pm.

If
       Time is 10:00:00PM
   And Status  'Hearth-5-Lamplinc' < 20%

Then
       Set 'Hearth-5-Lamplinc' Fast On
       Set 'Hearth-3-West Light, by TV' Fast On
       Wait  1 second
       Set 'Hearth-5-Lamplinc' Fast Off
       Set 'Hearth-3-West Light, by TV' Fast Off

Else
       Set 'Hearth-5-Lamplinc' Fast Off
       Set 'Hearth-3-West Light, by TV' Fast Off
       Wait  1 second
       Set 'Hearth-5-Lamplinc' Fast On
       Set 'Hearth-3-West Light, by TV' Fast On

Posted

Because you are checking the status of the 'Hearth-5-Lamplinc' in the condition and then setting that same light on in the Then section...which makes the condition change and become false, which immediately runs the Else section...which changes that light again and the status changes and it becomes True...so it immediately runs the Then section...which sets the light again...etc. etc. etc.

 

 

why would this program make my lights continue to flash on and off? I was intending to have them flash once to tell me that it is 10:00pm.

If
       Time is 10:00:00PM
   And Status  'Hearth-5-Lamplinc' < 20%

Then
       Set 'Hearth-5-Lamplinc' Fast On
       Set 'Hearth-3-West Light, by TV' Fast On
       Wait  1 second
       Set 'Hearth-5-Lamplinc' Fast Off
       Set 'Hearth-3-West Light, by TV' Fast Off

Else
       Set 'Hearth-5-Lamplinc' Fast Off
       Set 'Hearth-3-West Light, by TV' Fast Off
       Wait  1 second
       Set 'Hearth-5-Lamplinc' Fast On
       Set 'Hearth-3-West Light, by TV' Fast On

Posted

Your answer makes sense to me, but here is where I don't get it.

The IF part says "time is 10:00:00". It is only that time for one second, so why does it keep flashing even after it is 10:00:05, and at 10:00:30, etc.?

Posted
Your answer makes sense to me, but here is where I don't get it.

The IF part says "time is 10:00:00". It is only that time for one second, so why does it keep flashing even after it is 10:00:05, and at 10:00:30, etc.?

 

Because after the first go around, it executes the ELSE portion each time...because you turn the light on and off, which is one of the conditions so it evaluates the If...since it is NOT 10:00:00, it runs the ELSE again...and so on.

Posted

Okay, now I think I understand. so, why didn't it run the "else" part of the program right when I created the program at around 8pm last night?

Posted
Okay, now I think I understand. so, why didn't it run the "else" part of the program right when I created the program at around 8pm last night?

 

Likely because the light that you have in the conditions did not change state. ISY only evaluates the condition when one of the conditions change state. I am betting that it you turned that light brighter then 20% then less than 20% it would have.

 

Which reminds me...using status < 20% will not recognize when the light is OFF. OFF is not < 20% as far as ISY is concerned. If you want to trigger when the light is less than 20% OR Off...you need to specify that. Just thought I would mention it in case you were not aware of this little quirk...

Posted

just in case it isn't clear, I am wanting the lights to flash at 10pm:

off then on if they are on OR

on then off if they are off.

 

tell me where these go wrong:

 

program 1, enabled:

If
       Time is 10:00:00PM

Then
       Run Program 'Hearth Flash 10pm b' (If)

Else
  - No Actions - (To add one, press 'Action')

 

program 2, not enabled:

If
       Status  'Hearth-5-Lamplinc' < 20%
    Or Status  'Hearth-5-Lamplinc' is Off

Then
       Set 'Hearth-5-Lamplinc' Fast On
       Set 'Hearth-3-West Light, by TV' Fast On
       Wait  1 second
       Set 'Hearth-5-Lamplinc' Fast Off
       Set 'Hearth-3-West Light, by TV' Fast Off

Else
       Set 'Hearth-5-Lamplinc' Fast Off
       Set 'Hearth-3-West Light, by TV' Fast Off
       Wait  1 second
       Set 'Hearth-5-Lamplinc' Fast On
       Set 'Hearth-3-West Light, by TV' Fast On

Posted

I find it difficult to program in too and when I get something working it doesn't look very pretty.

 

Here are 4 programs that go close to achieving what you want. There is a gap of 2 seconds between the main two depending whether your light is on or off when the programs run. You just need to add the additional code for dimmed lighting.

Uncheck the 'Enabled' property of the last two when you create them.

 

Wayne

 

[Flash 1]

If
       Time is 10:00:00PM
   And Status  'Hearth-5-Lamplinc' is On

Then
       Run Program 'Run if on' (Then Path)

Else
  - No Actions - (To add one, press 'Action')

 

[Flash 2]

If
       Time is 10:00:02PM
   And Status  'Hearth-5-Lamplinc' is Off

Then
       Run Program 'Run if off' (Then Path)

Else
  - No Actions - (To add one, press 'Action')

 

[Run if off]

If
  - No Conditions - (To add one, press 'Schedule' or 'Condition')

Then
       Set 'Hearth-5-Lamplinc' On
       Wait  1 second
       Set 'Hearth-5-Lamplinc' Off

Else
  - No Actions - (To add one, press 'Action')

 

[Run if on]

If
  - No Conditions - (To add one, press 'Schedule' or 'Condition')

Then
       Set 'Hearth-5-Lamplinc' Off
       Wait  1 second
       Set 'Hearth-5-Lamplinc' On

Else
  - No Actions - (To add one, press 'Action')

Posted

wwat:

 

I suppose I could wait a couple of hours and find out, but what is wrong with my program. Why won't it work. I'm referring to the one that has two programs that you replied to with four programs. I'd just like to learn where I went wrong.

 

edit:

 

also: why did you use "then (path)" instead of "then (if)"? I have a hard time understanding the difference between these two. To me, if...then is if...then.

 

also: why was it necessary to make the two programs run two seconds apart?

Posted

You are basically doing the same thing with these programs as the first one program did. When it is 10:00:00 you run the IF section of your other program....which evaluates the state, if the light is off (or <20%) is runs Then and turns it on, which immediately re-evaluates and runs the Else, which turns it off, etc. etc.

 

I know it is confusing...lord knows I struggled with it at first (and still do). It gets tricky when you use Schedules and the Then and the Else.

 

I don't have time right now to write up a proggie for you, family is waiting to finish a movie before midnight...but I will try and jump on later and post.

 

 

 

wwat:

 

I suppose I could wait a couple of hours and find out, but what is wrong with my program. Why won't it work. I'm referring to the one that has two programs that you replied to with four programs. I'd just like to learn where I went wrong.

 

edit:

 

also: why did you use "then (path)" instead of "then (if)"? I have a hard time understanding the difference between these two. To me, if...then is if...then.

 

also: why was it necessary to make the two programs run two seconds apart?

Posted
wwat:

Why won't it work. I'm referring to the one that has two programs that you replied to with four programs. I'd just like to learn where I went wrong.

 

Initially I was also completely flumexed about how the program execution worked in ISY. Once I grasped the point that ISY is *continually* evaluating the 'If' part of the code, even during execution of the 'then' and 'else' parts, it came together for me.

 

If we take the following program as an example.

At some point in time the 'IF' statement might evaluate to true so then ISY starts executing the 'Then' part of the program. Even during execution of the 'Then' part it is still evaluating the 'If' part, so when the light is turned ON with the following statement; 'Set 'Hearth-5-Lamplinc' Fast On"

suddenly the 'IF' part evaluates to False even before it has time to complete the 'Then' section of the code. By placing the entire 'Then' part in a seperate program you take execution to that other program, ISY is no longer evaluating the 'IF' part so it then executes in full.

 

LOL, I hope I didn't make it worse for you, and by all mean if any guru's on this forum can help by showing us a better way to write this type of program flow please butt in and do so.

 

If 
       Status  'Hearth-5-Lamplinc' < 20% 
    Or Status  'Hearth-5-Lamplinc' is Off 

Then 
       Set 'Hearth-5-Lamplinc' Fast On 
       Set 'Hearth-3-West Light, by TV' Fast On 
       Wait  1 second 
       Set 'Hearth-5-Lamplinc' Fast Off 
       Set 'Hearth-3-West Light, by TV' Fast Off 

Else 
       Set 'Hearth-5-Lamplinc' Fast Off 
       Set 'Hearth-3-West Light, by TV' Fast Off 
       Wait  1 second 
       Set 'Hearth-5-Lamplinc' Fast On 
       Set 'Hearth-3-West Light, by TV' Fast On

 

 

wwat:

edit:

also: why did you use "then (path)" instead of "then (if)"? I have a hard time understanding the difference between these two. To me, if...then is if...then.

 

I used the 'then (path)' in those programs because they are just used to hold statements that execute something, I didn't need to evaluate anything more. If you place code in the 'If' portion of the construct it is there for evaluation only. It evaluates to either true or false.

 

 

wwat:

also: why was it necessary to make the two programs run two seconds apart?

 

Because everything is being continuously evaluated in ISY, its possible the same thing might occur when the light is turned on by one program and the other is evaluating the status it might start turning the lights on and off more than what you expect.

 

With this in mind try and do some experimenting with a lamp next to your computer so you can easily see the instant results of changes you make. Just change the time to suit your current time and rid the program of all the clutter for the experiment.

 

If any of the gurus on here picks up on any mistakes in this please be so kind as to correct it.

 

Thanks,

Wayne

Posted
just in case it isn't clear, I am wanting the lights to flash at 10pm:

off then on if they are on OR

on then off if they are off.

 

tell me where these go wrong:

 

program 1, enabled:

If
       Time is 10:00:00PM

Then
       Run Program 'Hearth Flash 10pm b' (If)

Else
  - No Actions - (To add one, press 'Action')

 

program 2, not enabled:

If
       Status  'Hearth-5-Lamplinc' < 20%
    Or Status  'Hearth-5-Lamplinc' is Off

Then
       Set 'Hearth-5-Lamplinc' Fast On
       Set 'Hearth-3-West Light, by TV' Fast On
       Wait  1 second
       Set 'Hearth-5-Lamplinc' Fast Off
       Set 'Hearth-3-West Light, by TV' Fast Off

Else
       Set 'Hearth-5-Lamplinc' Fast Off
       Set 'Hearth-3-West Light, by TV' Fast Off
       Wait  1 second
       Set 'Hearth-5-Lamplinc' Fast On
       Set 'Hearth-3-West Light, by TV' Fast On

A trick I use in this situation is to turn off "Enable" (in the Program Summary screen) for the second invoked program. This has the effect of disabling that program in the ISY event scheduler. The If part will still be evaluated when the program is directly invoked, but not reevaluated as part of the ISY scheduler. I know there are other ways to do what you're trying, but I find this approach the most intuitive for me. If you did that, I think your programs would work.

 

Randy

Posted

okay, well I'm not sure I completely understand all of this stuff but I'm learning. I think I'm up to the fourth grade level.

 

I really appreciate all of your help. This forum is damn good.

 

can anyone refer me to a place where I can read the real difference between "then (path)" and "then (if)". I read the FAQ and it doesn't really help me.

Posted
okay, well I'm not sure I completely understand all of this stuff but I'm learning. I think I'm up to the fourth grade level.

 

I really appreciate all of your help. This forum is damn good.

 

can anyone refer me to a place where I can read the real difference between "then (path)" and "then (if)". I read the FAQ and it doesn't really help me.

 

Have you read the Wiki? Particularly the Programs section of the How To section. There is some good stuff in there...

 

I had a bit too much cheer last night...so running a little slow this morning! (Afternoon already??) I will try and make a post with some descent details on what I have learned about programming. Not near what others know, but it might give you some ideas. I pretty much suck and showing (teaching) people how to do stuff...I tend to get too wordy and then my point gets a bit cloudy....but I will do my best (after several more cups of coffee and possibly a nap!) :(

 

Here's the link to the Wiki if you dont have it: Wiki

Posted
A trick I use in this situation is to turn off "Enable" (in the Program Summary screen) for the second invoked program. This has the effect of disabling that program in the ISY event scheduler. The If part will still be evaluated when the program is directly invoked, but not reevaluated as part of the ISY scheduler. I know there are other ways to do what you're trying, but I find this approach the most intuitive for me. If you did that, I think your programs would work.

Randy

 

Thanks Randy, armed with that piece of info I was able to get it down to 2 programs. So this effectively allows the 'disabled' program to run without the continual re-evaluating of the 'If' statement during execution. Perfect, now I can go and fix all the other inefficient programs I've written.

 

Regards,

Wayne

 

 

[set Flash Time]

If
       Time is  1:37:00PM

Then
       Run Program 'Flash Light' (If)

Else
  - No Actions - (To add one, press 'Action')

 

 

[Flash Light] *Disabled*

If
       Status  'My Lamp' is On

Then
       Set 'My Lamp' Fast Off
       Wait  1 second
       Set 'My Lamp' Fast On

Else
       Set 'My Lamp' Fast On
       Wait  1 second
       Set 'My Lamp' Fast Off

Posted
A trick I use in this situation is to turn off "Enable" (in the Program Summary screen) for the second invoked program. This has the effect of disabling that program in the ISY event scheduler. The If part will still be evaluated when the program is directly invoked, but not reevaluated as part of the ISY scheduler. I know there are other ways to do what you're trying, but I find this approach the most intuitive for me. If you did that, I think your programs would work.

Randy

 

Thanks Randy, armed with that piece of info I was able to get it down to 2 programs. So this effectively allows the 'disabled' program to run without the continual re-evaluating of the 'If' statement during execution. Perfect, now I can go and fix all the other inefficient programs I've written.

 

Regards,

Wayne

 

Good Job!

Rand

Posted

I have read these parts of the wiki, specifically:

 

http://www.universal-devices.com/mwiki/ ... ing_Run_If

http://www.universal-devices.com/mwiki/ ... ing_Run_If

 

I read them again and I don't think that they are explained very well. They use examples that are so friggin complicated that it makes no sense to me.

 

Anybody have a simpler explanation as to what the difference is between run (path) and run (if)?

Posted
Anybody have a simpler explanation as to what the difference is between run (path) and run (if)?

 

Run If evaluates the conditions in the If routine, sets the program True or False, and runs the Then (True) or Else (False) procedure.

 

Run Then ignores the If condition(s), sets the program to True, and runs the Then routine.

 

Run Else ignores the If condition(s), sets the program to False, and runs the Else routine.

 

Rand

Posted

okay, I guess I'll have to give up on this one, because I can't figure out for the life of me why I'd want to set up a program and then have a line in it set it as false and then run the else part. makes no sense to me, but I'm sure someone has a good use for it. My ISY just won't be running on that level.

 

Rand, thanks for your attempt.

Posted
okay, I guess I'll have to give up on this one, because I can't figure out for the life of me why I'd want to set up a program and then have a line in it set it as false and then run the else part. makes no sense to me, but I'm sure someone has a good use for it. My ISY just won't be running on that level.

 

Rand, thanks for your attempt.

 

You can use these options to 'reuse' a program with a different set of conditions.

 

Though I confess that I don't find many uses for this feature it does have some value and others use it.

It's a method to complicate the simple programming offered by the ISY ;)

 

Rand

Guest
This topic is now closed to further replies.

  • Recently Browsing

    • No registered users viewing this page.
  • Who's Online (See full list)

  • Forum Statistics

    • Total Topics
      37k
    • Total Posts
      371.4k
×
×
  • Create New...