From 8a41370950f951910c89f83089c3ce5285f3b845 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 5 May 2022 13:13:55 -0400 Subject: [PATCH] Add cache to split_entity_id (#71345) --- homeassistant/core.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/homeassistant/core.py b/homeassistant/core.py index d6b1ac85d8b..b181e4c4106 100644 --- a/homeassistant/core.py +++ b/homeassistant/core.py @@ -133,9 +133,12 @@ SOURCE_YAML = ConfigSource.YAML.value # How long to wait until things that run on startup have to finish. TIMEOUT_EVENT_START = 15 +MAX_EXPECTED_ENTITY_IDS = 16384 + _LOGGER = logging.getLogger(__name__) +@functools.lru_cache(MAX_EXPECTED_ENTITY_IDS) def split_entity_id(entity_id: str) -> tuple[str, str]: """Split a state entity ID into domain and object ID.""" domain, _, object_id = entity_id.partition(".")