A few general questions

This might be of help:

As far as the routine not working, you might have run into this common issue:

Or it might have been another presence detection issue. (There are several.) But it’s good to know about the mode anyway.