Presence detection is one of the hardest things to get setup reliably in home automation. NMAP is probably the easiest way to get it done, but it is also unreliable. Having automations disable themselves is a good workaround. Here is an example of how i have it setup.
The Away Automation triggers when my phone is off the network for 30mins. This automation when triggered turns on an automation that triggers when I come home.
The Home automation when triggered turns its self off.
I had my away automations trigger at 15mins, but then i would sometimes get false positives, so i would add 5mins, but i would still get one firing off when we are still home. So here i am at 30mins, and i haven’t got a false positive in probably over 2 months.