From b3a8a75e7548462ce1ae3603898c47d737bf30a7 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 23 Feb 2024 08:42:01 -1000 Subject: [PATCH] Improve performance of filtering HomeKit entities (#111201) Get the underlying filter with get_filter to avoid the wrapper --- homeassistant/components/homekit/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/homekit/__init__.py b/homeassistant/components/homekit/__init__.py index bfae426e57c..4fd88665f36 100644 --- a/homeassistant/components/homekit/__init__.py +++ b/homeassistant/components/homekit/__init__.py @@ -798,10 +798,11 @@ class HomeKit: } ) - entity_states = [] + entity_states: list[State] = [] + entity_filter = self._filter.get_filter() for state in self.hass.states.async_all(): entity_id = state.entity_id - if not self._filter(entity_id): + if not entity_filter(entity_id): continue if ent_reg_ent := ent_reg.async_get(entity_id):