From 1c1d8d0317e03a0a9f729570288528d23d81bb80 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sat, 23 Mar 2024 11:31:23 -1000 Subject: [PATCH] Avoid creating inner function in EntityComponent setup (#114050) --- homeassistant/helpers/entity_component.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/homeassistant/helpers/entity_component.py b/homeassistant/helpers/entity_component.py index dc9093b362b..b764a29a686 100644 --- a/homeassistant/helpers/entity_component.py +++ b/homeassistant/helpers/entity_component.py @@ -156,16 +156,16 @@ class EntityComponent(Generic[_EntityT]): # Generic discovery listener for loading platform dynamically # Refer to: homeassistant.helpers.discovery.async_load_platform() - async def component_platform_discovered( - platform: str, info: dict[str, Any] | None - ) -> None: - """Handle the loading of a platform.""" - await self.async_setup_platform(platform, {}, info) - discovery.async_listen_platform( - self.hass, self.domain, component_platform_discovered + self.hass, self.domain, self._async_component_platform_discovered ) + async def _async_component_platform_discovered( + self, platform: str, info: dict[str, Any] | None + ) -> None: + """Handle the loading of a platform.""" + await self.async_setup_platform(platform, {}, info) + async def async_setup_entry(self, config_entry: ConfigEntry) -> bool: """Set up a config entry.""" platform_type = config_entry.domain