Calculate Fuel consumption based on distance travelled

Zuo Bruno6 years ago

This has been a big question here on Traccar. So my device does not measure fuel consumption, but since I am using traccar for personal use, I would like to view fuel consumption on the summary reports tab based on the distance the car has moved, Say for example my car consumes 17 Litre for every 100 KM, I want to see the report on the Reports Summary, right now all I see is 0.l

How can I go about this @Anton.
Thank you

Anton Tananaev6 years ago

Traccar need fuel level attribute to calculate fuel usage. You can use computed attributes to convert distance into a virtual fuel level value.

Zuo Bruno6 years ago

Thanks, @Anton, Please I need to know two things
1- Will computed attributes show up in reports for fuel consumption?
2- Please can you help me with code for the computed attribute? (I know you hate such questions) but I am stuck here please.

Thank you

Anton Tananaev6 years ago
  1. Yes.
  2. Something like this:
9999999 - 17 * totalDistance / 100000
Zuo Bruno6 years ago

Hello @Anton, using the information sent to me, I have tried to apply this. I added it as a computed attributes to the admin section and gave the attribute to devices, however, when making summary report, fuel spent still shows 0.I which is kind of a problem

do you know how I can use your formula:

9999999 - 17 * totalDistance / 100000

so that I get some figures when getting reports?

Anton Tananaev6 years ago

Do you see fuel attribute in state? If not, it means that you have misconfigured something.

Zuo Bruno6 years ago

Hello @Anton, I think you are asking if I see fuel when adding the attribute, yes i see Fuel and Fuel Consumption, I have switched from Fuel consumption to just Fuel now. will this work? if this is not what you are asking,I am sorry but I have failed to understand you well

Anton Tananaev6 years ago

How about you test it first and tell us if it works or not.

Zuo Bruno6 years ago

Will test it for 2 days and let you know @Anton, Many Thanks

Zuo Bruno6 years ago

Good day @Anton, I have taken 2 days to check how fuel consumption will work but unfortunately, it does not work for me. I created computed Attribute with following details

Attribute: "fuel",
Expression: 9999999 - 17 * totalDistance / 100000,
Type: Number

I then attributed this to devices and waited for 2 days, the device summary shows everything in order but spent fuel shows 0.0l (0.0 Liters)
I am using the gt06 protocol. am I doing something wrong?
Once more thanks for your help in advance.

Anton Tananaev6 years ago

What values do you see in status?

Zuo Bruno6 years ago

All I get in Status @Anton is 0.0l

Anton Tananaev6 years ago

Then there must be some issue with your computed attribute.

I tried this i got some values Fuel: 9998099.4 l while Total Distance: 11174.30 km but i'm looking to capture fuel consumed on movement, any ideas.

Anton Tananaev6 years ago

That seems like expected value. Now you should see something reasonable in reports.