question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

tesla_custom.api throws an UnknownError

See original GitHub issue

Version of the custom_component

1.2.0

Configuration

service: tesla_custom.api
data:
  command: CHANGE_CLIMATE_TEMPERATURE_SETTING
  parameters:
    path_vars:
      vehicle_id: '786889216'
    driver_temp: 23.0
    passenger_temp: 23.0
    wake_if_asleep: true

or

service: tesla_custom.api
data:
  command: REMOTE_SEAT_HEATER_REQUEST
  parameters:
    path_vars:
      vehicle_id: '786889216'
    heater: 1
    level: 1
    wake_if_asleep: true

Describe the bug

Can’t seem to get any tesla_custom.api service calls to work.

Both the above examples return an UnknownError immediately. I imagine i’m doing something wrong, but not sure what. I grabbed the vehicle_id from teslafi - it should always be the same, right?

Logger: homeassistant.components.websocket_api.http.connection Source: custom_components/tesla_custom/services.py:89 Integration: Home Assistant WebSocket API (documentation, issues) First occurred: 4:13:54 PM (3 occurrences) Last logged: 4:24:49 PM

[281473288586144] Error handling message: Unknown error

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 525, in handle_execute_script await script_obj.async_run(msg.get(“variables”), context=context) File “/usr/src/homeassistant/homeassistant/helpers/script.py”, line 1219, in async_run await asyncio.shield(run.async_run()) File “/usr/src/homeassistant/homeassistant/helpers/script.py”, line 353, in async_run await self._async_step(log_exceptions=False) File “/usr/src/homeassistant/homeassistant/helpers/script.py”, line 371, in _async_step await getattr(self, handler)() File “/usr/src/homeassistant/homeassistant/helpers/script.py”, line 571, in _async_call_service_step await service_task File “/usr/src/homeassistant/homeassistant/core.py”, line 1491, in async_call task.result() File “/usr/src/homeassistant/homeassistant/core.py”, line 1526, in _execute_service await handler.job.target(service_call) File “/config/custom_components/tesla_custom/services.py”, line 43, in async_call_tesla_service await api(service_call) File “/config/custom_components/tesla_custom/services.py”, line 89, in api return await controller.api(name=command, path_vars=path_vars, **parameters) File “/usr/local/lib/python3.9/site-packages/teslajsonpy/controller.py”, line 166, in wake_up result = await wrapped(*args, **kwargs) File “/usr/local/lib/python3.9/site-packages/teslajsonpy/controller.py”, line 1180, in api return await self.__connection.post( File “/usr/local/lib/python3.9/site-packages/teslajsonpy/connection.py”, line 167, in post return await self.__open( File “/usr/local/lib/python3.9/site-packages/teslajsonpy/connection.py”, line 218, in __open raise TeslaException(resp.status_code) teslajsonpy.exceptions.TeslaException

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:14 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
cbirkenbeulcommented, Jan 14, 2022

Hi, i also get the same error. But can can see a very strange behavior. The Integration is installed fine in Home Assistant and I can control the car via the switches. I just cannot call the Tesla API via the service for example to change the amps. My ID in HASS ends with a 10. But if the integration makes a get request I get an id with 11 at the end. Rest is identical.

Therefore I results in an unknown error I guess:

2022-01-14 13:37:42 DEBUG (MainThread) [teslajsonpy.connection] post: https://owner-api.teslamotors.com/api/1/vehicles/554866356xxx42910/command/charge_start {}
2022-01-14 13:37:42 DEBUG (MainThread) [teslajsonpy.connection] 404: {"response":null,"error":"not_found","error_description":""}
2022-01-14 13:37:42 DEBUG (MainThread) [teslajsonpy.controller] Exception:
api(() {'name': 'START_CHARGE', 'path_vars': {'vehicle_id': '554866356xxx42910'}})
2022-01-14 13:37:42 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 381, in _async_step
await getattr(self, handler)()
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 584, in _async_call_service_step
await service_task
File "/usr/src/homeassistant/homeassistant/core.py", line 1495, in async_call
task.result()
File "/usr/src/homeassistant/homeassistant/core.py", line 1530, in _execute_service
await handler.job.target(service_call)
File "/config/custom_components/tesla_custom/services.py", line 43, in async_call_tesla_service
await api(service_call)
File "/config/custom_components/tesla_custom/services.py", line 89, in api
return await controller.api(name=command, path_vars=path_vars, **parameters)
File "/config/deps/lib/python3.9/site-packages/teslajsonpy/controller.py", line 170, in wake_up
result = await wrapped(*args, **kwargs)
File "/config/deps/lib/python3.9/site-packages/teslajsonpy/controller.py", line 1726, in api
return await self.__connection.post(
File "/config/deps/lib/python3.9/site-packages/teslajsonpy/connection.py", line 168, in post
return await self.__open(url, method=method, headers=self.head, data=data)
File "/config/deps/lib/python3.9/site-packages/teslajsonpy/connection.py", line 217, in __open
raise TeslaException(resp.status_code)
teslajsonpy.exceptions.TeslaException
2022-01-14 13:37:42 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [139980022390160] Error handling message: Unknown error
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 527, in handle_execute_script
await script_obj.async_run(msg.get("variables"), context=context)
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1260, in async_run
await asyncio.shield(run.async_run())
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 363, in async_run
await self._async_step(log_exceptions=False)
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 381, in _async_step
await getattr(self, handler)()
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 584, in _async_call_service_step
await service_task
File "/usr/src/homeassistant/homeassistant/core.py", line 1495, in async_call
task.result()
File "/usr/src/homeassistant/homeassistant/core.py", line 1530, in _execute_service
await handler.job.target(service_call)
File "/config/custom_components/tesla_custom/services.py", line 43, in async_call_tesla_service
await api(service_call)
File "/config/custom_components/tesla_custom/services.py", line 89, in api
return await controller.api(name=command, path_vars=path_vars, **parameters)
File "/config/deps/lib/python3.9/site-packages/teslajsonpy/controller.py", line 170, in wake_up
result = await wrapped(*args, **kwargs)
File "/config/deps/lib/python3.9/site-packages/teslajsonpy/controller.py", line 1726, in api
return await self.__connection.post(
File "/config/deps/lib/python3.9/site-packages/teslajsonpy/connection.py", line 168, in post
return await self.__open(url, method=method, headers=self.head, data=data)
File "/config/deps/lib/python3.9/site-packages/teslajsonpy/connection.py", line 217, in __open
raise TeslaException(resp.status_code)
teslajsonpy.exceptions.TeslaException

Thats a get command in the logs (charger switch in HASS)

2022-01-14 13:48:51 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in 44 days, 22:58:59
2022-01-14 13:48:51 DEBUG (MainThread) [teslajsonpy.connection] post: https://owner-api.teslamotors.com/api/1/vehicles/554866356xxx42911/command/charge_stop {}
2022-01-14 13:48:51 DEBUG (MainThread) [teslajsonpy.connection] 200: {"response":{"reason":"","result":true}}

Does his matter in which location the car is? I guess is should not important if its a US car or EU. Firmware is 2021.44.30.2

0reactions
alandtsecommented, Oct 21, 2021

… is going to be the standard template for just about every call, right? Would be cool if you could just do something like this instead:

This is intended to be direct access to the underlying api. Adding a translation layer defeats the point of direct access.

It seems to happen at a pretty steady rate. The 200: response json goes on for a while and has a lot of values. Can all of these values be made available as attributes?

Since every attribute get logged in HA at each update, this is not advisable. You’re welcome to submit a PR for a sensor that does this if you want but it must be default off and I won’t be maintaining it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues · alandtse/tesla - GitHub
Tesla custom integration for Home Assistant. This requires a refresh token be generated ... tesla_custom.api throws an UnknownError. #72 opened on Oct 18, ......
Read more >
Tesla Custom Integration - Error - Home Assistant Community
My Tesla Custom Intgegration (HACS) worked flawlessly until about 2 days ago. I tried everything figuring it was the 'Refresh Token'.
Read more >
Tesla App Cannot Connect to Vehicle: "Unknown Error" or ...
My app keeps saying unknown error. ... Details for geeks: the API gateway is currently returning HTTP 502 (Bad Gateway), HTTP 503 (Service ......
Read more >
Tesla API - Tesla API
Authentication - API commands to generate an {access_token} to communicate with your vehicle. Vehicles - API commands to communicate between your vehicle ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found