Jump to content

Program Bahaviour


deeepdish

Recommended Posts

Hi everyone,

 

I have a quick question how the "IF" criteria is evaluated and under what conditions.

 

Consider the following simple cieling fan example:

 

IF

 

CielingFan-Motor is OFF (happens to be a inline switchlinc relay)

 

THEN

 

Repeat every 30 minutes

Set CielingFanScene ON

Wait 30 seconds

Set CielingFanScene OFF

 

ELSE

 

Set CielingFanScene OFF

 

 

For those wondering why spin a fan for only 30 seconds, well it's intend for the baby room at night to keep the air moving.

 

In any regard, provided that the CeilingFan-Motor is off (which is part of by the scene CielingFanScene controlled by a KPL) the program should cycle the repeat loop of turning the fan on for 30 seconds then off. I expect that after every iteration of the Repeat loop the if condition would be checked. However it seems that the IF statemetn is polled everytime s statement is executed which would effectively kill the program after the second THEN statement. I also tried removing the ELSE Statement which didn't alter program behavour.

 

Thanks.

Link to comment

Hello deeepdish, long time no see!

 

Apologies for a tardy reply ...

 

At any point in the program, if the condition become false, the program stops running. As such, you are seeing the correct behavior.

 

May I humbly ask why you have that condition in the first place? It seems that all you want to do is to turn on a fan for 30 seconds every 30 minutes.

 

With kind regards,

Michel

 

 

Hi everyone,

 

I have a quick question how the "IF" criteria is evaluated and under what conditions.

 

Consider the following simple cieling fan example:

 

IF

 

CielingFan-Motor is OFF (happens to be a inline switchlinc relay)

 

THEN

 

Repeat every 30 minutes

Set CielingFanScene ON

Wait 30 seconds

Set CielingFanScene OFF

 

ELSE

 

Set CielingFanScene OFF

 

 

For those wondering why spin a fan for only 30 seconds, well it's intend for the baby room at night to keep the air moving.

 

In any regard, provided that the CeilingFan-Motor is off (which is part of by the scene CielingFanScene controlled by a KPL) the program should cycle the repeat loop of turning the fan on for 30 seconds then off. I expect that after every iteration of the Repeat loop the if condition would be checked. However it seems that the IF statemetn is polled everytime s statement is executed which would effectively kill the program after the second THEN statement. I also tried removing the ELSE Statement which didn't alter program behavour.

 

Thanks.

Link to comment

I've been staying below the radar -- had a baby girl within the past 3 weeks..

 

Correct. The Fan should run for 30s (or whatever set interval) every 30 mins. Provided the "scene" that controlls the fan is OFF. If the scene that controlls the fan is ON, this would override the program. This is what breaks the original program logic. The program furns the scene on and then the ISY sees the condition change, and stop the program. It fails to proceed to the next line to wait for 30s and turn the scnee off.

 

The program is for the baby actually. Idea is to circulate the air in the room every so often. Why not use the cieling fan and cycle it on/off for short bursts now and then provided the scene is off...

 

I agree with you that the program logic should be polled to make sure the condition initiating the program is still valid, however this should be done after every itteration of the program / loop (in my case the repeat every 30 mins loop) -- sequential. Perhaps an additional parameter can be made available to check conditions after every itteration. It's a fine line where the event that altered the condition was triggered from (self - program, or externally -- i.e. me turning on a switch) :) Too much for the ISY though :)

Link to comment

Congratulations on your baby girl!

 

The reason your program is not working is that whenever the status of 'CielingFan-Motor' changes, the 'If' condition is evaluated and either the 'Then' or 'Else' is run. Therefore, it goes into a big loop:

 

If -> Then -> scene on -> If -> Else -> scene off -> If -> Then -> scene on ... etc.

 

The question is when do you want this to run? It appears as though it should always be running, and if that is the case I would implement it in this way, making sure to have it 'Run At Startup':

 

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

