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

climate control RequestException error #953

Open
renatkh opened this issue Oct 25, 2024 · 12 comments
Open

climate control RequestException error #953

renatkh opened this issue Oct 25, 2024 · 12 comments

Comments

@renatkh
Copy link
Contributor

renatkh commented Oct 25, 2024

Please check Services, Known Bug / Issues and Troubleshooting over here first: https://github.com/fuatakgun/kia_uvo/blob/master/README.md
Region and Brand of car
USA, KIA
Version of the integration
2.27.2
Describe the bug
When attempting to start the climate control for a Kia vehicle using Home Assistant, a RequestException is raised. This occurs within the Kia Uvo API integration and prevents the climate feature from activating.

Debug logs if an error occurred
Logger: homeassistant.components.websocket_api.http.connection
Source: custom_components/kia_uvo/coordinator.py:225
integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 12:39:24 AM (1 occurrences)
Last logged: 12:39:24 AM

[140323417457344] Error handling message: Unknown error (unknown_error) Renat Khaliullin from 172.17.0.1 (Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36 Edg/130.0.0.0)
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 26, in _handle_async_response
await func(hass, connection, msg)
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 795, in handle_execute_script
script_result = await script_obj.async_run(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1600, in async_run
return await asyncio.shield(run.async_run())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 435, in async_run
await self._async_step(log_exceptions=False)
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 487, in _async_step
self._handle_exception(
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 512, in _handle_exception
raise exception
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 485, in _async_step
await getattr(self, handler)()
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 723, in _async_call_service_step
response_data = await self._async_run_long_action(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 685, in _async_run_long_action
return long_task.result()
^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2319, in async_call
response_data = await coro
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2356, in _execute_service
return await target(service_call)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/kia_uvo/services.py", line 98, in async_handle_start_climate
await coordinator.async_start_climate(vehicle_id, climate_request_options)
File "/config/custom_components/kia_uvo/coordinator.py", line 225, in async_start_climate
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 140, in start_climate
return self.api.start_climate(self.token, self.get_vehicle(vehicle_id), options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/hyundai_kia_connect_api/KiaUvoAPIUSA.py", line 732, in start_climate
response = self.post_request_with_logging_and_active_session(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/hyundai_kia_connect_api/KiaUvoAPIUSA.py", line 59, in request_with_active_session_wrapper
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/hyundai_kia_connect_api/KiaUvoAPIUSA.py", line 104, in request_with_logging_wrapper
raise RequestException
requests.exceptions.RequestException

To Reproduce

  1. Go to the Home Assistant dashboard.
  2. make sure the car is locked.
  3. Trigger the script or automation to start the vehicle's climate control.
  4. Observe the error in the logs.

Expected behavior
engine started.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
The car lock/unlock works and all sensors are updated normally.

@cdnninja
Copy link
Collaborator

Did you pass the correct variables?

@renatkh
Copy link
Contributor Author

renatkh commented Oct 31, 2024

I believe so.
I use the same settings in Hasssio when I start the climate as in the previous versions of the integration.
I tested the hyundai_kia_connect_api and the climate request works.
Locking and unlocking the vehicle works through the integration. Only climate_start doesn't.
LMK, how I can help to debug it.

@renatkh
Copy link
Contributor Author

renatkh commented Oct 31, 2024

more complete debug file

2024-10-31 05:45:57.020 DEBUG (SyncWorker_3) [hyundai_kia_connect_api.KiaUvoAPIUSA] hyundai_kia_connect_api - Planned start_climate payload: {'remoteClimate': {'airTemp': {'unit': 1, 'value': '76'}, 'airCtrl': True, 'defrost': True, 'heatingAccessory': {'rearWindow': 3, 'sideMirror': 3, 'steeringWheel': 3}, 'ignitionOnDuration': {'unit': 4, 'value': 5}, 'heatVentSeat': {'driverSeat': {'heatVentType': 1, 'heatVentLevel': 3, 'heatVentStep': 1}, 'passengerSeat': {'heatVentType': 0, 'heatVentLevel': 0, 'heatVentStep': 1}, 'rearLeftSeat': {'heatVentType': 0, 'heatVentLevel': 0, 'heatVentStep': 1}, 'rearRightSeat': {'heatVentType': 0, 'heatVentLevel': 0, 'heatVentStep': 1}}}}
2024-10-31 05:45:57.020 DEBUG (SyncWorker_3) [hyundai_kia_connect_api.KiaUvoAPIUSA] hyundai_kia_connect_api - sending https://api.owners.kia.com/apigw/v1/rems/start request with {'remoteClimate': {'airTemp': {'unit': 1, 'value': '76'}, 'airCtrl': True, 'defrost': True, 'heatingAccessory': {'rearWindow': 3, 'sideMirror': 3, 'steeringWheel': 3}, 'ignitionOnDuration': {'unit': 4, 'value': 5}, 'heatVentSeat': {'driverSeat': {'heatVentType': 1, 'heatVentLevel': 3, 'heatVentStep': 1}, 'passengerSeat': {'heatVentType': 0, 'heatVentLevel': 0, 'heatVentStep': 1}, 'rearLeftSeat': {'heatVentType': 0, 'heatVentLevel': 0, 'heatVentStep': 1}, 'rearRightSeat': {'heatVentType': 0, 'heatVentLevel': 0, 'heatVentStep': 1}}}}
2024-10-31 05:45:57.154 DEBUG (SyncWorker_3) [hyundai_kia_connect_api.KiaUvoAPIUSA] hyundai_kia_connect_api got response {"status":{"statusCode":1,"errorType":1,"errorCode":9001,"errorMessage":"Incorrect request payload format"}}
2024-10-31 05:45:57.154 ERROR (SyncWorker_3) [hyundai_kia_connect_api.KiaUvoAPIUSA] hyundai_kia_connect_api - Error: unknown error response {"status":{"statusCode":1,"errorType":1,"errorCode":9001,"errorMessage":"Incorrect request payload format"}}
2024-10-31 05:45:57.156 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 485, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 723, in _async_call_service_step
    response_data = await self._async_run_long_action(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 685, in _async_run_long_action
    return long_task.result()
           ^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2319, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2356, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/kia_uvo/services.py", line 98, in async_handle_start_climate
    await coordinator.async_start_climate(vehicle_id, climate_request_options)
  File "/config/custom_components/kia_uvo/coordinator.py", line 225, in async_start_climate
    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 140, in start_climate
    return self.api.start_climate(self.token, self.get_vehicle(vehicle_id), options)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/hyundai_kia_connect_api/KiaUvoAPIUSA.py", line 739, in start_climate
    response = self.post_request_with_logging_and_active_session(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/hyundai_kia_connect_api/KiaUvoAPIUSA.py", line 59, in request_with_active_session_wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/hyundai_kia_connect_api/KiaUvoAPIUSA.py", line 104, in request_with_logging_wrapper
    raise RequestException
requests.exceptions.RequestException
2024-10-31 05:45:57.164 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [140489690858048] Error handling message: Unknown error (unknown_error) Renat Khaliullin from X.X.X.X (Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36 Edg/130.0.0.0)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 26, in _handle_async_response
    await func(hass, connection, msg)
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 795, in handle_execute_script
    script_result = await script_obj.async_run(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1600, in async_run
    return await asyncio.shield(run.async_run())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 435, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 487, in _async_step
    self._handle_exception(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 512, in _handle_exception
    raise exception
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 485, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 723, in _async_call_service_step
    response_data = await self._async_run_long_action(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 685, in _async_run_long_action
    return long_task.result()
           ^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2319, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2356, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/kia_uvo/services.py", line 98, in async_handle_start_climate
    await coordinator.async_start_climate(vehicle_id, climate_request_options)
  File "/config/custom_components/kia_uvo/coordinator.py", line 225, in async_start_climate
    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 140, in start_climate
    return self.api.start_climate(self.token, self.get_vehicle(vehicle_id), options)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/hyundai_kia_connect_api/KiaUvoAPIUSA.py", line 739, in start_climate
    response = self.post_request_with_logging_and_active_session(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/hyundai_kia_connect_api/KiaUvoAPIUSA.py", line 59, in request_with_active_session_wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/hyundai_kia_connect_api/KiaUvoAPIUSA.py", line 104, in request_with_logging_wrapper
    raise RequestException
requests.exceptions.RequestException

I wonder if the API expects to receive temperature in integers but integration sends a string.

@cdnninja
Copy link
Collaborator

cdnninja commented Nov 1, 2024

Could be! Are you tech savvy enough to play with that in the code locally? I would also recommend simplifying the command and removing parameters for things like seats. Just do the basics and see if that works.

@cdnninja
Copy link
Collaborator

cdnninja commented Nov 1, 2024

I can't recall. Does USA have a website you can run these start commands from? If so sniffing and comparing is really easy.

@renatkh
Copy link
Contributor Author

renatkh commented Nov 2, 2024

I can code, so if you point me in the right direction I should be able to resolve this.
What is confusing is that I was able to execute the climate control command using the hyundai_kia_connect_api. So the backend is working fine. I am unfamiliar with how HASSIO wraps the command with the async request. What could be the difference? Is the latest version of integration using the latest kia_connect_api?

@cdnninja
Copy link
Collaborator

cdnninja commented Nov 2, 2024

Same values passed into the library?

It essentially just passes it via the service. Not much fancy changes. Sometimes data's issues exist. How do debug logs compare?

@cdnninja
Copy link
Collaborator

cdnninja commented Nov 2, 2024

@renatkh
Copy link
Contributor Author

renatkh commented Nov 3, 2024

I figured out what the problem is in the request. It is the climate_options.heating = 3. It is supposed to be binary, so the allowed values are 0 and 1. Here is a PR fixing the issue on the API side.

@renatkh
Copy link
Contributor Author

renatkh commented Nov 3, 2024

@renatkh
Copy link
Contributor Author

renatkh commented Nov 10, 2024

@cdnninja I still don't see the new version available on the HACS. Was the version auto bumped to *.2?

@cdnninja
Copy link
Collaborator

I fudged it to force a release. Should have one now.

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

2 participants