Car Travel Log / Car Mileage Log Blueprint

Description

This blueprint automatically logs the start and end of your car trips when your phone connects/disconnects from your car’s Bluetooth. It saves trip data like time, location, and Waze-estimated travel duration to a Google Sheet.

It requires:

  • Companion App with Bluetooth and Geolocation sensors enabled
  • Waze Travel Time integration
  • Google Sheets integration

:package: Requirements

  1. Bluetooth Binary Sensor
    Create a Template Binary Sensor that detects when your phone is connected to your car.

  2. Helpers

  • input_text helpers for start time, start location, end location, etc.
  1. Integrations
  • Waze Travel Time
  • Google Sheets
  1. Device Tracker & Geolocation
    Use the Companion App’s device_tracker and sensor.geocoded_location.

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.


:hammer_and_wrench: Setup Instructions

  • Create the required Helpers (input_text)
  • Enable Companion App sensors
  • Setup Google Sheets + find your config_entry_id
  • Configure Waze Travel Time (region, units, vehicle type, etc.)
  • Replace placeholder values in the Blueprint inputs

:world_map: Example Use Case

Log every work commute automatically into a spreadsheet with time, address, and travel data.
We needed to log when the car was used for work to claim this for tax, this is why I made this automation.

Note:

Any change to the value of the latitude and longitude action, will likely break your automation.

:clipboard: Blueprint YAML

blueprint:
  name: Car Travel Log
  description: >
    Tracks the start and end of car trips based on Bluetooth connection events.
    Logs time, location, and Waze-estimated travel data to Google Sheets.
    Requires: Waze Travel Time, Google Sheets, Companion App location and Geolocation sensors.
  domain: automation
  input:
    bluetooth_sensors:
      name: Bluetooth Trigger Sensors
      description: >
        A **Template Binary Sensor** that becomes `on` when your phone is connected to any of your car's Bluetooth devices.
        
        This sensor is created using the Companion App’s Bluetooth sensor, which shows the list of connected
        Bluetooth devices under the `connected_paired_devices` attribute.

        👉 **Steps to create it:**
        1. Go to: **Settings > Devices & Services > Helpers > Create Helper**
        2. Choose: **Template Binary Sensor**
        3. Name it something like: `Garage Car Bluetooth`
        4. Set the template like this:
          
          {{ 'A8:54:B2:F4:C1:98 (Skoda_VR)' in state_attr('sensor.name_phone_bluetooth_connection','connected_paired_devices') or
          'A8:41:F4:0A:EE:3A (AndroidAuto-ee3b)' in state_attr('sensor.name_phone_bluetooth_connection','connected_paired_devices') or
          '00:92:A5:3E:30:47 (Kia)' in state_attr('sensor.name_phone_bluetooth_connection','connected_paired_devices') }}
          

        📌 Replace each MAC/name string above with your actual car’s Bluetooth identifier. You can find these by:
        - Enabling the Bluetooth Connections sensor in the **Companion App** (`Settings > Companion App > Sensors > Bluetooth Connections`)
        - Viewing the attribute `connected_paired_devices` under your phone’s Bluetooth sensor (e.g., `sensor.name_phone_bluetooth_connection`) in Developer Tools > States.

        You can add as many cars as needed by chaining more `or` conditions following the same format.
      selector:
        entity:
          domain: binary_sensor
          multiple: true
    device_tracker:
      name: Device Tracker
      description: Device tracker for location and speed
      selector:
        entity:
          domain: device_tracker
    geocoded_sensor:
      name: Geocoded Location Sensor
      description: Sensor with the current location in text
      selector:
        entity:
          domain: sensor
    text_trip_start_time:
      name: Input Text - Trip Start Time
      description: Create a Text Helper for Trip Start Time
      selector:
        entity:
          domain: input_text
    text_trip_start_location:
      name: Input Text - Trip Start Lat,Lon
      description: Create a Text Helper for Trip Start Location
      selector:
        entity:
          domain: input_text
    text_trip_start_address:
      name: Input Text - Trip Start Address
      description: Create a Text Helper for Trip Start Address
      selector:
        entity:
          domain: input_text
    text_trip_end_location:
      name: Input Text - Trip End Lat,Lon
      description: Create a Text Helper for Trip End Location
      selector:
        entity:
          domain: input_text
    google_sheets_config_entry:
      name: Google Sheets Config Entry ID
      description: >
        Paste your Google Sheets config_entry ID.
        Find it under `.storage/core.config_entries` or Developer Tools > Services > `google_sheets.append_sheet`.
      selector:
        text:
    google_sheets_worksheet:
      name: Google Sheets Worksheet Name
      description: >
        The name of the sheet tab at the bottom of the Google Sheet (default file: "Home Assistant").
      default: Travel Log
      selector:
        text:
    waze_region:
      name: Waze Region
      description: Controls which Waze server is used
      default: au
      selector:
        select:
          options:
            - us
            - na
            - eu
            - il
            - au
    waze_units:
      name: Waze Units
      description: Unit system to use
      default: metric
      selector:
        select:
          options:
            - metric
            - imperial
    waze_vehicle_type:
      name: Waze Vehicle Type
      description: Vehicle type for routing
      default: car
      selector:
        select:
          options:
            - car
            - motorcycle
            - taxi
            - truck
    waze_real_time:
      name: Real-Time Travel Time
      description: Use real-time or statistical data
      default: true
      selector:
        boolean: {}
    waze_avoid_toll_roads:
      name: Avoid Toll Roads
      description: Whether to avoid toll roads
      default: false
      selector:
        boolean: {}
    waze_avoid_ferries:
      name: Avoid Ferries
      description: Whether to avoid ferries
      default: false
      selector:
        boolean: {}
    waze_avoid_vignette_roads:
      name: Avoid Vignette Roads
      description: Whether to avoid subscription roads
      default: false
      selector:
        boolean: {}
    allowed_days:
      name: Allowed Days
      description: Only run the automation on these days
      default:
        - monday
        - tuesday
        - wednesday
        - thursday
        - friday
        - saturday
        - sunday
      selector:
        select:
          multiple: true
          mode: list
          options:
            - monday
            - tuesday
            - wednesday
            - thursday
            - friday
            - saturday
            - sunday
