albaintor / homeassistant_electrolux_status

Get the status from your Electrolux Care devices
MIT License
81 stars 20 forks source link

Integration doesn't update states after a few hours #35

Closed Imperial-Guard closed 5 months ago

Imperial-Guard commented 6 months ago

Seems to be after several hours of time the integration stopped working. Running on latest version Home Assistant and electrolux_status.

Couldn't find anything in the debug log and looks like silent killed

slingshot74 commented 6 months ago

Same issue, there are no errors but also no updates. After reloading the integration the updates work again

tieskuh commented 6 months ago

Yes, the issue was mentioned before and a fix was released https://github.com/albaintor/homeassistant_electrolux_status/issues/27

I also still have the same problem. The fix should reset the connection but it seems it doesn't work.

EenerNL commented 6 months ago

I also still have the same issue.

Shammersland commented 6 months ago

Same issue.

micro521 commented 6 months ago

I face the same. After reloading the integration I can see the sensors again. I made an automation as a remedy until it is fixed:

`` alias: Electrolux reload integration description: "" trigger:

micro521 commented 6 months ago

Looks like the loss of connectivity is random. (I mean not due to some timer elapsing.) I had a washing phase which was connected all the time but after an hour when I turned on the machine again the inegration did not connect.

tieskuh commented 6 months ago

Yes, I can confirm it also happens when an appliance is running and sends updates every minute (time to end changes every minute when running). So the timeout isn’t because of inactivity.

I was thinking it might help investigating the problem when a last update sensor is added to an appliance. Also, that could be the trigger to renew the connection. For example last update was longer than an hour ago.

albaintor commented 6 months ago

Hi,

every x hours (see capture below, default = 12 hours) I reset the websocket client because the electrolux server seem to close it after a random time. The reset interval can be set through configure.

Apparently it does not address the problem : if the websocket is resetted, the disconnection from the server can occur just right after apparently (to be confirmed though). Which may explain why the appliance is not updated anymore. If my supposition is correct, I guess that you should recover the appliance state at the next refresh interval (so 12 hours later by default).

image

But there is also another possibility : this reset trick shouldn't be necessary though because websockets are designed to send ping/pong every few seconds to check after the connectivity. So maybe the ping/pong is still happening, but the server doesn't push any updates. To confirm this scenario : can someone check if when the update fails (no more updated entities), does it recover by its own 12 hours later ?

Anyway the electrolux servers are very unstable so it may be an explanation though

Imperial-Guard commented 6 months ago

@albaintor

Thanks for your reply on this, it looks like that the resetting the websocket is not working on my end and the connection is silently killed in about roughly 5 a 6 hours.

On the screendump below I've manually reinitiated the integration to having connection with the Electrolux server. Is there something like a kind of will testament possible while connecting to the Electrolux server.

image

tieskuh commented 6 months ago

Hi,

every x hours (see capture below, default = 12 hours) I reset the websocket client because the electrolux server seem to close it after a random time. The reset interval can be set through configure.

Apparently it does not address the problem : if the websocket is resetted, the disconnection from the server can occur just right after apparently (to be confirmed though). Which may explain why the appliance is not updated anymore. If my supposition is correct, I guess that you should recover the appliance state at the next refresh interval (so 12 hours later by default).

image

But there is also another possibility : this reset trick shouldn't be necessary though because websockets are designed to send ping/pong every few seconds to check after the connectivity. So maybe the ping/pong is still happening, but the server doesn't push any updates. To confirm this scenario : can someone check if when the update fails (no more updated entities), does it recover by its own 12 hours later ?

Anyway the electrolux servers are very unstable so it may be an explanation though

I have checked this several times and didn’t reset the integration manually to check if it would come back after 12 hours. I can confirm it doesn’t.

albaintor commented 6 months ago

Hi,

I have created a ticket to the repo of my friend @wokyen who manages the python library. He told me that he will look after it next weekend. The problem may come from the library itself also

Palmdale95 commented 6 months ago

For now I am not even able to lock in anymore. Looks like the connection is refused. Maybe to many attemps after new installation and reloads?

albaintor commented 6 months ago

Yes this happened to me too. If you plan to make a lot of restarts of HA, you should disable electrolux integration in the meantime. You should recover the connection after a while

tieskuh commented 6 months ago

Maybe it helps... I did another test:

