jrester / tesla_powerwall

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

Adding "busway" meter type to fix "ValueError: 'busway' is not a valid MeterType" #40

Closed maikukun closed 2 years ago

maikukun commented 2 years ago

Hi! Thank you for developing and maintaining this library! Looking forward to using it as part of Home Assistant.

I've found a missing meter in HomeAssistant 2022.6.6, tesla_powerwall 0.3.17, and Powerwall Gateway 22.9.2, similar to issue #30 (which added "generator"):

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 191, in _async_refresh self.data = await self._async_update_data() File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 150, in _async_update_data return await self.update_method() File "/usr/src/homeassistant/homeassistant/components/powerwall/init.py", line 85, in async_update_data return await self.hass.async_add_executor_job(self._update_data) File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) File "/usr/src/homeassistant/homeassistant/components/powerwall/init.py", line 94, in _update_data data = _fetch_powerwall_data(self.power_wall) File "/usr/src/homeassistant/homeassistant/components/powerwall/init.py", line 217, in _fetch_powerwall_data 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 104, in init self.meters = [MeterType(key) for key in response.keys()] File "/usr/local/lib/python3.9/site-packages/tesla_powerwall/responses.py", line 104, in 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: 'busway' is not a valid MeterType

Please let me know if you would like Unit Tests or Readme updates, as I'm initially modeling this PR off of #30, which just contained the enum update. Thank you again!

jrester commented 2 years ago

Hi @maikukun, thank you very much for your PR. It would be great if you could add busway to the available meters in the README.md as well as updating the supported powerwall software version. I don't believe that updating the unit tests is necessary, as there isn't any new logic.

maikukun commented 2 years ago

Thank you for the review, @jrester! I've updated the readme with the changes mentioned above. Please let me know if you have any questions or concerns.

jrester commented 2 years ago

@maikukun looks good!

jrester commented 2 years ago

included in Release v0.3.18

maikukun commented 2 years ago

Thank you, @jrester! :) Should I open a Home Assistant PR to have this version updated there or are there additional steps?

jrester commented 2 years ago

Yes, you can just bump the powerwall Version in Homeassistant. Just make sure to follow the contribution guidelines there ;)

maikukun commented 2 years ago

Cool, thanks again, @jrester! I've opened a PR on HA core: https://github.com/home-assistant/core/pull/74026, modeled after yours here: https://github.com/home-assistant/core/pull/58284.