trigger:
  - platform: state
    entity_id: !input bluetooth_sensors
    to: "on"
    id: Car On
  - platform: state
    entity_id: !input bluetooth_sensors
    from: "on"
    to: "off"
    id: Car Off

variables:
  selected_days: !input allowed_days

condition:
  - condition: template
    value_template: >
      {% set days = selected_days if selected_days is iterable and selected_days is not string else [selected_days] %}
      {{ now().strftime('%A') | lower in days }}


action:
  - variables:
      tracker: !input device_tracker
      geocoded: !input geocoded_sensor
      start_time: !input text_trip_start_time
      start_location: !input text_trip_start_location
      start_address: !input text_trip_start_address
      end_location: !input text_trip_end_location
  - choose:
      - conditions:
          - condition: trigger
            id: Car On
        sequence:
          - service: input_text.set_value
            target:
              entity_id: !input text_trip_start_time
            data:
              value: "{{ now().strftime('%Y-%m-%d %H:%M:%S') }}"
          - service: input_text.set_value
            target:
              entity_id: !input text_trip_start_location
            data:
              value: >
                {{ state_attr(tracker, 'latitude') }}, {{ state_attr(tracker, 'longitude') }}
          - service: input_text.set_value
            target:
              entity_id: !input text_trip_start_address
            data:
              value: "{{ states(geocoded) }}"
      - conditions:
          - condition: trigger
            id: Car Off
          - condition: template
            value_template: >
              {{ state_attr(tracker, 'speed') | float(0) == 0 }}
        sequence:
          - service: input_text.set_value
            target:
              entity_id: !input text_trip_end_location
            data:
              value: >
                {{ state_attr(tracker, 'latitude') }}, {{ state_attr(tracker, 'longitude') }}
          - delay:
              seconds: 1
          - service: waze_travel_time.get_travel_times
            data:
              origin: "{{ states(start_location) }}"
              destination: "{{ states(end_location) }}"
              region: !input waze_region
              units: !input waze_units
              vehicle_type: !input waze_vehicle_type
              realtime: !input waze_real_time
              avoid_toll_roads: !input waze_avoid_toll_roads
              avoid_ferries: !input waze_avoid_ferries
              avoid_subscription_roads: !input waze_avoid_vignette_roads
            response_variable: travel
          - delay:
              minutes: 1
          - service: google_sheets.append_sheet
            data:
              config_entry: !input google_sheets_config_entry
              worksheet: !input google_sheets_worksheet
              data:
                Start Time: "{{ states(start_time) }}"
                Start Address: "{{ states(start_address) }}"
                EndTime: "{{ now().strftime('%Y-%m-%d %H:%M:%S') }}"
                Duration: "{{ travel.routes[0].duration | round(1) }} mins"
                Distance: "{{ travel.routes[0].distance | round(2) }} km"
                End Address: "{{ states(geocoded) }}"

mode: single