Then
       Repeat Every  30 minutes 
          Set 'Ceiling Fan Scene' On
          Wait  30 seconds
          Set 'Ceiling Fan Scene' Off

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

 

Now, if you wanted to put it on schedule of some kind, you would do this:

If
       From     9:00:00PM
       To       6:00:00AM (next day)

Then
       Repeat Every  30 minutes 
          Set 'Ceiling Fan Scene' On
          Wait  30 seconds
          Set 'Ceiling Fan Scene' Off

Else
       Set 'Ceiling Fan Scene' Off

Link to comment

Thanks Chris. ....

 

 

However there is a slightly different condition criteria than just a time range.

 

Every ceiling fans is connected to one inline dimmer and one inline relay. The inline devices are part of scene(s) that are controlled by a wall mounted KPL.

 

Here's the challenge.

 

I would like the program I define to have sufficient logic to determine the right conditions for running:

 

1. The ceiling fan motor is OFF. This would assume that the Ceiling fan scene is off as well.

2. AND Time is within a certain range.

 

Because the Ceiling Fan Inline relay is checked (part of condition) to be OFF and the ISY program turns the Ceiling Fan Inline ON during program execution, the program is interrupted because the original condition is not valid anymore.

 

The ISY should check to see if the condition if valid at the end of each loop iteration instead of at the end of each statement executed. If there are already dependencies on this condition checking algorithm, perhaps a check box to change the condition checking algorithm can be made available when defining a program.

 

 

Congratulations on your baby girl!

 

The reason your program is not working is that whenever the status of 'CielingFan-Motor' changes, the 'If' condition is evaluated and either the 'Then' or 'Else' is run. Therefore, it goes into a big loop:

 

If -> Then -> scene on -> If -> Else -> scene off -> If -> Then -> scene on ... etc.

 

The question is when do you want this to run? It appears as though it should always be running, and if that is the case I would implement it in this way, making sure to have it 'Run At Startup':

 

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

Then
       Repeat Every  30 minutes 
          Set 'Ceiling Fan Scene' On
          Wait  30 seconds
          Set 'Ceiling Fan Scene' Off

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

 

Now, if you wanted to put it on schedule of some kind, you would do this:

If
       From     9:00:00PM
       To       6:00:00AM (next day)

Then
       Repeat Every  30 minutes 
          Set 'Ceiling Fan Scene' On
          Wait  30 seconds
          Set 'Ceiling Fan Scene' Off

Else
       Set 'Ceiling Fan Scene' Off

Link to comment

Here's the challenge.

 

I would like the program I define to have sufficient logic to determine the right conditions for running:

 

1. The ceiling fan motor is OFF. This would assume that the Ceiling fan scene is off as well.

2. AND Time is within a certain range.

 

Ok, now I understand, if the scene is turned on by something else, you want to leave it on and not cycle on/off for 30 seconds. I would also assume that if the fan is on (during the 30 second cycle), that if the KPL button is pressed, you would want the fan to remain on after 30 seconds.

 

The simplest way to solve this is base it on the status of the KPL button, basically when the KPL button A is off it cycles, otherwise it doesn't:

 

Program:  Fan Cycle  --> Enabled

If
       Status  'KPL Button A' is Off
   And From     9:00:00PM
       To       6:00:00AM (next day)

Then
       Repeat Every  30 minutes 
          Set Scene 'Ceiling Fan Scene' On 
          Wait  30 seconds 
          Set Scene 'Ceiling Fan Scene' Off 

Else
       Run Program 'Fan Cleanup' (If)

 

Program: Fan Cleanup  --> NOT enabled

If
       Status  'KPL Button A' is Off

Then
       Set Scene 'Ceiling Fan Scene' Off

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

Note: This program is needed to make sure the fan is shut off after the schedule ends, but not shut off if the KPL button is on.

 

 

The ISY should check to see if the condition if valid at the end of each loop iteration instead of at the end of each statement executed. If there are already dependencies on this con

