Don't set entity_id in ZHA entities (#28362)

* Don't set entity_id on ZHA entities.
* Update tests.
* Use comma as separator for multiple channel names.
* Address PR comments.
This commit is contained in:
Alexei Chetroi authored and GitHub committed 2019-10-31 12:31:06 -04:00
1 parent d133501735
commit 89213a4ce8
9 files changed
+55 -66

No files matched your search

+14 -21
View File
@@ -161,23 +161,22 @@ async def async_setup_entry(hass, config_entry):
return True
def make_entity_id(domain, device, cluster, use_suffix=True):
"""Make the entity id for the entity under testing.
async def find_entity_id(domain, zha_device, hass):
"""Find the entity id under the testing.
This is used to get the entity id in order to get the state from the state
machine so that we can test state changes.
"""
ieee = device.ieee
ieeetail = "".join([f"{o:02x}" for o in ieee[:4]])
entity_id = "{}.{}_{}_{}_{}{}".format(
domain,
slugify(device.manufacturer),
slugify(device.model),
ieeetail,
cluster.endpoint.endpoint_id,
("", "_{}".format(cluster.cluster_id))[use_suffix],
)
return entity_id
ieeetail = "".join([f"{o:02x}" for o in zha_device.ieee[:4]])
head = f"{domain}." + slugify(f"{zha_device.name} {ieeetail}")
enitiy_ids = hass.states.async_entity_ids(domain)
await hass.async_block_till_done()
for entity_id in enitiy_ids:
if entity_id.startswith(head):
return entity_id
return None
async def async_enable_traffic(hass, zha_gateway, zha_devices):
@@ -188,7 +187,7 @@ async def async_enable_traffic(hass, zha_gateway, zha_devices):
async def async_test_device_join(
hass, zha_gateway, cluster_id, domain, device_type=None
hass, zha_gateway, cluster_id, entity_id, device_type=None
):
"""Test a newly joining device.
@@ -205,21 +204,15 @@ async def async_test_device_join(
"zigpy.zcl.Cluster.bind",
return_value=mock_coro([zcl_f.Status.SUCCESS, zcl_f.Status.SUCCESS]),
):
zigpy_device = await async_init_zigpy_device(
await async_init_zigpy_device(
hass,
[cluster_id, zigpy.zcl.clusters.general.Basic.cluster_id],
[],
device_type,
zha_gateway,
ieee="00:0d:6f:00:0a:90:69:f7",
manufacturer="FakeMan{}".format(cluster_id),
model="FakeMod{}".format(cluster_id),
is_new_join=True,
)
cluster = zigpy_device.endpoints.get(1).in_clusters[cluster_id]
entity_id = make_entity_id(
domain, zigpy_device, cluster, use_suffix=device_type is None
)
assert hass.states.get(entity_id) is not None