Code Monkey home page Code Monkey logo

Comments (25)

raoulbhatia avatar raoulbhatia commented on September 26, 2024 2

Reg the web request, I see requests:

  1. OPTIONS Request – returns only response headers, no response body
OPTIONS https://api.wstw.at/gateway/WN_SMART_METER_PORTAL_API_B2B/1.0/zaehlpunkte/12020xxxxx/AT001000000000000000100000xxxxxxx/messwerte?datumVon=2023-06-01&datumBis=2023-06-30&wertetyp=DAY

Response headers

HTTP/1.1 200 OK
Date: Sat, 28 Oct 2023 11:24:18 GMT
Server: httpd
content-length: 0
access-control-max-age: -1
access-control-allow-origin: https://smartmeter-web.wienernetze.at
access-control-allow-methods: GET
access-control-allow-headers: authorization,expires,x-gateway-apikey,cache-control,pragma
strict-transport-security: max-age=15724800; includeSubDomains
set-cookie: LB_STICKY_SESSION=xxxxxxxxx; Path=/; Secure; HttpOnly
Keep-Alive: timeout=4, max=300
Connection: Keep-Alive
  1. GET request – returns response headers (omitted) and response body.
GET https://api.wstw.at/gateway/WN_SMART_METER_PORTAL_API_B2B/1.0/zaehlpunkte/12020xxxxx/AT001000000000000000100000xxxxxxx/messwerte?datumVon=2023-06-01&datumBis=2023-06-30&wertetyp=DAY

Response body (shortened)

{
  "zaehlwerke": [
    {
      "obisCode": "1-1:1.9.0",
      "einheit": "WH",
      "messwerte": [
        {
          "messwert": 7459.0,
          "zeitVon": "2023-05-31T22:00:00.000Z",
          "zeitBis": "2023-06-01T22:00:00.000Z",
          "qualitaet": "VAL"
        },
        {
          "messwert": 4776.0,
          "zeitVon": "2023-06-01T22:00:00.000Z",
          "zeitBis": "2023-06-02T22:00:00.000Z",
          "qualitaet": "VAL"
        },
[...]
        {
          "messwert": 8241.0,
          "zeitVon": "2023-06-29T22:00:00.000Z",
          "zeitBis": "2023-06-30T22:00:00.000Z",
          "qualitaet": "VAL"
        }
      ]
    }
  ],
  "zaehlpunkt": "AT001000000000000000100000xxxxxxx"
}

from wienernetzesmartmeter.

DarwinsBuddy avatar DarwinsBuddy commented on September 26, 2024 2

since we're calling the /zaehlpunkt endpoint anyway on device update, it's not a big deal to add this. good point. :)
I'm on it

from wienernetzesmartmeter.

raoulbhatia avatar raoulbhatia commented on September 26, 2024 2

@DarwinsBuddy first off, the good news – imports are started 🥳

Now, I see the following "WARNING" for each day of my historic data:

2023-10-29 18:12:05.079 WARNING (MainThread) [custom_components.wnsm.statistics_sensor] Starting import of historical data. This might take some time.
2023-10-29 18:12:05.994 WARNING (MainThread) [custom_components.wnsm.statistics_sensor] Unexpected time step detected in historic data: {'messwert': 2179.0, 'zeitVon': '2023-05-29T22:00:00.000Z', 'zeitBis': '2023-05-30T22:00:00.000Z', 'qualitaet': 'VAL'}
2023-10-29 18:12:05.995 WARNING (MainThread) [custom_components.wnsm.statistics_sensor] Unexpected time step detected in historic data: {'messwert': 4476.0, 'zeitVon': '2023-05-30T22:00:00.000Z', 'zeitBis': '2023-05-31T22:00:00.000Z', 'qualitaet': 'VAL'}
2023-10-29 18:12:05.996 WARNING (MainThread) [custom_components.wnsm.statistics_sensor] Unexpected time step detected in historic data: {'messwert': 7459.0, 'zeitVon': '2023-05-31T22:00:00.000Z', 'zeitBis': '2023-06-01T22:00:00.000Z', 'qualitaet': 'VAL'}
[...]

Shall I open a new issue for this? I guess this is something different/distinct to look at?

Cheers & thanks for working with me through this situation 😁

from wienernetzesmartmeter.

raoulbhatia avatar raoulbhatia commented on September 26, 2024 1

Also, I do not see anything suspicious in the home assistant logs, see below

  • Home Assistant 2023.10.3
  • Running in Docker on an 32bit RPi
  • Note: Some devices are offline