Essentially this is the same as saying there is no way to stop a program until the end of the repeat (without using an explicit Stop from html or admin console). This has undesirable effects if someone accidently starts something and wants to turn if off right away (such as away program random lighting, a sprinkler sequence etc.).

Link to comment

Thanks Chris, however your suggestion would not fuinction in my situation as I would like to have visual status of each device thats on via the KPL. This is why I'm triggering scenes. I realize that a spinning fan is sufficient indication that it's on, however this recent discovery is actually going to hinder how I'd like to deploy some other ideas I have for the house. I've invested quite a bit in the technology (I don't think I have a traditional switch in any part of the house or the shed at this point), as I've seen the potential and benefits of this technology.

 

I understand why the mechanism is in place to give the end user control over programs that may be triggered accidentally, however I would suggest that the ISY, given its PLC-type nature, be flexible enough to give users who wish to override this behaviour the capability to do so. At this point, the device has a limited scope in my household. There are a number of programs that I'd like to compose that would rely on condition checkon at the end of a loop vs statement that I can't, or I'll have to exponentially increase the complexity of the code through scenes, etc.. to get it done. I'm the type of person who like to set it once and essentially forget it. For me, home automation is a tool not a hobby :) As such when I define a program, I should be able to return to it in the next year or two and be able to figure it out quickly instead of going through a mess of scenes that have work arounds to various coding restrictions.

 

 

The other thing that would be nice is to programatically turn on/off individual KPL buttons (not the 0 button, but ABCD, etc..).. I realize this can be done through scenes, but again why all the complexity and work arounds.

 

.

 

Here's the challenge.

 

I would like the program I define to have sufficient logic to determine the right conditions for running:

 

1. The ceiling fan motor is OFF. This would assume that the Ceiling fan scene is off as well.

2. AND Time is within a certain range.

 

Ok, now I understand, if the scene is turned on by something else, you want to leave it on and not cycle on/off for 30 seconds. I would also assume that if the fan is on (during the 30 second cycle), that if the KPL button is pressed, you would want the fan to remain on after 30 seconds.

 

The simplest way to solve this is base it on the status of the KPL button, basically when the KPL button A is off it cycles, otherwise it doesn't:

 

Program:  Fan Cycle  --> Enabled

If
       Status  'KPL Button A' is Off
   And From     9:00:00PM
       To       6:00:00AM (next day)

Then
       Repeat Every  30 minutes 
          Set Scene 'Ceiling Fan Scene' On 
          Wait  30 seconds 
          Set Scene 'Ceiling Fan Scene' Off 

Else
       Run Program 'Fan Cleanup' (If)

 

Program: Fan Cleanup  --> NOT enabled

If
       Status  'KPL Button A' is Off

Then
       Set Scene 'Ceiling Fan Scene' Off

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

Note: This program is needed to make sure the fan is shut off after the schedule ends, but not shut off if the KPL button is on.

 

 

The ISY should check to see if the condition if valid at the end of each loop iteration instead of at the end of each statement executed. If there are already dependencies on this con

Essentially this is the same as saying there is no way to stop a program until the end of the repeat (without using an explicit Stop from html or admin console). This has undesirable effects if someone accidently starts something and wants to turn if off right away (such as away program random lighting, a sprinkler sequence etc.).

Link to comment
The other thing that would be nice is to programatically turn on/off individual KPL buttons (not the 0 button, but ABCD, etc..).. I realize this can be done through scenes, but again why all the complexity and work arounds.

 

I believe this is an Insteon limitation - a KPL secondary button must be a responder in a scene to be controlled.

Link to comment

Program 'Control Baby Fan'
If
       (
            Control 'KPLb Baby Fan' is switched On
         Or Control 'KPLb Baby Fan' is switched Fast On
       )
   And Control 'KPLb Baby Fan' is not switched Off
   And Control 'KPLb Baby Fan' is not switched Fast Off

Then
       Disable Program 'Cycle Baby Fan'

Else
       Enable Program 'Cycle Baby Fan'

