Got an error from Tesla custom integration. Just want to see if I missed anything.
Background: My energy provider is serving a 3-hour free energy window. I want to start charging at 11am and stop at 2pm. To start charging, Tesla official app has already provided a “schedule charging” function, so I just need to stop charging at 2pm.
I have installed the Tesla custom integration (GitHub - alandtse/tesla: Tesla custom integration for Home Assistant. This requires a refresh token be generated by third-party apps to login.) and I have been using the sensors for a few week. Yesterday I have created an automation to call service to turn off the switch of charger provided by this integration. I got an error just now
Logger: homeassistant.components.automation.garage_stop_charging_in_peak_hour
Source: custom_components/tesla_custom/switch.py:118
Integration: Automation (documentation, issues)
First occurred: 2:00:15 PM (2 occurrences)
Last logged: 2:00:15 PM
Garage: Stop charging when peak hour: Error executing script. Unexpected error for device at pos 1:
While executing automation automation.garage_stop_charging_in_peak_hour
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 468, in _async_step
await getattr(self, handler)()
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 720, in _async_device_step
await device_action.async_call_action_from_config(
File "/usr/src/homeassistant/homeassistant/components/device_automation/action.py", line 71, in async_call_action_from_config
await platform.async_call_action_from_config(hass, config, variables, context)
File "/usr/src/homeassistant/homeassistant/components/switch/device_action.py", line 35, in async_call_action_from_config
await toggle_entity.async_call_action_from_config(
File "/usr/src/homeassistant/homeassistant/components/device_automation/toggle_entity.py", line 123, in async_call_action_from_config
await hass.services.async_call(
File "/usr/src/homeassistant/homeassistant/core.py", line 1969, in async_call
response_data = await coro
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2006, in _execute_service
return await target(service_call)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 235, in handle_service
return await service.entity_service_call(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 870, in entity_service_call
response_data = await _handle_entity_call(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 942, in _handle_entity_call
result = await task
^^^^^^^^^^
File "/config/custom_components/tesla_custom/switch.py", line 118, in async_turn_off
await self._car.stop_charge()
File "/usr/local/lib/python3.11/site-packages/teslajsonpy/car.py", line 1122, in stop_charge
data = await self._send_command("STOP_CHARGE", wake_if_asleep=False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/teslajsonpy/car.py", line 775, in _send_command
raise ex
File "/usr/local/lib/python3.11/site-packages/teslajsonpy/car.py", line 760, in _send_command
data = await self._controller.api(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/teslajsonpy/controller.py", line 1319, in api
return await self.__post_with_retries_except_unavailable(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/tenacity/_asyncio.py", line 88, in async_wrapped
return await fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/tenacity/_asyncio.py", line 47, in __call__
do = self.iter(retry_state=retry_state)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/tenacity/__init__.py", line 325, in iter
raise retry_exc.reraise()
^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/tenacity/__init__.py", line 158, in reraise
raise self.last_attempt.result()
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/concurrent/futures/_base.py", line 449, in result
return self.__get_result()
^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/concurrent/futures/_base.py", line 401, in __get_result
raise self._exception
File "/usr/local/lib/python3.11/site-packages/tenacity/_asyncio.py", line 50, in __call__
result = await fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/teslajsonpy/controller.py", line 1351, in __post_with_retries_except_unavailable
return await self.__connection.post(command, method=method, data=data, url=url)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/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.11/site-packages/teslajsonpy/connection.py", line 216, in __open
raise TeslaException(resp.status_code)
teslajsonpy.exceptions.TeslaException