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

Battery Remaining Unavailable #998

Open
1 task done
DigitalCharon opened this issue Jun 13, 2024 · 4 comments
Open
1 task done

Battery Remaining Unavailable #998

DigitalCharon opened this issue Jun 13, 2024 · 4 comments
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed powerwall For items that to Tesla Powerwall teslajsonpy Issue with dependency triage New issues raised that need initial attention

Comments

@DigitalCharon
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.

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

@DigitalCharon DigitalCharon added powerwall For items that to Tesla Powerwall triage New issues raised that need initial attention labels Jun 13, 2024
@alandtse alandtse added bug Something isn't working help wanted Extra attention is needed good first issue Good for newcomers teslajsonpy Issue with dependency labels Jun 13, 2024
@Dr-ead
Copy link

Dr-ead commented Jun 15, 2024

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
Copy link

portaldon commented Jun 23, 2024

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: #919 (comment)

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

@vvuk
Copy link

vvuk commented Jul 8, 2024

Similar but subtly different issue. Lots of Task exception was never retrieved (might be nice if the integration catches internal exceptions and sets itself to an error state or similar?), but the traceback is:

...
home-assistant  |   File "/config/custom_components/tesla_custom/sensor.py", line 445, in native_value
home-assistant  |     return round(self._energysite.energy_left)
home-assistant  |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
home-assistant  |   File "/usr/local/lib/python3.12/site-packages/teslajsonpy/energy.py", line 152, in energy_left
home-assistant  |     return round (self._site_config.get("nameplate_energy") * self.percentage_charged / 100 )
home-assistant  |                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
home-assistant  | TypeError: unsupported operand type(s) for *: 'int' and 'NoneType'

which I believe means that nameplate_energy is an int, and percentage_charged is None -- whereas in the initial post about this issue, it looked like it was None and float. Could be the exact same issue just different python version/impl reporting differently, but it's odd.

@DigitalCharon
Copy link
Author

I ended up getting my integration working again by replacing
return round (self._site_config.get("nameplate_energy") * self.percentage_charged / 100 )
with
return round (self._site_config.get("battery_count")*self._site_summary.get("percentage_charged")*13500/100)

in the energy.py of my local copy of teslajsonpy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed powerwall For items that to Tesla Powerwall teslajsonpy Issue with dependency triage New issues raised that need initial attention
Projects
None yet
Development

No branches or pull requests

5 participants