From fb695ac6663574ce28ed2547d6fcefbe17181fed Mon Sep 17 00:00:00 2001 From: Alexey Vlasov Date: Fri, 16 Oct 2020 18:53:17 +0700 Subject: [PATCH] Add support of mileage_CAN parameter Mileage_CAN will be used if supported. --- custom_components/pandora_cas/api.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/custom_components/pandora_cas/api.py b/custom_components/pandora_cas/api.py index a57340e..b3e0ee8 100644 --- a/custom_components/pandora_cas/api.py +++ b/custom_components/pandora_cas/api.py @@ -282,6 +282,16 @@ def fuel_tank(self) -> int: """Get the capacity of fuel tank.""" return int(self._info["fuel_tank"]) + @property + def mileage(self) -> float: + """Get the mileage.""" + + # mileage_CAN will be used if supported + if self._attributes["mileage_CAN"] > 0: + return float(self._attributes["mileage_CAN"]) + + return float(self._attributes["mileage"]) + @property def device_info(self) -> dict: """Unified device info dictionary."""