diff --git a/custom_components/audiconnect/audi_connect_account.py b/custom_components/audiconnect/audi_connect_account.py index 214f1607..fe0f941e 100644 --- a/custom_components/audiconnect/audi_connect_account.py +++ b/custom_components/audiconnect/audi_connect_account.py @@ -444,11 +444,11 @@ async def update_vehicle_statusreport(self): raise except ClientResponseError as resp_exception: if resp_exception.status == 403 or resp_exception.status == 502: - _LOGGER.error( - "support_status_report set to False: {status}".format( - status=resp_exception.status - ) - ) + #_LOGGER.error( + # "support_status_report set to False: {status}".format( + # status=resp_exception.status + # ) + #) self.support_status_report = False else: self.log_exception_once( @@ -493,11 +493,11 @@ async def update_vehicle_position(self): raise except ClientResponseError as resp_exception: if resp_exception.status == 403 or resp_exception.status == 502: - _LOGGER.error( - "support_position set to False: {status}".format( - status=resp_exception.status - ) - ) + #_LOGGER.error( + # "support_position set to False: {status}".format( + # status=resp_exception.status + # ) + #) self.support_position = False # If error is 204 is returned, the position is currently not available elif resp_exception.status != 204: @@ -537,11 +537,11 @@ async def update_vehicle_climater(self): raise except ClientResponseError as resp_exception: if resp_exception.status == 403 or resp_exception.status == 502: - _LOGGER.error( - "support_climater set to False: {status}".format( - status=resp_exception.status - ) - ) + #_LOGGER.error( + # "support_climater set to False: {status}".format( + # status=resp_exception.status + # ) + #) self.support_climater = False else: self.log_exception_once( @@ -574,11 +574,11 @@ async def update_vehicle_preheater(self): raise except ClientResponseError as resp_exception: if resp_exception.status == 403 or resp_exception.status == 502: - _LOGGER.error( - "support_preheater set to False: {status}".format( - status=resp_exception.status - ) - ) + #_LOGGER.error( + # "support_preheater set to False: {status}".format( + # status=resp_exception.status + # ) + #) self.support_preheater = False else: self.log_exception_once( @@ -663,11 +663,11 @@ async def update_vehicle_charger(self): raise except ClientResponseError as resp_exception: if resp_exception.status == 403 or resp_exception.status == 502: - _LOGGER.error( - "support_charger set to False: {status}".format( - status=resp_exception.status - ) - ) + #_LOGGER.error( + # "support_charger set to False: {status}".format( + # status=resp_exception.status + # ) + #) self.support_charger = False else: self.log_exception_once( @@ -1174,24 +1174,31 @@ def energy_flow_supported(self): def max_charge_current(self): """Return max charge current""" if self.max_charge_current_supported: - return parse_float(self._vehicle.state.get("maxChargeCurrent")) + try: + return parse_float(self._vehicle.state.get("maxChargeCurrent")) + except ValueError: + return -1 @property def max_charge_current_supported(self): check = self._vehicle.state.get("maxChargeCurrent") - if check and parse_float(check): + if check is not None: return True @property def actual_charge_rate(self): """Return actual charge rate""" if self.actual_charge_rate_supported: - return parse_float(self._vehicle.state.get("actualChargeRate")) + try: + return parse_float(self._vehicle.state.get("actualChargeRate")) + except ValueError: + return -1 + @property def actual_charge_rate_supported(self): check = self._vehicle.state.get("actualChargeRate") - if check and parse_float(check): + if check is not None: return True @property @@ -1207,12 +1214,15 @@ def actual_charge_rate_unit(self): def charging_power(self): """Return charging power""" if self.charging_power_supported: - return parse_int(self._vehicle.state.get("chargingPower")) / 1000 + try: + return parse_int(self._vehicle.state.get("chargingPower")) / 1000 + except ValueError: + return -1 @property def charging_power_supported(self): check = self._vehicle.state.get("chargingPower") - if check and parse_int(check): + if check is not None: return True @property diff --git a/custom_components/audiconnect/audi_entity.py b/custom_components/audiconnect/audi_entity.py index f1885cff..43e53788 100644 --- a/custom_components/audiconnect/audi_entity.py +++ b/custom_components/audiconnect/audi_entity.py @@ -77,6 +77,5 @@ def device_info(self): "identifiers": {(DOMAIN, self._instrument.vehicle_name)}, "manufacturer": "Audi", "name": self._vehicle_name, - "device_type": self._component, "model": self._instrument.vehicle_model_family, } diff --git a/custom_components/audiconnect/audi_services.py b/custom_components/audiconnect/audi_services.py index e0e0bc5c..c3a42fc3 100644 --- a/custom_components/audiconnect/audi_services.py +++ b/custom_components/audiconnect/audi_services.py @@ -310,7 +310,8 @@ async def get_tripdata(self, vin: str, kind: str): ) td_current = td_sorted[0] - td_reset_trip = None + # FIX, TR/2023-03-25: Assign just in case td_sorted contains only one item + td_reset_trip = td_sorted[0] for trip in td_sorted: if (td_current["startMileage"] - trip["startMileage"]) > 2: diff --git a/custom_components/audiconnect/device_tracker.py b/custom_components/audiconnect/device_tracker.py index 6fa3f668..9b286f16 100644 --- a/custom_components/audiconnect/device_tracker.py +++ b/custom_components/audiconnect/device_tracker.py @@ -121,7 +121,6 @@ def device_info(self): "identifiers": {(DOMAIN, self._instrument.vehicle_name)}, "manufacturer": "Audi", "name": self._vehicle_name, - "device_type": "device_tracker", } @property