X10 Community Forum

🖥️ActiveHome Pro => Plug-ins => Smart Macros => Topic started by: spam4us on September 27, 2007, 03:46:01 PM

Title: When are flags recognized
Post by: spam4us on September 27, 2007, 03:46:01 PM
I want to turn a light on for 4 minutes then turn it off based on Trigger B1 (ActiveEye Motion Sensor).
I also want to sound a chime once every 10 seconds while motion is being sensed at the B1 ActiveEye.
I also have 2 monitored Housecode switches. One that's On if it's OK to turn on the light(D1 On).  Another if it's OK to sound the chime(D2 On).
I'm confused at to "when" a flag status gets recognized.
 Will this work?

Trigger B1 On
   If D1 On And If Flag2 Off
   Set Flag2 On (doesn't get turned off until Macro L1 below)
   Set F1 On (turn on light)
   Set C1 On (trigger for chime macro)
 else
  If Flag2 On    (will flag2 be recognized as ON the 1st time thru this execution or not until B1 is triggered again for a 2nd time?)
  OR D1 Off
   Set C1 On (trigger the chime module)
     (I only want the above else to execute if the light has already been turned on or if it's not OK to turn the light on (D1 is Off))

Trigger C1 On
   If D2 On And If flag3 off
    Set Flag3 On
    Set C9 On  (sound the Chime)
    Set L1 On (light disposition)
    delay 10 sec (so the chime doesn't continually sound)
    Set Flag3 Off
   Else
    If Flag3 On   (will flag3 be recognized as ON the 1st time thru this execution or when C1 gets triggered again for a 2nd time?)
   OR D2 OFF
     Set L1 On (light disposition)
         (I only want the above else to execute if the chime macro is in delay mode Or it's not OK to sound the chime (D2 is Off))

 
Trigger L1 On
    If flag5 off
     set Flag5 On
     Delay 4 minutes
     Set F1 Off (turn off the flood)
     Set Flag2 Off
     Set Flag5 Off

I've also read in an old post that flags are not recognized when running a macro on the PC.  Is this still true?

Thanks

Title: Re: When are flags recognized
Post by: Puck on September 27, 2007, 06:09:46 PM
I've also read in an old post that flags are not recognized when running a macro on the PC.  Is this still true?

I have not had any problem with setting flags on Run from PC macros and using that flag's status with Store in Interface macros, and vise-versa.

I would like to see a macro posting of a problem that someone is having with this to do some experimenting. (Probably another firmware date code difference issue.)

I use OnAlert macros to set flags and use lots of store in interface macros to do different actions based on the status of those flags when normal active-eye motion sensors are triggered.

Quote
Trigger B1 On
   If D1 On And If Flag2 Off
   Set Flag2 On (doesn't get turned off until Macro L1 below)
   Set F1 On (turn on light)
   Set C1 On (trigger for chime macro)
 else
  If Flag2 On    (will flag2 be recognized as ON the 1st time thru this execution or not until B1 is triggered again for a 2nd time?)
  OR D1 Off
   Set C1 On (trigger the chime module)
     (I only want the above else to execute if the light has already been turned on or if it's not OK to turn the light on (D1 is Off))


Trigger C1 On
   If D2 On And If flag3 off
    Set Flag3 On
    Set C9 On  (sound the Chime)
    Set L1 On (light disposition)
    delay 10 sec (so the chime doesn't continually sound)
    Set Flag3 Off
   Else
    If Flag3 On   (will flag3 be recognized as ON the 1st time thru this execution or when C1 gets triggered again for a 2nd time?)
   OR D2 OFF
     Set L1 On (light disposition)
         (I only want the above else to execute if the chime macro is in delay mode Or it's not OK to sound the chime (D2 is Off))

 
Trigger L1 On
    If flag5 off
     set Flag5 On
     Delay 4 minutes
     Set F1 Off (turn off the flood)
     Set Flag2 Off
     Set Flag5 Off

1) Flag 2 should not be recognized as On the first time through for the ELSE. The key word is "should not"; if you are having problems just move the set Flag 2 On after the Set F1 ON. (Same principle for the C1 Macro.)

2) Keep in mind that the motion sensor has an ~10 second reset time between ON triggers, so to get repeating chimes you don't really need a delayed macro.

3)  What you are doing here seems more complex than need be; definitely hard to follow through and think of all possibilities. Basically you have 2 variables (conditions) D1 & D2 to decide what to do when B1 ON is triggered. I suggest that you make one macro string of Else's based on the different combinations of these  2 variables. Then you can use just a single Flag to prevent re-entry of ones that are not to occur during the 4 minute delay and no dummy modules (C1 & L1).
Title: Re: When are flags recognized
Post by: spam4us on October 09, 2007, 02:01:59 AM
fyi

After some experimenting, in my example below, Flag2 is recognized as ON the first time thru the macro and because of this, both the initial if and the else statements are both executed the first time thru.

Trigger B1 On
   If D1 On And If Flag2 Off
   Set Flag2 On (doesn't get turned off until Macro L1 below)
   Set F1 On (turn on light)
   Set C1 On (trigger for chime macro)
 else
  If Flag2 On    (flag2 is recognized as ON the 1st time thru this execution)
      OR D1 Off
   Set C1 On (trigger the chime module)
     (I only want the above else to execute if the light has already been turned on or if it's not OK to turn the light on (D1 is Off))
Title: Re: When are flags recognized
Post by: Puck on October 09, 2007, 08:59:18 AM
1) Flag 2 should not be recognized as On the first time through for the ELSE. The key word is "should not"; if you are having problems just move the set Flag 2 On after the Set F1 ON. (Same principle for the C1 Macro.)

Try moving the Set Flag 2 away from the start of the macro as suggested. This will prevent the ELSE macro from running 1st time through. Since there are no delays in the macro, maybe just put it as the last step.
Title: Re: When are flags recognized
Post by: spam4us on October 09, 2007, 10:36:32 AM
I'll give it a try BUT moving the flag later in the macro opens it up to having it execute more often than needed thereby causing  more powerline activity.  B1 is an ActiveEye that will send multiple ONs when it detects motion. 

Another interesting thing that is happening is if I trigger B1 to run again during the 4 minute delay of Macro L1,  Macro C1 will not execute again UNTIL macro L1 has completed thru the delay. I've tried this with & without the 10 sec delay in Macro C1.  In the Activity monitor, the else statement of Macro B1 gets executed because I see it Set C1 On (trigger for chime macro) but Macro C1 itself does not execute.  Once Macro L1 has completed, then all the macros function as if it's the 1st time thru (which they should at this point).   It seems that Flag3 does not get cleared until Macro L1 is finished.

Thanks

Title: Re: When are flags recognized
Post by: Puck on October 09, 2007, 10:58:32 AM
I'll give it a try BUT moving the flag later in the macro opens it up to having it execute more often than needed thereby causing  more powerline activity.  B1 is an ActiveEye that will send multiple ONs when it detects motion. 

The complete macro will take 1 to 2 seconds to complete and set the flag; the cycle time of the motion detector is longer than this. The lowest I have measured my ActiveEye's re-trigger rate was 6 seconds. So you should not get any re-triggering of that macro while it is executing.

Quote
Another interesting thing that is happening is if I trigger B1 to run again during the 4 minute delay of Macro L1,  Macro C1 will not execute again UNTIL macro L1 has completed thru the delay. I've tried this with & without the 10 sec delay in Macro C1.  In the Activity monitor, the else statement of Macro B1 gets executed because I see it Set C1 On (trigger for chime macro) but Macro C1 itself does not execute.  Once Macro L1 has completed, then all the macros function as if it's the 1st time thru (which they should at this point).   It seems that Flag3 does not get cleared until Macro L1 is finished.

This is why a real-time flag status monitor is needed. ;)
Title: Re: When are flags recognized
Post by: spam4us on October 09, 2007, 11:18:32 AM
Puck,

     Thanks for the replies.  This is turning out to be hit or miss programming.  I wouldn't really call it programming either since things are so unpredictable :-[.  No wonder people get frustrated & want their money back or switch to another vendor. 

thanks again
Title: Re: When are flags recognized
Post by: spam4us on October 10, 2007, 10:57:46 AM
Even more interesting......
     I set Flag3 Off in the L1 Macro just to see if it had any effect.  I ran a status report during the 4 minute delay and it showed Flag3 as being off YET, macro C1 did not trigger until AFTER the 4 minute delay in Macro L1.  It didn't matter where I cleared Flag3.  AHP waited until Macro L1 completed.

Trigger L1 On
    If flag5 off
     set Flag5 On
     set Flag3 Off
     Delay 4 minutes
     Set F1 Off (turn off the flood)
     Set Flag2 Off
     Set Flag5 Off

It seems like AHP is stacking all of the "Flag Off" commands until it gets to the end of a processing cycle.  I define a processing cycle as AHP following a sequential series of macros from beginning to end.  Seems as though it's doing something like this:


Trigger B1.....Trigger C1........Trigger L1......Flags2,3,5  off. 
instead of
Trigger B1.....Trigger C1....Flag3 off....Trigger L1.....Flag2 Off...Flag5 Off

Looks like the Flags On are processed during the processing cycle but the flags off are not processed until the cycle ends.


   
Title: Re: When are flags recognized
Post by: spam4us on October 11, 2007, 09:03:08 PM
OK!  I did more testing (read hunting in the dark) and here's what is happening.
Here is the macro
Trigger B1 On
   If D1 On And If Flag2 Off
   Set Flag2 On (doesn't get turned off until Macro L1 below)
   Set F1 On (turn on light)
   Set C1 On (trigger for chime macro)
   If I "Set Flag2 Off" right here then this If statement always executes and the chime always sounds. If I take the "Set Flag2 Off" out & let it clear in Macro L1, then the chime doesn't sound until Macro L1 has completed. When I don't have the "Set Flag2 OFF" here, the else part of this macro executes and I can see in the Activity Monitor that C1 gets set On but the chime doesn't sound. else
  If Flag2 On    (will flag2 be recognized as ON the 1st time thru this execution or not until B1 is triggered again for a 2nd time?)
  OR D1 Off
   Set C1 On (trigger the chime module)
     (I only want the above else to execute if the light has already been turned on or if it's not OK to turn the light on (D1 is Off))


Trigger C1 On
   If D2 On And If flag3 off
    Set Flag3 On
    Set C9 On  (sound the Chime)
    Set L1 On (light disposition)
    delay 10 sec (so the chime doesn't continually sound)
    Set Flag3 Off
   Else
    If Flag3 On   (will flag3 be recognized as ON the 1st time thru this execution or when C1 gets triggered again for a 2nd time?)
   OR D2 OFF
     Set L1 On (light disposition)
         (I only want the above else to execute if the chime macro is in delay mode Or it's not OK to sound the chime (D2 is Off))

 
Trigger L1 On
    If flag5 off
     set Flag5 On
     Delay 4 minutes
     Set F1 Off (turn off the flood)
     Set Flag2 Off
     Set Flag5 Off

Can anyone explain why the chime Macro C1 doesn't run when it is triggered by the else statement in Macro B1?
Or
Can anyone explain why the Chime Macro C1 does run when I clear flag2 in blue above in the B1 Macro?

Is my CM15A defective???

Thanks

Title: Re: When are flags recognized
Post by: Boiler on October 11, 2007, 10:32:59 PM
spam4us,

What version of AHP are you running and what macros are being stored in the interface/PC. 

I'm running AHP 3.204 (OnAlert not installed) and have had similar problems setting flags from the PC.  I believe you replied to my post : Link-Macros calling Macros that set flags (http://www.x10community.com/forums/index.php?topic=13097.0)

I read Pucks post and don't doubt for an second that he has been successful in running macros from the PC and CM15a.  Possibly a difference in AHP (Puck is running 3.206 with OnAlert)?

If you are mixing your macro source (CM15a/PC) try downloading everything to the interface.





Title: Re: When are flags recognized
Post by: spam4us on October 11, 2007, 10:42:39 PM
I'm running version 3.206.  All my macros are run from the interface. 
Title: Re: When are flags recognized
Post by: Puck on October 11, 2007, 11:27:38 PM
Boiler: I am using 3.206 (OnAlert).

spam4us: (Just thinking out loud here)... You have a macro that calls a macro that calls another macro. We know that AHP does not treat each macro call as a subroutine, instead it attempts to run all of them simultaneously.  Even though the first macro call is the last command listed, that macro probably does not end (internally) do to software handling overhead, before the called macro tries to start executing. Maybe trying to get AHP to do too much at the same time causes these types of problems.  ??? On paper your macros are logical and correct, but it appears the way AHP handles them is not with the same logic. You may have to add a delay to the first macro to alter how & when it ends.  ???

Title: Re: When are flags recognized
Post by: spam4us on October 12, 2007, 02:17:17 AM
Thanks to everyone who has replied and also Bill & Dave for your help in the chat room.  I now have this working.  In macro 1 (trigger B1) it would process correctly according to what I saw in the Activity monitor.  Once the flag was set the first time thru the macro, it would take the ELSE path the second time thru and set C1 on BUT the C1 macro would not run (the chime never made a sound). The Activity monitor showed the C1 being set ON.  Per Pucks suggestion, I put a delay into the ELSE path (see below) and also turned off a dummy module since putting the delay as the 1st step of the macro would always cause the else to execute when it shouldn't.  So now, Macro 1 (trigger B1) looks like this. (the 2 statements in maroon are the ones I added).

Trigger B1 On
   If D1 On And If Flag2 Off
   Set Flag2 On (doesn't get turned off until Macro L1 below)
   Set F1 On (turn on light)
   Set C1 On (trigger for chime macro)
   else
  If Flag2 On    (will flag2 be recognized as ON the 1st time thru this execution or not until B1 is triggered again for a 2nd time?)
  OR D1 Off
   Set P3 Off
   Delay 1 Second   
   Set C1 On (trigger the chime module)
     
Now, Macro C1 sounds the chime and all is well.

I thank everyone for their help and I also hope this helps someone else out.  This shouldn't be this hard. It should have worked the way I originally had it.  It's hard to debug AHP macros because your not sure if you have a logic problem or you are dealing with a quirk (read.....undocumented feature.......  ;D) in AHP.

thanks again

Title: Re: When are flags recognized
Post by: Boiler on October 12, 2007, 08:59:16 PM
spam4us,
Congratulations on your success and kudos for your persistence.

As Puck indicated, nothing obvious wrong with the logic in your previous post.  Unfortunately AHP does have it's quirks and execution flow is one of them.

I routinely use Delay 0 commands to separate various commands and logic functions.  I'm not sure if this is a AHP equivalent of a NOP (assembly language - no operation) but, like your delay 1, it works.

If you've ever tried programming in a graphical language (Labview for instance), you come to understand that order of execution is not at all obvious.  The same may be true with AHP.
Title: Re: When are flags recognized
Post by: spam4us on October 12, 2007, 10:27:07 PM
Boiler,
Quote
NOP (assembly language - no operation)
you're showing your age......pretty soon we can talk about autocoder and hardwiring logic boards. ;D ;D ;D
I guess you can recognize the following
12
11
0
1
2
3
4
5
6
7
8
9
and you might even know who Grace Murray Hopper is and that the above is a 5081.
 :D ;D ;D ;D ;)
Title: Re: When are flags recognized
Post by: Boiler on October 16, 2007, 06:07:33 PM
Boiler,
Quote
NOP (assembly language - no operation)
you're showing your age......pretty soon we can talk about autocoder and hardwiring logic boards. ;D ;D ;D
I guess you can recognize the following
12
11
0
1
2
3
4
5
6
7
8
9
and you might even know who Grace Murray Hopper is and that the above is a 5081.
 :D ;D ;D ;D ;)
spam4us,
I gave up trying to hide my age some time ago (the term Grey Beard is quite literal here).

Thanks for the 5081 hint in your post.  It's been a few years (maybe 25) since I've used cards.  I doubt we have any readers left at work.  We do have a Vax and an 11/70 which are used on some automated test stands.

Grace Murray Hopper - yep, I once programmed in COBOL (only once).  I may still have some of her guidlines in a file cabinet somewhere.

Actually had the opportunity to "revise" the assembly code on a test stand early this year.  We still have a number of dedicated stands that are based off the old TI 9900 processor.  This particular stand had a massive amount of ram (16K) spread over 4 expansion boards.  It was actually quite a lot of fun - really took me back. 

Nice to meet another "Oldtimer"
Title: Re: When are flags recognized
Post by: -Bill- (of wgjohns.com) on November 02, 2007, 12:26:07 AM
I have (I haven't fixed it yet) an interesting and related problem with flags.

My keychain remote is set to house code B.

I created a MACRO to trigger on B1 On (and another similar one for B1 Off).

The first draft B1 On macro simply sent L1 On to turn on a living room lamp.

This way I can re-assign the keychain button by simply changing the B1 On MACRO in AHP instead of actually changing the settings of the keychain remote or modules!   8)

After playing with AHP, looking at the Activity Monitor, and playing with programs written with the SDK, I discovered the fact that most remotes send multiple signals if the button is held down for any period of time.

So, I decided to get tricky and prevent the MACRO from being re-triggered if the MACRO was already executing, by using a SmartMACRO's flag.

The modified MACRO for B1 On checks to see if flag 1 is Off and only executes if flag 1 is Off.

If flag 1 is Off the MACRO executes, and the first thing it does is set flag 1 to On.

It then sends the L1 On and sets flag 1 to Off.

This works great to prevent the MACRO from re-triggering while it is already executing.

The problem I have been having is that after a power failure the keychain remote would no longer turn on (or off) the light.

I could see the signal in the Activity Monitor and the MACRO flashed in the AHP display as if it was being triggered, but nothing happened with the light!   ???

More interesting was that if I clicked the MACRO in AHP, it worked!  Not only that, but the keychain remote worked from then on too!

I finally realized that flag 1 in the CM15A wasn't set to Off when the CM15A lost power... as a matter of fact, it appears to be On by default!

Triggering the MACRO manually by clicking on it in AHP ignores the conditions (ignores the fact that flag 1 is not Off) and the MACRO executes.  Since the MACRO turns flag 1 Off at the end, the next press of the keychain button finds flag 1 Off as expected and the MACRO executes as expected.

Moral:  Never assume!  Test, test and re-test!   ::)
Title: Re: When are flags recognized
Post by: spam4us on November 02, 2007, 01:44:20 AM
Bill- (of wgjohns.com) ,

     What you can do is create a macro that is triggered with a P16 On that will reset your flags (or at least flag 1 in this case).  AHP sends a P16 on after a power failure.  I'm not sure exactly what makes this happen but the P16 On is always sent according to my activity monitor.
     
Title: Re: When are flags recognized
Post by: steven r on November 02, 2007, 12:12:10 PM
...What you can do is create a macro that is triggered with a P16 On that will reset your flags (or at least flag 1 in this case).  AHP sends a P16 on after a power failure....
Unfortunately I've never been able to get that power up P16 ON signal to trigger a macro.
Title: Re: When are flags recognized
Post by: JMac on November 02, 2007, 12:51:45 PM
I have a macro that will work with P16.  Designate a "ghost" module as P16, and then have a macro using P16 as the trigger.  The first item on the macro is a 30 second delay (that's how long it takes my computer to autostart AHP) followed by the action you want.  I use a 5 second delay after that to turn off the P16 module.  I can use this to arm OnAlert, for example.
Title: Re: When are flags recognized
Post by: Puck on November 02, 2007, 01:03:27 PM
Unfortunately I've never been able to get that power up P16 ON signal to trigger a macro.

Have you tried all variations of: stored in interface, run from PC, house code P transceived, house code P not-transceived?

I have not tried P16 within a single CM15A, but since I have 2 of them running, the P16 signal from one triggers a macro in the other. This has worked quite well for me so far.
Title: Re: When are flags recognized
Post by: Tuicemen on November 02, 2007, 01:21:19 PM
It has been noted before that an extra transceiver is needed to make use of the P16 on power up command! ;)
Title: Re: When are flags recognized
Post by: steven r on November 02, 2007, 01:29:55 PM
It has been noted before that an extra transceiver is needed to make use of the P16 on power up command! ;)
So is the "P16 ON" command an RF signal rather than a power line signal?
Title: Re: When are flags recognized
Post by: Tuicemen on November 02, 2007, 01:48:18 PM
Quote from: steven r
So is the "P16 ON" command an RF signal rather than a power line signal?

The p16 On command is sent RF!
One note on flags:
There is/was an issue with flags 1,15 &16 although they appear to be fixed in  ver 3.206 on XP, Old problems have a tendency to pop up again in updates and depending on which OS your using! ::) ;)
Doing an advanced search will turn up lots of discussion on this!
For this reason I still avoid these flags!
Title: Re: When are flags recognized
Post by: Puck on November 02, 2007, 03:08:46 PM
There is/was an issue with flags 1,15 &16 although they appear to be fixed in  ver 3.206 on XP, Old problems have a tendency to pop up again in updates and depending on which OS your using! ::) ;)

I have been using 1 & 15 reliably (Ver 3.206 on win2k), but I have seen 16 still get cleared just by the process of running a macro... so 16 is the only one I now avoid for anything meaningful.

I do use #16 when I want to start a macro with a delay. Because of the documented issues, I start the macro with a Clear Flag 16 followed by the delay. This meaningless step has helped me work around the start with a delay issue.  ;)
Title: Re: When are flags recognized
Post by: Boiler on November 02, 2007, 04:13:48 PM
I have been using 1 & 15 reliably (Ver 3.206 on win2k), but I have seen 16 still get cleared just by the process of running a macro... so 16 is the only one I now avoid for anything meaningful.

I do use #16 when I want to start a macro with a delay. Because of the documented issues, I start the macro with a Clear Flag 16 followed by the delay. This meaningless step has helped me work around the start with a delay issue.  ;)

Puck,

Nice touch with the otherwise useless flag #16.  That's helpfull.

Like you I have bee using flags 1 and 15 without problems for some time.  I'm running XP and AHP 3.204.

I've also had problems with the "start with a delay issue".  Unfortunately (or maybe fortunately), I just tried reproducing the delay at the beginning of a macro problem and everything works great??  I've used RF, Time, and Powerline triggers to the macro. 

Did something get "fixed" in AHP, or am I not remembering the problem correctly?

Boiler


Title: Re: When are flags recognized
Post by: Puck on November 02, 2007, 05:02:08 PM
I've also had problems with the "start with a delay issue".  Unfortunately (or maybe fortunately), I just tried reproducing the delay at the beginning of a macro problem and everything works great??  I've used RF, Time, and Powerline triggers to the macro. 

Did something get "fixed" in AHP, or am I not remembering the problem correctly?

I don't think anything got fixed yet; the problem appears when the macro is part of an Else.