DarwinsBuddy / WienerNetzeSmartmeter

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

Error on device update #215

Closed antonmosich closed 8 months ago

antonmosich commented 8 months ago

I'm sorry, I'm really not deep enough into home-assistant to provide a proper bug report, but for me it only shows "Unknown" for the added entity, and isn't able to load any data from the API. Looking at my logs I seem to have 3 errors with this plugin. The first has this Traceback:

Traceback (most recent call last):
  File "/nix/store/gx2n17v083h4p8jf34cibp0qz4mrwxph-homeassistant-2024.1.3/lib/python3.11/site-packages/homeassistant/helpers/entity_platform.py", line 573, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/nix/store/gx2n17v083h4p8jf34cibp0qz4mrwxph-homeassistant-2024.1.3/lib/python3.11/site-packages/homeassistant/helpers/entity.py", line 1216, in async_device_update
    await self.async_update()
  File "/var/lib/hass/custom_components/wnsm/statistics_sensor.py", line 123, in async_update
    await self._import_bewegungsdaten(smartmeter)
  File "/var/lib/hass/custom_components/wnsm/statistics_sensor.py", line 187, in _import_bewegungsdaten
    recording = await self.get_bewegungsdaten(smartmeter)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/lib/hass/custom_components/wnsm/base_sensor.py", line 156, in get_bewegungsdaten
    response = await self.hass.async_add_executor_job(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/asiphbpiy2gmidfm3xbwcikayhs66289-python3-3.11.7/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/lib/hass/custom_components/wnsm/api/client.py", line 506, in bewegungsdaten
    if data["descriptor"]["zaehlpunktnummer"] != zaehlpunkt:
       ~~~~^^^^^^^^^^^^^^
KeyError: 'descriptor'

The second one just says unable to load consumption without further information. The third one has the following information (anonymized)

Please file an issue with this error and (anonymized) payload in github {'hasSmartMeter': True, 'isDataDeleted': False, 'zaehlpunkt': 'AT001000000000000000100000ddddddd', 'type': 'TAGSTROM', 'address': 'My Address', 'zip': 'dddd'} {'consumptionYesterdayValue': dddd, 'consumptionYesterdayValidated': True, 'consumptionYesterdayTimestamp': '2024-01-24T23:00:00.000Z', 'consumptionDayBeforeYesterdayValue': dddd, 'consumptionDayBeforeYesterdayValidated': True, 'consumptionDayBeforeYesterdayTimestamp': '2024-01-23T23:00:00.000Z'} {} {'optIn': True, 'consumptionAverage': 0, 'consumptionMinimum': 0, 'consumptionMaximum': 0}
achtnullzwei commented 8 months ago

Can confirm "descriptor" issue.

Logger: homeassistant.components.sensor
Source: helpers/entity_platform.py:573
Integration: Sensor ([documentation](https://www.home-assistant.io/integrations/sensor), [issues](https://github.com/home-assistant/core/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+sensor%22))
First occurred: 14:03:02 (1 occurrences)
Last logged: 14:03:02

wnsm: Error on device update!
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 573, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1216, in async_device_update
    await self.async_update()
  File "/config/custom_components/wnsm/statistics_sensor.py", line 123, in async_update
    await self._import_bewegungsdaten(smartmeter)
  File "/config/custom_components/wnsm/statistics_sensor.py", line 187, in _import_bewegungsdaten
    recording = await self.get_bewegungsdaten(smartmeter)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/wnsm/base_sensor.py", line 156, in get_bewegungsdaten
    response = await self.hass.async_add_executor_job(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/wnsm/api/client.py", line 506, in bewegungsdaten
    if data["descriptor"]["zaehlpunktnummer"] != zaehlpunkt:
       ~~~~^^^^^^^^^^^^^^
KeyError: 'descriptor'

Additionally I get this one but I think that might not be related to wnsm:

Logger: homeassistant.helpers.template
Source: helpers/template.py:2318
First occurred: 14:02:19 (3 occurrences)
Last logged: 14:06:19

Template variable warning: 'dict object' has no attribute 'displaymetric' when rendering '{{ value_json.displaymetric }}'
DarwinsBuddy commented 8 months ago

sorry for the back and forth. I think we have to invest into proper e2e tests