diff --git a/packages/modules/vehicles/vweuda/libeuda.py b/packages/modules/vehicles/vweuda/libeuda.py index 45c5fe4064..dba893773a 100755 --- a/packages/modules/vehicles/vweuda/libeuda.py +++ b/packages/modules/vehicles/vweuda/libeuda.py @@ -803,19 +803,18 @@ def update_result_from_payload(self, payload: dict, source: str) -> dict: if result['soc'] is None: _LOGGER.info("thread result skipped, no soc found") _valid = False + if _valid and result['odometer'] is not None: + if vin in euda.result and result['odometer'] < euda.result[vin]['odometer']: + _LOGGER.info("odometer less than earlier - keep earlier value") + result['odometer'] = euda.result[vin]['odometer'] + euda.result[vin] = result + _LOGGER.info("thread result is valid") else: - _LOGGER.info(f"no matching VIN found in euda.result:\npayload.vin: ({vin})") - _LOGGER.info(f"known VINs in euda.result:\n{euda.result.keys()}") - - if _valid and result['odometer'] is not None: - if vin in euda.result and result['odometer'] < euda.result[vin]['odometer']: - _LOGGER.info("odometer less than earlier - keep earlier value") - result['odometer'] = euda.result[vin]['odometer'] euda.result[vin] = result - _LOGGER.info("thread result is valid") + _LOGGER.info(f"new VIN {ano_vin(vin)} initialized in euda.result") _ano_j = {ano_vin(vin): euda.result[vin]} - _LOGGER.info(f"\n{json.dumps(_ano_j, indent=4)}") + _LOGGER.info(f"new cache result:\n{json.dumps(_ano_j, indent=4)}") return result