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
555 stars 99 forks source link

Powerwall Issue: TypeError: type NoneType doesn't define __round__ method - return round(self._energysite.energy_left) #930

Closed purcell-lab closed 3 months ago

purcell-lab commented 3 months ago

Is there an existing issue for this?

Version of the Tesla component

c3.20.4

Version of the Powerwall Gateway software

24.4.0 0fe780c9

Model

2

Current Behavior

With the recent upstream API breakage the Powerwall component of the integration isn't happy and refuses to load entity values:

image

Expected Behavior

The integration should report against the entities that it can receive and fail gracefully for others that it cannot identify.

Debug logs

This error originated from a custom integration.

Logger: homeassistant
Source: custom_components/tesla_custom/sensor.py:443
integration: Tesla Custom Integration (documentation, issues)
First occurred: March 28, 2024 at 8:26:42 PM (3818 occurrences)
Last logged: 9:05:03 AM

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 258, in _handle_refresh_interval
    await self._async_refresh(log_failures=True, scheduled=True)
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 414, in _async_refresh
    self.async_update_listeners()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 168, in async_update_listeners
    update_callback()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 998, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1119, in _async_write_ha_state
    state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1056, in __async_calculate_state
    state = self._stringify_state(available)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1004, in _stringify_state
    if (state := self.state) is None:
                 ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 548, in state
    value = self.native_value
            ^^^^^^^^^^^^^^^^^
  File "/config/custom_components/tesla_custom/sensor.py", line 443, in native_value
    return round(self._energysite.energy_left)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: type NoneType doesn't define __round__ method


### Anything else?

_No response_
skipishere commented 3 months ago

Duplicate of #919

alandtse commented 3 months ago

@skipishere feel free to close dupes once identified. It makes it easier to try to reduce the issues people have to search through. Thanks!