From 18df6e4c6023b15c0ea6de3db495e3ce64a2dc22 Mon Sep 17 00:00:00 2001 From: David Bonnes Date: Fri, 17 Apr 2026 15:20:36 +0100 Subject: [PATCH] Isolate Evohome's dispatcher framework to its controller class (#168395) --- homeassistant/components/evohome/climate.py | 16 ++++++++++++++++ homeassistant/components/evohome/entity.py | 21 --------------------- 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/homeassistant/components/evohome/climate.py b/homeassistant/components/evohome/climate.py index 0430dbf16b1f..b4624a44195d 100644 --- a/homeassistant/components/evohome/climate.py +++ b/homeassistant/components/evohome/climate.py @@ -35,6 +35,7 @@ from homeassistant.const import ( ) from homeassistant.core import HomeAssistant, callback from homeassistant.exceptions import HomeAssistantError, ServiceValidationError +from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType from homeassistant.util import dt as dt_util @@ -366,6 +367,21 @@ class EvoController(EvoClimateEntity): ClimateEntityFeature.TURN_OFF | ClimateEntityFeature.TURN_ON ) + async def async_added_to_hass(self) -> None: + """Run when entity about to be added to hass.""" + await super().async_added_to_hass() + + async_dispatcher_connect(self.hass, DOMAIN, self.process_signal) + + async def process_signal(self, payload: dict | None = None) -> None: + """Process any signals.""" + + if payload is None: + raise NotImplementedError + if payload["unique_id"] != self._attr_unique_id: + return + await self.async_tcs_svc_request(payload["service"], payload["data"]) + async def async_tcs_svc_request(self, service: str, data: dict[str, Any]) -> None: """Process a service request (system mode) for a controller. diff --git a/homeassistant/components/evohome/entity.py b/homeassistant/components/evohome/entity.py index 61b62d2fb62f..85688b3dacd1 100644 --- a/homeassistant/components/evohome/entity.py +++ b/homeassistant/components/evohome/entity.py @@ -13,10 +13,8 @@ from evohomeasync2.schemas.const import ( from evohomeasync2.schemas.typedefs import DayOfWeekDhwT from homeassistant.core import callback -from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.update_coordinator import CoordinatorEntity -from .const import DOMAIN from .coordinator import EvoDataUpdateCoordinator _LOGGER = logging.getLogger(__name__) @@ -52,30 +50,11 @@ class EvoEntity(CoordinatorEntity[EvoDataUpdateCoordinator]): self._device_state_attrs: dict[str, Any] = {} - async def process_signal(self, payload: dict | None = None) -> None: - """Process any signals.""" - - if payload is None: - raise NotImplementedError - if payload["unique_id"] != self._attr_unique_id: - return - await self.async_tcs_svc_request(payload["service"], payload["data"]) - - async def async_tcs_svc_request(self, service: str, data: dict[str, Any]) -> None: - """Process a service request (system mode) for a controller.""" - raise NotImplementedError - @property def extra_state_attributes(self) -> Mapping[str, Any]: """Return the evohome-specific state attributes.""" return {"status": self._device_state_attrs} - async def async_added_to_hass(self) -> None: - """Run when entity about to be added to hass.""" - await super().async_added_to_hass() - - async_dispatcher_connect(self.hass, DOMAIN, self.process_signal) - @callback def _handle_coordinator_update(self) -> None: """Handle updated data from the coordinator."""