Improve ozw websocket response when node is not found (#39653)

* Return not_found error over ws if node is not found

* Remove unrelated code from this PR

* Only import ERR_NOT_FOUND from core websocket_api
This commit is contained in:
Charles Garwood authored and GitHub committed 2020-09-04 15:52:47 -04:00
1 parent 1fb70625a3
commit 4885b22cb4
2 files changed
+33 -4

No files matched your search

@@ -150,6 +150,15 @@ def websocket_node_status(hass, connection, msg):
"""Get the status for a Z-Wave node."""
manager = hass.data[DOMAIN][MANAGER]
node = manager.get_instance(msg[OZW_INSTANCE]).get_node(msg[NODE_ID])
if not node:
connection.send_message(
websocket_api.error_message(
msg[ID], websocket_api.const.ERR_NOT_FOUND, "OZW Node not found"
)
)
return
connection.send_result(
msg[ID],
{
@@ -185,6 +194,15 @@ def websocket_node_metadata(hass, connection, msg):
"""Get the metadata for a Z-Wave node."""
manager = hass.data[DOMAIN][MANAGER]
node = manager.get_instance(msg[OZW_INSTANCE]).get_node(msg[NODE_ID])
if not node:
connection.send_message(
websocket_api.error_message(
msg[ID], websocket_api.const.ERR_NOT_FOUND, "OZW Node not found"
)
)
return
connection.send_result(
msg[ID],
{