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

Add "Open Charge Port" #980

Open
walter-ve opened this issue Nov 21, 2024 · 22 comments
Open

Add "Open Charge Port" #980

walter-ve opened this issue Nov 21, 2024 · 22 comments

Comments

@walter-ve
Copy link

Is your feature request related to a problem? Please describe.

Describe the solution you'd like
Allow to open the charge port from the HA

Include the logs of the end point from Data in HA if this is a sensor

Describe alternatives you've considered

Additional context
With several EVs at home, to plugin another EV one needs to open the charge port. But you doesn't always have a key to that car to open the Charge port. Combining opening the different cars in the Apps gives the advantage that the home users just have to use HA to manage the charging of the different cars.

@fuatakgun
Copy link
Member

did you try this action/service? kia_uvo.open_charge_port

@walter-ve
Copy link
Author

did you try this action/service? kia_uvo.open_charge_port

I can only Lock a door and set charging limits in the KIA EV6; Is there an hidden action?

@walter-ve
Copy link
Author

kia_uvo.open_charge_port

Indeed: I was maybe to quick: Extra info: KIA EV6 delivered 04/2024; but could be the 2022 version (ordered 2022, not sure what version I have).

I see the feature exists on some version/regions. Anything I can do help?

@cdnninja
Copy link
Collaborator

What do the logs say?

@walter-ve
Copy link
Author

Schermafdruk van 2024-11-21 22-44-19
In Attachement (sorry for the dutch): the only actions I have is lock/unlock the door, and set charging limits.

I don't see an action to open the charge port.

@cdnninja
Copy link
Collaborator

That doesn't look like the developer action menu?

@walter-ve
Copy link
Author

bigger screen shot?
What are you missing from the screen that makes you wonder?
Schermafdruk van 2024-11-22 00-23-15

@cdnninja
Copy link
Collaborator

That isn't the developer menu. That's an automation flow. Could you try the developer menu? I think for automation you need to use other actions? Not sure since don't have this installed anymore.

@walter-ve
Copy link
Author

That isn't the developer menu. That's an automation flow. Could you try the developer menu? I think for automation you need to use other actions? Not sure since don't have this installed anymore.

This does feel like a stupid question: can you send a link to explain what the 'developer menu' is?

@fuatakgun
Copy link
Member

can you just try to execute these actions inside script/automation page or in developer menu?

@walter-ve
Copy link
Author

can you just try to execute these actions inside script/automation page or in developer menu?

What actions?

I listed the only actions possible on my EV6.
My EV6 only has 2 numbers and a lock.

If I do something link:
alias: test can be removed
description: ""
triggers: []
conditions: []
actions: kia_uvo.open_charge_port
mode: single

I get:
ypeError: Cannot use 'in' operator to search for 'service' in kia_uvo.open_charge_port
action.map (src/data/script.ts:443:6)
migrateAutomationTrigger (src/data/automation.ts:419:45)
saveAutomationConfig (src/data/automation.ts:376:11)
ev.stopPropagation (src/panels/config/automation/ha-automation-editor.ts:637:35)
call (src/lit-html.ts:2018:28)
dispatchEvent (src/common/dom/fire_event.ts:76:7)
load (src/components/ha-yaml-editor.ts:148:14)
call (src/lit-html.ts:2018:28)
dispatchEvent (src/common/dom/fire_event.ts:76:7)
Number (src/components/ha-code-editor.ts:327:14)

Which seems logical as kia_uvo.open_charge_port doesn't exist.

@walter-ve
Copy link
Author

can you just try to execute these actions inside script/automation page or in developer menu?

to be clear: the actions I listed I can run: no problem there. Just looking to open the charge port.

@walter-ve
Copy link
Author

alias: test can be removed
description: ""
triggers: []
conditions: []
action: kia_uvo.open_charge_port
target:
device_id: ce8a625d37657cb782c9726fafd3f536

Where device_id is the id of my EV6 device
give a Message malformed: required key not provided @ data['actions']

@cdnninja
Copy link
Collaborator

That isn't the developer menu. That's an automation flow. Could you try the developer menu? I think for automation you need to use other actions? Not sure since don't have this installed anymore.

This does feel like a stupid question: can you send a link to explain what the 'developer menu' is?

https://www.home-assistant.io/docs/scripts/perform-actions/

Click developer on the left side of home assistant. Click actions.

@walter-ve
Copy link
Author

Good I got somewhere ;-).
action: kia_uvo.open_charge_port
data:
device_id: ce8a625d37657cb782c9726fafd3f536

