jrester / tesla_powerwall

Python API for Tesla Powerwall
MIT License
73 stars 25 forks source link

ValueError: 'generator' is not a valid MeterType #30

Closed Arsecroft closed 3 years ago

Arsecroft commented 3 years ago

I've been using this library via home-assistant for a year and it's great!

I recently upgraded to home-assistant 2021.10.6, which uses tesla_powerwall==0.3.11 and I am getting an exception when I attempt to communicate with the gateway:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 187, in _async_refresh
    self.data = await self._async_update_data()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 147, in _async_update_data
    return await self.update_method()
  File "/usr/src/homeassistant/homeassistant/components/powerwall/__init__.py", line 143, in async_update_data
    data = await _async_update_powerwall_data(hass, entry, power_wall)
  File "/usr/src/homeassistant/homeassistant/components/powerwall/__init__.py", line 191, in _async_update_powerwall_data
    return await hass.async_add_executor_job(_fetch_powerwall_data, power_wall)
  File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/powerwall/__init__.py", line 227, in _fetch_powerwall_data
    POWERWALL_API_METERS: power_wall.get_meters(),
  File "/usr/local/lib/python3.9/site-packages/tesla_powerwall/powerwall.py", line 92, in get_meters
    return MetersAggregates(self._api.get_meters_aggregates())
  File "/usr/local/lib/python3.9/site-packages/tesla_powerwall/responses.py", line 107, in __init__
    self.meters = [MeterType(key) for key in response.keys()]
  File "/usr/local/lib/python3.9/site-packages/tesla_powerwall/responses.py", line 107, in <listcomp>
    self.meters = [MeterType(key) for key in response.keys()]
  File "/usr/local/lib/python3.9/enum.py", line 384, in __call__
    return cls.__new__(cls, value)
  File "/usr/local/lib/python3.9/enum.py", line 702, in __new__
    raise ve_exc
ValueError: 'generator' is not a valid MeterType

My powerwall firmware version is 21.35.0, and I do have a generator power source.

Arsecroft commented 3 years ago

Let me know if there's any more information I can provide, I am conversant in python, although short on time. I might be able to work on a fix myself in the next few days.

jrester commented 3 years ago

Thanks for reporting! It is a very simple error, as generator is not an expected meter. I will fix it immediately and publish the changes to home assistant.

Arsecroft commented 3 years ago

Thank you! Let me know if there's anything I can help with in the future.

jrester commented 3 years ago

Sure, thanks!