From 52d949ec90f2cfb3ac4ee1dbfe35f722966c8a11 Mon Sep 17 00:00:00 2001 From: Charles Garwood Date: Fri, 21 Aug 2020 12:48:56 -0400 Subject: [PATCH] Tweak OZW Websocket Instance/Network Responses (#39107) --- homeassistant/components/ozw/websocket_api.py | 9 +++------ tests/components/ozw/test_websocket_api.py | 4 ++-- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/homeassistant/components/ozw/websocket_api.py b/homeassistant/components/ozw/websocket_api.py index 10d5255044d..7f7cc489ba5 100644 --- a/homeassistant/components/ozw/websocket_api.py +++ b/homeassistant/components/ozw/websocket_api.py @@ -36,7 +36,7 @@ def websocket_get_instances(hass, connection, msg): instances = [] for instance in manager.collections["instance"]: - instances.append(dict(instance.get_status().data, id=instance.id)) + instances.append(dict(instance.get_status().data, ozw_instance=instance.id)) connection.send_result( msg[ID], instances, @@ -53,12 +53,9 @@ def websocket_network_status(hass, connection, msg): """Get Z-Wave network status.""" manager = hass.data[DOMAIN][MANAGER] + status = manager.get_instance(msg[OZW_INSTANCE]).get_status().data connection.send_result( - msg[ID], - { - "state": manager.get_instance(msg[OZW_INSTANCE]).get_status().status, - OZW_INSTANCE: msg[OZW_INSTANCE], - }, + msg[ID], dict(status, ozw_instance=msg[OZW_INSTANCE]), ) diff --git a/tests/components/ozw/test_websocket_api.py b/tests/components/ozw/test_websocket_api.py index e83b7bb7b66..a8694bb29e6 100644 --- a/tests/components/ozw/test_websocket_api.py +++ b/tests/components/ozw/test_websocket_api.py @@ -17,7 +17,7 @@ async def test_websocket_api(hass, generic_data, hass_ws_client): msg = await client.receive_json() assert len(msg["result"]) == 1 result = msg["result"][0] - assert result["id"] == 1 + assert result[OZW_INSTANCE] == 1 assert result["Status"] == "driverAllNodesQueried" assert result["OpenZWave_Version"] == "1.6.1008" @@ -26,7 +26,7 @@ async def test_websocket_api(hass, generic_data, hass_ws_client): msg = await client.receive_json() result = msg["result"] - assert result["state"] == "driverAllNodesQueried" + assert result["Status"] == "driverAllNodesQueried" assert result[OZW_INSTANCE] == 1 # Test node status