Add dsk option to zwave_js/add_node WS command (#87823)
* Add dsk option to zwave_js/add_node WS command * Bump zwave-js-server-python to 0.46.0 (#88520) * fix tests
This commit is contained in:
parent
1f9f6ab1f0
commit
cab8a59be4
2 changed files with 34 additions and 5 deletions
|
@ -654,6 +654,7 @@ async def websocket_node_comments(
|
||||||
QR_PROVISIONING_INFORMATION, "options"
|
QR_PROVISIONING_INFORMATION, "options"
|
||||||
): QR_PROVISIONING_INFORMATION_SCHEMA,
|
): QR_PROVISIONING_INFORMATION_SCHEMA,
|
||||||
vol.Exclusive(QR_CODE_STRING, "options"): QR_CODE_STRING_SCHEMA,
|
vol.Exclusive(QR_CODE_STRING, "options"): QR_CODE_STRING_SCHEMA,
|
||||||
|
vol.Exclusive(DSK, "options"): str,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@websocket_api.async_response
|
@websocket_api.async_response
|
||||||
|
@ -676,6 +677,7 @@ async def websocket_add_node(
|
||||||
or msg.get(QR_PROVISIONING_INFORMATION)
|
or msg.get(QR_PROVISIONING_INFORMATION)
|
||||||
or msg.get(QR_CODE_STRING)
|
or msg.get(QR_CODE_STRING)
|
||||||
)
|
)
|
||||||
|
dsk = msg.get(DSK)
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def async_cleanup() -> None:
|
def async_cleanup() -> None:
|
||||||
|
@ -772,6 +774,7 @@ async def websocket_add_node(
|
||||||
INCLUSION_STRATEGY_NOT_SMART_START[inclusion_strategy.value],
|
INCLUSION_STRATEGY_NOT_SMART_START[inclusion_strategy.value],
|
||||||
force_security=force_security,
|
force_security=force_security,
|
||||||
provisioning=provisioning,
|
provisioning=provisioning,
|
||||||
|
dsk=dsk,
|
||||||
)
|
)
|
||||||
except ValueError as err:
|
except ValueError as err:
|
||||||
connection.send_error(
|
connection.send_error(
|
||||||
|
|
|
@ -780,13 +780,39 @@ async def test_add_node(
|
||||||
client.async_send_command.reset_mock()
|
client.async_send_command.reset_mock()
|
||||||
client.async_send_command.return_value = {"success": True}
|
client.async_send_command.return_value = {"success": True}
|
||||||
|
|
||||||
# Test Smart Start QR provisioning information with S2 inclusion strategy fails
|
# Test S2 DSK string string
|
||||||
await ws_client.send_json(
|
await ws_client.send_json(
|
||||||
{
|
{
|
||||||
ID: 6,
|
ID: 6,
|
||||||
TYPE: "zwave_js/add_node",
|
TYPE: "zwave_js/add_node",
|
||||||
ENTRY_ID: entry.entry_id,
|
ENTRY_ID: entry.entry_id,
|
||||||
INCLUSION_STRATEGY: InclusionStrategy.SECURITY_S2.value,
|
INCLUSION_STRATEGY: InclusionStrategy.SECURITY_S2.value,
|
||||||
|
DSK: "test_dsk",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
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": {
|
||||||
|
"strategy": InclusionStrategy.SECURITY_S2,
|
||||||
|
"dsk": "test_dsk",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
client.async_send_command.reset_mock()
|
||||||
|
client.async_send_command.return_value = {"success": True}
|
||||||
|
|
||||||
|
# Test Smart Start QR provisioning information with S2 inclusion strategy fails
|
||||||
|
await ws_client.send_json(
|
||||||
|
{
|
||||||
|
ID: 7,
|
||||||
|
TYPE: "zwave_js/add_node",
|
||||||
|
ENTRY_ID: entry.entry_id,
|
||||||
|
INCLUSION_STRATEGY: InclusionStrategy.SECURITY_S2.value,
|
||||||
QR_PROVISIONING_INFORMATION: {
|
QR_PROVISIONING_INFORMATION: {
|
||||||
VERSION: 1,
|
VERSION: 1,
|
||||||
SECURITY_CLASSES: [0],
|
SECURITY_CLASSES: [0],
|
||||||
|
@ -813,7 +839,7 @@ async def test_add_node(
|
||||||
# Test QR provisioning information with S0 inclusion strategy fails
|
# Test QR provisioning information with S0 inclusion strategy fails
|
||||||
await ws_client.send_json(
|
await ws_client.send_json(
|
||||||
{
|
{
|
||||||
ID: 7,
|
ID: 8,
|
||||||
TYPE: "zwave_js/add_node",
|
TYPE: "zwave_js/add_node",
|
||||||
ENTRY_ID: entry.entry_id,
|
ENTRY_ID: entry.entry_id,
|
||||||
INCLUSION_STRATEGY: InclusionStrategy.SECURITY_S0,
|
INCLUSION_STRATEGY: InclusionStrategy.SECURITY_S0,
|
||||||
|
@ -843,7 +869,7 @@ async def test_add_node(
|
||||||
# Test ValueError is caught as failure
|
# Test ValueError is caught as failure
|
||||||
await ws_client.send_json(
|
await ws_client.send_json(
|
||||||
{
|
{
|
||||||
ID: 8,
|
ID: 9,
|
||||||
TYPE: "zwave_js/add_node",
|
TYPE: "zwave_js/add_node",
|
||||||
ENTRY_ID: entry.entry_id,
|
ENTRY_ID: entry.entry_id,
|
||||||
INCLUSION_STRATEGY: InclusionStrategy.DEFAULT.value,
|
INCLUSION_STRATEGY: InclusionStrategy.DEFAULT.value,
|
||||||
|
@ -863,7 +889,7 @@ async def test_add_node(
|
||||||
):
|
):
|
||||||
await ws_client.send_json(
|
await ws_client.send_json(
|
||||||
{
|
{
|
||||||
ID: 9,
|
ID: 10,
|
||||||
TYPE: "zwave_js/add_node",
|
TYPE: "zwave_js/add_node",
|
||||||
ENTRY_ID: entry.entry_id,
|
ENTRY_ID: entry.entry_id,
|
||||||
}
|
}
|
||||||
|
@ -879,7 +905,7 @@ async def test_add_node(
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
await ws_client.send_json(
|
await ws_client.send_json(
|
||||||
{ID: 10, TYPE: "zwave_js/add_node", ENTRY_ID: entry.entry_id}
|
{ID: 11, TYPE: "zwave_js/add_node", ENTRY_ID: entry.entry_id}
|
||||||
)
|
)
|
||||||
msg = await ws_client.receive_json()
|
msg = await ws_client.receive_json()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue