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

Setting the car current charge rate (with fleet mode) throws an exception #973

Open
2 tasks done
i-am-shodan opened this issue May 26, 2024 · 4 comments
Open
2 tasks done
Labels
car For items that relate to Tesla vehicles triage New issues raised that need initial attention

Comments

@i-am-shodan
Copy link

Is there an existing issue for this?

  • I have searched both the existing open issues & recently closed issues and did not find a duplicate of this issue.

I have read about the Fleet API and understand I may need to use it

  • I understand issues relating to read only commands will be auto closed if not using the Fleet API.

Version of the Tesla component

2024.5.5

Version of the Tesla car software

2024.8.9

Model

Model Y

Current Behavior

I have set up the fleet mode API. It was very painful!

Up until the most recent version I could happily set the charge current current using

service: number.set_value
metadata: {}
data:
    value: "14"
  target:
    entity_id: number.lightning_charging_amps

now I get a TeslaException thrown

Expected Behavior

Charge rate is set, exception isn’t throw

Debug logs

Logger: homeassistant.components.websocket_api.http.connection
Source: components/websocket_api/commands.py:239
integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 22:25:32 (2 occurrences)
Last logged: 22:25:36

[2607083368] Unexpected exception
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 2738, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2779, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 975, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1047, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/number/__init__.py", line 116, in async_set_value
    await entity.async_set_native_value(native_value)
  File "/config/custom_components/tesla_custom/number.py", line 49, in async_set_native_value
    await self._car.change_charge_limit(value)
  File "/usr/local/lib/python3.12/site-packages/teslajsonpy/car.py", line 820, in change_charge_limit
    data = await self._send_command(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  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 142, in async_wrapped
    return await fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/tenacity/_asyncio.py", line 58, in __call__
    do = await self.iter(retry_state=retry_state)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/tenacity/_asyncio.py", line 110, in iter
    result = await action(retry_state)
             ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/tenacity/_asyncio.py", line 78, in inner
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/tenacity/__init__.py", line 410, in exc_check
    raise retry_exc.reraise()
          ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/tenacity/__init__.py", line 183, 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 61, 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

Anything else?

No response

@i-am-shodan i-am-shodan added car For items that relate to Tesla vehicles triage New issues raised that need initial attention labels May 26, 2024
@i-am-shodan
Copy link
Author

May be related

In the proxy logs I can see lots of logs for error 429 too many requests.

It looks like something is calling /api/1/product a lot, much more than the 11m I have set as my polling interval.

@i-am-shodan
Copy link
Author

The proxy logs have a lot of messages, these seem like a retry and a failure

Retrying transmission after error: Post "https://fleet-api.prd.eu.vn.cloud.tesla.com/api/1/vehicles/MYCARiD/signed_command": context deadline exceeded

2024-05-26T21:47:22Z [error] Returning error Internal Server Error

@raphmur
Copy link

raphmur commented May 27, 2024

Hi, saw the same error, which brought me to the quota limitations. See issue #961 ?

@llamafilm
Copy link
Collaborator

llamafilm commented May 29, 2024

Anytime you get a generic TeslaException in the log, there should be a more meaningful error message logged at debug level. See #935. But here it sounds like you've already identified it as a rate limit.

This integration polls the vehicle every 10 seconds. See this comment and link: #961 (comment)

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

3 participants