Presence automation: fire when entering zone AND was not in zone for at least N minutes prior

I use a presence based automation to unlock my smart lock inside my garage when I am driving home. The problem is that this automation fires off sometimes when I am leaving home as well. Right on the edge of departing my home zone, it puts me into Away but sometimes momentarily reverts to Home before it sticks with Away finally. Because of this my smart lock unlocks even though I am leaving the house.

I was hoping to solve this by only triggering the unlock automation if entering home AND was away for at least 5 minutes prior.

I tried using a condition for the latter part of that AND statement, but that doesn’t work. At the time of triggering the automation it doesn’t have any past state to deal with, and in the current state of Home the condition will always be False.

How can this be solved?

I use my wifi connection as a condition. If its not connected when entering the zone, my garage opens. It ususally takes a few minutes to show disconnected, so leaving is not an issue.

Thank you, that’s a simple and effective sounding idea.

I have a super old Google Wifi router, am new to HA, and have yet to figure out how to check for whether my device is on the network or not in HA. I’ll start exploring that path!