Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration loses connection to Digitalstrom server (DSS) #12

Closed
tmycgn opened this issue Feb 20, 2024 · 9 comments
Closed

Integration loses connection to Digitalstrom server (DSS) #12

tmycgn opened this issue Feb 20, 2024 · 9 comments

Comments

@tmycgn
Copy link

tmycgn commented Feb 20, 2024

Hi,

The integration often loses the connection after a few days, I suspect an authentication timeout according to the log. Does anyone have an idea or can confirm this? The solution is always to reload the integration, then it works again for a few days.

BR Thomas

Logger: homeassistant.components.websocket_api.http.connection
Source: components/websocket_api/commands.py:240
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 21:28:20 (1 occurrences)
Last logged: 21:28:20

[140082199918912] not logged in
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 240, in handle_call_service
    response = await hass.services.async_call(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  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/light/__init__.py", line 628, in async_handle_light_on_service
    await light.async_turn_on(**filter_turn_on_params(light, params))
  File "/config/custom_components/digitalstrom/light.py", line 128, in async_turn_on
    await self.client.request(
  File "/config/custom_components/digitalstrom/api/client.py", line 140, in request
    data = await self._request_raw(url, dict(token=self._session_token))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/digitalstrom/api/client.py", line 79, in _request_raw
    raise InvalidAuth(message)
custom_components.digitalstrom.api.exceptions.InvalidAuth: not logged in
@Mat931
Copy link
Owner

Mat931 commented Feb 20, 2024

Hi,

does this only happen once or on every request afterwards? The authentication works with session tokens which become invalid after Home Assistant makes no requests to DS for 60 seconds (i think). This timeout is tracked by my integration and a new token is requested if needed (if there were no requests made in the last 50 seconds). To try and fix the issue I'm now saving the timestamp only after a request is completed. This should have two effects: If a request fails then no timestamp is saved and the duration of the request is not counted towards the 50 seconds.

To test if the fix works, please install the 'main' version of this integration until v0.0.8 is released.

Best Regards

@tmycgn
Copy link
Author

tmycgn commented Feb 20, 2024

Hi,

With every request. My light buttons are then grayed out because they can not be operated due to lack of connection. Sounds like it could work. :) Sorry, probably a rookie question: The current version is still running, how do I update the main version?

Denke wir können auch auf deutsch wechseln... :)

LG

@Mat931
Copy link
Owner

Mat931 commented Feb 20, 2024

In HACS kann die Integration über die 3 Punkte oben rechts mit "Erneut herunterladen" neu installiert werden. Dabei einfach als Version 'main' auswählen und anschließend HA neu starten :)

@tmycgn
Copy link
Author

tmycgn commented Feb 20, 2024

Ah... wieder was gelernt... :) Erledigt, beobachte es mal. Danke für den ad-hoc Einsatz. :)

@Mat931
Copy link
Owner

Mat931 commented Mar 13, 2024

Hi @tmycgn ,
ist der Verbindungsfehler nochmal vorgekommen?

MfG

@tmycgn
Copy link
Author

tmycgn commented Mar 14, 2024

Hi, sorry, meine Antwort stand noch auf der Todo. :) Ja, die Änderung hat tatsächlich bewirkt dass es nicht mehr zu Verbindungsproblemen kommt. Ich musste seit dem Update den Adapter kein einziges Mal mehr neu laden, vielen Dank Dir!! Issue kann somit geschlossen werden.

@Mat931
Copy link
Owner

Mat931 commented Mar 14, 2024

Sehr gut!
Übrigens es gibt demnächst ein größeres Update und ich suche noch Tester dafür. Zum Testen bitte einfach wieder die "main" Version installieren. Ich habe auch schon überlegt, einen Discord Server einzurichten um solche Sachen zu besprechen falls da Interesse besteht :)

@tmycgn
Copy link
Author

tmycgn commented Mar 14, 2024

Bin für alles zu haben, fänd ich super!! :) Hätte auch noch Ideen und kleinere Sachen, wollte ich nochmal in Ruhe zusammenfassen. Main Version installiere ich gleich!

@Mat931
Copy link
Owner

Mat931 commented Mar 14, 2024

Hier der Link zum Discord: https://discord.gg/uTDweuNnHq

@Mat931 Mat931 closed this as completed Mar 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants