mirror of https://github.com/home-assistant/core
Upgrade Z-Wave JS Python to 0.17.0 (#45895)
This commit is contained in:
parent
a2ec1a47d5
commit
40ba182144
|
@ -45,7 +45,7 @@ from .const import (
|
|||
from .discovery import async_discover_values
|
||||
from .entity import get_device_id
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
LOGGER = logging.getLogger(__package__)
|
||||
CONNECT_TIMEOUT = 10
|
||||
DATA_CLIENT_LISTEN_TASK = "client_listen_task"
|
||||
DATA_START_PLATFORM_TASK = "start_platform_task"
|
||||
|
@ -263,13 +263,20 @@ async def client_listen(
|
|||
driver_ready: asyncio.Event,
|
||||
) -> None:
|
||||
"""Listen with the client."""
|
||||
should_reload = True
|
||||
try:
|
||||
await client.listen(driver_ready)
|
||||
except asyncio.CancelledError:
|
||||
should_reload = False
|
||||
except BaseZwaveJSServerError:
|
||||
# The entry needs to be reloaded since a new driver state
|
||||
# will be acquired on reconnect.
|
||||
# All model instances will be replaced when the new state is acquired.
|
||||
hass.async_create_task(hass.config_entries.async_reload(entry.entry_id))
|
||||
pass
|
||||
|
||||
# The entry needs to be reloaded since a new driver state
|
||||
# will be acquired on reconnect.
|
||||
# All model instances will be replaced when the new state is acquired.
|
||||
if should_reload:
|
||||
LOGGER.info("Disconnected from server. Reloading integration")
|
||||
asyncio.create_task(hass.config_entries.async_reload(entry.entry_id))
|
||||
|
||||
|
||||
async def disconnect_client(
|
||||
|
@ -280,14 +287,14 @@ async def disconnect_client(
|
|||
platform_task: asyncio.Task,
|
||||
) -> None:
|
||||
"""Disconnect client."""
|
||||
await client.disconnect()
|
||||
|
||||
listen_task.cancel()
|
||||
platform_task.cancel()
|
||||
|
||||
await asyncio.gather(listen_task, platform_task)
|
||||
|
||||
LOGGER.info("Disconnected from Zwave JS Server")
|
||||
if client.connected:
|
||||
await client.disconnect()
|
||||
LOGGER.info("Disconnected from Zwave JS Server")
|
||||
|
||||
|
||||
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
|
|
|
@ -51,7 +51,7 @@ def websocket_network_status(
|
|||
data = {
|
||||
"client": {
|
||||
"ws_server_url": client.ws_server_url,
|
||||
"state": client.state,
|
||||
"state": "connected" if client.connected else "disconnected",
|
||||
"driver_version": client.version.driver_version,
|
||||
"server_version": client.version.server_version,
|
||||
},
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"name": "Z-Wave JS",
|
||||
"config_flow": true,
|
||||
"documentation": "https://www.home-assistant.io/integrations/zwave_js",
|
||||
"requirements": ["zwave-js-server-python==0.16.0"],
|
||||
"requirements": ["zwave-js-server-python==0.17.0"],
|
||||
"codeowners": ["@home-assistant/z-wave"],
|
||||
"dependencies": ["http", "websocket_api"]
|
||||
}
|
||||
|
|
|
@ -2384,4 +2384,4 @@ zigpy==0.32.0
|
|||
zm-py==0.5.2
|
||||
|
||||
# homeassistant.components.zwave_js
|
||||
zwave-js-server-python==0.16.0
|
||||
zwave-js-server-python==0.17.0
|
||||
|
|
|
@ -1203,4 +1203,4 @@ zigpy-znp==0.3.0
|
|||
zigpy==0.32.0
|
||||
|
||||
# homeassistant.components.zwave_js
|
||||
zwave-js-server-python==0.16.0
|
||||
zwave-js-server-python==0.17.0
|
||||
|
|
|
@ -157,14 +157,14 @@ def mock_client_fixture(controller_state, version_state):
|
|||
|
||||
async def connect():
|
||||
await asyncio.sleep(0)
|
||||
client.state = "connected"
|
||||
client.connected = True
|
||||
|
||||
async def listen(driver_ready: asyncio.Event) -> None:
|
||||
driver_ready.set()
|
||||
await asyncio.sleep(30)
|
||||
assert False, "Listen wasn't canceled!"
|
||||
|
||||
async def disconnect():
|
||||
client.state = "disconnected"
|
||||
client.connected = False
|
||||
|
||||
client.connect = AsyncMock(side_effect=connect)
|
||||
|
|
Loading…
Reference in New Issue