Move zwave_js node metadata comments to separate WS API cmd (#71513)
* Move zwave_js node metadata comments to separate WS API cmd * fix pr
This commit is contained in:
parent
d0008683be
commit
352b7e86af
2 changed files with 42 additions and 2 deletions
|
@ -326,6 +326,7 @@ def async_register_api(hass: HomeAssistant) -> None:
|
||||||
websocket_api.async_register_command(hass, websocket_network_status)
|
websocket_api.async_register_command(hass, websocket_network_status)
|
||||||
websocket_api.async_register_command(hass, websocket_node_status)
|
websocket_api.async_register_command(hass, websocket_node_status)
|
||||||
websocket_api.async_register_command(hass, websocket_node_metadata)
|
websocket_api.async_register_command(hass, websocket_node_metadata)
|
||||||
|
websocket_api.async_register_command(hass, websocket_node_comments)
|
||||||
websocket_api.async_register_command(hass, websocket_add_node)
|
websocket_api.async_register_command(hass, websocket_add_node)
|
||||||
websocket_api.async_register_command(hass, websocket_grant_security_classes)
|
websocket_api.async_register_command(hass, websocket_grant_security_classes)
|
||||||
websocket_api.async_register_command(hass, websocket_validate_dsk_and_enter_pin)
|
websocket_api.async_register_command(hass, websocket_validate_dsk_and_enter_pin)
|
||||||
|
@ -503,7 +504,6 @@ async def websocket_node_metadata(
|
||||||
"wakeup": node.device_config.metadata.wakeup,
|
"wakeup": node.device_config.metadata.wakeup,
|
||||||
"reset": node.device_config.metadata.reset,
|
"reset": node.device_config.metadata.reset,
|
||||||
"device_database_url": node.device_database_url,
|
"device_database_url": node.device_database_url,
|
||||||
"comments": node.device_config.metadata.comments,
|
|
||||||
}
|
}
|
||||||
connection.send_result(
|
connection.send_result(
|
||||||
msg[ID],
|
msg[ID],
|
||||||
|
@ -511,6 +511,27 @@ async def websocket_node_metadata(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@websocket_api.websocket_command(
|
||||||
|
{
|
||||||
|
vol.Required(TYPE): "zwave_js/node_comments",
|
||||||
|
vol.Required(DEVICE_ID): str,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@websocket_api.async_response
|
||||||
|
@async_get_node
|
||||||
|
async def websocket_node_comments(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
connection: ActiveConnection,
|
||||||
|
msg: dict,
|
||||||
|
node: Node,
|
||||||
|
) -> None:
|
||||||
|
"""Get the comments of a Z-Wave JS node."""
|
||||||
|
connection.send_result(
|
||||||
|
msg[ID],
|
||||||
|
{"comments": node.device_config.metadata.comments},
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@websocket_api.require_admin
|
@websocket_api.require_admin
|
||||||
@websocket_api.websocket_command(
|
@websocket_api.websocket_command(
|
||||||
{
|
{
|
||||||
|
|
|
@ -261,7 +261,6 @@ async def test_node_metadata(hass, wallmote_central_scene, integration, hass_ws_
|
||||||
result["device_database_url"]
|
result["device_database_url"]
|
||||||
== "https://devices.zwave-js.io/?jumpTo=0x0086:0x0002:0x0082:0.0"
|
== "https://devices.zwave-js.io/?jumpTo=0x0086:0x0002:0x0082:0.0"
|
||||||
)
|
)
|
||||||
assert result["comments"] == [{"level": "info", "text": "test"}]
|
|
||||||
|
|
||||||
# Test getting non-existent node fails
|
# Test getting non-existent node fails
|
||||||
await ws_client.send_json(
|
await ws_client.send_json(
|
||||||
|
@ -292,6 +291,26 @@ async def test_node_metadata(hass, wallmote_central_scene, integration, hass_ws_
|
||||||
assert msg["error"]["code"] == ERR_NOT_LOADED
|
assert msg["error"]["code"] == ERR_NOT_LOADED
|
||||||
|
|
||||||
|
|
||||||
|
async def test_node_comments(hass, wallmote_central_scene, integration, hass_ws_client):
|
||||||
|
"""Test the node comments websocket command."""
|
||||||
|
ws_client = await hass_ws_client(hass)
|
||||||
|
|
||||||
|
dev_reg = dr.async_get(hass)
|
||||||
|
device = dev_reg.async_get_device({(DOMAIN, "3245146787-35")})
|
||||||
|
assert device
|
||||||
|
|
||||||
|
await ws_client.send_json(
|
||||||
|
{
|
||||||
|
ID: 3,
|
||||||
|
TYPE: "zwave_js/node_comments",
|
||||||
|
DEVICE_ID: device.id,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
msg = await ws_client.receive_json()
|
||||||
|
result = msg["result"]
|
||||||
|
assert result["comments"] == [{"level": "info", "text": "test"}]
|
||||||
|
|
||||||
|
|
||||||
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
|
||||||
):
|
):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue