-
Notifications
You must be signed in to change notification settings - Fork 78
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
Instructions how to use #12
Comments
This is still work in progress, a good starting point: home-assistant/core#62451 |
Let's keep this issue open to come up with basic documentation. |
I'll try come up with some of the basics in the next few days. Any example format you both like? |
Misclick on the close. I started on the homepage to document this. When I have more time I will add examples of initializing the module and a few basics calls. As a quick note we have done a recent refactor of the code, so far initial pass is done on EU and CA regions. USA hasn't been done yet, I hope to do that this weekend but don't have anyone lined up to test. The refactor allows all these APIs to work with multiple cars where as the previous versions only worked on the first car on an account. I am interested to hear what you are working on if willing to share! It may help us ensure this API works for others as well. |
My fist intention would to make sure that all API endpoints the app uses are made available. That is not to hard. That way this library will be up to par with Bluelinky. |
Maybe a working sample code:
|
Did you go through the open home assistant PR? You will find answers for almost of these questions. |
|
Got it, until documentation is ready, that will give you a brief idea how we are using this. |
@PierreLevres Any chance are your car is from the USA? Hoping to have someone help test and update either the Kia or Hyundai API to help get it working. |
Sorry no, European. But you can find some USA car owners in the discord server for BlueLinky. They might be willing to test. |
Hi All, I got the following so far: Which returns the vehicle id, name, model and registration_date - the rest is pretty much "None". |
Did you check the open PR link above? It will help you a lot? |
Try vm.update_all_vehicles_with_cached_state() right after you update vehicle manager. You will then have the data for the car. |
Or call All data will be stored and updated inside Manager.vehicles dictionary |
@PierreLevres the home page now has this above example listed plus the other methods vehicle manager offers. |
Hi all, Thank you for posting the example.
and
Potentially |
Great work !!!
… Op 15 jan. 2022 om 05:24 heeft cdnninja ***@***.***> het volgende geschreven:
@PierreLevres the home page now has this above example listed plus the other methods vehicle manager offers.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.
|
v1.18.8 should resolve that second keyError. Please retry and let me know if it is solved. |
I have also cut a PR #15 for the first issue. This is caused by it having a last updated yet since we haven't called for vehicle data. It should work if you first call for cached state and then force the update. That should be resolved soon too though. |
@cdnninja Thank you very much - v1.18.8 fixed it: I know see plenty of details. |
@Empor-co Remote start does exist in the base APIs. We haven't exposed it yet to vehicleManager. It does work in the older version of this for home assistant though: https://github.com/fuatakgun/kia_uvo. I don't think implementing this would take long at all. I will cut a separate issue for remote start. For each feature like this could you cut a issue and we can track separately? Testers like you are key to this growing and being robust so thanks for playing with it! This API is the early days of prepping for core integration. It eventually will be used by the above custom as well once it has feature parity. |
Hi, vm.check_and_refresh_token() Is this sequence good to get a complete refreshed status from the vehicle? |
You might want to take a look at https://github.com/JanJaapKo/BlUVO <https://github.com/JanJaapKo/BlUVO>
An already existing plugin for domoticz...
Location is refreshed by the api call /location, have a look at the bluelinky code: https://github.com/Hacksore/bluelinky/blob/master/src/vehicles/european.vehicle.ts <https://github.com/Hacksore/bluelinky/blob/master/src/vehicles/european.vehicle.ts>
public async location(): Promise<VehicleLocation> {
const http = await this.controller.getVehicleHttpService();
try {
const response = this.updateRates(
await http.get(`/api/v2/spa/vehicles/${this.vehicleConfig.id}/location`)
);
const data = response.body.resMsg?.gpsDetail ?? response.body.resMsg;
this._location = {
latitude: data?.coord?.lat,
longitude: data?.coord?.lon,
altitude: data?.coord?.alt,
speed: {
unit: data?.speed?.unit,
value: data?.speed?.value,
},
heading: data?.head,
};
return this._location;
} catch (err) {
throw manageBluelinkyError(err, 'EuropeVehicle.location');
}
}
… On 21 Feb 2022, at 16:46, Creasol ***@***.***> wrote:
Hi,
thanks for this great module: I've start using it to make a plugin for Domoticz, https://github.com/CreasolTech/domoticz-hyundai-kia <https://github.com/CreasolTech/domoticz-hyundai-kia>
I also think that some more comments in the VehicleManager.py will help who, as me, don't know enough about python programming and kia/hyundai API/restrictions/....
Every N minutes, I call:
vm.check_and_refresh_token()
vm.force_refresh_all_vehicles_states()
vm.update_all_vehicles_with_cached_state()
Is this sequence good to get a complete refreshed status from the vehicle?
While some status are freshed (e.g. is_charging, ev_range, ....), the location is 3 hours old. I tried several times to refresh, but location keeps old. Then I open Kia Connect app on my smartphone, check the location (that is old), enter pin, and location get refreshed to the new one on both smartphone and Domoticz.
What is the right way to get location refreshed?
Thanks a lot !!
Paolo
—
Reply to this email directly, view it on GitHub <#12 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AO7MCG4EC4UP5FVND27JRZDU4JM55ANCNFSM5LQWJVMA>.
You are receiving this because you were mentioned.
|
Thanks for the answer. |
Which region? I assume EU? I don’t think location update is implemented for EU. That will be a quick fix if you can test it for me since I am in CA.
… On Feb 23, 2022, at 11:26 AM, Creasol ***@***.***> wrote:
Thanks for the answer.
In this hyundai_kia_connect_api I cannot find a call to the url /location :
I've just checked the API from PierreLevres and found that, to get a refresh, he call, in sequence,
/status #to get all data and ask for vehicle fresh data
/status/latest # to read new data from cloud
then compare the first with second odometer: if differ, call the url
/location # to get fresh coordinates
Is it useful to call /location url to get a fresh location, or is it useless?
Thanks.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.
|
Yes, /location URL exists in EU region. |
#51 adds this calling method. Interested on feedback. Current approach automatically forces this location update if the odometer has changed on the cached vehicle call. Would you rather to have the control available to you to update or are you okay with us checking if odometer changed and updating. In a future PR I am also thinking of limiting since the last location call so it will only update location lets say once an hour. |
Thanks @cdnninja , I have just fetch your PR , but I have to move the car to know if it really works (and here is midnight!). |
Hi @cdnninja ,
to VehicleManager.py so I can call vm.get_location(). So, the main problem is that vm.force_refresh_all_vehicles_states() does not poll data from the car, but always from the cache, so odometer does not change and api.get_location() is not called. |
Any update to the question posted directly above: "What is the method I should call to ask Kia to fetch data from the car?" |
For EU users it is already there https://github.com/Hyundai-Kia-Connect/hyundai_kia_connect_api/blob/master/hyundai_kia_connect_api/KiaUvoApiEU.py#L328: |
That's what I thought but either there's a problem with my code or my understanding. Here's the essential part of the code:
which returns (formatted):
The problem is that the timestamp does not get updated when I run the code. Can you see the problem? |
Here is what happens (I think):
The call vm.force_refresh_vehicle_state(my_vehicle) will update the cached data on the Kia servers.
It will however NOT update the data in your VM object.
I think you should call update_vehicle_with_cached_state afterwards.
The way functions are handled is not consistant, and something to be improved in my opinion.
Sometimes they return a value, sometimes they update another object and sometimes they dont do anything.
… On 17 Mar 2022, at 18:51, ot3 ***@***.***> wrote:
That's what I thought but either there's a problem with my code or my understanding. Here's the essential part of the code:
def fetch_vehicle():
vm = VehicleManager(
brand=1,
region=1,
username=kia.username,
password=kia.password,
pin=kia.pin
)
vm.check_and_refresh_token()
my_vehicle = vm.get_vehicle(kia.vehicle_id)
vm.force_refresh_vehicle_state(my_vehicle)
return my_vehicle
which returns (formatted):
2022-03-17 16:53:50 - primary battery: 45%, secondary battery: 91%, range: 193km, odometer: 560.4km
The problem is that the timestamp does not get updated when I run the code. Can you see the problem?
—
Reply to this email directly, view it on GitHub <#12 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AO7MCG7MNU2CU3IHEDN2RTLVANWJVANCNFSM5LQWJVMA>.
You are receiving this because you were mentioned.
|
That seems to fix it. Current code:
with result:
It still seems to me a strange sequence of API calls and that a single call should suffice. Thanks for your advice; this was something I hadn't tried yet. |
Thanks for sharing the updates here. After creating VehicleManager object, you can call initialize() function which would generate the vehicle data from cached source. If you want, you can call Force update would consume your daily api call capacity but cache update is just getting latest data from cloud, without any incur on your account and we want this decision to happen explicitly rather than opaque to consumer. |
Please can you explain in details (with a source code) what is the sequence to:
As I don't know how the kia/hyundai cloud works and there is not much comments inside the library, maybe some doc about how to use the library methods is very helpful. |
How are you setting kia.vehicle_id? I try to set it to the first keyvalue in vehicles from the VehicleManager but I get KeyError. To the VIN-number of the car, still error. Can't understand what I'm doing wrong. Can someone give me a hint? |
Vehicle.id is where you get the id for a future all. |
Please add some pointers in the usage documentation as in how to you the module.
Apart from hyundai_kia_connect_api :
The text was updated successfully, but these errors were encountered: