kia_uvo icon indicating copy to clipboard operation
kia_uvo copied to clipboard

KeyError: 'calculativeOdo' since latest update

Open ridderr opened this issue 1 year ago • 6 comments

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

ridderr avatar Feb 25 '24 18:02 ridderr

What year of car? Is it a phev?

cdnninja avatar Feb 26 '24 05:02 cdnninja

Car build 2023 and it is a phev

ridderr avatar Feb 26 '24 06:02 ridderr

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

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

ridderr avatar Feb 26 '24 19:02 ridderr

Does native app show driving stats?

cdnninja avatar Feb 26 '24 20:02 cdnninja

Is this what you're looking for? Screenshot_20240226_210424_Kia Connect

ridderr avatar Feb 26 '24 20:02 ridderr

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

hmmbob avatar Feb 27 '24 17:02 hmmbob

+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.

elden1337 avatar Mar 06 '24 11:03 elden1337

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

cazzoo avatar Mar 12 '24 09:03 cazzoo

+1

pdcleyn avatar Mar 16 '24 17:03 pdcleyn

pr for eu-api published ^

elden1337 avatar Mar 17 '24 06:03 elden1337

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

elden1337 avatar Mar 25 '24 08:03 elden1337