Distance Sensor to show if car is home or away

Can someone help me figure out how to show if my car is in the garage or not, I have it set up as 2 sensors, one a binary and one a sensor, I’m pretty sure thats wrong but here is my code. Any and all help would be greatly appreciated

- platform: mqtt
name: "My Car"
state_topic: "tele/garagesensor/SENSOR"
value_template: '{{ value_json.SR04.Distance }}'

- platform: template
sensors:
car_presence:
value_template: >-
{% if is_state('sensor.my_car','true') | int > 200 %}
Home
{% else %}
Away
{% endif %}

Welcome to the forums. Please see point 11 about correct post formatting here: How to help us help you - or How to ask a good question

If you actually did this, then your indentation is way off.

e.g. should be:

sensor

- platform: mqtt
  name: "My Car"
  state_topic: "tele/garagesensor/SENSOR"
  value_template: '{{ value_json.SR04.Distance }}'

Also binary sensor templates must evaluate to true or false. So either make this a sensor (instead of a binary sensor):

- platform: template
  sensors:
    car_presence:
    value_template: >-
      {% if states('sensor.my_car') | int > 200 %}
        Home
      {% else %}
        Away
      {% endif %}

Or (a better idea) rearrange the template to be a true / false template for a binary sensor:

- platform: template
  sensors:
    car_presence:
      entity_id: sensor.my_car # this tells HA what to monitor for updates to the template
      value_template: "{{ states('sensor.my_car') | int < 200 }}"
      device_class: presence

The device class will convert the on/off state of the binary sensor to display as Home/Away. Though if using the state of this binary sensor in an automation still use the states on or off. Not Home or Away.

Device classes: https://www.home-assistant.io/components/binary_sensor/#device-class

Thank you so much @tom_l. I have been trying to figure this out for 2 weeks. Rearranging as a binary did the job! I actually understand this too. I will read up on post formatting… Once again, thank you so much