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

feat(EU): add schedule charging service #944

Merged
merged 1 commit into from
Oct 6, 2024

Conversation

asychow
Copy link
Contributor

@asychow asychow commented Oct 5, 2024

Should fix #928

@asychow asychow force-pushed the master branch 2 times, most recently from 6cfc8e3 to a58b8c2 Compare October 6, 2024 00:26
@cdnninja
Copy link
Collaborator

cdnninja commented Oct 6, 2024

Excellent! This is fantastic work!

@cdnninja cdnninja merged commit fe914ce into Hyundai-Kia-Connect:master Oct 6, 2024
11 checks passed
@HarriVa
Copy link

HarriVa commented Oct 6, 2024

This is great, thanks!!!

@Prodec-
Copy link

Prodec- commented Oct 6, 2024

Awesome! Thank you!

@Prodec-
Copy link

Prodec- commented Oct 8, 2024

Hmm, Either I try to use it wrong or there is some issue with the feature. I made a script like so:
alias: Aseta latausaika
sequence:

  • action: kia_uvo.schedule_charging_and_climate
    metadata: {}
    data:
    charging_enabled: true
    off_peak_start_time: "23:00:00"
    off_peak_end_time: "07:00:00"
    off_peak_charge_only_enabled: true
    defrost: true
    device_id: my-car-id-redacted
    climate_enabled: true
    first_departure_enabled: true
    first_departure_days:
    - "1"
    - "2"
    - "3"
    - "4"
    - "5"
    first_departure_time: "08:00:00"
    second_departure_enabled: true
    second_departure_days:
    - "0"
    - "6"
    second_departure_time: "12:00:00"
    temperature: 21
    temperature_unit: "0"
    description: ""
    icon: mdi:battery-charging-10

When I try to run it, schedule won't change and this is printrd to log:

Logger: homeassistant.components.script.aseta_latausaika
Source: helpers/script.py:525
integration: Scripts (documentation, issues)
First occurred: 7 October 2024 at 00:12:26 (9 occurrences)
Last logged: 13:19:22

Aseta latausaika: Error executing script. Unexpected error for call_service at pos 1: 'controlToken'
Traceback (most recent call last):
File "/var/lib/hass/.venv/lib/python3.12/site-packages/homeassistant/helpers/script.py", line 525, in _async_step
await getattr(self, handler)()
File "/var/lib/hass/.venv/lib/python3.12/site-packages/homeassistant/helpers/script.py", line 763, in _async_call_service_step
response_data = await self._async_run_long_action(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/lib/hass/.venv/lib/python3.12/site-packages/homeassistant/helpers/script.py", line 726, in _async_run_long_action
return await long_task
^^^^^^^^^^^^^^^
File "/var/lib/hass/.venv/lib/python3.12/site-packages/homeassistant/core.py", line 2761, in async_call
response_data = await coro
^^^^^^^^^^
File "/var/lib/hass/.venv/lib/python3.12/site-packages/homeassistant/core.py", line 2804, in _execute_service
return await target(service_call)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/lib/hass/custom_components/kia_uvo/services.py", line 229, in async_handle_schedule_charging_and_climate
await coordinator.async_schedule_charging_and_climate(
File "/var/lib/hass/custom_components/kia_uvo/coordinator.py", line 282, in async_schedule_charging_and_climate
action_id = await self.hass.async_add_executor_job(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/lib/hass/.venv/lib/python3.12/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 253, in schedule_charging_and_climate
self.api.schedule_charging_and_climate(
File "/var/lib/hass/.venv/lib/python3.12/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 1401, in schedule_charging_and_climate
url, json=payload, headers=self._get_control_headers(token, vehicle)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/lib/hass/.venv/lib/python3.12/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 234, in _get_control_headers
control_token, _ = self._get_control_token(token)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/lib/hass/.venv/lib/python3.12/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 1653, in _get_control_token
control_token = "Bearer " + response["controlToken"]
~~~~~~~~^^^^^^^^^^^^^^^^
KeyError: 'controlToken'

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

Successfully merging this pull request may close these issues.

Setting EV Off Peak Start and end times for charging
4 participants