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

Change AC-charge-current #864

Open dagobert opened 5 months ago

dagobert commented 5 months ago

It is possible to change am the AC charge current to 100%, 90% and 60% when sitting in the car using the settings in EV screen on an Ioniq 5 and others with the same platform.

This option would've great to expose to HA to be able to regulate the charge current when loading at home with solar.

Is it in the API? How to find out?

Speederer commented 5 months ago

I have the same car, but I think it is not possible to change the charging current from the car side. At least this feature is missing from the menu of the car screen and the BlueLink app as well. Most probably the API doesn't support it. Without a proper charger you cannot control the charging, just to change the charging limit to some predefined value as you already mentioned. I guess the key word for this problem is the OCPP. Which charger uses this protocol that one can be controlled via remotely, even from HA. If your current charger doesn't support it, you probably don't want to replace it just for this reason. But despite this I would try to solve this issue from the charger side.

dagobert commented 5 months ago

I am not sure I understand you correctly but there is a way to do what I wrote from the car screen. Just follow the screenshots and you will find it. Sorry the ui is in German.

From ev screen use the burger icon. IMG_20240419_162852

There you use ev-settings. IMG_20240419_162801

Than ac-current IMG_20240419_162715

Here you can change the percentage of the max available current of the charging process. This actually means that it uses x percent of what the charger offers at this right moment and not of what it could offer at maximum. Hence, if you setup your simple plugin charger to 8 amps at 230v than it would use this as 100 percent and the lower accordingly. This paragraph has nothing to do with my request but is for you to understand the mechanism of these settings options. IMG_20240419_162632

Speederer commented 5 months ago

Okay, you are right, I skipped over that setting. Sorry for that. It looks promising for controlling the charging, but too bad it's not supported remotely.

cdnninja commented 5 months ago

I assume that is different than the ac /dc charge setting we offer in this today?

dagobert commented 5 months ago

Yes, the difference is, that the charge option sets the maximum charge point to whî the car should be filled, eg. 80% full.

The option I talk about sets the current. It basically the speed the car is charging (in this case related to the amps the charger offers).

cdnninja commented 5 months ago

Someone will need to sniff this traffic and add it.

ReconOperator commented 3 months ago

Hi,

I have a KIA EV6 GT Line (model year 2022) here in Sweden. I have the settings for AC charge current (100%, 90% and 60%) available in the car. Updated today to v2.25.1. Tried the new service: kia_uvo.set_charging_current

