Jump to content

X10 Finally clause


GPG

Recommended Posts

Posted

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

Posted

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

Posted

I just used that as an example. The lamp remains on. Why doesn't the finally clause execute and turn the lamp off?

 

Thanks,

George

Posted

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.

Posted
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.

Posted

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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing

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

    • There are no registered users currently online
  • Forum Statistics

    • Total Topics
      37.2k
    • Total Posts
      372.5k
×
×
  • Create New...