VPN - Notify when iPhone not connected

My home assistant is behind a VPN. My phone connects to the home assistant over the VPN. Most of my notifications look like this:

  - device_id: xxxx
    domain: mobile_app
    type: notify
    message: xxx
    title: xxxx

There are a few times when my iOS VPN client disconnects (especially after app store updates), and I miss notifications. I was looking to come up with a notification over SMS to alert me of this scenario, but couldn’t find a good trigger to know when the phone is disconnected from the VPN. A “no phone activity since x minutes” seems hairy due to time of day (ie my phone won’t be doing anything when I’m sleeping).

Does anyone have any ideas about how to key a trigger when the phone is no longer connected?

Welcome to HA! :slight_smile:
What kind of VPN are you using?

Thank you! I’m using tailscale

Looks like they have a CLI, so something like i use should be possible.
I’m using wireguard on a Ubiquiti ER-X Router and made a script that checks the status of the clients every minute and publishes them to my mqtt server.
In HA there’s a simple mqtt binary_sensor for automations.