mirror of
https://github.com/home-assistant/core.git
synced 2026-09-27 18:08:37 -04:00
Use device ID as input for zwave_js WS device cmds (#71667)
* Use device ID as input for zwave_js WS device cmds * Additionally missed commands, update network_status command to include node status data * revert change to removed function * Revert register device change
This commit is contained in:
@@ -35,6 +35,7 @@ from homeassistant.components.zwave_js.api import (
|
||||
CLIENT_SIDE_AUTH,
|
||||
COMMAND_CLASS_ID,
|
||||
CONFIG,
|
||||
DEVICE_ID,
|
||||
DSK,
|
||||
ENABLED,
|
||||
ENTRY_ID,
|
||||
@@ -70,9 +71,17 @@ from homeassistant.components.zwave_js.const import (
|
||||
CONF_DATA_COLLECTION_OPTED_IN,
|
||||
DOMAIN,
|
||||
)
|
||||
from homeassistant.components.zwave_js.helpers import get_device_id
|
||||
from homeassistant.helpers import device_registry as dr
|
||||
|
||||
|
||||
def get_device(hass, node):
|
||||
"""Get device ID for a node."""
|
||||
dev_reg = dr.async_get(hass)
|
||||
device_id = get_device_id(node.client, node)
|
||||
return dev_reg.async_get_device({device_id})
|
||||
|
||||
|
||||
async def test_network_status(hass, integration, hass_ws_client):
|
||||
"""Test the network status websocket command."""
|
||||
entry = integration
|
||||
@@ -117,12 +126,16 @@ async def test_node_ready(
|
||||
node.data["ready"] = False
|
||||
client.driver.controller.nodes[node.node_id] = node
|
||||
|
||||
dev_reg = dr.async_get(hass)
|
||||
device = dev_reg.async_get_or_create(
|
||||
config_entry_id=entry.entry_id, identifiers={get_device_id(client, node)}
|
||||
)
|
||||
|
||||
await ws_client.send_json(
|
||||
{
|
||||
ID: 3,
|
||||
TYPE: "zwave_js/node_ready",
|
||||
ENTRY_ID: entry.entry_id,
|
||||
"node_id": node.node_id,
|
||||
DEVICE_ID: device.id,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -153,12 +166,12 @@ async def test_node_status(hass, multisensor_6, integration, hass_ws_client):
|
||||
ws_client = await hass_ws_client(hass)
|
||||
|
||||
node = multisensor_6
|
||||
device = get_device(hass, node)
|
||||
await ws_client.send_json(
|
||||
{
|
||||
ID: 3,
|
||||
TYPE: "zwave_js/node_status",
|
||||
ENTRY_ID: entry.entry_id,
|
||||
NODE_ID: node.node_id,
|
||||
DEVICE_ID: device.id,
|
||||
}
|
||||
)
|
||||
msg = await ws_client.receive_json()
|
||||
@@ -178,8 +191,7 @@ async def test_node_status(hass, multisensor_6, integration, hass_ws_client):
|
||||
{
|
||||
ID: 4,
|
||||
TYPE: "zwave_js/node_status",
|
||||
ENTRY_ID: entry.entry_id,
|
||||
NODE_ID: 99999,
|
||||
DEVICE_ID: "fake_device",
|
||||
}
|
||||
)
|
||||
msg = await ws_client.receive_json()
|
||||
@@ -194,8 +206,7 @@ async def test_node_status(hass, multisensor_6, integration, hass_ws_client):
|
||||
{
|
||||
ID: 5,
|
||||
TYPE: "zwave_js/node_status",
|
||||
ENTRY_ID: entry.entry_id,
|
||||
NODE_ID: node.node_id,
|
||||
DEVICE_ID: device.id,
|
||||
}
|
||||
)
|
||||
msg = await ws_client.receive_json()
|
||||
@@ -210,12 +221,12 @@ async def test_node_metadata(hass, wallmote_central_scene, integration, hass_ws_
|
||||
ws_client = await hass_ws_client(hass)
|
||||
|
||||
node = wallmote_central_scene
|
||||
device = get_device(hass, node)
|
||||
await ws_client.send_json(
|
||||
{
|
||||
ID: 3,
|
||||
TYPE: "zwave_js/node_metadata",
|
||||
ENTRY_ID: entry.entry_id,
|
||||
NODE_ID: node.node_id,
|
||||
DEVICE_ID: device.id,
|
||||
}
|
||||
)
|
||||
msg = await ws_client.receive_json()
|
||||
@@ -256,8 +267,7 @@ async def test_node_metadata(hass, wallmote_central_scene, integration, hass_ws_
|
||||
{
|
||||
ID: 4,
|
||||
TYPE: "zwave_js/node_metadata",
|
||||
ENTRY_ID: entry.entry_id,
|
||||
NODE_ID: 99999,
|
||||
DEVICE_ID: "fake_device",
|
||||
}
|
||||
)
|
||||
msg = await ws_client.receive_json()
|
||||
@@ -272,81 +282,7 @@ async def test_node_metadata(hass, wallmote_central_scene, integration, hass_ws_
|
||||
{
|
||||
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 FailedZWaveCommand is caught
|
||||
with patch(
|
||||
"zwave_js_server.model.node.Node.async_ping",
|
||||
side_effect=FailedZWaveCommand("failed_command", 1, "error message"),
|
||||
):
|
||||
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"] == "zwave_error"
|
||||
assert msg["error"]["message"] == "Z-Wave error 1: error message"
|
||||
|
||||
# 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: 6,
|
||||
TYPE: "zwave_js/ping_node",
|
||||
ENTRY_ID: entry.entry_id,
|
||||
NODE_ID: node.node_id,
|
||||
DEVICE_ID: device.id,
|
||||
}
|
||||
)
|
||||
msg = await ws_client.receive_json()
|
||||
@@ -1812,19 +1748,38 @@ async def test_remove_failed_node(
|
||||
client,
|
||||
hass_ws_client,
|
||||
nortek_thermostat_removed_event,
|
||||
nortek_thermostat_added_event,
|
||||
):
|
||||
"""Test the remove_failed_node websocket command."""
|
||||
entry = integration
|
||||
ws_client = await hass_ws_client(hass)
|
||||
device = get_device(hass, nortek_thermostat)
|
||||
|
||||
client.async_send_command.return_value = {"success": True}
|
||||
|
||||
# Test FailedZWaveCommand is caught
|
||||
with patch(
|
||||
"zwave_js_server.model.controller.Controller.async_remove_failed_node",
|
||||
side_effect=FailedZWaveCommand("failed_command", 1, "error message"),
|
||||
):
|
||||
await ws_client.send_json(
|
||||
{
|
||||
ID: 1,
|
||||
TYPE: "zwave_js/remove_failed_node",
|
||||
DEVICE_ID: device.id,
|
||||
}
|
||||
)
|
||||
msg = await ws_client.receive_json()
|
||||
|
||||
assert not msg["success"]
|
||||
assert msg["error"]["code"] == "zwave_error"
|
||||
assert msg["error"]["message"] == "Z-Wave error 1: error message"
|
||||
|
||||
await ws_client.send_json(
|
||||
{
|
||||
ID: 3,
|
||||
ID: 2,
|
||||
TYPE: "zwave_js/remove_failed_node",
|
||||
ENTRY_ID: entry.entry_id,
|
||||
NODE_ID: 67,
|
||||
DEVICE_ID: device.id,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -1846,29 +1801,15 @@ async def test_remove_failed_node(
|
||||
assert msg["event"]["event"] == "node removed"
|
||||
|
||||
# Verify device was removed from device registry
|
||||
device = dev_reg.async_get_device(
|
||||
identifiers={(DOMAIN, "3245146787-67")},
|
||||
)
|
||||
assert device is None
|
||||
|
||||
# Test FailedZWaveCommand is caught
|
||||
with patch(
|
||||
"zwave_js_server.model.controller.Controller.async_remove_failed_node",
|
||||
side_effect=FailedZWaveCommand("failed_command", 1, "error message"),
|
||||
):
|
||||
await ws_client.send_json(
|
||||
{
|
||||
ID: 4,
|
||||
TYPE: "zwave_js/remove_failed_node",
|
||||
ENTRY_ID: entry.entry_id,
|
||||
NODE_ID: 67,
|
||||
}
|
||||
assert (
|
||||
dev_reg.async_get_device(
|
||||
identifiers={(DOMAIN, "3245146787-67")},
|
||||
)
|
||||
msg = await ws_client.receive_json()
|
||||
is None
|
||||
)
|
||||
|
||||
assert not msg["success"]
|
||||
assert msg["error"]["code"] == "zwave_error"
|
||||
assert msg["error"]["message"] == "Z-Wave error 1: error message"
|
||||
# Re-add node so we can test config entry not loaded
|
||||
client.driver.receive_event(nortek_thermostat_added_event)
|
||||
|
||||
# Test sending command with not loaded entry fails
|
||||
await hass.config_entries.async_unload(entry.entry_id)
|
||||
@@ -1876,10 +1817,9 @@ async def test_remove_failed_node(
|
||||
|
||||
await ws_client.send_json(
|
||||
{
|
||||
ID: 5,
|
||||
ID: 3,
|
||||
TYPE: "zwave_js/remove_failed_node",
|
||||
ENTRY_ID: entry.entry_id,
|
||||
NODE_ID: 67,
|
||||
DEVICE_ID: device.id,
|
||||
}
|
||||
)
|
||||
msg = await ws_client.receive_json()
|
||||
@@ -2091,6 +2031,7 @@ async def test_stop_healing_network(
|
||||
|
||||
async def test_heal_node(
|
||||
hass,
|
||||
multisensor_6,
|
||||
integration,
|
||||
client,
|
||||
hass_ws_client,
|
||||
@@ -2098,6 +2039,7 @@ async def test_heal_node(
|
||||
"""Test the heal_node websocket command."""
|
||||
entry = integration
|
||||
ws_client = await hass_ws_client(hass)
|
||||
device = get_device(hass, multisensor_6)
|
||||
|
||||
client.async_send_command.return_value = {"success": True}
|
||||
|
||||
@@ -2105,8 +2047,7 @@ async def test_heal_node(
|
||||
{
|
||||
ID: 3,
|
||||
TYPE: "zwave_js/heal_node",
|
||||
ENTRY_ID: entry.entry_id,
|
||||
NODE_ID: 67,
|
||||
DEVICE_ID: device.id,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -2123,8 +2064,7 @@ async def test_heal_node(
|
||||
{
|
||||
ID: 4,
|
||||
TYPE: "zwave_js/heal_node",
|
||||
ENTRY_ID: entry.entry_id,
|
||||
NODE_ID: 67,
|
||||
DEVICE_ID: device.id,
|
||||
}
|
||||
)
|
||||
msg = await ws_client.receive_json()
|
||||
@@ -2141,8 +2081,7 @@ async def test_heal_node(
|
||||
{
|
||||
ID: 5,
|
||||
TYPE: "zwave_js/heal_node",
|
||||
ENTRY_ID: entry.entry_id,
|
||||
NODE_ID: 67,
|
||||
DEVICE_ID: device.id,
|
||||
}
|
||||
)
|
||||
msg = await ws_client.receive_json()
|
||||
@@ -2158,13 +2097,14 @@ async def test_refresh_node_info(
|
||||
entry = integration
|
||||
ws_client = await hass_ws_client(hass)
|
||||
|
||||
device = get_device(hass, multisensor_6)
|
||||
|
||||
client.async_send_command_no_wait.return_value = None
|
||||
await ws_client.send_json(
|
||||
{
|
||||
ID: 1,
|
||||
TYPE: "zwave_js/refresh_node_info",
|
||||
ENTRY_ID: entry.entry_id,
|
||||
NODE_ID: 52,
|
||||
DEVICE_ID: device.id,
|
||||
}
|
||||
)
|
||||
msg = await ws_client.receive_json()
|
||||
@@ -2232,8 +2172,7 @@ async def test_refresh_node_info(
|
||||
{
|
||||
ID: 2,
|
||||
TYPE: "zwave_js/refresh_node_info",
|
||||
ENTRY_ID: entry.entry_id,
|
||||
NODE_ID: 9999,
|
||||
DEVICE_ID: "fake_device",
|
||||
}
|
||||
)
|
||||
msg = await ws_client.receive_json()
|
||||
@@ -2249,8 +2188,7 @@ async def test_refresh_node_info(
|
||||
{
|
||||
ID: 3,
|
||||
TYPE: "zwave_js/refresh_node_info",
|
||||
ENTRY_ID: entry.entry_id,
|
||||
NODE_ID: 52,
|
||||
DEVICE_ID: device.id,
|
||||
}
|
||||
)
|
||||
msg = await ws_client.receive_json()
|
||||
@@ -2267,8 +2205,7 @@ async def test_refresh_node_info(
|
||||
{
|
||||
ID: 4,
|
||||
TYPE: "zwave_js/refresh_node_info",
|
||||
ENTRY_ID: entry.entry_id,
|
||||
NODE_ID: 52,
|
||||
DEVICE_ID: device.id,
|
||||
}
|
||||
)
|
||||
msg = await ws_client.receive_json()
|
||||
@@ -2283,14 +2220,14 @@ async def test_refresh_node_values(
|
||||
"""Test that the refresh_node_values WS API call works."""
|
||||
entry = integration
|
||||
ws_client = await hass_ws_client(hass)
|
||||
device = get_device(hass, multisensor_6)
|
||||
|
||||
client.async_send_command_no_wait.return_value = None
|
||||
await ws_client.send_json(
|
||||
{
|
||||
ID: 1,
|
||||
TYPE: "zwave_js/refresh_node_values",
|
||||
ENTRY_ID: entry.entry_id,
|
||||
NODE_ID: 52,
|
||||
DEVICE_ID: device.id,
|
||||
}
|
||||
)
|
||||
msg = await ws_client.receive_json()
|
||||
@@ -2303,26 +2240,12 @@ async def test_refresh_node_values(
|
||||
|
||||
client.async_send_command_no_wait.reset_mock()
|
||||
|
||||
# Test getting non-existent node fails
|
||||
# Test getting non-existent device fails
|
||||
await ws_client.send_json(
|
||||
{
|
||||
ID: 2,
|
||||
TYPE: "zwave_js/refresh_node_values",
|
||||
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 getting non-existent entry fails
|
||||
await ws_client.send_json(
|
||||
{
|
||||
ID: 3,
|
||||
TYPE: "zwave_js/refresh_node_values",
|
||||
ENTRY_ID: "fake_entry_id",
|
||||
NODE_ID: 52,
|
||||
DEVICE_ID: "fake_device",
|
||||
}
|
||||
)
|
||||
msg = await ws_client.receive_json()
|
||||
@@ -2338,8 +2261,7 @@ async def test_refresh_node_values(
|
||||
{
|
||||
ID: 4,
|
||||
TYPE: "zwave_js/refresh_node_values",
|
||||
ENTRY_ID: entry.entry_id,
|
||||
NODE_ID: 52,
|
||||
DEVICE_ID: device.id,
|
||||
}
|
||||
)
|
||||
msg = await ws_client.receive_json()
|
||||
@@ -2356,8 +2278,7 @@ async def test_refresh_node_values(
|
||||
{
|
||||
ID: 5,
|
||||
TYPE: "zwave_js/refresh_node_values",
|
||||
ENTRY_ID: entry.entry_id,
|
||||
NODE_ID: 52,
|
||||
DEVICE_ID: device.id,
|
||||
}
|
||||
)
|
||||
msg = await ws_client.receive_json()
|
||||
@@ -2367,19 +2288,19 @@ async def test_refresh_node_values(
|
||||
|
||||
|
||||
async def test_refresh_node_cc_values(
|
||||
hass, client, multisensor_6, integration, hass_ws_client
|
||||
hass, multisensor_6, client, integration, hass_ws_client
|
||||
):
|
||||
"""Test that the refresh_node_cc_values WS API call works."""
|
||||
entry = integration
|
||||
ws_client = await hass_ws_client(hass)
|
||||
device = get_device(hass, multisensor_6)
|
||||
|
||||
client.async_send_command_no_wait.return_value = None
|
||||
await ws_client.send_json(
|
||||
{
|
||||
ID: 1,
|
||||
TYPE: "zwave_js/refresh_node_cc_values",
|
||||
ENTRY_ID: entry.entry_id,
|
||||
NODE_ID: 52,
|
||||
DEVICE_ID: device.id,
|
||||
COMMAND_CLASS_ID: 112,
|
||||
}
|
||||
)
|
||||
@@ -2399,8 +2320,7 @@ async def test_refresh_node_cc_values(
|
||||
{
|
||||
ID: 2,
|
||||
TYPE: "zwave_js/refresh_node_cc_values",
|
||||
ENTRY_ID: entry.entry_id,
|
||||
NODE_ID: 52,
|
||||
DEVICE_ID: device.id,
|
||||
COMMAND_CLASS_ID: 9999,
|
||||
}
|
||||
)
|
||||
@@ -2408,13 +2328,12 @@ async def test_refresh_node_cc_values(
|
||||
assert not msg["success"]
|
||||
assert msg["error"]["code"] == ERR_NOT_FOUND
|
||||
|
||||
# Test getting non-existent node fails
|
||||
# Test getting non-existent device fails
|
||||
await ws_client.send_json(
|
||||
{
|
||||
ID: 3,
|
||||
TYPE: "zwave_js/refresh_node_cc_values",
|
||||
ENTRY_ID: entry.entry_id,
|
||||
NODE_ID: 9999,
|
||||
DEVICE_ID: "fake_device",
|
||||
COMMAND_CLASS_ID: 112,
|
||||
}
|
||||
)
|
||||
@@ -2431,8 +2350,7 @@ async def test_refresh_node_cc_values(
|
||||
{
|
||||
ID: 4,
|
||||
TYPE: "zwave_js/refresh_node_cc_values",
|
||||
ENTRY_ID: entry.entry_id,
|
||||
NODE_ID: 52,
|
||||
DEVICE_ID: device.id,
|
||||
COMMAND_CLASS_ID: 112,
|
||||
}
|
||||
)
|
||||
@@ -2450,8 +2368,7 @@ async def test_refresh_node_cc_values(
|
||||
{
|
||||
ID: 5,
|
||||
TYPE: "zwave_js/refresh_node_cc_values",
|
||||
ENTRY_ID: entry.entry_id,
|
||||
NODE_ID: 52,
|
||||
DEVICE_ID: device.id,
|
||||
COMMAND_CLASS_ID: 112,
|
||||
}
|
||||
)
|
||||
@@ -2462,11 +2379,12 @@ async def test_refresh_node_cc_values(
|
||||
|
||||
|
||||
async def test_set_config_parameter(
|
||||
hass, client, hass_ws_client, multisensor_6, integration
|
||||
hass, multisensor_6, client, hass_ws_client, integration
|
||||
):
|
||||
"""Test the set_config_parameter service."""
|
||||
entry = integration
|
||||
ws_client = await hass_ws_client(hass)
|
||||
device = get_device(hass, multisensor_6)
|
||||
|
||||
client.async_send_command_no_wait.return_value = None
|
||||
|
||||
@@ -2474,8 +2392,7 @@ async def test_set_config_parameter(
|
||||
{
|
||||
ID: 1,
|
||||
TYPE: "zwave_js/set_config_parameter",
|
||||
ENTRY_ID: entry.entry_id,
|
||||
NODE_ID: 52,
|
||||
DEVICE_ID: device.id,
|
||||
PROPERTY: 102,
|
||||
PROPERTY_KEY: 1,
|
||||
VALUE: 1,
|
||||
@@ -2523,8 +2440,7 @@ async def test_set_config_parameter(
|
||||
{
|
||||
ID: 2,
|
||||
TYPE: "zwave_js/set_config_parameter",
|
||||
ENTRY_ID: entry.entry_id,
|
||||
NODE_ID: 52,
|
||||
DEVICE_ID: device.id,
|
||||
PROPERTY: 102,
|
||||
PROPERTY_KEY: 1,
|
||||
VALUE: "0x1",
|
||||
@@ -2573,8 +2489,7 @@ async def test_set_config_parameter(
|
||||
{
|
||||
ID: 3,
|
||||
TYPE: "zwave_js/set_config_parameter",
|
||||
ENTRY_ID: entry.entry_id,
|
||||
NODE_ID: 52,
|
||||
DEVICE_ID: device.id,
|
||||
PROPERTY: 102,
|
||||
PROPERTY_KEY: 1,
|
||||
VALUE: 1,
|
||||
@@ -2593,8 +2508,7 @@ async def test_set_config_parameter(
|
||||
{
|
||||
ID: 4,
|
||||
TYPE: "zwave_js/set_config_parameter",
|
||||
ENTRY_ID: entry.entry_id,
|
||||
NODE_ID: 52,
|
||||
DEVICE_ID: device.id,
|
||||
PROPERTY: 102,
|
||||
PROPERTY_KEY: 1,
|
||||
VALUE: 1,
|
||||
@@ -2613,8 +2527,7 @@ async def test_set_config_parameter(
|
||||
{
|
||||
ID: 5,
|
||||
TYPE: "zwave_js/set_config_parameter",
|
||||
ENTRY_ID: entry.entry_id,
|
||||
NODE_ID: 52,
|
||||
DEVICE_ID: device.id,
|
||||
PROPERTY: 102,
|
||||
PROPERTY_KEY: 1,
|
||||
VALUE: 1,
|
||||
@@ -2633,8 +2546,7 @@ async def test_set_config_parameter(
|
||||
{
|
||||
ID: 6,
|
||||
TYPE: "zwave_js/set_config_parameter",
|
||||
ENTRY_ID: entry.entry_id,
|
||||
NODE_ID: 9999,
|
||||
DEVICE_ID: "fake_device",
|
||||
PROPERTY: 102,
|
||||
PROPERTY_KEY: 1,
|
||||
VALUE: 1,
|
||||
@@ -2653,8 +2565,7 @@ async def test_set_config_parameter(
|
||||
{
|
||||
ID: 7,
|
||||
TYPE: "zwave_js/set_config_parameter",
|
||||
ENTRY_ID: entry.entry_id,
|
||||
NODE_ID: 52,
|
||||
DEVICE_ID: device.id,
|
||||
PROPERTY: 102,
|
||||
PROPERTY_KEY: 1,
|
||||
VALUE: 1,
|
||||
@@ -2674,8 +2585,7 @@ async def test_set_config_parameter(
|
||||
{
|
||||
ID: 8,
|
||||
TYPE: "zwave_js/set_config_parameter",
|
||||
ENTRY_ID: entry.entry_id,
|
||||
NODE_ID: 52,
|
||||
DEVICE_ID: device.id,
|
||||
PROPERTY: 102,
|
||||
PROPERTY_KEY: 1,
|
||||
VALUE: 1,
|
||||
@@ -2693,14 +2603,14 @@ async def test_get_config_parameters(hass, multisensor_6, integration, hass_ws_c
|
||||
entry = integration
|
||||
ws_client = await hass_ws_client(hass)
|
||||
node = multisensor_6
|
||||
device = get_device(hass, node)
|
||||
|
||||
# Test getting configuration parameter values
|
||||
await ws_client.send_json(
|
||||
{
|
||||
ID: 4,
|
||||
TYPE: "zwave_js/get_config_parameters",
|
||||
ENTRY_ID: entry.entry_id,
|
||||
NODE_ID: node.node_id,
|
||||
DEVICE_ID: device.id,
|
||||
}
|
||||
)
|
||||
msg = await ws_client.receive_json()
|
||||
@@ -2722,8 +2632,7 @@ async def test_get_config_parameters(hass, multisensor_6, integration, hass_ws_c
|
||||
{
|
||||
ID: 5,
|
||||
TYPE: "zwave_js/get_config_parameters",
|
||||
ENTRY_ID: entry.entry_id,
|
||||
NODE_ID: 99999,
|
||||
DEVICE_ID: "fake_device",
|
||||
}
|
||||
)
|
||||
msg = await ws_client.receive_json()
|
||||
@@ -2738,8 +2647,7 @@ async def test_get_config_parameters(hass, multisensor_6, integration, hass_ws_c
|
||||
{
|
||||
ID: 6,
|
||||
TYPE: "zwave_js/get_config_parameters",
|
||||
ENTRY_ID: entry.entry_id,
|
||||
NODE_ID: node.node_id,
|
||||
DEVICE_ID: device.id,
|
||||
}
|
||||
)
|
||||
msg = await ws_client.receive_json()
|
||||
@@ -3276,14 +3184,14 @@ async def test_abort_firmware_update(
|
||||
"""Test that the abort_firmware_update WS API call works."""
|
||||
entry = integration
|
||||
ws_client = await hass_ws_client(hass)
|
||||
device = get_device(hass, multisensor_6)
|
||||
|
||||
client.async_send_command_no_wait.return_value = {}
|
||||
await ws_client.send_json(
|
||||
{
|
||||
ID: 1,
|
||||
TYPE: "zwave_js/abort_firmware_update",
|
||||
ENTRY_ID: entry.entry_id,
|
||||
NODE_ID: multisensor_6.node_id,
|
||||
DEVICE_ID: device.id,
|
||||
}
|
||||
)
|
||||
msg = await ws_client.receive_json()
|
||||
@@ -3303,8 +3211,7 @@ async def test_abort_firmware_update(
|
||||
{
|
||||
ID: 2,
|
||||
TYPE: "zwave_js/abort_firmware_update",
|
||||
ENTRY_ID: entry.entry_id,
|
||||
NODE_ID: multisensor_6.node_id,
|
||||
DEVICE_ID: device.id,
|
||||
}
|
||||
)
|
||||
msg = await ws_client.receive_json()
|
||||
@@ -3321,8 +3228,7 @@ async def test_abort_firmware_update(
|
||||
{
|
||||
ID: 3,
|
||||
TYPE: "zwave_js/abort_firmware_update",
|
||||
ENTRY_ID: entry.entry_id,
|
||||
NODE_ID: multisensor_6.node_id,
|
||||
DEVICE_ID: device.id,
|
||||
}
|
||||
)
|
||||
msg = await ws_client.receive_json()
|
||||
@@ -3332,32 +3238,19 @@ async def test_abort_firmware_update(
|
||||
|
||||
|
||||
async def test_abort_firmware_update_failures(
|
||||
hass, integration, multisensor_6, client, hass_ws_client
|
||||
hass, multisensor_6, client, integration, hass_ws_client
|
||||
):
|
||||
"""Test failures for the abort_firmware_update websocket command."""
|
||||
entry = integration
|
||||
ws_client = await hass_ws_client(hass)
|
||||
# Test sending command with improper entry ID fails
|
||||
await ws_client.send_json(
|
||||
{
|
||||
ID: 1,
|
||||
TYPE: "zwave_js/abort_firmware_update",
|
||||
ENTRY_ID: "fake_entry_id",
|
||||
NODE_ID: multisensor_6.node_id,
|
||||
}
|
||||
)
|
||||
msg = await ws_client.receive_json()
|
||||
device = get_device(hass, multisensor_6)
|
||||
|
||||
assert not msg["success"]
|
||||
assert msg["error"]["code"] == ERR_NOT_FOUND
|
||||
|
||||
# Test sending command with improper node ID fails
|
||||
# Test sending command with improper device ID fails
|
||||
await ws_client.send_json(
|
||||
{
|
||||
ID: 2,
|
||||
TYPE: "zwave_js/abort_firmware_update",
|
||||
ENTRY_ID: entry.entry_id,
|
||||
NODE_ID: multisensor_6.node_id + 100,
|
||||
DEVICE_ID: "fake_device",
|
||||
}
|
||||
)
|
||||
msg = await ws_client.receive_json()
|
||||
@@ -3373,8 +3266,7 @@ async def test_abort_firmware_update_failures(
|
||||
{
|
||||
ID: 3,
|
||||
TYPE: "zwave_js/abort_firmware_update",
|
||||
ENTRY_ID: entry.entry_id,
|
||||
NODE_ID: multisensor_6.node_id,
|
||||
DEVICE_ID: device.id,
|
||||
}
|
||||
)
|
||||
msg = await ws_client.receive_json()
|
||||
@@ -3384,11 +3276,11 @@ async def test_abort_firmware_update_failures(
|
||||
|
||||
|
||||
async def test_subscribe_firmware_update_status(
|
||||
hass, integration, multisensor_6, client, hass_ws_client
|
||||
hass, multisensor_6, integration, client, hass_ws_client
|
||||
):
|
||||
"""Test the subscribe_firmware_update_status websocket command."""
|
||||
entry = integration
|
||||
ws_client = await hass_ws_client(hass)
|
||||
device = get_device(hass, multisensor_6)
|
||||
|
||||
client.async_send_command_no_wait.return_value = {}
|
||||
|
||||
@@ -3396,8 +3288,7 @@ async def test_subscribe_firmware_update_status(
|
||||
{
|
||||
ID: 1,
|
||||
TYPE: "zwave_js/subscribe_firmware_update_status",
|
||||
ENTRY_ID: entry.entry_id,
|
||||
NODE_ID: multisensor_6.node_id,
|
||||
DEVICE_ID: device.id,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -3445,11 +3336,11 @@ async def test_subscribe_firmware_update_status(
|
||||
|
||||
|
||||
async def test_subscribe_firmware_update_status_initial_value(
|
||||
hass, integration, multisensor_6, client, hass_ws_client
|
||||
hass, multisensor_6, client, integration, hass_ws_client
|
||||
):
|
||||
"""Test subscribe_firmware_update_status websocket command with in progress update."""
|
||||
entry = integration
|
||||
ws_client = await hass_ws_client(hass)
|
||||
device = get_device(hass, multisensor_6)
|
||||
|
||||
assert multisensor_6.firmware_update_progress is None
|
||||
|
||||
@@ -3472,8 +3363,7 @@ async def test_subscribe_firmware_update_status_initial_value(
|
||||
{
|
||||
ID: 1,
|
||||
TYPE: "zwave_js/subscribe_firmware_update_status",
|
||||
ENTRY_ID: entry.entry_id,
|
||||
NODE_ID: multisensor_6.node_id,
|
||||
DEVICE_ID: device.id,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -3490,32 +3380,18 @@ async def test_subscribe_firmware_update_status_initial_value(
|
||||
|
||||
|
||||
async def test_subscribe_firmware_update_status_failures(
|
||||
hass, integration, multisensor_6, client, hass_ws_client
|
||||
hass, multisensor_6, client, integration, hass_ws_client
|
||||
):
|
||||
"""Test failures for the subscribe_firmware_update_status websocket command."""
|
||||
entry = integration
|
||||
ws_client = await hass_ws_client(hass)
|
||||
device = get_device(hass, multisensor_6)
|
||||
# Test sending command with improper entry ID fails
|
||||
await ws_client.send_json(
|
||||
{
|
||||
ID: 1,
|
||||
TYPE: "zwave_js/subscribe_firmware_update_status",
|
||||
ENTRY_ID: "fake_entry_id",
|
||||
NODE_ID: multisensor_6.node_id,
|
||||
}
|
||||
)
|
||||
msg = await ws_client.receive_json()
|
||||
|
||||
assert not msg["success"]
|
||||
assert msg["error"]["code"] == ERR_NOT_FOUND
|
||||
|
||||
# Test sending command with improper node ID fails
|
||||
await ws_client.send_json(
|
||||
{
|
||||
ID: 2,
|
||||
TYPE: "zwave_js/subscribe_firmware_update_status",
|
||||
ENTRY_ID: entry.entry_id,
|
||||
NODE_ID: multisensor_6.node_id + 100,
|
||||
DEVICE_ID: "fake_device",
|
||||
}
|
||||
)
|
||||
msg = await ws_client.receive_json()
|
||||
@@ -3531,8 +3407,7 @@ async def test_subscribe_firmware_update_status_failures(
|
||||
{
|
||||
ID: 3,
|
||||
TYPE: "zwave_js/subscribe_firmware_update_status",
|
||||
ENTRY_ID: entry.entry_id,
|
||||
NODE_ID: multisensor_6.node_id,
|
||||
DEVICE_ID: device.id,
|
||||
}
|
||||
)
|
||||
msg = await ws_client.receive_json()
|
||||
@@ -3783,13 +3658,13 @@ async def test_subscribe_node_statistics(
|
||||
"""Test the subscribe_node_statistics command."""
|
||||
entry = integration
|
||||
ws_client = await hass_ws_client(hass)
|
||||
device = get_device(hass, multisensor_6)
|
||||
|
||||
await ws_client.send_json(
|
||||
{
|
||||
ID: 1,
|
||||
TYPE: "zwave_js/subscribe_node_statistics",
|
||||
ENTRY_ID: entry.entry_id,
|
||||
NODE_ID: multisensor_6.node_id,
|
||||
DEVICE_ID: device.id,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -3843,8 +3718,7 @@ async def test_subscribe_node_statistics(
|
||||
{
|
||||
ID: 2,
|
||||
TYPE: "zwave_js/subscribe_node_statistics",
|
||||
ENTRY_ID: "fake_entry_id",
|
||||
NODE_ID: multisensor_6.node_id,
|
||||
DEVICE_ID: "fake_device",
|
||||
}
|
||||
)
|
||||
msg = await ws_client.receive_json()
|
||||
@@ -3852,17 +3726,6 @@ async def test_subscribe_node_statistics(
|
||||
assert not msg["success"]
|
||||
assert msg["error"]["code"] == ERR_NOT_FOUND
|
||||
|
||||
# Test sending command with improper node ID fails
|
||||
await ws_client.send_json(
|
||||
{
|
||||
ID: 3,
|
||||
TYPE: "zwave_js/subscribe_node_statistics",
|
||||
ENTRY_ID: entry.entry_id,
|
||||
NODE_ID: multisensor_6.node_id + 100,
|
||||
}
|
||||
)
|
||||
msg = await ws_client.receive_json()
|
||||
|
||||
# Test sending command with not loaded entry fails
|
||||
await hass.config_entries.async_unload(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
@@ -3871,8 +3734,7 @@ async def test_subscribe_node_statistics(
|
||||
{
|
||||
ID: 4,
|
||||
TYPE: "zwave_js/subscribe_node_statistics",
|
||||
ENTRY_ID: entry.entry_id,
|
||||
NODE_ID: multisensor_6.node_id,
|
||||
DEVICE_ID: device.id,
|
||||
}
|
||||
)
|
||||
msg = await ws_client.receive_json()
|
||||
|
||||
Reference in New Issue
Block a user