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

This commit is contained in:
Robert Svensson authored and Pascal Vizeli committed 2019-12-10 11:02:26 +01:00
1 parent f5d4878992
commit db0baab692
2 files changed
+9 -4

No files matched your search

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