Ludy87 / ecotrend-ista

ecotrend-ista Home Assistant Integration
MIT License
36 stars 1 forks source link

Login seems to not work anymore #108

Closed bigcookie closed 1 year ago

bigcookie commented 1 year ago

My HA instance is not anymore updating the entities. I deleted the integration and restarted from scratched. As it seems, something has changed on the login side of things. Error on ISTA side? I am using the latest version 2.1.2 of the integration. Not sure if this is connected to the latest update of pyecotrend - but my HA system complained about not getting an update since 3 weeks... Might also be easily on ISTA side...

Logger: aiohttp.server
Source: custom_components/ecotrend_ista/config_flow.py:57
Integration: ista EcoTrend ([documentation](https://github.com/Ludy87/ecotrend-ista/tree/main), [issues](https://github.com/Ludy87/ecotrend-ista/issues))
First occurred: 10:55:07 (1 occurrences)
Last logged: 10:55:07

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 85, in security_filter_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 100, in forwarded_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 80, in ban_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 236, in auth_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 148, in handle
    result = await handler(request, **request.match_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 181, in post
    return await super().post(request, flow_id)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 72, in wrapper
    result = await method(view, request, data, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 110, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 297, in async_configure
    result = await self._async_handle_step(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 393, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/ecotrend_ista/config_flow.py", line 99, in async_step_german
    info = await validate_input(self.hass, user_input)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/ecotrend_ista/config_flow.py", line 57, in validate_input
    login_info = await account.login()
                 ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyecotrend_ista/pyecotrend_ista.py", line 212, in login
    self._accessToken = await self.__login()
                        ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyecotrend_ista/pyecotrend_ista.py", line 96, in __login
    raise Error(await response.json())
                ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/client_reqrep.py", line 1104, in json
    raise ContentTypeError(
aiohttp.client_exceptions.ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: text/plain', url=URL('https://api.prod.eed.ista.com/login')
Ludy87 commented 1 year ago

Hi @bigcookie, please enable debugging - https://github.com/Ludy87/ecotrend-ista#debug

Did you restart homeassistant? It looks like the correct library is not being used, and please some more information: Settings -> System-> Repairs -> Three Dots in Upper Right -> System information

bigcookie commented 1 year ago

Actually debugging was enabled. And yes, the issue happened and HA didnt show any updates, so I also restarted HA. The trace is the one after the restart. I run HA in docker. Sorry for not including all information... The integration was installed via HACS. I will delete the integration and redownload again (though I thought that this I had done prior)

HA: Home Assistant 2023.7.1 (I didnt yet manage to update to 2023.8.x - will do asap, latest this weekend)

I can dig into the available libraries - I am not a developer, but I can do some scripting and find my way around in the Linux commandline environment ;-)... though I might need a hint.

I will also check information in the log directly. The above trace I copied from the protocol view in the UI...

This is the trace from the debug log files:

2023-08-28 08:53:04.383 DEBUG (MainThread) [custom_components.ecotrend_ista] Set up the ista EcoTrend Version 2 component
2023-08-28 08:53:04.438 DEBUG (MainThread) [custom_components.ecotrend_ista] Configure based on config entry 5a62a52b64769e9b0ff06b3f63bceecb
2023-08-28 08:53:06.466 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Ista V432EBNNU  for ecotrend_ista
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 390, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/ecotrend_ista/__init__.py", line 52, in async_setup_entry
    await coordinator.init()
  File "/config/custom_components/ecotrend_ista/coordinator.py", line 76, in init
    await self.controller.login()
  File "/usr/local/lib/python3.11/site-packages/pyecotrend_ista/pyecotrend_ista.py", line 212, in login
    self._accessToken = await self.__login()
                        ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyecotrend_ista/pyecotrend_ista.py", line 96, in __login
    raise Error(await response.json())
                ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/client_reqrep.py", line 1104, in json
    raise ContentTypeError(
aiohttp.client_exceptions.ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: text/plain', url=URL('https://api.prod.eed.ista.com/login')

and this

2023-08-28 08:55:07.739 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 85, in security_filter_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 100, in forwarded_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 80, in ban_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 236, in auth_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 148, in handle
    result = await handler(request, **request.match_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 181, in post
    return await super().post(request, flow_id)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 72, in wrapper
    result = await method(view, request, data, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 110, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 297, in async_configure
    result = await self._async_handle_step(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 393, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/ecotrend_ista/config_flow.py", line 99, in async_step_german
    info = await validate_input(self.hass, user_input)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/ecotrend_ista/config_flow.py", line 57, in validate_input
    login_info = await account.login()
                 ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyecotrend_ista/pyecotrend_ista.py", line 212, in login
    self._accessToken = await self.__login()
                        ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyecotrend_ista/pyecotrend_ista.py", line 96, in __login
    raise Error(await response.json())
                ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/client_reqrep.py", line 1104, in json
    raise ContentTypeError(
aiohttp.client_exceptions.ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: text/plain', url=URL('https://api.prod.eed.ista.com/login')
2023-08-28 08:59:17.156 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 85, in security_filter_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 100, in forwarded_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 80, in ban_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 236, in auth_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 148, in handle
    result = await handler(request, **request.match_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 181, in post
    return await super().post(request, flow_id)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 72, in wrapper
    result = await method(view, request, data, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 110, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 297, in async_configure
    result = await self._async_handle_step(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 393, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/ecotrend_ista/config_flow.py", line 99, in async_step_german
    info = await validate_input(self.hass, user_input)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/ecotrend_ista/config_flow.py", line 57, in validate_input
    login_info = await account.login()
                 ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyecotrend_ista/pyecotrend_ista.py", line 212, in login
    self._accessToken = await self.__login()
                        ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyecotrend_ista/pyecotrend_ista.py", line 96, in __login
    raise Error(await response.json())
                ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/client_reqrep.py", line 1104, in json
    raise ContentTypeError(
aiohttp.client_exceptions.ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: text/plain', url=URL('https://api.prod.eed.ista.com/login')
bigcookie commented 1 year ago

Ok, it seems, that the update in HACS failed... I checked the custom_components folder, and still shows

{
    "domain": "ecotrend_ista",
    "name": "ista EcoTrend",
    "codeowners": [
        "@Ludy87"
    ],
    "config_flow": true,
    "dependencies": [],
    "documentation": "https://github.com/Ludy87/ecotrend-ista/tree/main",
    "integration_type": "device",
    "iot_class": "local_polling",
    "issue_tracker": "https://github.com/Ludy87/ecotrend-ista/issues",
    "requirements": [
        "pyecotrend_ista==2.0.19",
        "marshmallow-enum"
    ],
    "version": "v2.0.8"
}

Let me delete this and try to get it downloaded freshly...

Ludy87 commented 1 year ago

Hi @bigcookie You are using a Home Assistant version that is older than required. You have to download the integration manually and copy it to the folder, pay attention to the folder structure.

bigcookie commented 1 year ago

Hi upgraded HA to the latest version, deleted and reinstalled the integration. All works now. Unclear, why there was a fail in the previous setup. Sorry for bugging you - in this case the issue was located between my ears I guess. Nevertheless thanks for the integration (and yes, I donated - I think it is great, that some people do such work on the side - not trying to paint a specific picture of me here, but this is really great, you solved me a lot of hassle to get those readings)

Bug can be closed. User error.

Ludy87 commented 1 year ago

@bigcookie, thanks for your support contribution