Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check_and_force_update_vehicles() seems not to work #412

Closed
awenius opened this issue Sep 24, 2023 · 1 comment
Closed

check_and_force_update_vehicles() seems not to work #412

awenius opened this issue Sep 24, 2023 · 1 comment

Comments

@awenius
Copy link

awenius commented Sep 24, 2023

First of all, thanks a lot for the great work on this package!

  • Hyundai / Kia Connect version: 3.9
  • Python version: 3.10
  • Operating System: Windows and Debian Linux

Description

Despite calling check_and_force_update_vehicles(1) the vehicle data is always from the last cached point in time.

What I Did

Tried various parameters for check_and_force_update_vehicles() including 0, 1, 60 and 600.

from hyundai_kia_connect_api import *
import json
import datetime

vehicle_id = 'xxx'
vm = VehicleManager(region=1, brand=1, username="xxx", password="xxx", pin="", language="de")
vm.check_and_refresh_token()
vm.check_and_force_update_vehicles(1)  
dict = vars(list(vm.vehicles.values())[0])
print(f"current time: {datetime.datetime.now()}")
last_updated_at = dict["last_updated_at"]
print(f"last updated at: {last_updated_at}")

The code above yields the following output (example):

d:\ python refresh_test.py
current time: 2023-09-24 11:14:51.865252
last updated at: 2023-09-24 11:02:44+02:00

When I refresh the status in the KIA Connect app, the API returns the values from the moment, where the refresh command was issued in the app.

Am I doing something wrong? I'm pretty sure, this approach worked some weeks ago.
How can I get current values using the API?

@awenius
Copy link
Author

awenius commented Sep 29, 2023

Thanks to this comment #12 (comment) I realized that an additional call to update_all_vehicles_with_cached_state() is required.
This code works now:

vm.check_and_refresh_token()
vm.force_refresh_all_vehicles_states()
vm.update_all_vehicles_with_cached_state()
dict = vars(list(vm.vehicles.values())[0])
print(f"current time: {datetime.datetime.now()}")
last_updated_at = dict["last_updated_at"]
print(f"last updated at: {last_updated_at}")

This now yields the expected behavior:

d:\>python refresh_test.py
current time: 2023-09-29 21:20:05.338277
last updated at: 2023-09-29 21:20:04+02:00

@awenius awenius closed this as not planned Won't fix, can't repro, duplicate, stale Sep 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant