How to turn the heating on prior to arriving home?

Has anyone come up with some logic for turning the heating (or anything else for that matter) on prior to arriving home?

Currently I am trying the following:

  1. Create a ‘Nearly Home’ zone
  2. Create a binary_sensor for every person based on the ‘Nearly Home’ zone and on proximity sensors to show if the person is travelling towards, and is nearly home:

It is close to being good enough but by no means perfect.
Does anyone have a better idea?

    zone: home
    tolerance: 50
    unit_of_measurement: mi

  - platform: template
        value_template: >
            is_state('', 'nearly_home') and
            is_state_attr('proximity.me_proximity_to_home', 'dir_of_travel', 'towards')

Hi, I did not even look at your script but more to the context.
Heating usually takes time and usually the time between you going home and reach home vs. having the effect of heating is not enough. Although I have none nor tried anyone, there are some ‘smart’ thermostats that seem to make this happen with some AI
If you want it to be based on ‘you’ then you imo you would need a heating-on quite a bit earlier.
An option is to create a large ‘zone’ centered your home, that helps to trigger things when you enter it

Take a look at your habits when you’re on your way home and see if you can leverage them to turn on your heating.
For instance. I drive a bike. I have bluetooth speakers in my helmet. I have created a zone called work. So when my home assistant detects that I’m in work, my helmet speakers have just switched on, and it’s in a certain time range, then I’m preparing to go home. Currently I use this to let my partner know when I’m on my way home (It helps when she’s making dinner) but I could just as easily turn on the heating, or anything I liked really.

In your case, if you’re driving home, maybe your car has bluetooth? If you work predictable hours, you could set a time range, and if you work in a single location, then you could create a zone. If these options are not relevant to you, maybe examine your habits, see if you can somehow create sensors around them.

Just my thoughts.