You will get highly inaccurate estimates using this method.
Thank you for the clarification.
My device provides a real odometer value in kilometers (not meters).
So my intention is to calculate estimated fuel consumption based on the difference between odometer values and the vehicle’s average consumption (km per liter).
For example:
• Odometer unit: kilometers
• Average consumption: 10 km/l
Expected formula:
(deltaOdometer) / 10
However, I’m still not getting consistent results using computed attributes.
Is there a correct way in Traccar to reference the previous odometer value inside a computed attribute?
Or would this require processing externally via API?
Any recommendation to improve this manual estimation would be appreciated.
Thank you.

What is deltaOdometer?
Sorry, that was a typo.
I meant the difference between two odometer readings (current odometer minus previous odometer).
Since my device provides odometer in kilometers, I was trying to calculate fuel consumption like this:
(currentOdometer - previousOdometer) / averageConsumption
For example:
If odometer increases 50 km and the vehicle average is 10 km/l:
50 / 10 = 5 liters
However, I understand now that computed attributes may not have access to the previous odometer value.
Is there a recommended way to calculate this inside Traccar?
Thank you.
So have you actually tried this? Because the formula is definitely incorrect.
Yes, I tested different approaches.
I tried using the odometer value (which is provided in kilometers by the device), and I also tested using Traccar’s distance attribute.
For example:
Using distance:
distance / 10
And also converting units when needed.
However, the results are still inconsistent, especially when comparing with real fuel usage.
My goal is only to create a manual estimation (I understand it won’t be 100% accurate).
What would be the recommended way to improve this estimation inside Traccar?
Thank you.
What is the result you're getting from the following formula?
(currentOdometer - previousOdometer) / averageConsumption
From what I understand now:
The correct way to estimate fuel usage would be:
(currentOdometer - previousOdometer) / averageConsumption
This would calculate fuel based on the actual distance traveled between two positions.
However, in Traccar computed attributes, I only have access to the current odometer value. There doesn’t seem to be a way to reference the previous odometer value inside the expression.
When I try:
odometer / 10
It only returns a large accumulated value (total estimated fuel since the vehicle started operating), which is not what I want.
So my understanding is:
• The formula concept is correct.
• But computed attributes do not maintain state between positions.
• Therefore, calculation is not directly possible there.
Is my understanding correct?
Thank you.
You can get the last odometer value, so I don't understand why you're not trying your correct concept.
Hello,
I would like to calculate fuel consumption manually using a computed attribute.
My goal is to estimate fuel usage based on distance traveled, since my device does not provide fuel level data.
For example:
Vehicle average consumption: 10 km per liter
Distance from trip: distance attribute
I was thinking about something like:
distance / 10
Would this be the correct approach to calculate estimated fuel consumption in liters?
Is there a recommended way in Traccar to:
Calculate fuel used per trip?
Accumulate total estimated fuel consumption?
Store this as a persistent attribute?
Thank you!