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!
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!