mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 01:08:12 +00:00
Allow lamarzocco to reconnect websocket (#133635)
This commit is contained in:
parent
78c9e47428
commit
66e863a2e3
@ -91,9 +91,11 @@ class LaMarzoccoConfigUpdateCoordinator(LaMarzoccoUpdateCoordinator):
|
||||
|
||||
_scale_address: str | None = None
|
||||
|
||||
async def _async_setup(self) -> None:
|
||||
async def _async_connect_websocket(self) -> None:
|
||||
"""Set up the coordinator."""
|
||||
if self._local_client is not None:
|
||||
if self._local_client is not None and (
|
||||
self._local_client.websocket is None or self._local_client.websocket.closed
|
||||
):
|
||||
_LOGGER.debug("Init WebSocket in background task")
|
||||
|
||||
self.config_entry.async_create_background_task(
|
||||
@ -123,6 +125,7 @@ class LaMarzoccoConfigUpdateCoordinator(LaMarzoccoUpdateCoordinator):
|
||||
"""Fetch data from API endpoint."""
|
||||
await self.device.get_config()
|
||||
_LOGGER.debug("Current status: %s", str(self.device.config))
|
||||
await self._async_connect_websocket()
|
||||
self._async_add_remove_scale()
|
||||
|
||||
@callback
|
||||
|
@ -199,8 +199,11 @@ async def test_websocket_closed_on_unload(
|
||||
) as local_client:
|
||||
client = local_client.return_value
|
||||
client.websocket = AsyncMock()
|
||||
client.websocket.closed = False
|
||||
|
||||
await async_init_integration(hass, mock_config_entry)
|
||||
mock_lamarzocco.websocket_connect.assert_called_once()
|
||||
|
||||
client.websocket.closed = False
|
||||
hass.bus.async_fire(EVENT_HOMEASSISTANT_STOP)
|
||||
await hass.async_block_till_done()
|
||||
client.websocket.close.assert_called_once()
|
||||
|
Loading…
x
Reference in New Issue
Block a user