DarwinsBuddy / WienerNetzeSmartmeter

A home-assistant integration supporting WienerNetze Smartmeters as sensors
121 stars 12 forks source link

Cannot log in anymore #189

Closed dexonter closed 10 months ago

dexonter commented 11 months ago

Hi!

This add-on was working in the past, but stopped at some point (some months ago) and did not have time to debug it.

Now I deleted the entry and wanted to log in again and....does not let me. I know for sure that I am using the right login details for the smart meter webpage because I logged out and in again on their website just to make sure.

All I am getting is: Username/password invalid (it thinks for 1-2 seconds before this error; if I put a wrong password the same message appears but instantly, not 1-2 seconds later)

reox commented 11 months ago

Maybe the API has changed... I get sporadic errors like:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 695, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 940, in async_device_update
    await self.async_update()
  File "/config/custom_components/wnsm/live_sensor.py", line 40, in async_update
    await self.hass.async_add_executor_job(smartmeter.login)
  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 124, in login
    url = self.load_login_page()
          ^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/wnsm/api/client.py", line 49, in load_login_page
    raise SmartmeterConnectionError(
custom_components.wnsm.api.errors.SmartmeterConnectionError: Could not load login page. Error: b'<html>\r\n<head><title>503 Service Temporarily Unavailable</title><script type="text/javascript" src="/ruxitagentjs_ICA2NVfjqru_10267230522124059.js" data-dtconfig="[....redacted...]|agentUri=/ruxitagentjs_ICA2NVfjqru_10267230522124059.js"></script></head>\r\n<body>\r\n<center><h1>503 Service Temporarily Unavailable</h1></center>\r\n<hr><center>nginx</center>\r\n</body>\r\n</html>\r\n'

or

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 695, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 940, 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

or

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 695, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 940, in async_device_update
    await self.async_update()
  File "/config/custom_components/wnsm/live_sensor.py", line 40, in async_update
    await self.hass.async_add_executor_job(smartmeter.login)
  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 125, in login
    code = self.credentials_login(url)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/wnsm/api/client.py", line 75, in credentials_login
    raise SmartmeterLoginError("Login failed. Check username/password.")
custom_components.wnsm.api.errors.SmartmeterLoginError: Login failed. Check username/password.

or

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/requests/models.py", line 971, in json
    return complexjson.loads(self.text, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/simplejson/__init__.py", line 514, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/simplejson/decoder.py", line 386, in decode
    obj, end = self.raw_decode(s)
               ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/simplejson/decoder.py", line 416, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 695, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 940, in async_device_update
    await self.async_update()
  File "/config/custom_components/wnsm/live_sensor.py", line 46, in async_update
    base_information = await self.get_base_information(smartmeter)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/wnsm/base_sensor.py", line 134, in get_base_information
    response = await self.hass.async_add_executor_job(smartmeter.base_information)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  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 249, in base_information
    return self._call_api("zaehlpunkt/baseInformation")
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/wnsm/api/client.py", line 234, in _call_api
    return response.json()
           ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/requests/models.py", line 975, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

However, it still works for me... maybe just some hickups on the API side?

DarwinsBuddy commented 10 months ago

Can confirm. They are seemingly migrating users as I can also see some odd looking calls from the web app to some endpoints called like migrationStatus.

@dexonter if this still persists feel free to reopen or open another issue