Looking for a way to consider different users to be 'home' based on different distances

Kind of a weird idea here. My wife and I are long-haul truckers, and two of our (adult) children live with us. For purposes of automating the thermostat, I’d like to consider the kids to be home if they’re actually AT the house (say 200m or so) and my wife and I to be home if we’re within more like 30km. Well, honestly I’d really like to have it consider “is someone at home or on the way home right now” but I can’t wrap my brain around the whole “on the way home right now” part. Anyways.

What I’m thinking so far is two zones, Home and Approaching. Home is the usual 200m radius, Approaching is 30000m. Two groups, the regular people group with everyone in it and ‘truckers’ with just my wife and myself. Then I could do…if self.anyone_home() or self.truckers_approaching() ? I haven’t tried that yet but I’m assuming it’d explode violently. Is there an elegant way to make that happen?

first i must say that i never used zones or worked with devicetrackers more then home (on) or not_home (off).

the first thing i think you should do is to get the distance from each device (no groups or so)
if you are able to see that a trucker is inside the 30 km range in HA or when a “not trucker” is inside the 200 m range in HA then you got all you need.

in that case you just can use an app like:

def initialise(...):
  self.listen_state(self.check_home_state, "device_tracker.trucker1")
  self.listen_state(self.check_home_state, "device_tracker.trucker2")
  self.listen_state(self.check_home_state, "device_tracker.nottrucker1")
  self.listen_state(self.check_home_state, "device_tracker.nottrucker2")
def check_home_state(...):
  noone_home = True
  if self.get_state( "device_tracker.trucker1") == "home" or  self.get_state("device_tracker.trucker1") == "approaching":
    noone_home = False
  elif self.get_state( "device_tracker.trucker2") == "home" or  self.get_state("device_tracker.trucker2") == "approaching":
    noone_home = False
  elif self.get_state( "device_tracker.nottrucker1") == "home":
    noone_home = False
  elif self.get_state( "device_tracker.nottrucker2") == "home":
    noone_home = False
  self.set_state("sensor.noone_home", state = noone_home)

now you have a sensor that shows if someone is home or not and you can create any actions based on that.

Use the proximity component as it can tell you distance and direction toward your home zone. Rest is simple automations.