mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
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 .discovery import async_discover_values
|
||||||
from .entity import get_device_id
|
from .entity import get_device_id
|
||||||
|
|
||||||
LOGGER = logging.getLogger(__name__)
|
LOGGER = logging.getLogger(__package__)
|
||||||
CONNECT_TIMEOUT = 10
|
CONNECT_TIMEOUT = 10
|
||||||
DATA_CLIENT_LISTEN_TASK = "client_listen_task"
|
DATA_CLIENT_LISTEN_TASK = "client_listen_task"
|
||||||
DATA_START_PLATFORM_TASK = "start_platform_task"
|
DATA_START_PLATFORM_TASK = "start_platform_task"
|
||||||
@ -263,13 +263,20 @@ async def client_listen(
|
|||||||
driver_ready: asyncio.Event,
|
driver_ready: asyncio.Event,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Listen with the client."""
|
"""Listen with the client."""
|
||||||
|
should_reload = True
|
||||||
try:
|
try:
|
||||||
await client.listen(driver_ready)
|
await client.listen(driver_ready)
|
||||||
|
except asyncio.CancelledError:
|
||||||
|
should_reload = False
|
||||||
except BaseZwaveJSServerError:
|
except BaseZwaveJSServerError:
|
||||||
# The entry needs to be reloaded since a new driver state
|
pass
|
||||||
# will be acquired on reconnect.
|
|
||||||
# All model instances will be replaced when the new state is acquired.
|
# The entry needs to be reloaded since a new driver state
|
||||||
hass.async_create_task(hass.config_entries.async_reload(entry.entry_id))
|
# 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(
|
async def disconnect_client(
|
||||||
@ -280,14 +287,14 @@ async def disconnect_client(
|
|||||||
platform_task: asyncio.Task,
|
platform_task: asyncio.Task,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Disconnect client."""
|
"""Disconnect client."""
|
||||||
await client.disconnect()
|
|
||||||
|
|
||||||
listen_task.cancel()
|
listen_task.cancel()
|
||||||
platform_task.cancel()
|
platform_task.cancel()
|
||||||
|
|
||||||
await asyncio.gather(listen_task, platform_task)
|
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:
|
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
|
@ -51,7 +51,7 @@ def websocket_network_status(
|
|||||||
data = {
|
data = {
|
||||||
"client": {
|
"client": {
|
||||||
"ws_server_url": client.ws_server_url,
|
"ws_server_url": client.ws_server_url,
|
||||||
"state": client.state,
|
"state": "connected" if client.connected else "disconnected",
|
||||||
"driver_version": client.version.driver_version,
|
"driver_version": client.version.driver_version,
|
||||||
"server_version": client.version.server_version,
|
"server_version": client.version.server_version,
|
||||||
},
|
},
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
"name": "Z-Wave JS",
|
"name": "Z-Wave JS",
|
||||||
"config_flow": true,
|
"config_flow": true,
|
||||||
"documentation": "https://www.home-assistant.io/integrations/zwave_js",
|
"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"],
|
"codeowners": ["@home-assistant/z-wave"],
|
||||||
"dependencies": ["http", "websocket_api"]
|
"dependencies": ["http", "websocket_api"]
|
||||||
}
|
}
|
||||||
|
@ -2384,4 +2384,4 @@ zigpy==0.32.0
|
|||||||
zm-py==0.5.2
|
zm-py==0.5.2
|
||||||
|
|
||||||
# homeassistant.components.zwave_js
|
# 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
|
zigpy==0.32.0
|
||||||
|
|
||||||
# homeassistant.components.zwave_js
|
# 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():
|
async def connect():
|
||||||
await asyncio.sleep(0)
|
await asyncio.sleep(0)
|
||||||
client.state = "connected"
|
|
||||||
client.connected = True
|
client.connected = True
|
||||||
|
|
||||||
async def listen(driver_ready: asyncio.Event) -> None:
|
async def listen(driver_ready: asyncio.Event) -> None:
|
||||||
driver_ready.set()
|
driver_ready.set()
|
||||||
|
await asyncio.sleep(30)
|
||||||
|
assert False, "Listen wasn't canceled!"
|
||||||
|
|
||||||
async def disconnect():
|
async def disconnect():
|
||||||
client.state = "disconnected"
|
|
||||||
client.connected = False
|
client.connected = False
|
||||||
|
|
||||||
client.connect = AsyncMock(side_effect=connect)
|
client.connect = AsyncMock(side_effect=connect)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user