Bump zwave-js-server-python to 0.29.0 (#54931)
* Bump zwave-js-server-python to 0.29.0 * Cover secure flag true paths for add node WS commands
This commit is contained in:
parent
dd8542e01f
commit
11c6a33594
6 changed files with 105 additions and 10 deletions
|
@ -10,7 +10,7 @@ from aiohttp import hdrs, web, web_exceptions, web_request
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
from zwave_js_server import dump
|
from zwave_js_server import dump
|
||||||
from zwave_js_server.client import Client
|
from zwave_js_server.client import Client
|
||||||
from zwave_js_server.const import CommandClass, LogLevel
|
from zwave_js_server.const import CommandClass, InclusionStrategy, LogLevel
|
||||||
from zwave_js_server.exceptions import (
|
from zwave_js_server.exceptions import (
|
||||||
BaseZwaveJSServerError,
|
BaseZwaveJSServerError,
|
||||||
FailedCommand,
|
FailedCommand,
|
||||||
|
@ -386,7 +386,11 @@ async def websocket_add_node(
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Add a node to the Z-Wave network."""
|
"""Add a node to the Z-Wave network."""
|
||||||
controller = client.driver.controller
|
controller = client.driver.controller
|
||||||
include_non_secure = not msg[SECURE]
|
|
||||||
|
if msg[SECURE]:
|
||||||
|
inclusion_strategy = InclusionStrategy.SECURITY_S0
|
||||||
|
else:
|
||||||
|
inclusion_strategy = InclusionStrategy.INSECURE
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def async_cleanup() -> None:
|
def async_cleanup() -> None:
|
||||||
|
@ -454,7 +458,7 @@ async def websocket_add_node(
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
result = await controller.async_begin_inclusion(include_non_secure)
|
result = await controller.async_begin_inclusion(inclusion_strategy)
|
||||||
connection.send_result(
|
connection.send_result(
|
||||||
msg[ID],
|
msg[ID],
|
||||||
result,
|
result,
|
||||||
|
@ -594,9 +598,13 @@ async def websocket_replace_failed_node(
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Replace a failed node with a new node."""
|
"""Replace a failed node with a new node."""
|
||||||
controller = client.driver.controller
|
controller = client.driver.controller
|
||||||
include_non_secure = not msg[SECURE]
|
|
||||||
node_id = msg[NODE_ID]
|
node_id = msg[NODE_ID]
|
||||||
|
|
||||||
|
if msg[SECURE]:
|
||||||
|
inclusion_strategy = InclusionStrategy.SECURITY_S0
|
||||||
|
else:
|
||||||
|
inclusion_strategy = InclusionStrategy.INSECURE
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def async_cleanup() -> None:
|
def async_cleanup() -> None:
|
||||||
"""Remove signal listeners."""
|
"""Remove signal listeners."""
|
||||||
|
@ -677,7 +685,7 @@ async def websocket_replace_failed_node(
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
result = await controller.async_replace_failed_node(node_id, include_non_secure)
|
result = await controller.async_replace_failed_node(node_id, inclusion_strategy)
|
||||||
connection.send_result(
|
connection.send_result(
|
||||||
msg[ID],
|
msg[ID],
|
||||||
result,
|
result,
|
||||||
|
|
|
@ -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.28.0"],
|
"requirements": ["zwave-js-server-python==0.29.0"],
|
||||||
"codeowners": ["@home-assistant/z-wave"],
|
"codeowners": ["@home-assistant/z-wave"],
|
||||||
"dependencies": ["http", "websocket_api"],
|
"dependencies": ["http", "websocket_api"],
|
||||||
"iot_class": "local_push"
|
"iot_class": "local_push"
|
||||||
|
|
|
@ -2482,4 +2482,4 @@ zigpy==0.36.1
|
||||||
zm-py==0.5.2
|
zm-py==0.5.2
|
||||||
|
|
||||||
# homeassistant.components.zwave_js
|
# homeassistant.components.zwave_js
|
||||||
zwave-js-server-python==0.28.0
|
zwave-js-server-python==0.29.0
|
||||||
|
|
|
@ -1390,4 +1390,4 @@ zigpy-znp==0.5.3
|
||||||
zigpy==0.36.1
|
zigpy==0.36.1
|
||||||
|
|
||||||
# homeassistant.components.zwave_js
|
# homeassistant.components.zwave_js
|
||||||
zwave-js-server-python==0.28.0
|
zwave-js-server-python==0.29.0
|
||||||
|
|
|
@ -3,7 +3,7 @@ import json
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from zwave_js_server.const import LogLevel
|
from zwave_js_server.const import InclusionStrategy, LogLevel
|
||||||
from zwave_js_server.event import Event
|
from zwave_js_server.event import Event
|
||||||
from zwave_js_server.exceptions import (
|
from zwave_js_server.exceptions import (
|
||||||
FailedCommand,
|
FailedCommand,
|
||||||
|
@ -29,6 +29,7 @@ from homeassistant.components.zwave_js.api import (
|
||||||
OPTED_IN,
|
OPTED_IN,
|
||||||
PROPERTY,
|
PROPERTY,
|
||||||
PROPERTY_KEY,
|
PROPERTY_KEY,
|
||||||
|
SECURE,
|
||||||
TYPE,
|
TYPE,
|
||||||
VALUE,
|
VALUE,
|
||||||
)
|
)
|
||||||
|
@ -318,6 +319,31 @@ async def test_ping_node(
|
||||||
assert msg["error"]["code"] == ERR_NOT_LOADED
|
assert msg["error"]["code"] == ERR_NOT_LOADED
|
||||||
|
|
||||||
|
|
||||||
|
async def test_add_node_secure(
|
||||||
|
hass, nortek_thermostat_added_event, integration, client, hass_ws_client
|
||||||
|
):
|
||||||
|
"""Test the add_node websocket command with secure flag."""
|
||||||
|
entry = integration
|
||||||
|
ws_client = await hass_ws_client(hass)
|
||||||
|
|
||||||
|
client.async_send_command.return_value = {"success": True}
|
||||||
|
|
||||||
|
await ws_client.send_json(
|
||||||
|
{ID: 1, TYPE: "zwave_js/add_node", ENTRY_ID: entry.entry_id, SECURE: True}
|
||||||
|
)
|
||||||
|
|
||||||
|
msg = await ws_client.receive_json()
|
||||||
|
assert msg["success"]
|
||||||
|
|
||||||
|
assert len(client.async_send_command.call_args_list) == 1
|
||||||
|
assert client.async_send_command.call_args[0][0] == {
|
||||||
|
"command": "controller.begin_inclusion",
|
||||||
|
"options": {"inclusionStrategy": InclusionStrategy.SECURITY_S0},
|
||||||
|
}
|
||||||
|
|
||||||
|
client.async_send_command.reset_mock()
|
||||||
|
|
||||||
|
|
||||||
async def test_add_node(
|
async def test_add_node(
|
||||||
hass, nortek_thermostat_added_event, integration, client, hass_ws_client
|
hass, nortek_thermostat_added_event, integration, client, hass_ws_client
|
||||||
):
|
):
|
||||||
|
@ -334,6 +360,12 @@ async def test_add_node(
|
||||||
msg = await ws_client.receive_json()
|
msg = await ws_client.receive_json()
|
||||||
assert msg["success"]
|
assert msg["success"]
|
||||||
|
|
||||||
|
assert len(client.async_send_command.call_args_list) == 1
|
||||||
|
assert client.async_send_command.call_args[0][0] == {
|
||||||
|
"command": "controller.begin_inclusion",
|
||||||
|
"options": {"inclusionStrategy": InclusionStrategy.INSECURE},
|
||||||
|
}
|
||||||
|
|
||||||
event = Event(
|
event = Event(
|
||||||
type="inclusion started",
|
type="inclusion started",
|
||||||
data={
|
data={
|
||||||
|
@ -599,6 +631,52 @@ async def test_remove_node(
|
||||||
assert msg["error"]["code"] == ERR_NOT_LOADED
|
assert msg["error"]["code"] == ERR_NOT_LOADED
|
||||||
|
|
||||||
|
|
||||||
|
async def test_replace_failed_node_secure(
|
||||||
|
hass,
|
||||||
|
nortek_thermostat,
|
||||||
|
integration,
|
||||||
|
client,
|
||||||
|
hass_ws_client,
|
||||||
|
):
|
||||||
|
"""Test the replace_failed_node websocket command with secure flag."""
|
||||||
|
entry = integration
|
||||||
|
ws_client = await hass_ws_client(hass)
|
||||||
|
|
||||||
|
dev_reg = dr.async_get(hass)
|
||||||
|
|
||||||
|
# Create device registry entry for mock node
|
||||||
|
dev_reg.async_get_or_create(
|
||||||
|
config_entry_id=entry.entry_id,
|
||||||
|
identifiers={(DOMAIN, "3245146787-67")},
|
||||||
|
name="Node 67",
|
||||||
|
)
|
||||||
|
|
||||||
|
client.async_send_command.return_value = {"success": True}
|
||||||
|
|
||||||
|
await ws_client.send_json(
|
||||||
|
{
|
||||||
|
ID: 1,
|
||||||
|
TYPE: "zwave_js/replace_failed_node",
|
||||||
|
ENTRY_ID: entry.entry_id,
|
||||||
|
NODE_ID: 67,
|
||||||
|
SECURE: True,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
msg = await ws_client.receive_json()
|
||||||
|
assert msg["success"]
|
||||||
|
assert msg["result"]
|
||||||
|
|
||||||
|
assert len(client.async_send_command.call_args_list) == 1
|
||||||
|
assert client.async_send_command.call_args[0][0] == {
|
||||||
|
"command": "controller.replace_failed_node",
|
||||||
|
"nodeId": nortek_thermostat.node_id,
|
||||||
|
"options": {"inclusionStrategy": InclusionStrategy.SECURITY_S0},
|
||||||
|
}
|
||||||
|
|
||||||
|
client.async_send_command.reset_mock()
|
||||||
|
|
||||||
|
|
||||||
async def test_replace_failed_node(
|
async def test_replace_failed_node(
|
||||||
hass,
|
hass,
|
||||||
nortek_thermostat,
|
nortek_thermostat,
|
||||||
|
@ -638,6 +716,15 @@ async def test_replace_failed_node(
|
||||||
assert msg["success"]
|
assert msg["success"]
|
||||||
assert msg["result"]
|
assert msg["result"]
|
||||||
|
|
||||||
|
assert len(client.async_send_command.call_args_list) == 1
|
||||||
|
assert client.async_send_command.call_args[0][0] == {
|
||||||
|
"command": "controller.replace_failed_node",
|
||||||
|
"nodeId": nortek_thermostat.node_id,
|
||||||
|
"options": {"inclusionStrategy": InclusionStrategy.INSECURE},
|
||||||
|
}
|
||||||
|
|
||||||
|
client.async_send_command.reset_mock()
|
||||||
|
|
||||||
event = Event(
|
event = Event(
|
||||||
type="inclusion started",
|
type="inclusion started",
|
||||||
data={
|
data={
|
||||||
|
|
|
@ -437,7 +437,7 @@ async def test_get_condition_capabilities_value(
|
||||||
(98, "DOOR_LOCK"),
|
(98, "DOOR_LOCK"),
|
||||||
(122, "FIRMWARE_UPDATE_MD"),
|
(122, "FIRMWARE_UPDATE_MD"),
|
||||||
(114, "MANUFACTURER_SPECIFIC"),
|
(114, "MANUFACTURER_SPECIFIC"),
|
||||||
(113, "ALARM"),
|
(113, "NOTIFICATION"),
|
||||||
(152, "SECURITY"),
|
(152, "SECURITY"),
|
||||||
(99, "USER_CODE"),
|
(99, "USER_CODE"),
|
||||||
(134, "VERSION"),
|
(134, "VERSION"),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue