DarwinsBuddy / WienerNetzeSmartmeter

A home-assistant integration supporting WienerNetze Smartmeters as sensors
134 stars 14 forks source link

API Changed? #192

Closed reox closed 1 year ago

reox commented 1 year ago

Since some time, I cannot query the zählpunkt. There are errors like these:

Traceback (most recent call last):
  File "/config/custom_components/wnsm/statistics_sensor.py", line 113, in async_update
    zaehlpunkt = await self.get_zaehlpunkt(smartmeter)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/wnsm/base_sensor.py", line 96, in get_zaehlpunkt
    raise RuntimeError(f"Cannot access Zaehlpunkt {self.zaehlpunkt}")
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 576, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 938, in async_device_update
    await self.async_update()
  File "/config/custom_components/wnsm/live_sensor.py", line 41, in async_update
    zaehlpunkt = await self.get_zaehlpunkt(smartmeter)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/wnsm/base_sensor.py", line 98, in get_zaehlpunkt
    z for z in zps[0]["zaehlpunkte"] if z["zaehlpunktnummer"] == self.zaehlpunkt
               ~~~^^^
KeyError: 0

Is it failing for someone else as well? The statistics import is still working though.

reox commented 1 year ago

mhhh so I checked the API manually and there I get the correct result. It is also interesting how I can get the KeyError, when there is a check before that asserts the length is non-zero. Any hints?

reox commented 1 year ago

Weird. After 3 weeks it started working again. Maybe just a hickup in their system? I'll close it for now