Hyundai-Kia-Connect / kia_uvo

A Home Assistant HACS integration that supports Kia Connect(Uvo) and Hyundai Bluelink. The integration supports the EU, Canada and the USA.
MIT License
391 stars 81 forks source link

KeyError: 'calculativeOdo' since latest update #842

Closed ridderr closed 3 months ago

ridderr commented 4 months ago

Region and Brand of car KIA Sportage - Europe

Version of the integration V2.22.0

Describe the bug There are bugs reported in the log (see below)

Debug logs if an error occurred

Logger: hyundai_kia_connect_api.KiaUvoApiEU
Source: /usr/local/lib/python3.12/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py:362
First occurred: 17:04:54 (4 occurrences)
Last logged: 19:05:27

Failed to parse driving info. Possible reasons: - incompatible vehicle (ICE) - new API format - API outage
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 357, in update_vehicle_with_cached_state
    state = self._get_driving_info(token, vehicle)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 1382, in _get_driving_info
    and drivingInfoItem["calculativeOdo"] > 0
        ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
KeyError: 'calculativeOdo'

To Reproduce Reported after each update with data from car

cdnninja commented 4 months ago

What year of car? Is it a phev?

ridderr commented 4 months ago

Car build 2023 and it is a phev

ridderr commented 4 months ago

Hi @cdnninja , I have added some debug information. Maybe this helps.

home-assistant_kia_uvo_2024-02-26T18-58-05.423Z.log

cdnninja commented 4 months ago

Does native app show driving stats?

ridderr commented 4 months ago

Is this what you're looking for? Screenshot_20240226_210424_Kia Connect

hmmbob commented 4 months ago

Seeing the same error with my PHEV, and only since last update.

elden1337 commented 4 months ago

+1.

Perhaps this https://github.com/Hyundai-Kia-Connect/hyundai_kia_connect_api/blob/31182c658d7638ac37524f4f08590a4ac42068f0/hyundai_kia_connect_api/KiaUvoApiEU.py#L1382C21-L1382C62

if (
      drivingInfoItem["drivingPeriod"] == 0
      and drivingInfoItem["calculativeOdo"] > 0
    ):

can be changed to:

if (
    drivingInfoItem["drivingPeriod"] == 0 
    and next((v for k, v in drivingInfoItem.items() if k.lower() == "calculativeodo"), 0) > 0
    ):

In that case we would atleast not have it raise on comparing it. The data would still lack of course, so if the issue lies elsewhere and the api is supposed to ship that info to all vehicles then please ignore this comment.

cazzoo commented 4 months ago

I have the same error in HA with a Kia xCeed PHEV 2020

pdcleyn commented 3 months ago

+1

elden1337 commented 3 months ago

pr for eu-api published ^

elden1337 commented 3 months ago

should be fine now @ridderr if you update to latest. please check and verify.