So 'pushing' a command to the washing machine does work when the integration stops updating. After reloading the integration it also starts updating again.

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/automation/__init__.py", line 666, in async_trigger
    return await self.action_script.async_run(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1600, in async_run
    return await asyncio.shield(run.async_run())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 435, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 487, in _async_step
    self._handle_exception(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 512, in _handle_exception
    raise exception
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 485, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 943, in _async_choose_step
    await self._async_run_script(script)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1100, in _async_run_script
    result = await self._async_run_long_action(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 685, in _async_run_long_action
    return long_task.result()
           ^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1600, in async_run
    return await asyncio.shield(run.async_run())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 435, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 487, in _async_step
    self._handle_exception(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 512, in _handle_exception
    raise exception
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 485, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 723, in _async_call_service_step
    response_data = await self._async_run_long_action(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 685, in _async_run_long_action
    return long_task.result()
           ^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2279, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2316, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 892, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 962, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/button/__init__.py", line 139, in _async_press_action
    await self.async_press()
  File "/config/custom_components/electrolux_status/button.py", line 72, in async_press
    await self.send_command()
  File "/config/custom_components/electrolux_status/button.py", line 67, in send_command
    result = await client.execute_appliance_command(self.pnc_id, {"executeCommand": self.val_to_send})
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyelectroluxocp/oneAppApi.py", line 177, in execute_appliance_command
    token = await self._get_formatted_user_token()
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyelectroluxocp/oneAppApi.py", line 383, in _get_formatted_user_token
    token = await self.get_user_token()
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyelectroluxocp/oneAppApi.py", line 102, in get_user_token
    token = await self._api_client.refresh_token_user(
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyelectroluxocp/oneAppApiClient.py", line 161, in refresh_token_user
    response.raise_for_status()
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client_reqrep.py", line 1060, in raise_for_status
    raise ClientResponseError(
aiohttp.client_exceptions.ClientResponseError: 401, message='Unauthorized', url=URL('https://api.eu.ocp.electrolux.one/one-account-authorization/api/v1/token'

The error is 'unauthorized' so it maybe the access token is expired. That might be the reason for not updating.

allistermaguire commented 6 months ago

https://github.com/Woyken/py-electrolux-ocp/releases/tag/0.0.14 was released today with a fix for token renewal. See https://github.com/Woyken/py-electrolux-ocp/issues/9#issuecomment-1977028498

allistermaguire commented 6 months ago

@tieskuh If you want to try it out, update the version in manifest.json and restart Hass.

tieskuh commented 6 months ago

@tieskuh If you want to try it out, update the version in manifest.json and restart Hass.

Thanks! I just did. I'll share the results tomorrow.

tieskuh commented 6 months ago

@tieskuh If you want to try it out, update the version in manifest.json and restart Hass.

Thanks! I just did. I'll share the results tomorrow.

It still doesn't work after changing to "pyelectroluxocp==0.0.14" in manifest.json. But I didn't check what the changes are in pyelectroluxocp. Maybe some additional work needs to be done in homeassistant_electrolux_status.

allistermaguire commented 6 months ago

@tieskuh If you want to try it out, update the version in manifest.json and restart Hass.

Thanks! I just did. I'll share the results tomorrow.

It still doesn't work after changing to "pyelectroluxocp==0.0.14" in manifest.json. But I didn't check what the changes are in pyelectroluxocp. Maybe some additional work needs to be done in homeassistant_electrolux_status.

I had a quick look and it didn't look like it needed changes. But I also see 0.0.15 has been released with additional logging to help debug. So maybe still work todo.

albaintor commented 6 months ago

I have released a new version which fixes the token renewal, maybe it will fix this problem but I am not sure. To be confirmed

tieskuh commented 6 months ago

I have released a new version which fixes the token renewal, maybe it will fix this problem but I am not sure. To be confirmed

For me it doesn’t fix it unfortunately

kfjellerup commented 6 months ago

I updated yesterday and have tested today by running a wash. Unfortunately the integration had to be reloaded in when i started the wash due to no updates to entities and it lost connection again in the end (5 minutes left)

dfips commented 5 months ago

The new v1.0.15 solves this issue for me 👍 It's been more than 24 hours and the integration is still properly updating without a reload of the integration. Thanks @albaintor and @Woyken

tieskuh commented 5 months ago

The new v1.0.15 solves this issue for me 👍 It's been more than 24 hours and the integration is still properly updating without a reload of the integration. Thanks @albaintor and @Woyken

Looks promising so far!!

kfjellerup commented 5 months ago

Works perfect for me! <3

micro521 commented 5 months ago

For me it disconnects on v1.0.15 as well. What changes were introduced in 1.0.15?

Woyken commented 5 months ago

@albaintor I found that mine broke when Electrolux API randomly broke, responding 500 (unexpected error) to login request. Released 0.0.16 to retry login when trying to reconnect to websocket

albaintor commented 5 months ago

@albaintor I found that mine broke when Electrolux API randomly broke, responding 500 (unexpected error) to login request.

Released 0.0.16 to retry login when trying to reconnect to websocket

Hi ok I will update the integration

Thanks !