You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I had the same issue, so I investigated and found out what the root cause is. The Drivvo API returns that higher number as the general average, because it calculates with the total volume including the last refuelling, but that's not correct, because the last tank of gas is not yet consumed (at the point of making the last log in the app anyway), so it shouldn't be included in the calculation. The good thing is that the integration returns (almost) everything that we need to calculate the correct value, so the correct formula for the data that we have access to is: (Total volume refuelings - Last refueling volume) / (Total volume refuelings * General fuel average) * 100. So I just created a template sensor with this template:
{% set entity_id = 'sensor.new_refuellings' %}
{% set total_volume = state_attr(entity_id, 'refuelling_volume_total') %}
{% set last_volume = state_attr(entity_id, 'refuelling_volume') %}
{% set drivvo_average = state_attr(entity_id, 'media_geral') %}
{{ (total_volume - last_volume) / (total_volume * drivvo_average) * 100 }}
By the way, this calculation results in the value being L/100 km, so if you want the original km/L unit, you need to change the formula to (Total volume refuelings * General fuel average) / (Total volume refuelings - Last refueling volume).
When doing the app analysis, and the sensor attribute analysis, I noticed that the overall average is not the same as what it shows in the app.
General average showing the value of 7.17 km/L

General average showing the value of 2.90 km/L
The text was updated successfully, but these errors were encountered: