Skip to content

Commit

Permalink
Fixes calculation of the last fuel average
Browse files Browse the repository at this point in the history
  • Loading branch information
dougiteixeira committed Apr 29, 2023
1 parent 3c0415e commit 63318e2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions custom_components/drivvo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,17 +272,17 @@ def sort_by_key(list):
odometer_init = odometer["odometro"]

if odometer_init is not None:
if odometer["volume"] != 0:
volume = odometer["volume"]
else:
volume = odometer["valor_total"] / odometer["preco"]

if (odometer["tanque_cheio"]) and (
odometer["odometro"] != odometer_init
):
odometer_old = odometer["odometro"]
break

if odometer["volume"] != 0:
volume += odometer["volume"]
else:
volume += odometer["valor_total"] / odometer["preco"]

if volume > 0 and odometer_old is not None:
refuelling_last_average = (
refuellings_odometers[0]["odometro"] - odometer_old
Expand Down
2 changes: 1 addition & 1 deletion custom_components/drivvo/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
"iot_class": "cloud_polling",
"issue_tracker": "https://github.com/hudsonbrendon/sensor.drivvo/issues",
"requirements": [],
"version": "1.0.5"
"version": "1.0.6"
}

0 comments on commit 63318e2

Please sign in to comment.