Guess this means my car does not support this via the API? AttributeError: 'VehicleManager' object has no attribute 'set_charging_current'

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 27, in _handle_async_response await func(hass, connection, msg) File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 793, in handle_execute_script script_result = await script_obj.async_run( ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1769, 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 763, in _async_call_service_step response_data = await self._async_run_long_action( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 726, in _async_run_long_action return await long_task ^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2741, in async_call response_data = await coro ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2784, in _execute_service return await target(service_call) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/kia_uvo/services.py", line 148, in async_handle_set_charging_current await coordinator.set_charging_current(vehicle_id, int(current_level)) File "/config/custom_components/kia_uvo/coordinator.py", line 268, in set_charging_current self.vehicle_manager.set_charging_current, vehicle_id, level ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'VehicleManager' object has no attribute 'set_charging_current'

cdnninja commented 3 months ago

try updating to master branch. That was an error in the code.

ReconOperator commented 3 months ago

@cdnninja

Updated to Master and restarted HA. Now i get some different errors. Calling for example Start Climate works fine.

2024-06-28 10:22:13.278 ERROR (SyncWorker_45) [hyundai_kia_connect_api.KiaUvoApiEU] Failed to parse driving info. Possible reasons:

Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 356, in update_vehicle_with_cached_state state = self._get_driving_info(token, vehicle) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 1205, in _get_driving_info _check_response_for_errors(response30d) File "/usr/local/lib/python3.12/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 128, in _check_response_for_errors raise error_code_mappingresponse["resCode"] hyundai_kia_connect_api.exceptions.DeviceIDError: Invalid request body - Invalid deviceId.

2024-06-28 10:22:37.922 ERROR (MainThread) [homeassistant.helpers.script.websocket_api_script] websocket_api script: Error executing script. Unexpected error for call_service at pos 1: Invalid request body - Invalid deviceId. 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 763, in _async_call_service_step response_data = await self._async_run_long_action( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 726, in _async_run_long_action return await long_task ^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2741, in async_call response_data = await coro ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2784, in _execute_service return await target(service_call) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/kia_uvo/services.py", line 148, in async_handle_set_charging_current await coordinator.set_charging_current(vehicle_id, int(current_level)) File "/config/custom_components/kia_uvo/coordinator.py", line 267, in set_charging_current 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 169, in set_charging_current return self.api.set_charging_current( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 1302, in set_charging_current _check_response_for_errors(response) File "/usr/local/lib/python3.12/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 128, in _check_response_for_errors raise error_code_mappingresponse["resCode"] hyundai_kia_connect_api.exceptions.DeviceIDError: Invalid request body - Invalid deviceId.

cdnninja commented 2 months ago

This may be two errors. Is it still occurring for you?

ReconOperator commented 1 month ago

@cdnninja Hi, yes I still get the same error

SeatFX commented 1 month ago

Also getting the same Error on a 2021 Kia E-Niro in the EU. Invalid Device ID whenever trying to set the charging current. Any updates on this?

mastameista commented 1 week ago

I also get 2 Errors in HA Log file. But changing AC-charge-current on my EV9 works! BUT: After calling the service the integration crashes entirely. I need to reload the integration in order to make entities available again.

Error 1:

Logger: custom_components.kia_uvo.coordinator
Source: helpers/update_coordinator.py:386
integration: Hyundai / Kia Connect ([documentation](https://github.com/Hyundai-Kia-Connect/kia_uvo), [issues](https://github.com/Hyundai-Kia-Connect/kia_uvo/issues))
First occurred: 4:22:57 PM (2 occurrences)
Last logged: 4:25:11 PM

Error fetching kia_uvo data: Error communicating with API: Traceback (most recent call last): File "/config/custom_components/kia_uvo/coordinator.py", line 126, in _async_update_data 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 113, in check_and_force_update_vehicles self.update_vehicle_with_cached_state(vehicle_id) File "/usr/local/lib/python3.12/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 90, in update_vehicle_with_cached_state self.api.update_vehicle_with_cached_state(self.token, vehicle) File "/usr/local/lib/python3.12/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 341, in update_vehicle_with_cached_state _check_response_for_errors(response) File "/usr/local/lib/python3.12/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 128, in _check_response_for_errors raise error_code_mapping[response["resCode"]](response["resMsg"]) hyundai_kia_connect_api.exceptions.DeviceIDError: Invalid request body - Invalid deviceId. During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/config/custom_components/kia_uvo/coordinator.py", line 135, in _async_update_data 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 85, in update_all_vehicles_with_cached_state self.update_vehicle_with_cached_state(vehicle_id) File "/usr/local/lib/python3.12/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 90, in update_vehicle_with_cached_state self.api.update_vehicle_with_cached_state(self.token, vehicle) File "/usr/local/lib/python3.12/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 341, in update_vehicle_with_cached_state _check_response_for_errors(response) File "/usr/local/lib/python3.12/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 128, in _check_response_for_errors raise error_code_mapping[response["resCode"]](response["resMsg"]) hyundai_kia_connect_api.exceptions.DeviceIDError: Invalid request body - Invalid deviceId.

Error 2:

Logger: homeassistant
Source: custom_components/kia_uvo/coordinator.py:175
integration: Hyundai / Kia Connect ([documentation](https://github.com/Hyundai-Kia-Connect/kia_uvo), [issues](https://github.com/Hyundai-Kia-Connect/kia_uvo/issues))
First occurred: 4:22:57 PM (2 occurrences)
Last logged: 4:25:11 PM

Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/config/custom_components/kia_uvo/coordinator.py", line 175, in async_await_action_and_refresh
    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 206, in check_action_status
    return self.api.check_action_status(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 1687, in check_action_status
    state = self.check_action_status(
            ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 1709, in check_action_status
    _check_response_for_errors(response)
  File "/usr/local/lib/python3.12/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 128, in _check_response_for_errors
    raise error_code_mapping[response["resCode"]](response["resMsg"])
hyundai_kia_connect_api.exceptions.DeviceIDError: Invalid request body - Invalid deviceId.
eekhoorn commented 4 days ago

Also getting the same Error on a 2023 Kia E-Niro in the EU. Invalid Device ID whenever trying to set the charging current. Any updates on this?