DarwinsBuddy / WienerNetzeSmartmeter

A home-assistant integration supporting WienerNetze Smartmeters as sensors
143 stars 15 forks source link

Add new anlage-typ in api/constants.py #244

Closed Skaldhor closed 4 months ago

Skaldhor commented 4 months ago

Please add the new Anlage-Typ "WAERMEPUMPE" as an alias for type "CONSUMING". My consuming anlage is of type "WAERMEPUMPE" according to the logs, which is the reason for wnsm to throw the following error:

2024-07-16 08:33:31.341 WARNING (MainThread) [custom_components.wnsm.statistics_sensor] Starting import of historical data. This might take some time.
2024-07-16 08:33:31.765 WARNING (MainThread) [custom_components.wnsm.statistics_sensor] Data starting at 2024-07-15 22:00:00+00:00 does not contain granular data! Opt-in was not set back then. Skipping.
2024-07-16 08:33:32.398 ERROR (MainThread) [custom_components.wnsm.statistics_sensor] Error retrieving data from smart meter api - Error: 
Traceback (most recent call last):
  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 155, 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 475, in bewegungsdaten
    customer_id, zaehlpunkt, anlagetype = self.get_zaehlpunkt(zaehlpunktnummer)
                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/wnsm/api/client.py", line 254, in get_zaehlpunkt
    return customer_id, zp, const.AnlageType.from_str(anlagetype)
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/wnsm/api/constants.py", line 66, in from_str
    raise NotImplementedError
NotImplementedError

For reference, here's the API response of the Zählpunkt:

{
    "bezeichnung": "name and kundennummer",
    "geschaeftspartner": "kundennummer",
    "zaehlpunkte": [
      {
        "zaehlpunktnummer": "AT0010000000000000001xxxxxxxxxxxx",
        "customLabel": null,
        "equipmentNumber": "xxx",
        "geraetNumber": "LGZxxxxxxxxxxxxx",
        "isSmartMeter": true,
        "isDefault": true,
        "isActive": true,
        "isDataDeleted": false,
        "isSmartMeterMarketReady": true,
        "dataDeletionTimestampUTC": null,
        "verbrauchsstelle": {
          "vstelle": "xxxxxxxxx",
          "strasse": "my street name",
          "hausnummer": "my hausnummer",
          "anlageHausnummer": "my hausnummer",
          "postleitzahl": "PLZ",
          "ort": "city",
          "laengengrad": "coord1",
          "breitengrad": "coord2"
        },
        "anlage": {
          "typ": "WAERMEPUMPE"
        },
        "vertraege": [
          {
            "einzugsdatum": "2023-11-16",
            "auszugsdatum": null
          }
        ],
        "idexStatus": {
          "granularity": {
            "status": "DAY",
            "canBeChanged": false
          },
          "customerInterface": {
            "status": "inactive",
            "canBeChanged": true
          },
          "display": {
            "isLocked": true,
            "canBeChanged": true
          },
          "displayProfile": {
            "canBeChanged": true,
            "displayProfile": "VERBRAUCH"
          }
        },
        "optOutDetails": {
          "isOptOut": false
        },
        "zpSharingInfo": {
          "isOwner": false
        }
 }

Maybe filtering for the "displayProfile": "VERBRAUCH" would also work?

Thanks and best regards, Florian

Skaldhor commented 4 months ago

@DarwinsBuddy Created a pull request for this, I tested the edit in my local environment and it works. https://github.com/DarwinsBuddy/WienerNetzeSmartmeter/pull/245

DarwinsBuddy commented 4 months ago

Thank you @Skaldhor for your contribution. Released https://github.com/DarwinsBuddy/WienerNetzeSmartmeter/releases/tag/v1.5.1