Prevent CoordinatorEntity from requesting updates on disabled entities (#39452)

This commit is contained in:
J. Nick Koston 2020-08-30 12:10:22 -05:00 committed by GitHub
parent 17734d54ab
commit 8b893173fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 0 deletions

View File

@ -221,4 +221,9 @@ class CoordinatorEntity(entity.Entity):
Only used by the generic entity update service.
"""
# Ignore manual update requests if the entity is disabled
if not self.enabled:
return
await self.coordinator.async_request_refresh()

View File

@ -244,3 +244,9 @@ async def test_coordinator_entity(crd):
await entity.async_added_to_hass()
assert mock_async_on_remove.called
# Verify we do not update if the entity is disabled
crd.last_update_success = False
with patch("homeassistant.helpers.entity.Entity.enabled", False):
await entity.async_update()
assert entity.available is False