diff --git a/homeassistant/components/evohome/__init__.py b/homeassistant/components/evohome/__init__.py index 1bb84dfc40a..27c3698143b 100644 --- a/homeassistant/components/evohome/__init__.py +++ b/homeassistant/components/evohome/__init__.py @@ -540,11 +540,11 @@ class EvoDevice(Entity): return await self.async_tcs_svc_request(payload["service"], payload["data"]) - async def async_tcs_svc_request(self, service: dict, data: dict) -> None: + 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 - async def async_zone_svc_request(self, service: dict, data: dict) -> None: + async def async_zone_svc_request(self, service: str, data: dict[str, Any]) -> None: """Process a service request (setpoint override) for a zone.""" raise NotImplementedError diff --git a/homeassistant/components/evohome/climate.py b/homeassistant/components/evohome/climate.py index 700fa6ab078..841619af6f1 100644 --- a/homeassistant/components/evohome/climate.py +++ b/homeassistant/components/evohome/climate.py @@ -3,6 +3,7 @@ from __future__ import annotations from datetime import datetime as dt import logging +from typing import Any from homeassistant.components.climate import ClimateEntity from homeassistant.components.climate.const import ( @@ -15,6 +16,7 @@ from homeassistant.components.climate.const import ( ) from homeassistant.const import PRECISION_TENTHS, TEMP_CELSIUS from homeassistant.core import HomeAssistant +from homeassistant.exceptions import HomeAssistantError from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType import homeassistant.util.dt as dt_util @@ -93,9 +95,8 @@ async def async_setup_platform( broker.params[CONF_LOCATION_IDX], ) - controller = EvoController(broker, broker.tcs) + entities: list[EvoClimateEntity] = [EvoController(broker, broker.tcs)] - zones = [] for zone in broker.tcs.zones.values(): if zone.modelType == "HeatingZone" or zone.zoneType == "Thermostat": _LOGGER.debug( @@ -107,7 +108,7 @@ async def async_setup_platform( ) new_entity = EvoZone(broker, zone) - zones.append(new_entity) + entities.append(new_entity) else: _LOGGER.warning( @@ -119,7 +120,7 @@ async def async_setup_platform( zone.name, ) - async_add_entities([controller] + zones, update_before_add=True) + async_add_entities(entities, update_before_add=True) class EvoClimateEntity(EvoDevice, ClimateEntity): @@ -168,7 +169,7 @@ class EvoZone(EvoChild, EvoClimateEntity): ClimateEntityFeature.PRESET_MODE | ClimateEntityFeature.TARGET_TEMPERATURE ) - async def async_zone_svc_request(self, service: dict, data: dict) -> None: + async def async_zone_svc_request(self, service: str, data: dict[str, Any]) -> None: """Process a service request (setpoint override) for a zone.""" if service == SVC_RESET_ZONE_OVERRIDE: await self._evo_broker.call_client_api( @@ -272,7 +273,7 @@ class EvoZone(EvoChild, EvoClimateEntity): self._evo_device.cancel_temp_override() ) - async def async_set_preset_mode(self, preset_mode: str | None) -> None: + async def async_set_preset_mode(self, preset_mode: str) -> None: """Set the preset mode; if None, then revert to following the schedule.""" evo_preset_mode = HA_PRESET_TO_EVO.get(preset_mode, EVO_FOLLOW) @@ -332,7 +333,7 @@ class EvoController(EvoClimateEntity): ClimateEntityFeature.PRESET_MODE if self._attr_preset_modes else 0 ) - async def async_tcs_svc_request(self, service: dict, data: dict) -> None: + async def async_tcs_svc_request(self, service: str, data: dict[str, Any]) -> None: """Process a service request (system mode) for a controller. Data validation is not required, it will have been done upstream. @@ -385,25 +386,17 @@ class EvoController(EvoClimateEntity): """Return the current preset mode, e.g., home, away, temp.""" return TCS_PRESET_TO_HA.get(self._evo_tcs.systemModeStatus["mode"]) - @property - def min_temp(self) -> float: - """Return None as Controllers don't have a target temperature.""" - return None - - @property - def max_temp(self) -> float: - """Return None as Controllers don't have a target temperature.""" - return None - async def async_set_temperature(self, **kwargs) -> None: """Raise exception as Controllers don't have a target temperature.""" raise NotImplementedError("Evohome Controllers don't have target temperatures.") - async def async_set_hvac_mode(self, hvac_mode: str) -> None: + async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None: """Set an operating mode for a Controller.""" - await self._set_tcs_mode(HA_HVAC_TO_TCS.get(hvac_mode)) + if not (tcs_mode := HA_HVAC_TO_TCS.get(hvac_mode)): + raise HomeAssistantError(f"Invalid hvac_mode: {hvac_mode}") + await self._set_tcs_mode(tcs_mode) - async def async_set_preset_mode(self, preset_mode: str | None) -> None: + async def async_set_preset_mode(self, preset_mode: str) -> None: """Set the preset mode; if None, then revert to 'Auto' mode.""" await self._set_tcs_mode(HA_PRESET_TO_TCS.get(preset_mode, EVO_AUTO)) diff --git a/mypy.ini b/mypy.ini index 93ae6c2f78c..2297869dbb0 100644 --- a/mypy.ini +++ b/mypy.ini @@ -2665,9 +2665,6 @@ ignore_errors = true [mypy-homeassistant.components.evohome] ignore_errors = true -[mypy-homeassistant.components.evohome.climate] -ignore_errors = true - [mypy-homeassistant.components.minecraft_server] ignore_errors = true diff --git a/script/hassfest/mypy_config.py b/script/hassfest/mypy_config.py index 3b8e80490b6..f53d6a6e6b0 100644 --- a/script/hassfest/mypy_config.py +++ b/script/hassfest/mypy_config.py @@ -19,7 +19,6 @@ IGNORED_MODULES: Final[list[str]] = [ "homeassistant.components.cloud.client", "homeassistant.components.cloud.http_api", "homeassistant.components.evohome", - "homeassistant.components.evohome.climate", "homeassistant.components.minecraft_server", "homeassistant.components.minecraft_server.helpers", "homeassistant.components.minecraft_server.sensor",