$ docker logs -f homeassistant 2>&1| grep -v better_thermostat  # remove verbose better thermostat logs

2023-10-28 11:31:48.269 WARNING (SyncWorker_4) [homeassistant.loader] We found a custom integration scheduler which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-10-28 11:31:48.275 WARNING (SyncWorker_4) [homeassistant.loader] We found a custom integration wnsm which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-10-28 11:32:26.149 WARNING (MainThread) [homeassistant.setup] Setup of zone is taking over 10 seconds.
2023-10-28 11:32:38.017 WARNING (MainThread) [homeassistant.config_entries] Config entry 'HP Officejet Pro XXXX [XXXXX]' for ipp integration not ready yet: Invalid response from API: Timeout occurred while connecting to IPP server.; Retrying in background
2023-10-28 11:32:52.334 WARNING (MainThread) [aioesphomeapi.reconnect_logic] Can't connect to ESPHome API for esp-mobile @ 192.x.x.5: Error connecting to ('192.x.x.5', 6053): [Errno 113] Connect call failed ('192.x.x.5', 6053) (SocketAPIError)
2023-10-28 11:32:53.800 WARNING (MainThread) [custom_components.wnsm.statistics_sensor] Starting import of historical data. This might take some time.
2023-10-28 11:32:54.571 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 573, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 991, in async_device_update
    await self.async_update()
  File "/config/custom_components/wnsm/statistics_sensor.py", line 126, in async_update
    await self._import_historical_data(smartmeter)
  File "/config/custom_components/wnsm/statistics_sensor.py", line 150, in _import_historical_data
    raise ValueError("WienerNetze does not report hsitorical data (yet)")
ValueError: WienerNetze does not report hsitorical data (yet)
2023-10-28 11:33:18.178 WARNING (MainThread) [homeassistant.components.kodi.media_player] Unable to connect to Kodi via websocket
  update_hvac_action(self)

from wienernetzesmartmeter.

raoulbhatia avatar raoulbhatia commented on September 26, 2024 1

@DarwinsBuddy please find the debug log attached (shortened to exclude better_thermostat). anon.log

What i notice is

  • the Customer ID 12020xxxxx is missing from the second request
  • wertetyp=QUARTER_HOUR – my smart meter reports in days, I think (= default?)
REQUEST: https://api.wstw.at/gateway/WN_SMART_METER_PORTAL_API_B2B/1.0/zaehlpunkte/messwerte?zaehlpunkt=AT001000000000000000100000xxxxxxx&datumVon=2020-10-28&datumBis=2023-10-28&wertetyp=QUARTER_HOUR

Cheers,
Raoul

from wienernetzesmartmeter.

raoulbhatia avatar raoulbhatia commented on September 26, 2024 1

Will do so in the evening. Thanks!

from wienernetzesmartmeter.

DarwinsBuddy avatar DarwinsBuddy commented on September 26, 2024 1

yes please, open another one for that 😊

I'll have a look if it's still causing troubles

from wienernetzesmartmeter.

raoulbhatia avatar raoulbhatia commented on September 26, 2024 1

See #194

from wienernetzesmartmeter.

donkristo avatar donkristo commented on September 26, 2024

Same here. HA v2023.10.3

from wienernetzesmartmeter.

reox avatar reox commented on September 26, 2024

looks like they changed that... have to look into that!

from wienernetzesmartmeter.

raoulbhatia avatar raoulbhatia commented on September 26, 2024

Please let us know how we can support!

from wienernetzesmartmeter.

donkristo avatar donkristo commented on September 26, 2024

In my case it could be because my smartmeter is not yet exporting any usage data to csv.
maybe this helps.

from wienernetzesmartmeter.

raoulbhatia avatar raoulbhatia commented on September 26, 2024

Thanks @DarwinsBuddy, the error is now gone.

FYI there is a typo in the error message: hsitorical vs. historical.

Lastly, if I log into the account at https://smartmeter-web.wienernetze.at/
I am able do download historical data as a CSV.

Data Export

Would you know what the issue might be that the component is not able to retrieve/import the historical data?

from wienernetzesmartmeter.

DarwinsBuddy avatar DarwinsBuddy commented on September 26, 2024

@raoulbhatia Thanks for reading more careful than I did 😅
I'll fix it with the next release 👍

I'll have to investigate, maybe the API response changed again without releasing a new version.

from wienernetzesmartmeter.

DarwinsBuddy avatar DarwinsBuddy commented on September 26, 2024

@raoulbhatia I just checked if the API changed somehow and cannot confirm.

Could it be that you have different "zaehlwerke", i.e. different entities of counting your consumption?

from wienernetzesmartmeter.

DarwinsBuddy avatar DarwinsBuddy commented on September 26, 2024

could you possibly hit F12 on your smart meter webinterface, navigate to your Network tab, select some month to export and copy the response of the underlying request here (depicted in attached screenshot)?

2023-10-28_12-23

from wienernetzesmartmeter.

raoulbhatia avatar raoulbhatia commented on September 26, 2024

Will do so within the next hour

from wienernetzesmartmeter.

DarwinsBuddy avatar DarwinsBuddy commented on September 26, 2024

Furthermore: Is there anything suspicious in your ha log?

from wienernetzesmartmeter.

DarwinsBuddy avatar DarwinsBuddy commented on September 26, 2024

that's really odd. It looks like everything should be working correctly, so maybe it has something to do with your response from this API call. We are calling

GET https://api.wstw.at/gateway/WN_SMART_METER_PORTAL_API_B2B/1.0/zaehlpunkte//messwerte?datumVon=2023-06-01&datumBis=2023-06-30&wertetyp=DAY

which returns a list of zaehlpunkte

the webinterface calls and endpoint where it adds the "contractId" and "zaehlpunktnummer" as path parameters, hence

GET https://api.wstw.at/gateway/WN_SMART_METER_PORTAL_API_B2B/1.0/zaehlpunkte/12020xxxxx/AT001000000000000000100000xxxxxxx/messwerte?datumVon=2023-06-01&datumBis=2023-06-30&wertetyp=DAY

which returns an object with presumably just the information for that zaehlpunkt.

I'd like to check if the responses somehow differ in your case.
Thus I released a new version 1.3.1 which adds some debug logs.

Could you

  • Enable debug logs for the wnsm integration
  • restart home assistant
  • disable debug logs (you should be presented a save as dialog for the logs)
  • attach the (anonymized) logs here

I'd very much appreciate it.

from wienernetzesmartmeter.

DarwinsBuddy avatar DarwinsBuddy commented on September 26, 2024

alright. I think I know what's up.
it seems that this endpoint which we are using is not returning values, but rather the one with the two path Params does.

I'll try to fix this. give me some time

from wienernetzesmartmeter.

raoulbhatia avatar raoulbhatia commented on September 26, 2024

FYI I fiddled around with the URL and it seems that one needs to pass the proper wertetyp= parameter.

Upon a manual check (copied the web request to a curl command)

  • If I pass wertetyp=QUARTER_HOUR, it returns a basically empty reply
    curl -s 'https://api.wstw.at/gateway/WN_SMART_METER_PORTAL_API_B2B/1.0/zaehlpunkte/12020xxxxx/AT001000000000000000100000xxxxxxx/messwerte?datumVon=2023-07-01&datumBis=2023-07-31&wertetyp=QUARTER_HOUR'
  • If I pass wertetyp=DAY I get actual numbers.
    curl -s 'https://api.wstw.at/gateway/WN_SMART_METER_PORTAL_API_B2B/1.0/zaehlpunkte/12020xxxxx/AT001000000000000000100000xxxxxxx/messwerte?datumVon=2023-07-01&datumBis=2023-07-31&wertetyp=DAY'

from wienernetzesmartmeter.

raoulbhatia avatar raoulbhatia commented on September 26, 2024

Might be worth to extract this information from the GET /zaehlpunkte endpoint?

GET /zaehlpunkte
cat resp | jq '.[].zaehlpunkte.[].idexStatus.granularity'
{
  "status": "DAY",
  "canBeChanged": true
}

from wienernetzesmartmeter.

DarwinsBuddy avatar DarwinsBuddy commented on September 26, 2024

interesting. so I guess you didn't opt into quarter hourly reports.
if that's the reason, I think a fallback to hourly would do the trick.

from wienernetzesmartmeter.

raoulbhatia avatar raoulbhatia commented on September 26, 2024

Actually, as the granularity is available via the API,
why not use the data provided to select the right wertetyp.

Wouldn't this make it more versatile and generic?

from wienernetzesmartmeter.

DarwinsBuddy avatar DarwinsBuddy commented on September 26, 2024

@raoulbhatia I released https://github.com/DarwinsBuddy/WienerNetzeSmartmeter/releases/tag/v1.3.2 which should use the "zaehlpunkt"'s granularity setting for pulling historical data. Please upgrade and report back with what you're observing :)

from wienernetzesmartmeter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.