Don't poll entities for unavailable ZHA devices (#39756)

* Don't poll entities for unavailable ZHA devices

* Update homeassistant/components/zha/entity.py

Co-authored-by: Bas Nijholt <basnijholt@gmail.com>

* cleanup after accepting suggestion

Co-authored-by: Bas Nijholt <basnijholt@gmail.com>
This commit is contained in:
David F. Mulcahey 2020-09-07 13:52:00 -04:00 committed by GitHub
parent 36a1877cbd
commit be8aa16170
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 8 deletions

View file

@ -202,9 +202,13 @@ class ZhaEntity(BaseZhaEntity, RestoreEntity):
async def async_update(self) -> None:
"""Retrieve latest state."""
for channel in self.cluster_channels.values():
if hasattr(channel, "async_update"):
await channel.async_update()
tasks = [
channel.async_update()
for channel in self.cluster_channels.values()
if hasattr(channel, "async_update")
]
if tasks:
await asyncio.gather(*tasks)
class ZhaGroupEntity(BaseZhaEntity):