Remove area_id from entity_registry.async_get_or_create (#77700)
* Remove area_id from entity_registry.async_get_or_create * Adjust tests * Fix lying comment in test
This commit is contained in:
parent
8924725d69
commit
1bc8770b51
5 changed files with 11 additions and 17 deletions
|
@ -327,7 +327,6 @@ class EntityRegistry:
|
|||
disabled_by: RegistryEntryDisabler | None = None,
|
||||
hidden_by: RegistryEntryHider | None = None,
|
||||
# Data that we want entry to have
|
||||
area_id: str | None | UndefinedType = UNDEFINED,
|
||||
capabilities: Mapping[str, Any] | None | UndefinedType = UNDEFINED,
|
||||
config_entry: ConfigEntry | None | UndefinedType = UNDEFINED,
|
||||
device_id: str | None | UndefinedType = UNDEFINED,
|
||||
|
@ -353,7 +352,6 @@ class EntityRegistry:
|
|||
if entity_id:
|
||||
return self.async_update_entity(
|
||||
entity_id,
|
||||
area_id=area_id,
|
||||
capabilities=capabilities,
|
||||
config_entry_id=config_entry_id,
|
||||
device_id=device_id,
|
||||
|
@ -404,7 +402,6 @@ class EntityRegistry:
|
|||
return None if value is UNDEFINED else value
|
||||
|
||||
entry = RegistryEntry(
|
||||
area_id=none_if_undefined(area_id),
|
||||
capabilities=none_if_undefined(capabilities),
|
||||
config_entry_id=none_if_undefined(config_entry_id),
|
||||
device_id=none_if_undefined(device_id),
|
||||
|
|
|
@ -197,9 +197,8 @@ async def test_google_device_registry_sync(hass, mock_cloud_login, cloud_prefs):
|
|||
hass, GACTIONS_SCHEMA({}), "mock-user-id", cloud_prefs, hass.data["cloud"]
|
||||
)
|
||||
ent_reg = er.async_get(hass)
|
||||
entity_entry = ent_reg.async_get_or_create(
|
||||
"light", "hue", "1234", device_id="1234", area_id="ABCD"
|
||||
)
|
||||
entity_entry = ent_reg.async_get_or_create("light", "hue", "1234", device_id="1234")
|
||||
entity_entry = ent_reg.async_update_entity(entity_entry.entity_id, area_id="ABCD")
|
||||
|
||||
with patch.object(config, "async_sync_entities_all"):
|
||||
await config.async_initialize()
|
||||
|
|
|
@ -232,7 +232,9 @@ async def test_sync_in_area(area_on_device, hass, registries):
|
|||
"1235",
|
||||
suggested_object_id="demo_light",
|
||||
device_id=device.id,
|
||||
area_id=area.id if not area_on_device else None,
|
||||
)
|
||||
entity = registries.entity.async_update_entity(
|
||||
entity.entity_id, area_id=area.id if not area_on_device else None
|
||||
)
|
||||
|
||||
light = DemoLight(
|
||||
|
|
|
@ -73,7 +73,6 @@ def test_get_or_create_updates_data(registry):
|
|||
"light",
|
||||
"hue",
|
||||
"5678",
|
||||
area_id="mock-area-id",
|
||||
capabilities={"max": 100},
|
||||
config_entry=orig_config_entry,
|
||||
device_id="mock-dev-id",
|
||||
|
@ -92,7 +91,6 @@ def test_get_or_create_updates_data(registry):
|
|||
"light.hue_5678",
|
||||
"5678",
|
||||
"hue",
|
||||
area_id="mock-area-id",
|
||||
capabilities={"max": 100},
|
||||
config_entry_id=orig_config_entry.entry_id,
|
||||
device_class=None,
|
||||
|
@ -117,8 +115,7 @@ def test_get_or_create_updates_data(registry):
|
|||
"light",
|
||||
"hue",
|
||||
"5678",
|
||||
area_id="new-mock-area-id",
|
||||
capabilities={"new-max": 100},
|
||||
capabilities={"new-max": 150},
|
||||
config_entry=new_config_entry,
|
||||
device_id="new-mock-dev-id",
|
||||
disabled_by=er.RegistryEntryDisabler.USER,
|
||||
|
@ -136,8 +133,8 @@ def test_get_or_create_updates_data(registry):
|
|||
"light.hue_5678",
|
||||
"5678",
|
||||
"hue",
|
||||
area_id="new-mock-area-id",
|
||||
capabilities={"new-max": 100},
|
||||
area_id=None,
|
||||
capabilities={"new-max": 150},
|
||||
config_entry_id=new_config_entry.entry_id,
|
||||
device_class=None,
|
||||
device_id="new-mock-dev-id",
|
||||
|
@ -159,7 +156,6 @@ def test_get_or_create_updates_data(registry):
|
|||
"light",
|
||||
"hue",
|
||||
"5678",
|
||||
area_id=None,
|
||||
capabilities=None,
|
||||
config_entry=None,
|
||||
device_id=None,
|
||||
|
@ -235,7 +231,6 @@ async def test_loading_saving_data(hass, registry):
|
|||
"light",
|
||||
"hue",
|
||||
"5678",
|
||||
area_id="mock-area-id",
|
||||
capabilities={"max": 100},
|
||||
config_entry=mock_config,
|
||||
device_id="mock-dev-id",
|
||||
|
@ -251,6 +246,7 @@ async def test_loading_saving_data(hass, registry):
|
|||
)
|
||||
registry.async_update_entity(
|
||||
orig_entry2.entity_id,
|
||||
area_id="mock-area-id",
|
||||
device_class="user-class",
|
||||
name="User Name",
|
||||
icon="hass:user-icon",
|
||||
|
|
|
@ -2768,13 +2768,13 @@ async def test_area_entities(hass):
|
|||
assert info.rate_limit is None
|
||||
|
||||
area_entry = area_registry.async_get_or_create("sensor.fake")
|
||||
entity_registry.async_get_or_create(
|
||||
entity_entry = entity_registry.async_get_or_create(
|
||||
"light",
|
||||
"hue",
|
||||
"5678",
|
||||
config_entry=config_entry,
|
||||
area_id=area_entry.id,
|
||||
)
|
||||
entity_registry.async_update_entity(entity_entry.entity_id, area_id=area_entry.id)
|
||||
|
||||
info = render_to_info(hass, f"{{{{ area_entities('{area_entry.id}') }}}}")
|
||||
assert_result_info(info, ["light.hue_5678"])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue