Skip to content

Commit

Permalink
Few more logs to help figuring out websocket failures
Browse files Browse the repository at this point in the history
  • Loading branch information
Woyken committed Mar 6, 2024
1 parent 0a980cc commit 150bfd5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/pyelectroluxocp/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Python package wrapper around Electrolux OneApp (OCP) api."""

__all__ = ["OneAppApi"]
__version__ = "0.0.14"
__version__ = "0.0.15"

from .oneAppApi import OneAppApi
7 changes: 7 additions & 0 deletions src/pyelectroluxocp/oneAppApi.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ async def get_client_cred_token(self):

async def connect_websocket(self, appliance_ids: list[str]):
"""Start websocket connection, listen to events"""
_LOGGER.debug("connect_websocket(), appliance_ids: %s", dumps(appliance_ids))

async def get_websocket_headers():
token = await self._get_formatted_user_token()
Expand All @@ -79,6 +80,7 @@ async def get_websocket_headers():

async def disconnect_websocket(self):
"""Stop websocket connection"""
_LOGGER.debug("disconnect_websocket()")
ws_client = await self._get_websocket_client()
await ws_client.disconnect()

Expand Down Expand Up @@ -195,6 +197,10 @@ async def watch_for_appliance_state_updates(
callback: Callable[[dict[str, Dict[str, Any]]], None],
):
"""Fetch current appliance state and watch for state changes"""
_LOGGER.debug(
"watch_for_appliance_state_updates(), appliance_ids: %s",
dumps(appliance_ids),
)

def handle_websocket_response(responseData: WebSocketResponse):
_LOGGER.debug(
Expand Down Expand Up @@ -305,6 +311,7 @@ async def debug_dump_everything_to_files(

async def close(self) -> None:
"""Dispose session and dependencies"""
_LOGGER.debug("close()")
if self._gigya_client:
await self._gigya_client.close()
if self._ws_client:
Expand Down
3 changes: 3 additions & 0 deletions src/pyelectroluxocp/webSocketClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def remove_disconnected_event_handler(self, handler: Callable[[], None]):
async def connect(
self, get_headers: Callable[[], Coroutine[Any, Any, dict[str, Any]]]
):
_LOGGER.debug("connect()")
await self.disconnect()
await self._connect(get_headers)

Expand Down Expand Up @@ -114,6 +115,8 @@ async def disconnect(self):
await self.websocket.close()

async def close(self) -> None:
_LOGGER.debug("close()")
self.retry = False
if self.websocket is not None:
await self.websocket.close()
if self._client_session and self._close_session:
Expand Down

0 comments on commit 150bfd5

Please sign in to comment.