flashg1 / TeslaSolarCharger

Home Assistant smart charger Blueprint to charge Tesla car using surplus solar electricity.
MIT License
13 stars 5 forks source link

Script crashed #11

Open kimme1024 opened 10 months ago

kimme1024 commented 10 months ago

Hi,

Today I noticed that the car was charging at a higher rate than what I was producing in solar. Normally, when the automation crashes, I'm getting a notification via another automation which also will try to restart the script. However this time it didn't..

Any idea's on this?

Logger: homeassistant.components.automation.tesla_solar_charger
Source: helpers/script.py:468
Integration: Automatisering ([documentation](https://www.home-assistant.io/integrations/automation), [issues](https://github.com/home-assistant/core/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+automation%22))
First occurred: 10:49:55 (4 occurrences)
Last logged: 10:49:55

Tesla Solar Charger: Repeat at step 7: Choose at step 3: choice 4: Repeat at step 1: Error executing script. Unexpected error for call_service at pos 1:
Tesla Solar Charger: Repeat at step 7: Choose at step 3: choice 4: Error executing script. Unexpected error for repeat at pos 1:
Tesla Solar Charger: Repeat at step 7: Error executing script. Unexpected error for choose at pos 3:
Tesla Solar Charger: Error executing script. Unexpected error for repeat at pos 7:
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 704, in _async_call_service_step
    response_data = await self._async_run_long_action(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 666, in _async_run_long_action
    return long_task.result()
           ^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2012, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2049, 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 876, in entity_service_call
    response_data = await _handle_entity_call(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 948, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/number/__init__.py", line 105, in async_set_value
    await entity.async_set_native_value(native_value)
  File "/config/custom_components/tesla_custom/number.py", line 82, in async_set_native_value
    await self._car.set_charging_amps(value)
  File "/usr/local/lib/python3.11/site-packages/teslajsonpy/car.py", line 897, in set_charging_amps
    data = await self._send_command(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  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 1313, in api
    raise ex
  File "/usr/local/lib/python3.11/site-packages/teslajsonpy/controller.py", line 1307, in api
    response = await self.__post_with_retries(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  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 314, in iter
    return fut.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 1342, in __post_with_retries
    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

About an hour later I had 12 errors that the car wasn't available, 20min after the first error the script stopped working and was restarted by my other automation.. I don't know that both issues have anything to do with each other.

When the vehicle seems to be unavailable, could it be possible to implement a failsafe for this (autorestart after 1min and 5min by example)?

Logger: homeassistant.components.automation.tesla_solar_charger
Source: helpers/script.py:468
Integration: Automatisering ([documentation](https://www.home-assistant.io/integrations/automation), [issues](https://github.com/home-assistant/core/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+automation%22))
First occurred: 12:00:06 (12 occurrences)
Last logged: 12:20:18

Tesla Solar Charger: Repeat at step 7: Choose at step 3: choice 4: Error executing script. Unexpected error for repeat at pos 1: vehicle_unavailable
Tesla Solar Charger: Repeat at step 7: Error executing script. Unexpected error for choose at pos 3: vehicle_unavailable
Tesla Solar Charger: Error executing script. Unexpected error for repeat at pos 7: vehicle_unavailable
Tesla Solar Charger: Repeat at step 7: Choose at step 3: choice 5: Repeat at step 1: Error executing script. Unexpected error for call_service at pos 1: vehicle_unavailable
Tesla Solar Charger: Repeat at step 7: Choose at step 3: choice 5: Error executing script. Unexpected error for repeat at pos 1: vehicle_unavailable
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 704, in _async_call_service_step
    response_data = await self._async_run_long_action(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 666, in _async_run_long_action
    return long_task.result()
           ^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2012, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2049, 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 876, in entity_service_call
    response_data = await _handle_entity_call(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 948, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/number/__init__.py", line 105, in async_set_value
    await entity.async_set_native_value(native_value)
  File "/config/custom_components/tesla_custom/number.py", line 82, in async_set_native_value
    await self._car.set_charging_amps(value)
  File "/usr/local/lib/python3.11/site-packages/teslajsonpy/car.py", line 897, in set_charging_amps
    data = await self._send_command(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  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
    response = await self.__post_with_retries(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  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 1342, in __post_with_retries
    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 215, in __open
    raise TeslaException(resp.status_code, "vehicle_unavailable")
teslajsonpy.exceptions.TeslaException: vehicle_unavailable