For iOS. This one is easy and reliable as long as HomeKit presence is reliable. It does mean buying another device, although it’s a pretty inexpensive one.
How to Use a Meross or Matter Plug to Use HomeKit Presence to Trigger ST Routines
For Android, Tasker plus SharpTools is currently a popular presence option. it does require buying two paid apps if you don’t already have them. As @charlie969 notes below The old method with Tasker plug-ins and sharptools will not work after the transition, but there is a different method using webhooks that would.
SharpTools/Tasker for presence detection (2022)
Another android option is to capture when the phone connects to the home Wi-Fi. there’s an Edge Driver option for that, although I think that one is technically more complex to set up. And it won’t work with all Wi-Fi routers.