mirror of
https://github.com/home-assistant/core.git
synced 2025-07-26 06:37:52 +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
|
_scale_address: str | None = None
|
||||||
|
|
||||||
async def _async_setup(self) -> None:
|
async def _async_connect_websocket(self) -> None:
|
||||||
"""Set up the coordinator."""
|
"""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")
|
_LOGGER.debug("Init WebSocket in background task")
|
||||||
|
|
||||||
self.config_entry.async_create_background_task(
|
self.config_entry.async_create_background_task(
|
||||||
@ -123,6 +125,7 @@ class LaMarzoccoConfigUpdateCoordinator(LaMarzoccoUpdateCoordinator):
|
|||||||
"""Fetch data from API endpoint."""
|
"""Fetch data from API endpoint."""
|
||||||
await self.device.get_config()
|
await self.device.get_config()
|
||||||
_LOGGER.debug("Current status: %s", str(self.device.config))
|
_LOGGER.debug("Current status: %s", str(self.device.config))
|
||||||
|
await self._async_connect_websocket()
|
||||||
self._async_add_remove_scale()
|
self._async_add_remove_scale()
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
|
@ -199,8 +199,11 @@ async def test_websocket_closed_on_unload(
|
|||||||
) as local_client:
|
) as local_client:
|
||||||
client = local_client.return_value
|
client = local_client.return_value
|
||||||
client.websocket = AsyncMock()
|
client.websocket = AsyncMock()
|
||||||
client.websocket.closed = False
|
|
||||||
await async_init_integration(hass, mock_config_entry)
|
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)
|
hass.bus.async_fire(EVENT_HOMEASSISTANT_STOP)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
client.websocket.close.assert_called_once()
|
client.websocket.close.assert_called_once()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user