Skip to content

Commit

Permalink
Fix hilo_state.yaml bug
Browse files Browse the repository at this point in the history
Il y avait un string literal donc websocket ne se faisait pas remplir, websocket2 oui.

Retrait et modification de quelques commentaires
  • Loading branch information
ic-dev21 committed Nov 28, 2024
1 parent 70cc6bb commit e750453
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
1 change: 0 additions & 1 deletion pyhilo/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,6 @@ async def _async_post_init(self) -> None:
LOG.debug("Websocket postinit")
await self._get_fid()
await self._get_device_token()
# await self.refresh_ws_token()
# self.websocket = WebsocketClient(self)

# Initialize WebsocketManager ic-dev21
Expand Down
9 changes: 4 additions & 5 deletions pyhilo/websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,9 +417,9 @@ def __init__(
self.async_request = async_request
self._state_yaml = state_yaml
self._set_state = set_state_callback
self._shared_token = None # ic-dev21 need to share the token
self._shared_token = None

# Initialize websocket configurations
# Initialize websocket configurations, more can be added here
self.devicehub = WebsocketConfig(
endpoint=AUTOMATION_DEVICEHUB_ENDPOINT, session=session
)
Expand All @@ -431,7 +431,7 @@ async def initialize_websockets(self) -> None:
"""Initialize both websocket connections"""
# ic-dev21 get token from device hub
await self.refresh_token(self.devicehub, get_new_token=True)
# ic-dev21 reuse it for challenge hub
# ic-dev21 get token from challenge hub
await self.refresh_token(self.challengehub, get_new_token=True)

async def refresh_token(
Expand All @@ -446,7 +446,6 @@ async def refresh_token(
config.url, self._shared_token = await self._negotiate(config)
config.token = self._shared_token
else:
# ic-dev21 reuse existing token but get new URL
config.url, _ = await self._negotiate(config)
config.token = self._shared_token

Expand Down Expand Up @@ -521,7 +520,7 @@ async def _get_websocket_params(self, config: WebsocketConfig) -> None:
# Save state
state_key = (
"websocket"
if config.endpoint == "AUTOMATION_DEVICEHUB_ENDPOINT"
if config.endpoint == AUTOMATION_DEVICEHUB_ENDPOINT
else "websocket2"
)
LOG.debug(f"Calling set_state {state_key}_params")
Expand Down

0 comments on commit e750453

Please sign in to comment.