Jump to content

X10 Finally clause


GPG

Recommended Posts

Is the finally clause meant to work with x10 as in the following example? Is something else required?

 

If
       Receive X10 House Code 'L'  Unit Code '7' Command '3 - On'

Then
       Set 'Office - Test LL' On

Finally
       Wait  10 seconds
       Set 'Office - Test LL' Off

Link to comment

GPG,

 

I think for what you want accomplish, you can simply put the 'Wait' and 'Set Office - Test LL' statements right below the first statement in your Then clause.

 

With kind regards,

Michel

 

Is the finally clause meant to work with x10 as in the following example? Is something else required?

 

If
       Receive X10 House Code 'L'  Unit Code '7' Command '3 - On'

Then
       Set 'Office - Test LL' On

Finally
       Wait  10 seconds
       Set 'Office - Test LL' Off

Link to comment

The 'Finally' clause is run when the 'If' is no longer true.

 

This description pertains to Controls in conditions as well (eg. Fast On/Fast Off etc.)

 

In this case, you received an X10 L.7.3 message, and thus the light goes on. It is not possible to make this 'If' false, therefore the 'Finally' won't run.

If
       Receive X10 House Code 'L'  Unit Code '7' Command '3 - On'

Then
       Set 'Office - Test LL' On 

Finally
       Set 'Office - Test LL' Off 

 

There are two solutions

 

First Solution

The simplest is to just add another program and not use 'Finally'

Program1:
If
       Receive X10 House Code 'L'  Unit Code '7' Command '3 - On'

Then
       Set 'Office - Test LL' On 

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

Program2:
If
       Receive X10 House Code 'L'  Unit Code '7' Command '11 - Off'

Then
       Set 'Office - Test LL' Off 

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

 

Second Solution

Include the 'Off' button in the 'If', thus allowing the 'If' condition to change:

If
       (
           Receive X10 House Code 'L'  Unit Code '7' Command '3 - On'
        Or Receive X10 House Code 'L'  Unit Code '7' Command '11 - Off'
       )
   And Receive X10 House Code 'L'  Unit Code '7' Command '3 - On'

Then
       Set 'Office - Test LL' On

Finally
       Set 'Office - Test LL' Off 

 

Summary

The thing to notice in the second one is that the 'If' condition is only dependent on L.7.11 (off) and L.7.3 (on). Therefore this program will only turn the light on/off if an On or Off is received; bright/dim/status request/etc. have no effect because they are not part of the 'If' condition.

 

One difference between the first and second solution is if the 'Then' action is long running. The second solution handles it properly, but the first does not. In this case, to make the first solution equal to the second, you would have to add a 'Stop Program' as in this modified example:

Program1:
If
       Receive X10 House Code 'L'  Unit Code '7' Command '3 - On'

Then
       Repeat Every  1 minute 
          Set 'Office - Test LL' On 
          Wait  30 seconds
          Set 'Office - Test LL' Off 

Finally
       Set 'Office - Test LL' Off 

Program2:
If
       Receive X10 House Code 'L'  Unit Code '7' Command '11 - Off'

Then
       Stop Program 'Program1'

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

 

Another difference is that in the Second solution, the light will only Turn Off if that program turned it on. In the First solution, it will turn the light off whenever it receives an 'Off' command, regardless of how the light was originally turned on.

 

Of course having just written out this explanation, this really does stoke the 'Else' vs 'Finally' debate. I guess thats one of the reasons we have a Beta for something like this.

Link to comment

Mark,

 

The debate to use Else vs. Finally is still open as such we a little hesitant doing cosmetic changes where a functional change is required.

 

With kind regards,

Michel

The 'Finally' clause is executed, when the 'If' statement is no longer true.

Could a hover bubble noting this above statement be added to the "If" text so users could remember its function. Personally I can't remember ever learning about it in all the classes I took so it may be remote concept to most people.

Link to comment

Archived

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


×
×
  • Create New...