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

Running Tesla Commands from Home Assistant does not work #901

Open
dnviti opened this issue Mar 13, 2024 · 33 comments
Open

Running Tesla Commands from Home Assistant does not work #901

dnviti opened this issue Mar 13, 2024 · 33 comments
Labels
car For items that relate to Tesla vehicles triage New issues raised that need initial attention

Comments

@dnviti
Copy link

dnviti commented Mar 13, 2024

Version of the custom_component

latest

Describe the bug

I'm trying to start and stop charge from home assistant but it does not work, logs below

image

Debug log

Warning! Logs in italian language!


Registratore: homeassistant.components.websocket_api.http.connection
Fonte: components/websocket_api/commands.py:239
integration: Home Assistant WebSocket API (documentazione, problemi)
Prima occorrenza: 13 marzo 2024 alle ore 23:45:03 (5 occorrenze)
Ultima registrazione: 00:17:17

[139675757021120]
[139675626396736]
[139675593994944]
[139675593440704]
[139675637387584]
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 239, in handle_call_service
    response = await hass.services.async_call(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  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 "/usr/src/homeassistant/homeassistant/helpers/service.py", line 905, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 975, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/config/custom_components/tesla_custom/switch.py", line 114, in async_turn_on
    await self._car.start_charge()
  File "/usr/local/lib/python3.12/site-packages/teslajsonpy/car.py", line 1113, in start_charge
    data = await self._send_command("START_CHARGE")
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/teslajsonpy/car.py", line 775, in _send_command
    raise ex
  File "/usr/local/lib/python3.12/site-packages/teslajsonpy/car.py", line 760, in _send_command
    data = await self._controller.api(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/teslajsonpy/controller.py", line 1317, in api
    response = await self.__post_with_retries(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/tenacity/_asyncio.py", line 88, in async_wrapped
    return await fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/tenacity/_asyncio.py", line 47, in __call__
    do = self.iter(retry_state=retry_state)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/tenacity/__init__.py", line 325, in iter
    raise retry_exc.reraise()
          ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/tenacity/__init__.py", line 158, in reraise
    raise self.last_attempt.result()
          ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 449, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/usr/local/lib/python3.12/site-packages/tenacity/_asyncio.py", line 50, in __call__
    result = await fn(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/teslajsonpy/controller.py", line 1340, in __post_with_retries
    return await self.__connection.post(command, method=method, data=data, url=url)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/teslajsonpy/connection.py", line 165, in post
    return await self.__open(url, method=method, headers=self.head, data=data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/teslajsonpy/connection.py", line 217, in __open
    raise TeslaException(resp.status_code)
teslajsonpy.exceptions.TeslaException


@skipishere
Copy link
Collaborator

Hi can you please add in the version of the integration you have installed in home assistant, latest isn't descriptive and given there have been a few releases in the last few days you could be on a few different potential versions.

@skipishere skipishere added car For items that relate to Tesla vehicles triage New issues raised that need initial attention labels Mar 13, 2024
@flogitgeek
Copy link

I have the same problem. I jsut installed this custom component and was hopign to change the Charging amps based on solar production but no commands works (honk,, etc.). I am running the latest version which is v3.20.3 (I just updated) but that problem was also on v3.20.2.

Below are the logs:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 239, in handle_call_service
    response = await hass.services.async_call(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  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 "/usr/src/homeassistant/homeassistant/helpers/service.py", line 905, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 975, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/button/__init__.py", line 139, in _async_press_action
    await self.async_press()
  File "/config/custom_components/tesla_custom/button.py", line 45, in async_press
    await self._car.honk_horn()
  File "/usr/local/lib/python3.12/site-packages/teslajsonpy/car.py", line 850, in honk_horn
    await self._send_command("HONK_HORN", on=True)
  File "/usr/local/lib/python3.12/site-packages/teslajsonpy/car.py", line 775, in _send_command
    raise ex
  File "/usr/local/lib/python3.12/site-packages/teslajsonpy/car.py", line 760, in _send_command
    data = await self._controller.api(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/teslajsonpy/controller.py", line 1367, in api
    response = await self.__post_with_retries(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/tenacity/_asyncio.py", line 88, in async_wrapped
    return await fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/tenacity/_asyncio.py", line 47, in __call__
    do = self.iter(retry_state=retry_state)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/tenacity/__init__.py", line 325, in iter
    raise retry_exc.reraise()
          ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/tenacity/__init__.py", line 158, in reraise
    raise self.last_attempt.result()
          ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 449, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/usr/local/lib/python3.12/site-packages/tenacity/_asyncio.py", line 50, in __call__
    result = await fn(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/teslajsonpy/controller.py", line 1390, in __post_with_retries
    return await self.__connection.post(command, method=method, data=data, url=url)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/teslajsonpy/connection.py", line 166, in post
    return await self.__open(url, method=method, headers=self.head, data=data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/teslajsonpy/connection.py", line 218, in __open
    raise TeslaException(resp.status_code)
teslajsonpy.exceptions.TeslaException

@MrBLJ
Copy link

MrBLJ commented Mar 14, 2024

I have the same problem. I jsut installed this custom component and was hopign to change the Charging amps based on solar production but no commands works (honk,, etc.). I am running the latest version which is v3.20.3 (I just updated) but that problem was also on v3.20.2.

Below are the logs:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 239, in handle_call_service
    response = await hass.services.async_call(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  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 "/usr/src/homeassistant/homeassistant/helpers/service.py", line 905, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 975, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/button/__init__.py", line 139, in _async_press_action
    await self.async_press()
  File "/config/custom_components/tesla_custom/button.py", line 45, in async_press
    await self._car.honk_horn()
  File "/usr/local/lib/python3.12/site-packages/teslajsonpy/car.py", line 850, in honk_horn
    await self._send_command("HONK_HORN", on=True)
  File "/usr/local/lib/python3.12/site-packages/teslajsonpy/car.py", line 775, in _send_command
    raise ex
  File "/usr/local/lib/python3.12/site-packages/teslajsonpy/car.py", line 760, in _send_command
    data = await self._controller.api(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/teslajsonpy/controller.py", line 1367, in api
    response = await self.__post_with_retries(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/tenacity/_asyncio.py", line 88, in async_wrapped
    return await fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/tenacity/_asyncio.py", line 47, in __call__
    do = self.iter(retry_state=retry_state)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/tenacity/__init__.py", line 325, in iter
    raise retry_exc.reraise()
          ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/tenacity/__init__.py", line 158, in reraise
    raise self.last_attempt.result()
          ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 449, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/usr/local/lib/python3.12/site-packages/tenacity/_asyncio.py", line 50, in __call__
    result = await fn(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/teslajsonpy/controller.py", line 1390, in __post_with_retries
    return await self.__connection.post(command, method=method, data=data, url=url)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/teslajsonpy/connection.py", line 166, in post
    return await self.__open(url, method=method, headers=self.head, data=data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/teslajsonpy/connection.py", line 218, in __open
    raise TeslaException(resp.status_code)
teslajsonpy.exceptions.TeslaException

I'm in the exact same case with solar optimization. Downgrading to 3.19.11 fixed the issue. I also noticed, twice, that if after a reboot I send a command while the car is awake then it runs fine, even if the cars goes to sleep after a while.

@flogitgeek
Copy link

I'm in the exact same case with solar optimization. Downgrading to 3.19.11 fixed the issue. I also noticed, twice, that if after a reboot I send a command while the car is awake then it runs fine, even if the cars goes to sleep after a while.

I have tried that but still the car does not respond to commands. The asleep sensor is off so the car should be awake! It is a newer car (1 week old) in Europe but I don't see the error about requiring the new API.

@skipishere
Copy link
Collaborator

skipishere commented Mar 14, 2024

I have tried that but still the car does not respond to commands. The asleep sensor is off so the car should be awake! It is a newer car (1 week old) in Europe but I don't see the error about requiring the new API.

@flogitgeek can you send any command to your car and get a response? e.g. Unlock doors? If your car is that new there is a strong chance you can't use the unofficial API to send commands

Edit read you other post, your issue is you have to use the new API to send commands so downgrading to an older version will not work for you

@MrBLJ
Copy link

MrBLJ commented Mar 15, 2024

I did some digging into this.

In my case, the error arises when a command is sent to the car when it sleeps. In my case, the command start_charge has been sent by the integration that optimizes my solar production, at 08:54:19. The car was asleep at this time. Sending the command appears to have wake the vehicle, which was reported online one minute later :
image

However, the command did not wait for the vehicle to be awake and failed instead :

Enregistreur: homeassistant.core
Source: core.py:2335
S'est produit pour la première fois: 08:54:19 (2 occurrences)
Dernier enregistrement: 08:54:21

Error executing service: <ServiceCall switch.turn_on (c:XXXXXX): entity_id=['switch.titine_charger']>
Error executing service: <ServiceCall number.set_value (c:XXXXXX): value=7.0, entity_id=['number.titine_charging_amps']>
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/core.py", line 2335, in _run_service_call_catch_exceptions
    await coro_or_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 2356, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 905, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 975, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/config/custom_components/tesla_custom/switch.py", line 114, in async_turn_on
    await self._car.start_charge()
  File "/usr/local/lib/python3.12/site-packages/teslajsonpy/car.py", line 1113, in start_charge
    data = await self._send_command("START_CHARGE")
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/teslajsonpy/car.py", line 775, in _send_command
    raise ex
  File "/usr/local/lib/python3.12/site-packages/teslajsonpy/car.py", line 760, in _send_command
    data = await self._controller.api(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/teslajsonpy/controller.py", line 1348, in api
    await self.wake_up(car_id=car_id)
  File "/usr/local/lib/python3.12/site-packages/teslajsonpy/controller.py", line 486, in wake_up
    response = await self.get_vehicle_summary(vin=car_vin)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/teslajsonpy/controller.py", line 343, in get_vehicle_summary
    await self.api(
  File "/usr/local/lib/python3.12/site-packages/teslajsonpy/controller.py", line 1375, in api
    return await self.__post_with_retries_except_unavailable(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/tenacity/_asyncio.py", line 88, in async_wrapped
    return await fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/tenacity/_asyncio.py", line 47, in __call__
    do = self.iter(retry_state=retry_state)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/tenacity/__init__.py", line 314, in iter
    return fut.result()
           ^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 449, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/usr/local/lib/python3.12/site-packages/tenacity/_asyncio.py", line 50, in __call__
    result = await fn(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/teslajsonpy/controller.py", line 1407, in __post_with_retries_except_unavailable
    return await self.__connection.post(command, method=method, data=data, url=url)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/teslajsonpy/connection.py", line 166, in post
    return await self.__open(url, method=method, headers=self.head, data=data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/teslajsonpy/connection.py", line 218, in __open
    raise TeslaException(resp.status_code)
teslajsonpy.exceptions.TeslaException

@Chacsam
Copy link

Chacsam commented Mar 15, 2024

Similar issue here.
Some commands (flash lights) work, but not the key ones regarding charging.
Tesla software 2024.2.7 (model 3)
Tesla integration software: 3.20.3
HA Core docker 2024.3.1

Enregistreur: homeassistant.components.websocket_api.http.connection
Source: components/websocket_api/commands.py:239
intégration: Home Assistant WebSocket API (documentation, problèmes)
S'est produit pour la première fois: 09:46:35 (1 occurrences)
Dernier enregistrement: 09:46:35

[140334190349248]
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 239, in handle_call_service
    response = await hass.services.async_call(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  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 "/usr/src/homeassistant/homeassistant/helpers/service.py", line 905, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 975, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/config/custom_components/tesla_custom/switch.py", line 114, in async_turn_on
    await self._car.start_charge()
  File "/usr/local/lib/python3.12/site-packages/teslajsonpy/car.py", line 1113, in start_charge
    data = await self._send_command("START_CHARGE")
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/teslajsonpy/car.py", line 775, in _send_command
    raise ex
  File "/usr/local/lib/python3.12/site-packages/teslajsonpy/car.py", line 760, in _send_command
    data = await self._controller.api(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/teslajsonpy/controller.py", line 1367, in api
    response = await self.__post_with_retries(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/tenacity/_asyncio.py", line 88, in async_wrapped
    return await fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/tenacity/_asyncio.py", line 47, in __call__
    do = self.iter(retry_state=retry_state)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/tenacity/__init__.py", line 325, in iter
    raise retry_exc.reraise()
          ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/tenacity/__init__.py", line 158, in reraise
    raise self.last_attempt.result()
          ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 449, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/usr/local/lib/python3.12/site-packages/tenacity/_asyncio.py", line 50, in __call__
    result = await fn(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/teslajsonpy/controller.py", line 1390, in __post_with_retries
    return await self.__connection.post(command, method=method, data=data, url=url)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/teslajsonpy/connection.py", line 166, in post
    return await self.__open(url, method=method, headers=self.head, data=data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/teslajsonpy/connection.py", line 218, in __open
    raise TeslaException(resp.status_code)
teslajsonpy.exceptions.TeslaException

@top-gun
Copy link

top-gun commented Mar 16, 2024

Have any of you guys read the information about the latest releases and using the new fleet API for newer Tesla vehicles? The old APi can no longer control cars that Tesla migrated to the Fleet API. The new api requies the latest version and more extensive configuration. Please read the documentation.

@flogitgeek
Copy link

Have any of you guys read the information about the latest releases and using the new fleet API for newer Tesla vehicles? The old APi can no longer control cars that Tesla migrated to the Fleet API. The new api requies the latest version and more extensive configuration. Please read the documentation.

I was not getting the error listed in the documentation and wasn't sure if it impacted every regions as people could still use their integration from what I was reading on the home assistant forum.

Maybe be best to update the documentation to clarify better?

@Chacsam
Copy link

Chacsam commented Mar 16, 2024

Have any of you guys read the information about the latest releases and using the new fleet API for newer Tesla vehicles? The old APi can no longer control cars that Tesla migrated to the Fleet API. The new api requies the latest version and more extensive configuration. Please read the documentation.

I thought about it, but the error seemed different, so I added my input.
If I read the doc right, the new setup requires an add-on that won't be easy to install on a core HA, that will be the challenge of the day

@top-gun
Copy link

top-gun commented Mar 16, 2024

Have any of you guys read the information about the latest releases and using the new fleet API for newer Tesla vehicles? The old APi can no longer control cars that Tesla migrated to the Fleet API. The new api requies the latest version and more extensive configuration. Please read the documentation.

I thought about it, but the error seemed different, so I added my input. If I read the doc right, the new setup requires an add-on that won't be easy to install on a core HA, that will be the challenge of the day

Actually, I was able to set the new solution up on my HA pi which is just a standard SD image setup. The challenge was more about getting all the domains into the right add on and performing steps in the right order despite the nested addons.

@Chacsam
Copy link

Chacsam commented Mar 16, 2024

Have any of you guys read the information about the latest releases and using the new fleet API for newer Tesla vehicles? The old APi can no longer control cars that Tesla migrated to the Fleet API. The new api requies the latest version and more extensive configuration. Please read the documentation.

I thought about it, but the error seemed different, so I added my input. If I read the doc right, the new setup requires an add-on that won't be easy to install on a core HA, that will be the challenge of the day

Actually, I was able to set the new solution up on my HA pi which is just a standard SD image setup. The challenge was more about getting all the domains into the right add on and performing steps in the right order despite the nested addons.

My setup is HA in a docker behind a nginx proxy manager on another machine.
I am convinced there must be a way to set a Tesla api proxy up, but just haven't found how yet.

@dnviti
Copy link
Author

dnviti commented Mar 17, 2024

Have any of you guys read the information about the latest releases and using the new fleet API for newer Tesla vehicles? The old APi can no longer control cars that Tesla migrated to the Fleet API. The new api requies the latest version and more extensive configuration. Please read the documentation.

I thought about it, but the error seemed different, so I added my input. If I read the doc right, the new setup requires an add-on that won't be easy to install on a core HA, that will be the challenge of the day

Yes, Fleet Api requires a complex setup, i'm not sure if the effort will be worth the result...

@dnviti
Copy link
Author

dnviti commented Mar 17, 2024

I have to add that i run no business so i cannot register to developer portal at all

image

@kmil4
Copy link

kmil4 commented Mar 21, 2024

+1 on this issue. A few weeks back my car stopped responding to commands. All sensor data seems to work just fine. But pressing any button, toggle, dropdown, etc... nothing. Just get a similar error. Makes me sad, this is my favorite integration.

Source: components/websocket_api/commands.py:239
integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 12:50:24 PM (1 occurrences)
Last logged: 12:50:24 PM

[546532505024]
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 239, in handle_call_service
    response = await hass.services.async_call(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  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 "/usr/src/homeassistant/homeassistant/helpers/service.py", line 905, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 975, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/button/__init__.py", line 139, in _async_press_action
    await self.async_press()
  File "/config/custom_components/tesla_custom/button.py", line 56, in async_press
    await self._car.flash_lights()
  File "/usr/local/lib/python3.12/site-packages/teslajsonpy/car.py", line 846, in flash_lights
    await self._send_command("FLASH_LIGHTS", on=True)
  File "/usr/local/lib/python3.12/site-packages/teslajsonpy/car.py", line 775, in _send_command
    raise ex
  File "/usr/local/lib/python3.12/site-packages/teslajsonpy/car.py", line 760, in _send_command
    data = await self._controller.api(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/teslajsonpy/controller.py", line 1367, in api
    response = await self.__post_with_retries(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/tenacity/_asyncio.py", line 88, in async_wrapped
    return await fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/tenacity/_asyncio.py", line 47, in __call__
    do = self.iter(retry_state=retry_state)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/tenacity/__init__.py", line 325, in iter
    raise retry_exc.reraise()
          ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/tenacity/__init__.py", line 158, in reraise
    raise self.last_attempt.result()
          ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 449, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/usr/local/lib/python3.12/site-packages/tenacity/_asyncio.py", line 50, in __call__
    result = await fn(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/teslajsonpy/controller.py", line 1390, in __post_with_retries
    return await self.__connection.post(command, method=method, data=data, url=url)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/teslajsonpy/connection.py", line 166, in post
    return await self.__open(url, method=method, headers=self.head, data=data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/teslajsonpy/connection.py", line 218, in __open
    raise TeslaException(resp.status_code)
teslajsonpy.exceptions.TeslaException

@llamafilm
Copy link
Collaborator

Have you read the README? It explains how to make this work with Tesla’s recent API change. Warning: it’s a complicated setup, not for the faint of heart.

@Chacsam
Copy link

Chacsam commented Mar 22, 2024

Have you read the README? It explains how to make this work with Tesla’s recent API change. Warning: it’s a complicated setup, not for the faint of heart.

yes I have, an it requires the installation of two add-ons, which is not possible on my docker-based HA core setup

@darek-margas
Copy link

yes I have, an it requires the installation of two add-ons, which is not possible on my docker-based HA core setup

Why it isn't? It seems I just did it on my stockpile of docker-composed containers. Just need one container and proxy if you don't have it already.

@darek-margas
Copy link

I have to add that i run no business so i cannot register to developer portal at all

Just type your name.

@dnviti
Copy link
Author

dnviti commented Mar 22, 2024

I have to add that i run no business so i cannot register to developer portal at all

Just type your name.

ofc... then i make up completely the TAX ID also.
and when pricing will become available then i'll have big fiscal problems...

@Chacsam
Copy link

Chacsam commented Mar 22, 2024

yes I have, an it requires the installation of two add-ons, which is not possible on my docker-based HA core setup

Why it isn't? It seems I just did it on my stockpile of docker-composed containers. Just need one container and proxy if you don't have it already.

Fully agree, it's my lack of capacity going beyond the basic readme.
My docker core is behind a NPM on another server and I don't see how to get it set up in my case

@Mattheinrichs
Copy link
Contributor

Same problem here. Also a brand new vehicle, one of the Highland edition Model3's, if that's a factor.
All of my sensor data is working fine, just not commands. I am NOT running the Fleet proxy, but I had (wrongly?) assumed that since I a) wasn't getting the errors described in the docs and b) the sensor data was returning correctly, that I didn't need it. Bad assumption?

@skipishere
Copy link
Collaborator

Same problem here. Also a brand new vehicle, one of the Highland edition Model3's, if that's a factor. All of my sensor data is working fine, just not commands. I am NOT running the Fleet proxy, but I had (wrongly?) assumed that since I a) wasn't getting the errors described in the docs and b) the sensor data was returning correctly, that I didn't need it. Bad assumption?

This has been mentioned many times, including in this thread. New cars and in theory all cars at some point (bar some older ones) will need to use the Fleet API going forward.

@llamafilm
Copy link
Collaborator

I've just updated the Tesla HTTP Proxy add-on to version 2.1.1 which removes the OAuth flow piece entirely. I hope this simplifies the setup for some people. Now the only "hard" part is figuring out how to host your public key. I recommend using Auth App For Tesla to generate the API token.

@darek-margas
Copy link

I've just updated the Tesla HTTP Proxy add-on to version 2.1.1 which removes the OAuth flow piece entirely.

That was actually best part of it, otherwise it would be enough to run original Tesla stuff.

@Mattheinrichs
Copy link
Contributor

I've just updated the Tesla HTTP Proxy add-on to version 2.1.1 which removes the OAuth flow piece entirely. I hope this simplifies the setup for some people. Now the only "hard" part is figuring out how to host your public key. I recommend using Auth App For Tesla to generate the API token.

Thank you! Updated docs are also great - I understand where the complexity is now too (hosting the key).
Trying to think through alternatives, is there any opportunity to use my Nabu Casa URL (which has a cert) to host the public key? Looks like I would just need to put my key somewhere in my HAOS install that would expose it as: https://my.nabucasa.URL/.well-known/appspecific/com.tesla.3p.public-key.pem

Is there anything obvious I'm missing here? (Before I spend a bunch of time trying to figure out how to make this work :) ). Does the Redirect URI need to be on the same domain?

@Mattheinrichs
Copy link
Contributor

I'm going to take my question over to here, and stop spamming this issue: llamafilm/tesla-http-proxy-addon#3

@llamafilm
Copy link
Collaborator

For anyone getting a generic TeslaException, please enable debug logging by clicking on Settings > Devices > Tesla Custom Integration > Enable Debug Logging. Next time the issue happens, you should see the real error message at debug level. I'm looking for ideas on how to improve the error logging: #935

@BenoitDuffez
Copy link

2024-06-05 08:46:16.994 DEBUG (MainThread) [teslajsonpy.connection] post: https://owner-api.teslamotors.com/api/1/vehicles/1493134057821178/command/honk_horn {'on': True}
2024-06-05 08:46:17.196 DEBUG (MainThread) [teslajsonpy.connection] 403: {"response":null,"error":"Tesla Vehicle Command Protocol required, please refer to the documentation here: https://developer.tesla.com/docs/fleet-api#2023-10-09-rest-api-vehicle-commands-endpoint-deprecation-warning","error_description":""}

@skipishere
Copy link
Collaborator

@BenoitDuffez you need to be using the fleet API like the error detail mentions

@BenoitDuffez
Copy link

@skipishere Maybe I am mistaken but I am just a user of the HA Tesla integration and I have no control over what API is used. I can't honk from HA because it seems the integration does not use the appropriate API. I'm not myself choosing either API and I have no control over this, but I could be wrong

@skipishere
Copy link
Collaborator

Please see https://github.com/alandtse/tesla#tesla-fleet-api-proxy for information about why and how to setup with regards to the API

@BenoitDuffez
Copy link

Indeed, thank you. Sorry about the noise, I thought I was helping :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
car For items that relate to Tesla vehicles triage New issues raised that need initial attention
Projects
None yet
Development

No branches or pull requests