diff --git a/homeassistant/helpers/entity_registry.py b/homeassistant/helpers/entity_registry.py index 5946542b394..ef9274c6ceb 100644 --- a/homeassistant/helpers/entity_registry.py +++ b/homeassistant/helpers/entity_registry.py @@ -643,29 +643,6 @@ class EntityRegistry(BaseRegistry): run_immediately=True, ) - @callback - def async_get_device_class_lookup( - self, domain_device_classes: set[tuple[str, str | None]] - ) -> dict[str, dict[tuple[str, str | None], str]]: - """Return a lookup of entity ids for devices which have matching entities. - - Entities must match a set of (domain, device_class) tuples. - The result is indexed by device_id, then by the matching (domain, device_class) - """ - lookup: dict[str, dict[tuple[str, str | None], str]] = {} - for entity in self.entities.values(): - if not entity.device_id: - continue - device_class = entity.device_class or entity.original_device_class - domain_device_class = (entity.domain, device_class) - if domain_device_class not in domain_device_classes: - continue - if entity.device_id not in lookup: - lookup[entity.device_id] = {domain_device_class: entity.entity_id} - else: - lookup[entity.device_id][domain_device_class] = entity.entity_id - return lookup - @callback def async_is_registered(self, entity_id: str) -> bool: """Check if an entity_id is currently registered.""" diff --git a/tests/helpers/test_entity_registry.py b/tests/helpers/test_entity_registry.py index a9177fc8c83..91c749a0d7f 100644 --- a/tests/helpers/test_entity_registry.py +++ b/tests/helpers/test_entity_registry.py @@ -954,85 +954,6 @@ async def test_restore_states( assert hass.states.get("light.all_info_set") is None -async def test_async_get_device_class_lookup( - hass: HomeAssistant, entity_registry: er.EntityRegistry -) -> None: - """Test registry device class lookup.""" - hass.set_state(CoreState.not_running) - - entity_registry.async_get_or_create( - "binary_sensor", - "light", - "battery_charging", - device_id="light_device_entry_id", - original_device_class="battery_charging", - ) - entity_registry.async_get_or_create( - "sensor", - "light", - "battery", - device_id="light_device_entry_id", - original_device_class="battery", - ) - entity_registry.async_get_or_create( - "light", "light", "demo", device_id="light_device_entry_id" - ) - entity_registry.async_get_or_create( - "binary_sensor", - "vacuum", - "battery_charging", - device_id="vacuum_device_entry_id", - original_device_class="battery_charging", - ) - entity_registry.async_get_or_create( - "sensor", - "vacuum", - "battery", - device_id="vacuum_device_entry_id", - original_device_class="battery", - ) - entity_registry.async_get_or_create( - "vacuum", "vacuum", "demo", device_id="vacuum_device_entry_id" - ) - entity_registry.async_get_or_create( - "binary_sensor", - "remote", - "battery_charging", - device_id="remote_device_entry_id", - original_device_class="battery_charging", - ) - entity_registry.async_get_or_create( - "remote", "remote", "demo", device_id="remote_device_entry_id" - ) - - device_lookup = entity_registry.async_get_device_class_lookup( - {("binary_sensor", "battery_charging"), ("sensor", "battery")} - ) - - assert device_lookup == { - "remote_device_entry_id": { - ( - "binary_sensor", - "battery_charging", - ): "binary_sensor.remote_battery_charging" - }, - "light_device_entry_id": { - ( - "binary_sensor", - "battery_charging", - ): "binary_sensor.light_battery_charging", - ("sensor", "battery"): "sensor.light_battery", - }, - "vacuum_device_entry_id": { - ( - "binary_sensor", - "battery_charging", - ): "binary_sensor.vacuum_battery_charging", - ("sensor", "battery"): "sensor.vacuum_battery", - }, - } - - async def test_remove_device_removes_entities( hass: HomeAssistant, entity_registry: er.EntityRegistry,