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

wnsm: Error on device update #223

Open
sonypsx opened this issue Mar 11, 2024 · 7 comments · May be fixed by #228
Open

wnsm: Error on device update #223

sonypsx opened this issue Mar 11, 2024 · 7 comments · May be fixed by #228

Comments

@sonypsx
Copy link

sonypsx commented Mar 11, 2024

Hello,

first i am excited that this nice piece of software is avail!

But,I never got that wnsm working completly. The only value i can get is the value of my grid export smartmeter point. All other features like Historical data or the Grid import Smartmeter value aren't working since i found this addon.
Am i am doing something wrong?

Hint: i am aware that currently Wiener Netze do some maintenance these days, but it wasn't working before also so ...

Using:
Core 2024.3.0
Supervisor 2024.02.1
Operating System
HACS:
Integrations Version: 1.34.0
Frontend Version: 20220906112053
wnsm: v1.4.6

2024-03-10 21:49:00.368 WARNING (MainThread) [homeassistant.components.sensor] Setup of sensor platform wnsm is taking over 10 seconds. 2024-03-10 21:49:00.442 ERROR (MainThread) [homeassistant.components.sensor] wnsm: Error on device update! Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 682, in _async_add_entity await entity.async_device_update(warning=False) File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1262, 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 154, in get_bewegungsdaten response = await self.hass.async_add_executor_job( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/wnsm/api/client.py", line 504, in bewegungsdaten raise SmartmeterQueryError("Historical data is empty") custom_components.wnsm.api.errors.SmartmeterQueryError: Historical data is empty 2024-03-10 21:49:01.194 ERROR (MainThread) [custom_components.wnsm.live_sensor] Unable to load consumption 2024-03-10 21:49:01.195 ERROR (MainThread) [custom_components.wnsm.live_sensor] Please file an issue with this error and (anonymized) payload in github {'hasSmartMeter': True, 'isDataDeleted': False, 'zaehlpunkt': 'AT0010000000000000001xxxxxxxx', 'type': 'BEZUG', 'address': 'Adresse', 'zip': '1234'} {} {'lastValue': 302025, 'lastReading': '2024-03-08T23:00:00.000Z', 'lastValidated': True, 'lastType': '1-2:2.8.0'} {'optIn': True, 'consumptionAverage': 0, 'consumptionMinimum': 0, 'consumptionMaximum': 0}

@DarwinsBuddy
Copy link
Owner

Hi @sonypsx
Happy to see that this integration helps. :)
After some time of deciphering your log message (it's hard without linebreaks), I am wondering if this issue still persists.
It seems like you get back no historical meter readings from the API.
Since the Wiener Netze API is not a public API and thus may be subject to change, it could be that

  • a) for your account WN is reporting your readings differently
  • b) there was an outage for your user batch
  • c) the api changed and our client has to adapt those changes

In order to rule out the first two possibilities, could you

  1. install the new release 1.4.7
  2. again look into your installation and check if you still get the same error
    ?

Thanks in advance.

@sonypsx
Copy link
Author

sonypsx commented Mar 17, 2024

Hello,

