Hyundai-Kia-Connect / hyundai_kia_connect_api

This is a Kia UVO and Hyundai Bluelink written in python. It is primary consumed by home assistant. If you are looking for a home assistant Kia / Hyundai implementation please look here: https://github.com/Hyundai-Kia-Connect/kia_uvo. Much of this base code came from reading bluelinky and contributions to the kia_uvo home assistant project.
MIT License
123 stars 71 forks source link

API Rate Limit or 24h "bug"? #35

Closed Empor-co closed 2 years ago

Empor-co commented 2 years ago

Description

My MQTT loop runs fine for 24h + ~13 mins, but after that I don't receive any update anymore. My loop sleeps for 10 mins between updates resulting in about 144 requests/24h which should leave enough headroom for "manual" bluelink app usage and start_climat calls.

I works again after restarting my script.

Any ideas?

What I Did

Traceback (most recent call last):
  File "/home/user/PycharmProjects/bluelinx/main.py", line 152, in <module>
    update_data()
  File "/home/user/PycharmProjects/bluelinx/main.py", line 39, in update_data
    vm.check_and_force_update_vehicles(600)
  File "/home/user/PycharmProjects/bluelinx/venv/lib/python3.10/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 74, in check_and_force_update_vehicles
    self.update_vehicle_with_cached_state(vehicle)
  File "/home/user/PycharmProjects/bluelinx/venv/lib/python3.10/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 61, in update_vehicle_with_cached_state
    self.api.update_vehicle_with_cached_state(self.token, vehicle)
  File "/home/user/PycharmProjects/bluelinx/venv/lib/python3.10/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 171, in update_vehicle_with_cached_state
    state = self._get_cached_vehicle_state(token, vehicle)
  File "/home/user/PycharmProjects/bluelinx/venv/lib/python3.10/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 312, in _get_cached_vehicle_state
    return response["resMsg"]["vehicleStatusInfo"]
KeyError: 'resMsg'
cdnninja commented 2 years ago

It does appear you are hitting the rate limit but probably will need debug level enabled on the package to confirm. I am not familiar how to do that straight in python. We run cached updates every 30 with certain forced updates in a select window. Maybe try lower the frequency to see if that helps? As well are you just calling for cached status or also force update at that rate as the force update I think consumes two calls.

Here is the closest we have on the rate limit documentation. https://github.com/Hacksore/bluelinky/wiki/API-Rate-Limits