X10 Community Forum

🖥️ActiveHome Pro => Plug-ins => Smart Macros => Topic started by: emil on April 26, 2007, 07:47:09 AM

Title: Else problem
Post by: emil on April 26, 2007, 07:47:09 AM
I encountered a bug last night that someone mentioned here that for the life of me I can't find the post.
It seems the else condition doesn't operate properly, both branches are executed.

i.e.
IF A3 turns off
    IF flag 2 set
        clear flag 7
        dim light 50%
    ELSE
        clear flag 7
        turn off light   

LIGHT DIMS THEN TURNS OFF - this is incorrect!

When I watch the light I see it dim down then about 1 sec. later it turns off !
I simply flipped the flag clear and light operation in both branches and it works now

IF A3 turns off
    IF flag 2 set
        dim light 50%
        clear flag 7
    ELSE
        turn off light   
        clear flag 7

LIGHT DIMS - this is correct!

I wanted to find the post to see if there is more insight on this problem and if others had the problem. (v3.203)

Thanks
Title: Re: Else problem
Post by: Tuicemen on April 26, 2007, 08:20:05 AM
Not knowing what flag 7 is used for only tells us 1/2 the story! ::) ;)
The placement of flags in a macro is key, They can cause different out comes based on where you place them in a macro!
So stating it is a bug isn't entirely true, you just discovered the correct placement for that flag based on where else you have it(flag 7) in your setup! ;) :D ;D
Title: Re: ELSE Problem
Post by: TakeTheActive on April 26, 2007, 09:06:16 AM

I encountered a bug last night that someone mentioned here that for the life of me I can't find the post.

How about:

Title: Re: Else problem
Post by: steven r on April 26, 2007, 09:45:08 AM
I'd be curious if the dim command is affecting your results. AHP has some known problems executing commands after dims.

i.e. I'd be curious if either of these scenarios works.

IF A3 turns off
    IF flag 2 set
        clear flag 7
        dim light 50%
        delay 2 sec
    ELSE
        clear flag 7
        turn off light   


Or this scenario...

IF A3 turns off
    IF flag 2 set
        clear flag 7
        P1 on                ;Where P1 is any other HC that you use
    ELSE
        clear flag 7
        turn off light   
Title: Re: Else problem
Post by: emil on April 26, 2007, 11:06:38 AM
Quote
Not knowing what flag 7 is used for only tells us 1/2 the story!   
The placement of flags in a macro is key, They can cause different out comes based on where you place them in a macro!
So stating it is a bug isn't entirely true, you just discovered the correct placement for that flag based on where else you have it(flag 7) in your setup!   
Flag 7 is used to eliminate repeated entries when A3 turns on. So when A3 turns on flag 7 is set.

What Flag 7's function was did not seem relevant to the operation of the macro, it was just the fact that I was clearing a flag right after a condition (I think).

Putting the flag operation after the on or dim command fixed the "feature" (not bug :) ).


IF we could only get some sort of functional description on how the CM15a works internally we could easily work around these nuances.

Again, I could have sworn I saw somewhere on this forum someone mentioning about both parts of the macro being called. It was like a tips thing, I'll keep looking.

Thanks for the help guys.
Title: Re: Else problem
Post by: Walt2 on May 09, 2007, 01:03:10 PM

It seems the else condition doesn't operate properly, both branches are executed.

i.e.
IF A3 turns off
    IF flag 2 set
        clear flag 7
        dim light 50%
    ELSE
        clear flag 7
        turn off light   


From my experiences, the "safe" way to program it is...

IF A3 turns off
    IF flag 2 set
        clear flag 7
        dim light 50%
    ELSE IF flag 2 reset
        clear flag 7
        turn off light   

Yea, I know that logically, the ELSE should only be executed if flag 2 was reset (ie, not set), but it doesn't hurt to verify it (and sometimes it even makes AHP do the right thing).

I have learned the hard way, and now all my ELSE macros re-check conditions.