From a074c06f9289bb57e786a821d43ee040dabc6a97 Mon Sep 17 00:00:00 2001 From: Raman Gupta <7243222+raman325@users.noreply.github.com> Date: Sun, 26 Nov 2023 04:08:20 -0500 Subject: [PATCH] Add alert to zwave_js device info page for custom device config (#104115) --- homeassistant/components/zwave_js/api.py | 13 ++++++++----- tests/components/zwave_js/test_api.py | 5 +++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/zwave_js/api.py b/homeassistant/components/zwave_js/api.py index a917aa44889..9e50b55830c 100644 --- a/homeassistant/components/zwave_js/api.py +++ b/homeassistant/components/zwave_js/api.py @@ -393,7 +393,7 @@ def async_register_api(hass: HomeAssistant) -> None: websocket_api.async_register_command(hass, websocket_subscribe_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_comments) + websocket_api.async_register_command(hass, websocket_node_alerts) 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_validate_dsk_and_enter_pin) @@ -616,22 +616,25 @@ async def websocket_node_metadata( @websocket_api.websocket_command( { - vol.Required(TYPE): "zwave_js/node_comments", + vol.Required(TYPE): "zwave_js/node_alerts", vol.Required(DEVICE_ID): str, } ) @websocket_api.async_response @async_get_node -async def websocket_node_comments( +async def websocket_node_alerts( hass: HomeAssistant, connection: ActiveConnection, msg: dict[str, Any], node: Node, ) -> None: - """Get the comments of a Z-Wave JS node.""" + """Get the alerts for a Z-Wave JS node.""" connection.send_result( msg[ID], - {"comments": node.device_config.metadata.comments}, + { + "comments": node.device_config.metadata.comments, + "is_embedded": node.device_config.is_embedded, + }, ) diff --git a/tests/components/zwave_js/test_api.py b/tests/components/zwave_js/test_api.py index 9c4a6339a78..aa20bd3bb84 100644 --- a/tests/components/zwave_js/test_api.py +++ b/tests/components/zwave_js/test_api.py @@ -457,7 +457,7 @@ async def test_node_metadata( assert msg["error"]["code"] == ERR_NOT_LOADED -async def test_node_comments( +async def test_node_alerts( hass: HomeAssistant, wallmote_central_scene, integration, @@ -473,13 +473,14 @@ async def test_node_comments( await ws_client.send_json( { ID: 3, - TYPE: "zwave_js/node_comments", + TYPE: "zwave_js/node_alerts", DEVICE_ID: device.id, } ) msg = await ws_client.receive_json() result = msg["result"] assert result["comments"] == [{"level": "info", "text": "test"}] + assert result["is_embedded"] async def test_add_node(