mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Small cleanups to expand_entity_ids (#96585)
This commit is contained in:
parent
7d4016d7bf
commit
fca40be5df
@ -10,7 +10,6 @@ from typing import Any, Protocol, cast
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import core as ha
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
ATTR_ASSUMED_STATE,
|
||||
@ -82,6 +81,8 @@ PLATFORMS = [
|
||||
|
||||
REG_KEY = f"{DOMAIN}_registry"
|
||||
|
||||
ENTITY_PREFIX = f"{DOMAIN}."
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
current_domain: ContextVar[str] = ContextVar("current_domain")
|
||||
@ -180,12 +181,8 @@ def expand_entity_ids(hass: HomeAssistant, entity_ids: Iterable[Any]) -> list[st
|
||||
continue
|
||||
|
||||
entity_id = entity_id.lower()
|
||||
|
||||
try:
|
||||
# If entity_id points at a group, expand it
|
||||
domain, _ = ha.split_entity_id(entity_id)
|
||||
|
||||
if domain == DOMAIN:
|
||||
if entity_id.startswith(ENTITY_PREFIX):
|
||||
child_entities = get_entity_ids(hass, entity_id)
|
||||
if entity_id in child_entities:
|
||||
child_entities = list(child_entities)
|
||||
@ -195,14 +192,9 @@ def expand_entity_ids(hass: HomeAssistant, entity_ids: Iterable[Any]) -> list[st
|
||||
for ent_id in expand_entity_ids(hass, child_entities)
|
||||
if ent_id not in found_ids
|
||||
)
|
||||
|
||||
elif entity_id not in found_ids:
|
||||
found_ids.append(entity_id)
|
||||
|
||||
except AttributeError:
|
||||
# Raised by split_entity_id if entity_id is not a string
|
||||
pass
|
||||
|
||||
return found_ids
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user