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

All sensor states report Unavailable #848

Closed stintov closed 3 months ago

stintov commented 4 months ago

Please check Services, Known Bug / Issues and Troubleshooting over here first: https://github.com/fuatakgun/kia_uvo/blob/master/README.md Region and Brand of car EU Kia EV9 Version of the integration 2.22.0

Describe the bug All sensor states report Unavailable

Screenshots If applicable, add screenshots to help explain your problem. image

Additional context The itegration has been working fine for over a week, but today for no reason all the sensors report "Unavailable" A restart of HA has not helped. The Kia Connect mobile app is working fine.

renatkh commented 3 months ago

Same here. My integration failed to setup. When I turn on debugging and reload the integration, I can see that it successfully logs in, reads sensor data at towards the end of the logs I see this

2024-03-19 00:11:33.514 DEBUG (SyncWorker_2) [hyundai_kia_connect_api.KiaUvoAPIUSA] hyundai_kia_connect_api - last_updated_at - after 2024-03-18 23:13:55+00:00
2024-03-19 00:11:33.514 DEBUG (SyncWorker_2) [hyundai_kia_connect_api.KiaUvoAPIUSA] hyundai_kia_connect_api - SOC Levels couldn't be found. May not be an EV.
2024-03-19 00:11:33.514 DEBUG (SyncWorker_2) [hyundai_kia_connect_api.KiaUvoAPIUSA] hyundai_kia_connect_api - last_updated_at - before 20240318231355
2024-03-19 00:11:33.514 DEBUG (SyncWorker_2) [hyundai_kia_connect_api.KiaUvoAPIUSA] hyundai_kia_connect_api - last_updated_at - after 2024-03-18 23:13:55+00:00
2024-03-19 00:11:35.511 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 5.183 seconds (success: False)
renatkh commented 3 months ago

This issue may be a duplicate of #837

damz commented 3 months ago

I haven't investigated why yet, but it seems like it is the Geocoding API that is silently failing. Can you try to disable the "Enable Geolocation Entity using OpenStreetMap" option in the integration configuration?

Here is a stack trace that I got by adding logging into HyundaiKiaConnectDataUpdateCoordinator._async_update_data (it seems like Home Assistant swallows exceptions happening in executor jobs?), it is failing inside update_geocoded_location, presumably because of a bogus API response.

Update failed: Expecting value: line 1 column 1 (char 0)
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/requests/models.py", line 971, in json
    return complexjson.loads(self.text, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/simplejson/__init__.py", line 514, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/simplejson/decoder.py", line 386, in decode
    obj, end = self.raw_decode(s)
               ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/simplejson/decoder.py", line 416, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/config/custom_components/kia_uvo/coordinator.py", line 113, in _async_update_data
    await self.hass.async_add_executor_job(
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 80, in update_all_vehicles_with_cached_state
    self.update_vehicle_with_cached_state(vehicle_id)
  File "/usr/local/lib/python3.12/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 87, in update_vehicle_with_cached_state
    self.api.update_geocoded_location(
  File "/usr/local/lib/python3.12/site-packages/hyundai_kia_connect_api/ApiImpl.py", line 98, in update_geocoded_location
    response = response.json()
               ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/requests/models.py", line 975, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
csmracing commented 3 months ago

I haven't investigated why yet, but it seems like it is the Geocoding API that is silently failing. Can you try to disable the "Enable Geolocation Entity using OpenStreetMap" option in the integration configuration?

I started experiencing this same problem within the last 24-48 hours. As suggested, I disabled "Enable Geolocation Entity using OpenStreetMap" and now the integration is working again.

alexwhittemore commented 3 months ago

Same experience: the integration stopped providing entities yesterday midday, about 24h ago, and disabling the geolocation entity config option immediately recovered normal operation.

renatkh commented 3 months ago

Yes, disabling geolocation fixed the issue. Thanks @damz!

Legrand5382 commented 3 months ago

Same here, i disabled geolocation and now everything is fine 😊

cdnninja commented 3 months ago

After you disable geolocation is lat long look correct? When I manually test the geolocation API it has no issue.

Here is an example API call to geo location: https://[nominatim.openstreetmap.org/reverse?lat=57&lon=-112&format=json&addressdetails=1&zoom=18&](https://nominatim.openstreetmap.org/reverse?lat=57&lon=-112&format=json&addressdetails=1&zoom=18&)

alexwhittemore commented 3 months ago

Yes- the lag long entity remains accurate and up to date.

przemekp833 commented 3 months ago

excuse me guys, quite new with HA. How do I disable the "Enable Geolocation Entity using OpenStreetMap" option in the integration configuration? :) thanks

alexwhittemore commented 3 months ago

excuse me guys, quite new with HA. How do I disable the "Enable Geolocation Entity using OpenStreetMap" option in the integration configuration? :) thanks

Settings>Devices>Hyundai/Kia Connect, then on the one line that should exist for your kia account, click "Configure"

Uncheck "Enable Geolocation Entity using OpenStreetMap"

And don't feel bad, HA's UI can be desperately confusing if you don't already know all the implementation details of what you're trying to do, and sometimes if you do ;)

cdnninja commented 3 months ago

Looks like we have two thread on this. I put code in for lat Lon protection. I could use debug logs from someone who has functional location entity to understand what's happening here.

cdnninja commented 3 months ago

Lets track this in #853

przemekp833 commented 3 months ago

Thanks for the information. I found it, but to be my surprise it was already unchecked and the integration is still not working, whether its checked or unchecked. Do you have any suggestions where to look further? Thanks