A Home Assistant custom integration that tracks leased vehicle mileage against your contract terms. It calculates whether you are over or under your allowed mileage and what that means financially, so you can stay on top of your lease without surprises.
- Tracks usage from any absolute odometer sensor (km, miles, or meters)
- Compares used distance against a linear daily contract allowance
- Shows clear plus/minus balance where positive means over quota
- Calculates current and projected overage cost in SEK
- Calculates under-mile refund value in SEK with configurable cap
- Supports contract term versioning and optional early termination date
- Stores daily history internally (not dependent on Recorder)
- Emits events for threshold crossings and stale source detection
- Provides a
rebaselineservice for forward-only odometer correction
The easiest way to install Leasing Mileage Tracker is via HACS (Home Assistant Community Store)
or
- Click on the three dots in the top right corner of the HACS overview menu.
- Select Custom repositories.
- Add the repository URL:
https://github.com/Nicxe/home-assistant-leasing-mileage-tracker. - Select type: Integration.
- Click the ADD button.
Without HACS
- Download the latest release of the Leasing Mileage Tracker integration from GitHub Releases.
- Extract the downloaded files and place the
leasing_mileage_trackerfolder in your Home Assistantcustom_componentsdirectory (usually located in theconfig/custom_componentsdirectory). - Restart your Home Assistant instance to load the new integration.
To add the Leasing Mileage Tracker integration to your Home Assistant instance, use this My button:
Manual Configuration
If the button above does not work, you can also perform the following steps manually:
- Browse to your Home Assistant instance.
- Go to Settings > Devices & Services.
- In the bottom right corner, select the Add Integration button.
- From the list, select Leasing Mileage Tracker.
- Follow the on-screen instructions to complete the setup.
- Odometer sensor - Any sensor with
state_classoftotalortotal_increasingand unitkm,mi, orm - Contract start/end date - Lease contract period
- Contract total km - Total allowed distance over the contract
- Pickup odometer km - Odometer reading at vehicle pickup
- Overage rate - Cost per mil (10 km) when over quota (SEK)
- Underage refund rate - Refund per mil when under quota (SEK)
- Underage refund cap - Maximum refundable distance (mil)
| Entity | Description |
|---|---|
balance_km |
Current balance in km against contract pace. Positive means over quota |
balance_mil |
Same balance converted to mil |
allowed_km_today |
Cumulative km you are allowed to have driven up to today |
used_km |
Cumulative km actually driven since pickup |
remaining_km_to_contract_end |
Remaining km to contract total. Can be negative when over |
daily_quota_km |
Planned quota pace per day from now |
weekly_quota_km |
Planned quota pace per week from now |
monthly_quota_km |
Planned quota pace per month from now |
current_overage_cost_sek |
Current overage cost based on present over-quota distance |
projected_overage_cost_sek |
Projected overage cost at contract end using rolling pace |
avoided_overage_value_sek |
Capped under-mile refund value based on current under-quota distance |
| Entity | Description |
|---|---|
over_quota_now |
On when current balance is above quota tolerance |
projected_over_quota_end |
On when projection indicates overage at contract end |
source_stale |
On when source odometer has not updated for 48 hours |
Applies a forward-only odometer correction and stores an audit record.
| Field | Required | Description |
|---|---|---|
entry_id |
Yes | Config entry ID |
new_odometer_km |
Yes | New odometer reading in km |
note |
No | Optional audit note |
The integration fires events on the Home Assistant event bus when thresholds are crossed:
leasing_mileage_tracker.over_quota_enteredleasing_mileage_tracker.over_quota_clearedleasing_mileage_tracker.projected_overage_enteredleasing_mileage_tracker.projected_overage_clearedleasing_mileage_tracker.source_staleleasing_mileage_tracker.source_recovered
type: entities
title: Leasing status
entities:
- entity: sensor.my_car_balance_km
- entity: sensor.my_car_balance_mil
- entity: sensor.my_car_allowed_km_today
- entity: sensor.my_car_used_km
- entity: binary_sensor.my_car_over_quota_now
- entity: binary_sensor.my_car_projected_over_quota_endtype: entities
title: Cost and refund
entities:
- entity: sensor.my_car_current_overage_cost_sek
- entity: sensor.my_car_projected_overage_cost_sek
- entity: sensor.my_car_avoided_overage_value_sektype: conditional
conditions:
- condition: state
entity: binary_sensor.my_car_over_quota_now
state: "on"
card:
type: markdown
content: |
**Warning:** Current usage is above allowed contract pace.