From 632951ff7a970541dec7bcde0960c47bcbaa71a2 Mon Sep 17 00:00:00 2001 From: jrnk Date: Mon, 24 Jun 2024 21:30:04 +0200 Subject: [PATCH] feat(EU): Support setting the charging current (#580) --- hyundai_kia_connect_api/ApiImpl.py | 4 ++++ hyundai_kia_connect_api/ApiImplType1.py | 3 +++ hyundai_kia_connect_api/KiaUvoApiEU.py | 17 +++++++++++++++++ hyundai_kia_connect_api/Vehicle.py | 1 + 4 files changed, 25 insertions(+) diff --git a/hyundai_kia_connect_api/ApiImpl.py b/hyundai_kia_connect_api/ApiImpl.py index a782ed99..56524ac4 100644 --- a/hyundai_kia_connect_api/ApiImpl.py +++ b/hyundai_kia_connect_api/ApiImpl.py @@ -146,6 +146,10 @@ def set_charge_limits( """Sets charge limits. Returns the tracking ID""" pass + def set_charging_current(self, token: Token, vehicle: Vehicle, level: int) -> str: + """Sets charge current level (1=100%, 2=90%, 3=60%). Returns the tracking ID""" + pass + def set_windows_state( self, token: Token, vehicle: Vehicle, options: WindowRequestOptions ) -> str: diff --git a/hyundai_kia_connect_api/ApiImplType1.py b/hyundai_kia_connect_api/ApiImplType1.py index d8a6a3db..8d4d59f7 100644 --- a/hyundai_kia_connect_api/ApiImplType1.py +++ b/hyundai_kia_connect_api/ApiImplType1.py @@ -231,6 +231,9 @@ def _update_vehicle_properties_ccs2(self, vehicle: Vehicle, state: dict) -> None vehicle.ev_charge_limits_dc = get_child_value( state, "Green.ChargingInformation.TargetSoC.Quick" ) + vehicle.ev_charging_current = get_child_value( + state, "Green.ChargingInformation.ElectricCurrentLevel.State" + ) vehicle.ev_v2l_discharge_limit = get_child_value( state, "Green.Electric.SmartGrid.VehicleToLoad.DischargeLimitation.SoC" ) diff --git a/hyundai_kia_connect_api/KiaUvoApiEU.py b/hyundai_kia_connect_api/KiaUvoApiEU.py index 9e1885cf..d158596c 100644 --- a/hyundai_kia_connect_api/KiaUvoApiEU.py +++ b/hyundai_kia_connect_api/KiaUvoApiEU.py @@ -1285,6 +1285,23 @@ def set_charge_limits( _check_response_for_errors(response) return response["msgId"] + def set_charging_current(self, token: Token, vehicle: Vehicle, level: int) -> str: + url = ( + self.SPA_API_URL + "vehicles/" + vehicle.id + "/ccs2/charge/chargingcurrent" + ) + + body = {"chargingCurrent": level} + response = requests.post( + url, + json=body, + headers=self._get_authenticated_headers( + token, vehicle.ccu_ccs2_protocol_support + ), + ).json() + _LOGGER.debug(f"{DOMAIN} - Set Charging Current Response: {response}") + _check_response_for_errors(response) + return response["msgId"] + def schedule_charging_and_climate( self, token: Token, diff --git a/hyundai_kia_connect_api/Vehicle.py b/hyundai_kia_connect_api/Vehicle.py index 45bf0e57..9e5455e1 100644 --- a/hyundai_kia_connect_api/Vehicle.py +++ b/hyundai_kia_connect_api/Vehicle.py @@ -159,6 +159,7 @@ class Vehicle: ev_charge_limits_dc: typing.Union[int, None] = None ev_charge_limits_ac: typing.Union[int, None] = None + ev_charging_current: typing.Union[int, None] = None # Europe feature only ev_v2l_discharge_limit: typing.Union[int, None] = None # energy consumed and regenerated since the vehicle was paired with the account