Creating template sensor incremental_total from Torque sensors

Hi,
I’m using Torque - Home Assistant to track my car gas and distance.
The problem is that the sensor resets to zero at the beginning of each trip, so it only reports the ‘per trip’ values, going back to zero.
I want to have a sensor of the accumulated distance and gas usage.
For that, i created the following template sensor: Template - Home Assistant

- sensor:
    - unique_id: 'mycar_fuel_used_total'
      name: "MyCar Fuel Total Consumed"
      state: "{{ (states('sensor.mycar_fuel_used_trip')|float(default=0)) }}"
      unit_of_measurement: "L"
      icon: "mdi:gauge"
      state_class: total_increasing
      device_class: volume

With special emphasis on the ‘total_increasing’ which, per definition, should identify that when the value drops below the previous one it means is a ‘reset’ and should account to be adding it up to the recurring total. Sensor Entity | Home Assistant Developer Docs

Statistics of the accumulated growth of the sensor’s value since it was first added is updated every 5 minutes.

However, my sensor is not calculating the accumulated growth, when the underlying sensors goes back to zero, the new template sensor goes back to zero as well.

  • Any idea why this is not working? I’m using the wrong sensor type maybe?

Thanks.

Use a utility meter helper. It will only count up (as long as you do not set it to net metering).

I looked at it, but i asks me about a ‘cycle’ which i can’t tell because it won’t be regular as it depends when the car is used.

  • Will it identify the ‘drops’ as a cycle restart?

Thanks.

Cycle is optional. Don’t specify one and it counts up forever.

It will ignore drops.

1 Like

Seems like the UI helper did the trick. Yet I don’t understand why the YAML version did not work.

Now the doubt I have is wether there’s any way to increase the counter state value to a specific number manually, and let it grow from there. So that I can manually set it to the cars builtin counter.

Thanks.

Sure there is. Use the utility meter calibrate service in Dev Tools Services.

1 Like