Configure ZHA entity on new ZHA device join (#19470)

* Address PR#19177 comments.

* Make 'new_join' part of ZhaEntity.

Call async_configure() automatically when new device ZHA device joins.
This commit is contained in:
Alexei Chetroi authored and Martin Hjelmare committed 2018-12-23 20:47:06 +01:00
1 parent 0b84eefa2e
commit 4a1da0b041
6 files changed
+19 -40

No files matched your search

+2 -5
View File
@@ -46,10 +46,7 @@ async def _async_setup_entities(hass, config_entry, async_add_entities,
"""Set up the ZHA switches."""
entities = []
for discovery_info in discovery_infos:
switch = Switch(**discovery_info)
if discovery_info['new_join']:
await switch.async_configure()
entities.append(switch)
entities.append(Switch(**discovery_info))
async_add_entities(entities, update_before_add=True)
@@ -119,7 +116,7 @@ class Switch(ZhaEntity, SwitchDevice):
async def async_update(self):
"""Retrieve latest state."""
result = await helpers.safe_read(self._endpoint.on_off,
result = await helpers.safe_read(self.cluster,
['on_off'],
allow_cache=False,
only_cache=(not self._initialized))