thanks the reply!
Die install 1.4.7 as requested, didn't help much :(
2024-03-17 15:54:01.931 WARNING (MainThread) [custom_components.wnsm.statistics_sensor] Starting import of historical data. This might take some time. 2024-03-17 15:54:02.735 WARNING (MainThread) [homeassistant.components.sensor] Setup of sensor platform wnsm is taking over 10 seconds. 2024-03-17 15:54:03.963 ERROR (MainThread) [homeassistant.components.sensor] wnsm: Error on device update! Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 682, in _async_add_entity await entity.async_device_update(warning=False) File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1262, 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 195, in _import_bewegungsdaten recording = await self.get_bewegungsdaten(smartmeter) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/wnsm/base_sensor.py", line 154, in get_bewegungsdaten response = await self.hass.async_add_executor_job( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/wnsm/api/client.py", line 505, in bewegungsdaten raise SmartmeterQueryError("Historical data is empty") custom_components.wnsm.api.errors.SmartmeterQueryError: Historical data is empty 2024-03-17 15:54:05.321 WARNING (MainThread) [homeassistant.helpers.frame] Detected that custom integration 'hacs' accesses hass.components.frontend. This is deprecated and will stop working in Home Assistant 2024.9, it should be updated to import functions used from frontend directly at custom_components/hacs/frontend.py, line 68: hass.components.frontend.async_register_built_in_panel(, please create a bug report at https://github.com/hacs/integration/issues 2024-03-17 15:54:05.662 ERROR (MainThread) [custom_components.wnsm.live_sensor] Unable to load consumption 2024-03-17 15:54:05.663 ERROR (MainThread) [custom_components.wnsm.live_sensor] Please file an issue with this error and (anonymized) payload in github {'hasSmartMeter': True, 'isDataDeleted': False, 'zaehlpunkt': 'AT0010000000000000001000012345678', 'type': 'BEZUG', 'address': 'Street, 1234 MyCity', 'zip': '1234'} {'consumptionYesterdayValue': 19737, 'consumptionYesterdayValidated': True, 'consumptionYesterdayTimestamp': '2024-03-15T23:00:00.000Z', 'consumptionDayBeforeYesterdayValue': 18839, 'consumptionDayBeforeYesterdayValidated': True, 'consumptionDayBeforeYesterdayTimestamp': '2024-03-14T23:00:00.000Z'} {'lastValue': 385734, 'lastReading': '2024-03-16T23:00:00.000Z', 'lastValidated': True, 'lastType': '1-2:2.8.0'} {'optIn': True, 'consumptionAverage': 0, 'consumptionMinimum': 0, 'consumptionMaximum': 0}

If i look the attributes of the 3 entities it looks valid.
CustomerId and all other values look legit!
About the theory that there was an outage of my user batch: I know that last week were some maintenance at WN, but i have this issue since the begining of using WNSM which was several month ago.
About the API - yeah could be a reason.

if i click on the "statistics" entity and check for "last month" i'm getting VERY low (unusual low) reading ~0.5 to 1.5kWh which isn't right, if compared to the WN web portal.
2024-03-17 16_17_58-Verlauf – Home Assistant – Mozilla Firefox

vs. the values from the Web Portal:
2024-03-17 16_20_28-TAGESWERTE-20240201-bis-20240229 csv - Excel

About "2024-03-17 15:54:01.931 WARNING (MainThread) [custom_components.wnsm.statistics_sensor] Starting import of historical data. This might take some time."

How long does this normally take? and how many days are pulled?

Best regards
sonypsx

@tschoerk
Copy link

tschoerk commented May 7, 2024

I also get the "Error on device update" for my feed in Zählerpunkt. The consumption works and creates two sensors a live and statistics one, but for the feed in there's only 1 sensor created (the live one, not the statistics one) and that one is empty, so it's not usable in the energy dashboard. I only have that feedin Zählerpunkt for a couple of days, maybe it has to be a certain age before it's usable?

Core 2024.5.2
Supervisor 2024.04.4
Operating System 12.2
Frontend 20240501.1
wnsm: v1.4.

2024-05-07 10:38:06.760 DEBUG (SyncWorker_8) [custom_components.wnsm.api.client] 
API Request: https://service.wienernetze.at/sm/api/user/messwerte/bewegungsdaten?geschaeftspartner=#########&zaehlpunktnummer=AT001000000000000000##########&rolle=V002&zeitpunktVon=2021-05-07T00%3A00%3A00.000Z&zeitpunktBis=2024-05-07T23%3A59%3A59.999Z&aggregat=NONE


API Response: {
  "descriptor": {
    "geschaeftspartnernummer": "###########",
    "zaehlpunktnummer": "AT00100000000000000010000##########",
    "rolle": "V002",
    "aggregat": "NONE",
    "granularitaet": "QH",
    "einheit": "KWH"
  },
  "values": []
}
2024-05-07 10:38:06.763 ERROR (MainThread) [homeassistant.components.sensor] wnsm: Error on device update!
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 707, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1293, 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 195, in _import_bewegungsdaten
    recording = await self.get_bewegungsdaten(smartmeter)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/wnsm/base_sensor.py", line 154, in get_bewegungsdaten
    response = await self.hass.async_add_executor_job(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/wnsm/api/client.py", line 505, in bewegungsdaten
    raise SmartmeterQueryError("Historical data is empty")
custom_components.wnsm.api.errors.SmartmeterQueryError: Historical data is empty

@W-M-B
Copy link

W-M-B commented May 7, 2024

hi, @tschoerk it works nicely for me. I am running on y x86 device, HA updated to the latest version, same for wnsm and HACS.

I had issues before, but I removed the wnsm deleted all at.. data eintries etc. rebootet. then it worked.

if you log in the Portal of Wiener Netze it works nicely I assume?

@tschoerk
Copy link

tschoerk commented May 7, 2024

Thanks for the hint. I tried it as well, deleted everything like described in the FAQs with reboots between each step and reinstalled everything. The error still persists. Also got an error like described in issue #227 maybe they are stemming from the same issue.

@W-M-B
Copy link

W-M-B commented May 7, 2024

strange .. the code base 1.40 works (at least for me), so either some config data in your smartmeter is different creating an issue, or something is wrong with your data.
my next try would be to try to retrieve the data with another system/app to see if this is an issue with Wiener Netze or a bug due to some data topics.

@tschoerk
Copy link

tschoerk commented May 8, 2024

After testing it on several devices and the error still persisted, I figured it out. The Zählerpunkt which feeds in the unused power as the Anlagetyp "BEZUG" instead of "TAGSTROM", like the normal Zählerpunkte.

Checking the API calls directly at the Wiener Netze Portal showed me the correct URL.
https://service.wienernetze.at/sm/api/user/messwerte/bewegungsdaten?geschaeftspartner=XXXXXXXXX&zaehlpunktnummer=AT001000000000000000###########&rolle=E002&zeitpunktVon=2024-05-06T22%3A00%3A00.000Z&zeitpunktBis=2024-05-07T21%3A59%3A59.999Z&aggregat=NONE

The correct parameter for rolle is E002 (quarterly check in this case) instead of the hard-coded V002 (or E001 instead of V001).

I made a fix by changing the get_zaehlpunkt method in the client.py to also return the Anlagentyp and then check if the type is BEZUG. If true, then the role is changed to E001 or E002 depending on the valuetype. I will make a pull request, maybe it's viable to use - at least the idea should be. Not too much experience with it.

Restarted HA and now I have a fourth entity with all the feeding statistics to use for the energy dashboard.

@tschoerk tschoerk linked a pull request May 8, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants