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

+5 -13
View File
@@ -9,7 +9,6 @@ from homeassistant.helpers import entity
from homeassistant.helpers.device_registry import CONNECTION_ZIGBEE
from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.restore_state import RestoreEntity
from homeassistant.util import slugify
from .core.const import (
ATTR_MANUFACTURER,
@@ -38,17 +37,10 @@ class ZhaEntity(RestoreEntity, LogMixin, entity.Entity):
self._force_update = False
self._should_poll = False
self._unique_id = unique_id
if not skip_entity_id:
ieee = zha_device.ieee
ieeetail = "".join([f"{o:02x}" for o in ieee[:4]])
self.entity_id = "{}.{}_{}_{}_{}{}".format(
self._domain,
slugify(zha_device.manufacturer),
slugify(zha_device.model),
ieeetail,
channels[0].cluster.endpoint.endpoint_id,
kwargs.get(ENTITY_SUFFIX, ""),
)
ieeetail = "".join([f"{o:02x}" for o in zha_device.ieee[:4]])
ch_names = [ch.cluster.ep_attribute for ch in channels]
ch_names = ", ".join(sorted(ch_names))
self._name = f"{zha_device.name} {ieeetail} {ch_names}"
self._state = None
self._device_state_attributes = {}
self._zha_device = zha_device
@@ -63,7 +55,7 @@ class ZhaEntity(RestoreEntity, LogMixin, entity.Entity):
@property
def name(self):
"""Return Entity's default name."""
return self.zha_device.name
return self._name
@property
def unique_id(self) -> str: