alandtse / tesla

Tesla custom integration for Home Assistant. This requires a refresh token be generated by third-party apps to login.
Apache License 2.0
552 stars 99 forks source link

Battery Remaining Unavailable #998

Open DigitalCharon opened 2 weeks ago

DigitalCharon commented 2 weeks ago

Is there an existing issue for this?

Version of the Tesla component

v3.23.0

Version of the Powerwall Gateway software

24.12.6 3cc46fb9

Model

3

Current Behavior

battery remaining is unavailable.

Expected Behavior

battery percentage shows up

Debug logs

Logger: homeassistant.components.sensor
Source: helpers/entity_platform.py:914
integration: Sensor (documentation, issues)
First occurred: June 12, 2024 at 11:06:25 PM (5 occurrences)
Last logged: 10:46:49 AM

Error adding entity sensor.powerwall_battery_remaining for domain sensor with platform tesla_custom
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 914, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1355, in add_to_platform_finish
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1000, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1126, in _async_write_ha_state
    state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1061, in __async_calculate_state
    state = self._stringify_state(available)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1006, in _stringify_state
    if (state := self.state) is None:
                 ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 543, in state
    value = self.native_value
            ^^^^^^^^^^^^^^^^^
  File "/config/custom_components/tesla_custom/sensor.py", line 445, in native_value
    return round(self._energysite.energy_left)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/teslajsonpy/energy.py", line 152, in energy_left
    return round (self._site_config.get("nameplate_energy") * self.percentage_charged / 100 )
                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
TypeError: unsupported operand type(s) for *: 'NoneType' and 'float'

Anything else?

No response

Dr-ead commented 2 weeks ago

Having a similar issue here: Since yesterday I did not get any data from my Model S and I cannot send anything to it. via HA. Possible that the connection to the Tesla servers seem to be interrupted? Anyone else having this issue? For me it looks similar to the API thing at the start of this year.

portaldon commented 1 week ago

I have had the same issue just now (in addition to all powerwall sensors not updating) and performing the same fix here resolved it - perhaps this is a regression: https://github.com/alandtse/tesla/issues/919#issuecomment-2015548967

I am on v3.24.0 PWG v24.12.6 3cc46fb9 2x Powerwall 3