Add zwave_js WS API commands for node ping and metadata (#51049)
This commit is contained in:
parent
e9ff4b1342
commit
4875035ff8
4 changed files with 907 additions and 8 deletions
|
@ -59,7 +59,7 @@ async def test_network_status(hass, integration, hass_ws_client):
|
|||
assert msg["error"]["code"] == ERR_NOT_LOADED
|
||||
|
||||
|
||||
async def test_node_status(hass, integration, multisensor_6, hass_ws_client):
|
||||
async def test_node_status(hass, multisensor_6, integration, hass_ws_client):
|
||||
"""Test the node status websocket command."""
|
||||
entry = integration
|
||||
ws_client = await hass_ws_client(hass)
|
||||
|
@ -113,8 +113,139 @@ async def test_node_status(hass, integration, multisensor_6, hass_ws_client):
|
|||
assert msg["error"]["code"] == ERR_NOT_LOADED
|
||||
|
||||
|
||||
async def test_node_metadata(hass, wallmote_central_scene, integration, hass_ws_client):
|
||||
"""Test the node metadata websocket command."""
|
||||
entry = integration
|
||||
ws_client = await hass_ws_client(hass)
|
||||
|
||||
node = wallmote_central_scene
|
||||
await ws_client.send_json(
|
||||
{
|
||||
ID: 3,
|
||||
TYPE: "zwave_js/node_metadata",
|
||||
ENTRY_ID: entry.entry_id,
|
||||
NODE_ID: node.node_id,
|
||||
}
|
||||
)
|
||||
msg = await ws_client.receive_json()
|
||||
result = msg["result"]
|
||||
|
||||
assert result[NODE_ID] == 35
|
||||
assert result["inclusion"] == (
|
||||
"To add the ZP3111 to the Z-Wave network (inclusion), place the Z-Wave "
|
||||
"primary controller into inclusion mode. Press the Program Switch of ZP3111 "
|
||||
"for sending the NIF. After sending NIF, Z-Wave will send the auto inclusion, "
|
||||
"otherwise, ZP3111 will go to sleep after 20 seconds."
|
||||
)
|
||||
assert result["exclusion"] == (
|
||||
"To remove the ZP3111 from the Z-Wave network (exclusion), place the Z-Wave "
|
||||
"primary controller into \u201cexclusion\u201d mode, and following its "
|
||||
"instruction to delete the ZP3111 to the controller. Press the Program Switch "
|
||||
"of ZP3111 once to be excluded."
|
||||
)
|
||||
assert result["reset"] == (
|
||||
"Remove cover to triggered tamper switch, LED flash once & send out Alarm "
|
||||
"Report. Press Program Switch 10 times within 10 seconds, ZP3111 will send "
|
||||
"the \u201cDevice Reset Locally Notification\u201d command and reset to the "
|
||||
"factory default. (Remark: This is to be used only in the case of primary "
|
||||
"controller being inoperable or otherwise unavailable.)"
|
||||
)
|
||||
assert result["manual"] == (
|
||||
"https://products.z-wavealliance.org/ProductManual/File?folder=&filename=MarketCertificationFiles/2479/ZP3111-5_R2_20170316.pdf"
|
||||
)
|
||||
assert not result["wakeup"]
|
||||
assert (
|
||||
result["device_database_url"]
|
||||
== "https://devices.zwave-js.io/?jumpTo=0x0086:0x0002:0x0082:0.0"
|
||||
)
|
||||
|
||||
# Test getting non-existent node fails
|
||||
await ws_client.send_json(
|
||||
{
|
||||
ID: 4,
|
||||
TYPE: "zwave_js/node_metadata",
|
||||
ENTRY_ID: entry.entry_id,
|
||||
NODE_ID: 99999,
|
||||
}
|
||||
)
|
||||
msg = await ws_client.receive_json()
|
||||
assert not msg["success"]
|
||||
assert msg["error"]["code"] == ERR_NOT_FOUND
|
||||
|
||||
# Test sending command with not loaded entry fails
|
||||
await hass.config_entries.async_unload(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
await ws_client.send_json(
|
||||
{
|
||||
ID: 5,
|
||||
TYPE: "zwave_js/node_metadata",
|
||||
ENTRY_ID: entry.entry_id,
|
||||
NODE_ID: node.node_id,
|
||||
}
|
||||
)
|
||||
msg = await ws_client.receive_json()
|
||||
|
||||
assert not msg["success"]
|
||||
assert msg["error"]["code"] == ERR_NOT_LOADED
|
||||
|
||||
|
||||
async def test_ping_node(
|
||||
hass, wallmote_central_scene, integration, client, hass_ws_client
|
||||
):
|
||||
"""Test the ping_node websocket command."""
|
||||
entry = integration
|
||||
ws_client = await hass_ws_client(hass)
|
||||
node = wallmote_central_scene
|
||||
|
||||
client.async_send_command.return_value = {"responded": True}
|
||||
|
||||
await ws_client.send_json(
|
||||
{
|
||||
ID: 3,
|
||||
TYPE: "zwave_js/ping_node",
|
||||
ENTRY_ID: entry.entry_id,
|
||||
NODE_ID: node.node_id,
|
||||
}
|
||||
)
|
||||
|
||||
msg = await ws_client.receive_json()
|
||||
assert msg["success"]
|
||||
assert msg["result"]
|
||||
|
||||
# Test getting non-existent node fails
|
||||
await ws_client.send_json(
|
||||
{
|
||||
ID: 4,
|
||||
TYPE: "zwave_js/ping_node",
|
||||
ENTRY_ID: entry.entry_id,
|
||||
NODE_ID: 99999,
|
||||
}
|
||||
)
|
||||
msg = await ws_client.receive_json()
|
||||
assert not msg["success"]
|
||||
assert msg["error"]["code"] == ERR_NOT_FOUND
|
||||
|
||||
# Test sending command with not loaded entry fails
|
||||
await hass.config_entries.async_unload(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
await ws_client.send_json(
|
||||
{
|
||||
ID: 5,
|
||||
TYPE: "zwave_js/ping_node",
|
||||
ENTRY_ID: entry.entry_id,
|
||||
NODE_ID: node.node_id,
|
||||
}
|
||||
)
|
||||
msg = await ws_client.receive_json()
|
||||
|
||||
assert not msg["success"]
|
||||
assert msg["error"]["code"] == ERR_NOT_LOADED
|
||||
|
||||
|
||||
async def test_add_node(
|
||||
hass, integration, client, hass_ws_client, nortek_thermostat_added_event
|
||||
hass, nortek_thermostat_added_event, integration, client, hass_ws_client
|
||||
):
|
||||
"""Test the add_node websocket command."""
|
||||
entry = integration
|
||||
|
@ -324,10 +455,10 @@ async def test_remove_node(
|
|||
|
||||
async def test_replace_failed_node(
|
||||
hass,
|
||||
nortek_thermostat,
|
||||
integration,
|
||||
client,
|
||||
hass_ws_client,
|
||||
nortek_thermostat,
|
||||
nortek_thermostat_added_event,
|
||||
nortek_thermostat_removed_event,
|
||||
):
|
||||
|
@ -475,10 +606,10 @@ async def test_replace_failed_node(
|
|||
|
||||
async def test_remove_failed_node(
|
||||
hass,
|
||||
nortek_thermostat,
|
||||
integration,
|
||||
client,
|
||||
hass_ws_client,
|
||||
nortek_thermostat,
|
||||
nortek_thermostat_removed_event,
|
||||
):
|
||||
"""Test the remove_failed_node websocket command."""
|
||||
|
@ -538,7 +669,7 @@ async def test_remove_failed_node(
|
|||
|
||||
|
||||
async def test_refresh_node_info(
|
||||
hass, client, integration, hass_ws_client, multisensor_6
|
||||
hass, client, multisensor_6, integration, hass_ws_client
|
||||
):
|
||||
"""Test that the refresh_node_info WS API call works."""
|
||||
entry = integration
|
||||
|
@ -637,7 +768,7 @@ async def test_refresh_node_info(
|
|||
|
||||
|
||||
async def test_refresh_node_values(
|
||||
hass, client, integration, hass_ws_client, multisensor_6
|
||||
hass, client, multisensor_6, integration, hass_ws_client
|
||||
):
|
||||
"""Test that the refresh_node_values WS API call works."""
|
||||
entry = integration
|
||||
|
@ -690,7 +821,7 @@ async def test_refresh_node_values(
|
|||
|
||||
|
||||
async def test_refresh_node_cc_values(
|
||||
hass, client, integration, hass_ws_client, multisensor_6
|
||||
hass, client, multisensor_6, integration, hass_ws_client
|
||||
):
|
||||
"""Test that the refresh_node_cc_values WS API call works."""
|
||||
entry = integration
|
||||
|
@ -920,7 +1051,7 @@ async def test_set_config_parameter(
|
|||
assert msg["error"]["code"] == ERR_NOT_LOADED
|
||||
|
||||
|
||||
async def test_get_config_parameters(hass, integration, multisensor_6, hass_ws_client):
|
||||
async def test_get_config_parameters(hass, multisensor_6, integration, hass_ws_client):
|
||||
"""Test the get config parameters websocket command."""
|
||||
entry = integration
|
||||
ws_client = await hass_ws_client(hass)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue