I started to write my own version of this a while back but, it relied on some "server-side" work.
I had a daemon running inside my house which looked for my iPhone on the internal WiFi network. When my phone went off-line it signaled that I had "left" and after a certain duration went into "watch-to-unlock" mode. When my phone reappeared on my network I would signal to unlock.
I know you are probably trying to keep as much of the logic off the perimeter of your ecosystem (Phone App and in-home hardware) but, it was the best way I could figure it out.
I had a daemon running inside my house which looked for my iPhone on the internal WiFi network. When my phone went off-line it signaled that I had "left" and after a certain duration went into "watch-to-unlock" mode. When my phone reappeared on my network I would signal to unlock.
I know you are probably trying to keep as much of the logic off the perimeter of your ecosystem (Phone App and in-home hardware) but, it was the best way I could figure it out.