Program 'Cycle Baby Fan'
If
       From     9:00:00PM
       To       6:00:00AM (next day)

Then
       Repeat Every  30 minutes 
          Set 'sBaby Fan' On
          Wait  30 seconds
          Set 'sBaby Fan' Off

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

Link to comment

this may seem like a stupid question, and that probably is because it is :oops: but still, how long will an insteon relay last if you cycle it on/off every thirty seconds? that would be 86400 cycles per day assuming my math is right, and you don't turn the fan on and just let it run...

is an insteon relay like a normal relay that has a rated life around a around a million cycles or so? if so doesn't that mean you will go through relays every 12 days or so? even assuming it is rated for like 100 million cycle, that's every 3 years you need to replace the relay? are they easy to get too?

or do insteon relays have an infinite amount of cycle in them? just curious really?

Link to comment
this may seem like a stupid question, and that probably is because it is :oops: but still, how long will an insteon relay last if you cycle it on/off every thirty seconds? that would be 86400 cycles per day assuming my math is right, and you don't turn the fan on and just let it run...

is an insteon relay like a normal relay that has a rated life around a around a million cycles or so? if so doesn't that mean you will go through relays every 12 days or so? even assuming it is rated for like 100 million cycle, that's every 3 years you need to replace the relay? are they easy to get too?

or do insteon relays have an infinite amount of cycle in them? just curious really?

Hello SomeWhat,

 

You raise a very good point, in that the number of cycles should be considered. There are 86,400 seconds in a day, but not 86,400 cycles. At a 30 second interval, there would be 2,880 cycles per day. At that rate, one million cycles would be reached in 347 days, or just under a year.

 

However, he didn't wish to cycle the fan every 30 seconds, but rather every 30 minutes (for a 30 second duration), and only at night. At that rate it would cycle twice an hour, so even if cycled throughout the entire day, there would be only 48 cycles per day, so it would take 57 years to cycle a million times.

Link to comment
...

 

I understand why the mechanism is in place to give the end user control over programs that may be triggered accidentally, however I would suggest that the ISY, given its PLC-type nature, be flexible enough to give users who wish to override this behaviour the capability to do so. At this point, the device has a limited scope in my household. There are a number of programs that I'd like to compose that would rely on condition checkon at the end of a loop vs statement that I can't, or I'll have to exponentially increase the complexity of the code through scenes, etc.. to get it done. I'm the type of person who like to set it once and essentially forget it. For me, home automation is a tool not a hobby :) As such when I define a program, I should be able to return to it in the next year or two and be able to figure it out quickly instead of going through a mess of scenes that have work arounds to various coding restrictions.

 

I understand what you are saying, some of these can get tricky. I still think you would find it frustrating not to be able to stop a program during a repeat cycle, but there may be a way to do what you want.

 

Not sure when this would be implemented:

 

When a program runs, it may cause events, such as 'Fan On', 'Fan Off' etc.. This is problematic in your example because once the program is running, you only want it to stop if 'Fan On' or 'Fan Off' were done manually via the KPL, but not if the program itself did a 'Fan On' or 'Fan Off'.

 

One answer to this would be to add an option that tells a program to ignore events that originated from itself, (or possibly any program), meaning that if a 'Fan On' or 'Fan Off' was sent by the program, the 'If' would ignore it.

 

Not sure how this would eventually look in a program, but the following gets the idea across:

Options
       Ignore events sent from This program

If 
       Status 'Ceiling Fan' is Off 
   And From     9:00:00PM 
       To       6:00:00AM (next day) 

Then 
       Repeat Every  30 minutes 
          Set Scene 'Ceiling Fan Scene' On 
          Wait  30 seconds 
          Set Scene 'Ceiling Fan Scene' Off 

 

 

The other thing that would be nice is to programatically turn on/off individual KPL buttons (not the 0 button, but ABCD, etc..).. I realize this can be done through scenes, but again why all the complexity and work arounds.

 

