Only bind clusters in ZHA remote entity (#19577)

* split bind and configure reporting helpers

* only bind remote clusters

* update comments - review comment
This commit is contained in:
David F. Mulcahey 2018-12-29 19:17:17 -05:00 committed by Martin Hjelmare
parent e096532cf1
commit d0742cb332
3 changed files with 58 additions and 22 deletions

View file

@ -179,12 +179,6 @@ class Remote(RestoreEntity, ZhaEntity, BinarySensorDevice):
out_clusters = kwargs.get('out_clusters')
self._zcl_reporting = {}
for cluster_id in [general.OnOff.cluster_id,
general.LevelControl.cluster_id]:
if cluster_id not in out_clusters:
continue
cluster = out_clusters[cluster_id]
self._zcl_reporting[cluster] = {0: REPORT_CONFIG_IMMEDIATE}
if general.LevelControl.cluster_id in out_clusters:
self._out_listeners.update({
@ -233,6 +227,19 @@ class Remote(RestoreEntity, ZhaEntity, BinarySensorDevice):
self._level = 255
self.async_schedule_update_ha_state()
async def async_configure(self):
"""Bind clusters."""
from zigpy.zcl.clusters import general
await helpers.bind_cluster(
self.entity_id,
self._out_clusters[general.OnOff.cluster_id]
)
if general.LevelControl.cluster_id in self._out_clusters:
await helpers.bind_cluster(
self.entity_id,
self._out_clusters[general.LevelControl.cluster_id]
)
async def async_added_to_hass(self):
"""Run when about to be added to hass."""
await super().async_added_to_hass()