mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
Clean up device update, add via-hub (#16659)
* Clean up device update, add via-hub * Test loading/saving data * Lint * Add to Hue" * Lint + tests
This commit is contained in:
@@ -31,7 +31,7 @@ STORAGE_VERSION = 1
|
||||
STORAGE_KEY = 'core.entity_registry'
|
||||
|
||||
|
||||
@attr.s(slots=True)
|
||||
@attr.s(slots=True, frozen=True)
|
||||
class RegistryEntry:
|
||||
"""Entity Registry Entry."""
|
||||
|
||||
@@ -113,14 +113,9 @@ class EntityRegistry:
|
||||
"""Get entity. Create if it doesn't exist."""
|
||||
entity_id = self.async_get_entity_id(domain, platform, unique_id)
|
||||
if entity_id:
|
||||
entry = self.entities[entity_id]
|
||||
if entry.config_entry_id == config_entry_id:
|
||||
return entry
|
||||
|
||||
self._async_update_entity(
|
||||
return self._async_update_entity(
|
||||
entity_id, config_entry_id=config_entry_id,
|
||||
device_id=device_id)
|
||||
return self.entities[entity_id]
|
||||
|
||||
entity_id = self.async_generate_entity_id(
|
||||
domain, suggested_object_id or '{}_{}'.format(platform, unique_id))
|
||||
@@ -253,10 +248,9 @@ class EntityRegistry:
|
||||
@callback
|
||||
def async_clear_config_entry(self, config_entry):
|
||||
"""Clear config entry from registry entries."""
|
||||
for entry in self.entities.values():
|
||||
for entity_id, entry in self.entities.items():
|
||||
if config_entry == entry.config_entry_id:
|
||||
entry.config_entry_id = None
|
||||
self.async_schedule_save()
|
||||
self._async_update_entity(entity_id, config_entry_id=None)
|
||||
|
||||
|
||||
@bind_hass
|
||||
|
||||
Reference in New Issue
Block a user