This an Insteon limitation, the only way to turn a KPL button on/off is through a scene.

Link to comment
  • 8 months later...

Hi Chris & UD Developers,

 

I'm going to resurrect this issue as I feel it's a flaw in the logic of the way IF statements are handled by the ISY.

 

Here's a scenario that actually happened today:

 

Program in question:

 

IF

 

FROM 10:00:00 PM

TO 8:00:00 AM (next day)

 

AND

 

STATUS "KPL-FANBTN-A" is OFF

 

THEN

 

REPEAT EVERY 30 mins

STATUS "FAN-MOTOR" ON

WAIT 2 MINUTES

STATUS "FAN-MOTOR" OFF

 

In the above program example, and using the IF logic as described earlier in the thread. At 8AM, the fan turned on, however never turned off since the IF loop was no longer valid and therefore interrupted the WAIT 2 MINUTES statement.

 

Regardless whether the IF statement is valid or not at the time of executing the THEN statement; any THEN statement that is actively running should be able to run it's course without interruption.

 

The IF logic in the ISY should mirror that of the standard implementaion in actual development languages (e.g. Basic, C, PHP, even good old ASM code -- look up CMPs , etc..).

Link to comment

deeepdish,

 

Long time no see! I am going to leave the philosophical discussion to Chris. For your specific program you can solve it by adding an Off in the Else path.

 

Perhaps () for atomic operations would be a good compromise but, like Chris, I believe the way this is handled right now is the correct way.

 

With kind regards,

Michel

 

 

Hi Chris & UD Developers,

 

I'm going to resurrect this issue as I feel it's a flaw in the logic of the way IF statements are handled by the ISY.

 

Here's a scenario that actually happened today:

 

Program in question:

 

IF

 

FROM 10:00:00 PM

TO 8:00:00 AM (next day)

 

AND

 

STATUS "KPL-FANBTN-A" is OFF

 

THEN

 

REPEAT EVERY 30 mins

STATUS "FAN-MOTOR" ON

WAIT 2 MINUTES

STATUS "FAN-MOTOR" OFF

 

In the above program example, and using the IF logic as described earlier in the thread. At 8AM, the fan turned on, however never turned off since the IF loop was no longer valid and therefore interrupted the WAIT 2 MINUTES statement.

 

Regardless whether the IF statement is valid or not at the time of executing the THEN statement; any THEN statement that is actively running should be able to run it's course without interruption.

 

The IF logic in the ISY should mirror that of the standard implementaion in actual development languages (e.g. Basic, C, PHP, even good old ASM code -- look up CMPs , etc..).

Link to comment

Thanks Michel.

 

Perhaps adding the ability to apply "flags" to a program to define its execution characteristics. For instance adding a NO_IF_OVERRIDE flag to a program would prevent the IF statement's state (TRUE/FALSE) from impacting THEN statement's execution.

 

More flexibility at the end of the day.

 

I understand where you and Chris are coming from, however there are cases where not having the behavior outlined in the previous email complicating the program and making the user jump through (unnecessary) hoops just to get a desired behavior to function as intended.

Link to comment

Hi dd,

 

If you want the program to just run the fan every so often, and not interfere when it has been switched on, then I suggest you remove the Status line and replace it with two other programs (if I am understanding you correctly).

 

Run Fan

If
       From     9:30:00AM
       To      12:00:00PM (same day)

Then
       Repeat Every  1 minute 
          Set 'FAN-MOTOR' On
          Wait  10 seconds
          Set 'FAN-MOTOR' Off

Else
       Set 'FAN-MOTOR' Off

 

This drove my wife to work today ;)

 

If
       Control 'KPL-FANBTN-A' is switched On

Then
       Stop program 'Run Fan'

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

 

If
       Control 'KPL-FANBTN-A' is switched Off

Then
       Run Program 'Run Fan' (If)

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

 

Rand

Link to comment

Archived

This topic is now archived and is closed to further replies.


×
×
  • Create New...