Dedicated odometer entity type

With the proliferation of tech-equipped cars and e-bikes comes a geek’s desire to track everything related to said vehicles. Many of these integrations already bring in an odometer reading for the vehicle, but they fall prey to default database limitations that keep HA users from getting themselves into trouble.

I’m using a number entity today, which only saves ~10 days of data. This limitation kneecaps its utility as an odometer. A true odometer should:

  • Persist all historical data by default
  • Only allow new values that are >= its current value.

To my knowledge, this is not currently possible in HA without tinkering under the hood in the database settings. It’s certainly out of reach for non-technical users.

There’s real value in seeing historical odometer readings across months and years, even for casual HA users. Creating automations based on metrics like VMTs (vehicle miles traveled) would be slick.

I recognize this creates a narrow opening for well-intentioned power users to shoot themselves in the foot. Surely there are ways to mitigate this.

Thoughts?

A sensor with state_class: total_increasing would keep the sensor values forever in long term statistics. That might satisfy your requirement?

Read up on long term statistics. A properly configured entity/device will not have the dB values purged, ever.

That’s the way the energy dashboard currently retains data, so you don’t really need this feature request

The number entity is the wrong entity type for your requirements. You should use a sensor.

In addition to the advice above there is also already a device_class: distance.

So any sensor with

device_class: distance
state_class: measurement

Will also do what you want.