This gave

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 1704, in _get_control_token
control_token = "Bearer " + response["controlToken"]
~~~~~~~~^^^^^^^^^^^^^^^^
KeyError: 'controlToken'
2024-11-24 00:28:41.514 INFO (MainThread) [homeassistant.helpers.script.websocket_api_script] websocket_api script: Running websocket_api script
2024-11-24 00:28:41.515 INFO (MainThread) [homeassistant.helpers.script.websocket_api_script] websocket_api script: Executing step call service
2024-11-24 00:28:41.643 ERROR (MainThread) [homeassistant.helpers.script.websocket_api_script] websocket_api script: Error executing script. Unexpected error for call_service at pos 1: 'controlToken'
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 526, in _async_step
await getattr(self, handler)()
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 764, in _async_call_service_step
response_data = await self._async_run_long_action(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 727, in _async_run_long_action
return await long_task
^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2802, in async_call
response_data = await coro
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2845, in _execute_service
return await target(service_call)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/kia_uvo/services.py", line 126, in async_handle_open_charge_port
await coordinator.async_open_charge_port(vehicle_id)
File "/config/custom_components/kia_uvo/coordinator.py", line 205, in async_open_charge_port
action_id = 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 220, in open_charge_port
return self.api.charge_port_action(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 932, in charge_port_action
url, json=payload, headers=self._get_control_headers(token, vehicle)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 235, in _get_control_headers
control_token, _ = self._get_control_token(token)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 1704, in _get_control_token
control_token = "Bearer " + response["controlToken"]
~~~~~~~~^^^^^^^^^^^^^^^^
KeyError: 'controlToken'
2024-11-24 00:28:41.649 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [281473056408624] Error handling message: Unknown error (unknown_error) Walter Van Eetvelt from 127.0.0.1 (Mozilla/5.0 (Linux; Android 14; SM-S911B Build/UP1A.231005.007; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/130.0.6723.108 Mobile Safari/537.36 Home Assistant/2024.10.3-14058 (Android 14; SM-S911B))
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 28, in _handle_async_response
await func(hass, connection, msg)
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 816, in handle_execute_script
script_result = await script_obj.async_run(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1801, in async_run
return await asyncio.shield(create_eager_task(run.async_run()))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 464, in async_run
await self._async_step(log_exceptions=False)
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 528, in _async_step
self._handle_exception(
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 558, in _handle_exception
raise exception
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 526, in _async_step
await getattr(self, handler)()
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 764, in _async_call_service_step
response_data = await self._async_run_long_action(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 727, in _async_run_long_action
return await long_task
^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2802, in async_call
response_data = await coro
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2845, in _execute_service
return await target(service_call)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/kia_uvo/services.py", line 126, in async_handle_open_charge_port
await coordinator.async_open_charge_port(vehicle_id)
File "/config/custom_components/kia_uvo/coordinator.py", line 205, in async_open_charge_port
action_id = 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 220, in open_charge_port
return self.api.charge_port_action(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 932, in charge_port_action
url, json=payload, headers=self._get_control_headers(token, vehicle)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 235, in _get_control_headers
control_token, _ = self._get_control_token(token)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 1704, in _get_control_token
control_token = "Bearer " + response["controlToken"]
~~~~~~~~^^^^^^^^^^^^^^^^
KeyError: 'controlToken'
ConnectedDDisconnectSDisable Autoscroll^KClear

@cdnninja
Copy link
Collaborator

Does the Kia or Hyundai native app work to open it?

@walter-ve
Copy link
Author

Yes the native app works perfectly.

@walter-ve
Copy link
Author

That isn't the developer menu. That's an automation flow. Could you try the developer menu? I think for automation you need to use other actions? Not sure since don't have this installed anymore.

Note ; it would have been better understandable if you referred to 'Developer Tools' and said to run that on my car's device.

@cdnninja
Copy link
Collaborator

That isn't the developer menu. That's an automation flow. Could you try the developer menu? I think for automation you need to use other actions? Not sure since don't have this installed anymore.

Note ; it would have been better understandable if you referred to 'Developer Tools' and said to run that on my car's device.

Please submit a pull request to improve documentation.

@cdnninja
Copy link
Collaborator

Good I got somewhere ;-).

action: kia_uvo.open_charge_port

data:

device_id: ce8a625d37657cb782c9726fafd3f536

This gave

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/usr/local/lib/python3.12/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 1704, in _get_control_token

control_token = "Bearer " + response["controlToken"]

                            ~~~~~~~~^^^^^^^^^^^^^^^^

KeyError: 'controlToken'

2024-11-24 00:28:41.514 INFO (MainThread) [homeassistant.helpers.script.websocket_api_script] websocket_api script: Running websocket_api script

2024-11-24 00:28:41.515 INFO (MainThread) [homeassistant.helpers.script.websocket_api_script] websocket_api script: Executing step call service

2024-11-24 00:28:41.643 ERROR (MainThread) [homeassistant.helpers.script.websocket_api_script] websocket_api script: Error executing script. Unexpected error for call_service at pos 1: 'controlToken'

Traceback (most recent call last):

File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 526, in _async_step

await getattr(self, handler)()

File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 764, in _async_call_service_step

response_data = await self._async_run_long_action(

                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 727, in _async_run_long_action

return await long_task

       ^^^^^^^^^^^^^^^

File "/usr/src/homeassistant/homeassistant/core.py", line 2802, in async_call

response_data = await coro

                ^^^^^^^^^^

File "/usr/src/homeassistant/homeassistant/core.py", line 2845, in _execute_service

return await target(service_call)

       ^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/config/custom_components/kia_uvo/services.py", line 126, in async_handle_open_charge_port

await coordinator.async_open_charge_port(vehicle_id)

File "/config/custom_components/kia_uvo/coordinator.py", line 205, in async_open_charge_port

action_id = 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 220, in open_charge_port

return self.api.charge_port_action(

       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/usr/local/lib/python3.12/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 932, in charge_port_action

url, json=payload, headers=self._get_control_headers(token, vehicle)

                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/usr/local/lib/python3.12/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 235, in _get_control_headers

control_token, _ = self._get_control_token(token)

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/usr/local/lib/python3.12/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 1704, in _get_control_token

control_token = "Bearer " + response["controlToken"]

                            ~~~~~~~~^^^^^^^^^^^^^^^^

KeyError: 'controlToken'

2024-11-24 00:28:41.649 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [281473056408624] Error handling message: Unknown error (unknown_error) Walter Van Eetvelt from 127.0.0.1 (Mozilla/5.0 (Linux; Android 14; SM-S911B Build/UP1A.231005.007; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/130.0.6723.108 Mobile Safari/537.36 Home Assistant/2024.10.3-14058 (Android 14; SM-S911B))

Traceback (most recent call last):

File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 28, in _handle_async_response

await func(hass, connection, msg)

File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 816, in handle_execute_script

script_result = await script_obj.async_run(

                ^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1801, in async_run

return await asyncio.shield(create_eager_task(run.async_run()))

       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 464, in async_run

await self._async_step(log_exceptions=False)

File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 528, in _async_step

self._handle_exception(

File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 558, in _handle_exception

raise exception

File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 526, in _async_step

await getattr(self, handler)()

File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 764, in _async_call_service_step

response_data = await self._async_run_long_action(

                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 727, in _async_run_long_action

return await long_task

       ^^^^^^^^^^^^^^^

File "/usr/src/homeassistant/homeassistant/core.py", line 2802, in async_call

response_data = await coro

                ^^^^^^^^^^

File "/usr/src/homeassistant/homeassistant/core.py", line 2845, in _execute_service

return await target(service_call)

       ^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/config/custom_components/kia_uvo/services.py", line 126, in async_handle_open_charge_port

await coordinator.async_open_charge_port(vehicle_id)

File "/config/custom_components/kia_uvo/coordinator.py", line 205, in async_open_charge_port

action_id = 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 220, in open_charge_port

return self.api.charge_port_action(

       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/usr/local/lib/python3.12/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 932, in charge_port_action

url, json=payload, headers=self._get_control_headers(token, vehicle)

                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/usr/local/lib/python3.12/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 235, in _get_control_headers

control_token, _ = self._get_control_token(token)

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/usr/local/lib/python3.12/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 1704, in _get_control_token

control_token = "Bearer " + response["controlToken"]

                            ~~~~~~~~^^^^^^^^^^^^^^^^

KeyError: 'controlToken'

ConnectedDDisconnectSDisable Autoscroll^KClear

Looks like for your car sniffing the traffic will be needed.

@walter-ve
Copy link
Author

Is there somewhere a description of the hyundai/kia API?
I could check once how it works from Postman.

@cdnninja
Copy link
Collaborator

Beyond the api we have written no. Each time we hit something like this need to sniff traffic and figure it out.

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

3 participants