Only update disabled_by when enabled default and entity enabled states differ (#29643)

This commit is contained in:
Robert Svensson 2019-12-10 11:02:26 +01:00 committed by Paulus Schoutsen
parent 90de5652b9
commit f7015703bb
2 changed files with 9 additions and 4 deletions

View file

@ -76,6 +76,9 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
"""Update the values of the controller."""
for entity in tracked.values():
if entity.entity_registry_enabled_default == entity.enabled:
continue
disabled_by = None
if not entity.entity_registry_enabled_default and entity.enabled:
disabled_by = DISABLED_CONFIG_ENTRY
@ -228,10 +231,9 @@ class UniFiDeviceTracker(ScannerEntity):
@property
def entity_registry_enabled_default(self):
"""Return if the entity should be enabled when first added to the entity registry."""
if not self.controller.option_track_devices:
return False
return True
if self.controller.option_track_devices:
return True
return False
async def async_added_to_hass(self):
"""Subscribe to device events."""

View file

@ -40,6 +40,9 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
"""Update the values of the controller."""
for entity in sensors.values():
if entity.entity_registry_enabled_default == entity.enabled:
continue
disabled_by = None
if not entity.entity_registry_enabled_default and entity.enabled:
disabled_by = DISABLED_CONFIG_ENTRY