On second thought, I implemented this logic, and it did appear to work initially, but then later on it just stopped working. My door bell now never gets triggered.
This could only happen if the flag didn't get cleared from an A2 OFF signal. Did you check your Activity Monitor to verify that A2 OFF was received?
Update:
Having read your other posts today, in one you stated using multiple transceivers. Multiple transceivers along with the CM15A/AHP can cause a system to be unreliable, so it may not be Flags that are the cause of your problems.