You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have filled out the issue template to the best of my ability.
This issue only contains 1 issue (if you have multiple issues, open one issue for each issue).
This issue is not a duplicate issue of any previous issues..
Describe the issue
This may be an issue in the fleet api library. When an error is returned, the response is not JSON but text. The variable "result" then is of type string instead of dict, resulting in exceptions. Probably affects more entities like trunk or maybe all error handling.
With the reproduction steps, the error is "car could not execute command: already closed". Showing an error here is fine as the entity's state is still changing. The issue is that not the above error message is shown to the user, but "[...]string indices must be integers, not 'str'".
Reproduction steps
Click open charge port
Quickly(!) click close charge port
Debug logs
2024-02-13 14:01:23.595 DEBUG (MainThread) [tesla_fleet_api] Sending request to api/1/vehicles/VVVVVVVVVVVVVVVVV/command/charge_port_door_open
2024-02-13 14:01:25.695 DEBUG (MainThread) [tesla_fleet_api] Response Status: 200
2024-02-13 14:01:25.695 DEBUG (MainThread) [tesla_fleet_api] Response JSON: {'response': {'result': True, 'reason': ''}}
2024-02-13 14:01:25.696 DEBUG (MainThread) [custom_components.teslemetry] Command result: {'response': {'result': True, 'reason': ''}}
2024-02-13 14:01:26.045 DEBUG (MainThread) [tesla_fleet_api] Sending request to api/1/vehicles/VVVVVVVVVVVVVVVVV/command/charge_port_door_close
2024-02-13 14:01:26.564 DEBUG (MainThread) [tesla_fleet_api] Response Status: 200
2024-02-13 14:01:26.564 DEBUG (MainThread) [tesla_fleet_api] Response Text: {"response":{"result":false,"string":"car could not execute command: already closed"},"error":"","error_description":""}
2024-02-13 14:01:26.565 DEBUG (MainThread) [custom_components.teslemetry] Command result: {"response":{"result":false,"string":"car could not execute command: already closed"},"error":"","error_description":""}
2024-02-13 14:01:26.565 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [CCCCCCCCCCCCCCC] string indices must be integers, not 'str'
Traceback (most recent call last):
File "/home/hass/.local/lib/python3.12/site-packages/homeassistant/components/websocket_api/commands.py", line 240, in handle_call_service
response = await hass.services.async_call(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/hass/.local/lib/python3.12/site-packages/homeassistant/core.py", line 2279, in async_call
response_data = await coro
^^^^^^^^^^
File "/home/hass/.local/lib/python3.12/site-packages/homeassistant/core.py", line 2316, in _execute_service
return await target(service_call)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/hass/.local/lib/python3.12/site-packages/homeassistant/helpers/service.py", line 892, in entity_service_call
single_response = await _handle_entity_call(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/hass/.local/lib/python3.12/site-packages/homeassistant/helpers/service.py", line 962, in _handle_entity_call
result = await task
^^^^^^^^^^
File "/home/hass/.homeassistant/custom_components/teslemetry/cover.py", line 124, in async_close_cover
await self.handle_command(self.api.charge_port_door_close())
File "/home/hass/.homeassistant/custom_components/teslemetry/entity.py", line 138, in handle_command
if not result["response"]["result"]:
~~~~~~^^^^^^^^^^^^
TypeError: string indices must be integers, not 'str'
2024-02-13 14:01:30.617 DEBUG (MainThread) [tesla_fleet_api] Sending request to api/1/vehicles/VVVVVVVVVVVVVVVVV/command/charge_port_door_close
2024-02-13 14:01:31.139 DEBUG (MainThread) [tesla_fleet_api] Response Status: 200
2024-02-13 14:01:31.140 DEBUG (MainThread) [tesla_fleet_api] Response JSON: {'response': {'result': True, 'reason': ''}}
2024-02-13 14:01:31.140 DEBUG (MainThread) [custom_components.teslemetry] Command result: {'response': {'result': True, 'reason': ''}}
The text was updated successfully, but these errors were encountered:
Alright, I think all of your issues are related to the Tesla Command Proxy, as it does not have the same types of responses as the Fleet API directly. I'll have to add some custom code for this server side.
Checklist
Describe the issue
This may be an issue in the fleet api library. When an error is returned, the response is not JSON but text. The variable "result" then is of type string instead of dict, resulting in exceptions. Probably affects more entities like trunk or maybe all error handling.
With the reproduction steps, the error is "car could not execute command: already closed". Showing an error here is fine as the entity's state is still changing. The issue is that not the above error message is shown to the user, but "[...]string indices must be integers, not 'str'".
Reproduction steps
Debug logs
The text was updated successfully, but these errors were encountered: