mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-11-16 22:40:47 +00:00
Compare commits
2 Commits
copilot/su
...
fail-grace
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8e026bd945 | ||
|
|
3d74d2bb7c |
@@ -98,6 +98,7 @@ class WSClient:
|
|||||||
|
|
||||||
async def start_listener(self) -> None:
|
async def start_listener(self) -> None:
|
||||||
"""Start listening to the websocket."""
|
"""Start listening to the websocket."""
|
||||||
|
_LOGGER.debug("Starting WebSocket listener")
|
||||||
if not self.connected:
|
if not self.connected:
|
||||||
raise HomeAssistantWSConnectionError("Not connected when start listening")
|
raise HomeAssistantWSConnectionError("Not connected when start listening")
|
||||||
|
|
||||||
@@ -202,6 +203,7 @@ class HomeAssistantWebSocket(CoreSysAttributes):
|
|||||||
return self._client
|
return self._client
|
||||||
|
|
||||||
await self.sys_homeassistant.api.ensure_access_token()
|
await self.sys_homeassistant.api.ensure_access_token()
|
||||||
|
_LOGGER.debug("Connecting via WebSocket to Home Assistant Core")
|
||||||
client = await WSClient.connect_with_auth(
|
client = await WSClient.connect_with_auth(
|
||||||
self.sys_websession,
|
self.sys_websession,
|
||||||
self.sys_loop,
|
self.sys_loop,
|
||||||
@@ -266,7 +268,8 @@ class HomeAssistantWebSocket(CoreSysAttributes):
|
|||||||
try:
|
try:
|
||||||
await self._client.async_send_command(message)
|
await self._client.async_send_command(message)
|
||||||
except HomeAssistantWSConnectionError:
|
except HomeAssistantWSConnectionError:
|
||||||
await self._client.close()
|
if self._client:
|
||||||
|
await self._client.close()
|
||||||
self._client = None
|
self._client = None
|
||||||
|
|
||||||
async def async_send_command(self, message: dict[str, Any]) -> dict[str, Any]:
|
async def async_send_command(self, message: dict[str, Any]) -> dict[str, Any]:
|
||||||
@@ -277,7 +280,8 @@ class HomeAssistantWebSocket(CoreSysAttributes):
|
|||||||
try:
|
try:
|
||||||
return await self._client.async_send_command(message)
|
return await self._client.async_send_command(message)
|
||||||
except HomeAssistantWSConnectionError:
|
except HomeAssistantWSConnectionError:
|
||||||
await self._client.close()
|
if self._client:
|
||||||
|
await self._client.close()
|
||||||
self._client = None
|
self._client = None
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user