Add alert to zwave_js device info page for custom device config (#104115)

pull/103227/head
Raman Gupta 2023-11-26 04:08:20 -05:00 committed by GitHub
parent b42629ecf3
commit a074c06f92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 7 deletions

View File

@ -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_subscribe_node_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_node_alerts)
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)
@ -616,22 +616,25 @@ async def websocket_node_metadata(
@websocket_api.websocket_command( @websocket_api.websocket_command(
{ {
vol.Required(TYPE): "zwave_js/node_comments", vol.Required(TYPE): "zwave_js/node_alerts",
vol.Required(DEVICE_ID): str, vol.Required(DEVICE_ID): str,
} }
) )
@websocket_api.async_response @websocket_api.async_response
@async_get_node @async_get_node
async def websocket_node_comments( async def websocket_node_alerts(
hass: HomeAssistant, hass: HomeAssistant,
connection: ActiveConnection, connection: ActiveConnection,
msg: dict[str, Any], msg: dict[str, Any],
node: Node, node: Node,
) -> None: ) -> None:
"""Get the comments of a Z-Wave JS node.""" """Get the alerts for a Z-Wave JS node."""
connection.send_result( connection.send_result(
msg[ID], msg[ID],
{"comments": node.device_config.metadata.comments}, {
"comments": node.device_config.metadata.comments,
"is_embedded": node.device_config.is_embedded,
},
) )

View File

@ -457,7 +457,7 @@ async def test_node_metadata(
assert msg["error"]["code"] == ERR_NOT_LOADED assert msg["error"]["code"] == ERR_NOT_LOADED
async def test_node_comments( async def test_node_alerts(
hass: HomeAssistant, hass: HomeAssistant,
wallmote_central_scene, wallmote_central_scene,
integration, integration,
@ -473,13 +473,14 @@ async def test_node_comments(
await ws_client.send_json( await ws_client.send_json(
{ {
ID: 3, ID: 3,
TYPE: "zwave_js/node_comments", TYPE: "zwave_js/node_alerts",
DEVICE_ID: device.id, DEVICE_ID: device.id,
} }
) )
msg = await ws_client.receive_json() msg = await ws_client.receive_json()
result = msg["result"] result = msg["result"]
assert result["comments"] == [{"level": "info", "text": "test"}] assert result["comments"] == [{"level": "info", "text": "test"}]
assert result["is_embedded"]
async def test_add_node( async def test_add_node(