Track "home/away" based on charging state of android phone's battery

I’m trying to run automation based on when my vehicle arrives home. It doesn’t have WiFi so I have a Samsung Note 9 with a smashed screen that I want to leave in the car. I have it connected to my home wifi which can be picked up from my driveway.

I have created a person called “BMW” and I’ve installed the Home Assistant apk on the phone. The phone’s current device tracking doesn’t work well because the phone doesn’t have a sim data connection. Once the phone disconnects from my home wifi home assistant don’t immediately update BMW as being away.

I did notice I can track the state of the phone’s battery (charging or discharging) on home assistant and it’s very fast to update. I have a USB port in my glovebox that only has power when the car’s ignition is turned on so using this I can keep the phone battery topped up to stay connected to the wifi for a few days.

What I want to do is change the BMW user’s home/away state based on the charging/discharging state of the phone. Can this be done?

set up an automation to trigger on the state of the phone charging or discharging.

the action will be a choose action with the condition being that you are home (however you do that) and then use the device_tracker.see service with the GPS coordinates being your home coordinates if the state is discharging.

if you aren’t home then use the coordinates of the current location of your phone when you turn off the car (goes to discharging).

and if the phone is charging you can just use whichever GPS coordinates make the most sense for your needs. I would use something far enough away from home but not in another zone so the device tracker just says not_home instead of being in a zone.