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
413 stars 85 forks source link

Bluelink/Hyundai - Open & Close charging door #243

Closed beanian closed 3 months ago

beanian commented 2 years ago

Is it possible to extend the functionality of this service to support the opening & closing of the charing port door? I can perform those actions from the Bluelink app. I have an EU Hyundai Ioniq 5.

fuatakgun commented 2 years ago

Hey, normally it is doable BUT in EU region, i needed to reverse engineer all the mobile app calls via installing the app into my phone and directly executing the commands. If you have tech knowledge, follow our wiki page to do the similar, otherwise, i have to access your car to extract exact calls and functions.

beanian commented 2 years ago

Thanks, tried following the steps to capture the traffic, however upon launching the modified Bluelink app I get a message saying "This application has been forged" and it quits. Any ideas?

povlhp commented 2 years ago

Opening/closing charge port (I5/EV6)is done by calling below URL - Note the api/v2 in the URL as opposed the the other stuff on v1.

https://prd.eu-ccapi.kia.com:8080/api/v2/spa/vehicles/a0...10/control/portdoor HTTP/1.1

with Json message:

{"action":"open"}
{"action":"close"}
fuatakgun commented 2 years ago

thanks for this, we need to modify based on v1 vs v2, you are right.

nrfribeiro commented 1 year ago

Hi @fuatakgun , Great work on this. Any plans to ad this feature, "open/close charging port"?

cdnninja commented 1 year ago

@ZuinigeRijder with the above sniffed URL would you up to implement this in EU and give it a try? Once working in the API I can extend here in UVO.

cdnninja commented 1 year ago

FYI Initial work on this in the API is here: https://github.com/Hyundai-Kia-Connect/hyundai_kia_connect_api/pull/153 and needs testing.

cdnninja commented 1 year ago

I have created a PR with a service for this. If able to test it out before I merge that would be great!

cdnninja commented 1 year ago

This has since been released in the 2.X branch. If you could test that would be awesome. I will close this in a few days if I don't hear back.

cdnninja commented 1 year ago

Anyone had a chance to test this out?

beanian commented 1 year ago

Just tested this on my Hyundai Ioniq 5 in Ireland and it does not work. When I call the service it unlocks the car and the charging port door remains closed.

cdnninja commented 1 year ago

https://github.com/Hyundai-Kia-Connect/hyundai_kia_connect_api/pull/194

cdnninja commented 1 year ago

Could you update in HACS from "master" and try again?

beanian commented 1 year ago

So I tried again and got this Logger: hyundai_kia_connect_api.KiaUvoApiEU Source: /usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py:66 First occurred: 4:49:11 PM (1 occurrences) Last logged: 4:49:11 PM

Unknown API response format: {'error': 'Access to this API has been disallowed'}

cdnninja commented 1 year ago

Could you enable debug logs and provide those?

beanian commented 1 year ago

2022-12-21 15:47:58.152 DEBUG (SyncWorker_9) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - Charge Port Action Request: {'action': 'open', 'deviceId': 'xxxxxx-a166-4504-83ec-xxxxxxxxx'} 2022-12-21 15:47:58.153 DEBUG (SyncWorker_9) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - get_stamp 2022-12-21 13:02:53.523000+00:00 120000 82 998 82.53858847500001 2022-12-21 15:47:58.764 DEBUG (SyncWorker_9) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - Charge Port Action Response: {'error': 'Access to this API has been disallowed'} 2022-12-21 15:47:58.765 ERROR (SyncWorker_9) [hyundai_kia_connect_api.KiaUvoApiEU] Unknown API response format: {'error': 'Access to this API has been disallowed'} 2022-12-21 15:47:58.777 ERROR (MainThread) [homeassistant.helpers.script.websocket_api_script] websocket_api script: Error executing script. Unexpected error for call_service at pos 1: Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 451, in _async_step await getattr(self, handler)() File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 684, in _async_call_service_step await service_task File "/usr/src/homeassistant/homeassistant/core.py", line 1744, in async_call task.result() File "/usr/src/homeassistant/homeassistant/core.py", line 1781, in _execute_service await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)( File "/config/custom_components/kia_uvo/services.py", line 90, in async_handle_open_charge_port await coordinator.async_open_charge_port(vehicle_id) File "/config/custom_components/kia_uvo/coordinator.py", line 174, in async_open_charge_port await self.hass.async_add_executor_job( File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 126, in open_charge_port return self.api.charge_port_action(self.token, self.get_vehicle(vehicle_id), CHARGE_PORT_ACTION.OPEN) File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 565, in charge_port_action _check_response_for_errors(response) File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 67, in _check_response_for_errors raise InvalidAPIResponseError() hyundai_kia_connect_api.exceptions.InvalidAPIResponseError

cdnninja commented 1 year ago

Unfortunately not alot for me to go on. Looks like we are sending the correct command but something isn't correct. I assume this works fine in your mobile app? @povlhp are you able to test it out and compare payloads?

tmjo commented 5 months ago

I came here to look for this feature. Any news or status? I notice that my Bluelink app asks for biometrics to allow opening the charging port, can that be related?

cdnninja commented 5 months ago

Code was created but no one has tested it. https://github.com/Hyundai-Kia-Connect/hyundai_kia_connect_api/pull/506

Could you test?

tmjo commented 5 months ago

Code was created but no one has tested it. Hyundai-Kia-Connect/hyundai_kia_connect_api#506

Could you test?

Ah, cool! I'll test it. Currently away from home for some weeks, but I'll test it when I get back home!

tmjo commented 3 months ago

Code was created but no one has tested it. Hyundai-Kia-Connect/hyundai_kia_connect_api#506 Could you test?

Ah, cool! I'll test it. Currently away from home for some weeks, but I'll test it when I get back home!

Hi again! Sorry for the delay here, I was away for a month and then forgot it for another month :) Finally remembered to test this feature on my Hyundai Ioniq 5 (2023, EU-model if it matters) and can confirm that both opening and closing charge port works perfectly fine.

Thanks for this feature! It particularly comes in handy when I forget to plug in my car and later walk out to the garage just to realize I didn't grab the keys with me. Lot's of forgetting, I know :)