Add web socket API command to get a single ZHA device (#26196)

* get single device web socket command

* test get single device

* add not found error

* fix handling when device doesn't exist

* add test for zha device not found
This commit is contained in:
David F. Mulcahey authored and GitHub committed 2019-08-26 09:54:19 -04:00
1 parent 7a111bf863
commit 6f2ac705eb
2 files changed
+46

No files matched your search

+20
View File
@@ -13,6 +13,7 @@ from homeassistant.components.zha.core.const import (
ATTR_MANUFACTURER,
ATTR_ENDPOINT_ID,
)
from homeassistant.components.websocket_api import const
from .common import async_init_zigpy_device
@@ -126,3 +127,22 @@ async def test_list_devices(hass, config_entry, zha_gateway, zha_client):
for entity_reference in device["entities"]:
assert entity_reference[ATTR_NAME] is not None
assert entity_reference["entity_id"] is not None
await zha_client.send_json(
{ID: 6, TYPE: "zha/device", ATTR_IEEE: device[ATTR_IEEE]}
)
msg = await zha_client.receive_json()
device2 = msg["result"]
assert device == device2
async def test_device_not_found(hass, config_entry, zha_gateway, zha_client):
"""Test not found response from get device API."""
await zha_client.send_json(
{ID: 6, TYPE: "zha/device", ATTR_IEEE: "28:6d:97:00:01:04:11:8c"}
)
msg = await zha_client.receive_json()
assert msg["id"] == 6
assert msg["type"] == const.TYPE_RESULT
assert not msg["success"]
assert msg["error"]["code"] == const.ERR_NOT_FOUND