diff --git a/homeassistant/components/maxcube/climate.py b/homeassistant/components/maxcube/climate.py index 65b1795023f..c20a855d656 100644 --- a/homeassistant/components/maxcube/climate.py +++ b/homeassistant/components/maxcube/climate.py @@ -192,7 +192,7 @@ class MaxCubeClimate(ClimateEntity): self._set_target(None, temp) @property - def preset_mode(self): + def preset_mode(self) -> str: """Return the current preset mode.""" if self._device.mode == MAX_DEVICE_MODE_MANUAL: if self._device.target_temperature == self._device.comfort_temperature: diff --git a/homeassistant/components/nexia/climate.py b/homeassistant/components/nexia/climate.py index 52ff87e11c7..1e698713935 100644 --- a/homeassistant/components/nexia/climate.py +++ b/homeassistant/components/nexia/climate.py @@ -225,7 +225,7 @@ class NexiaZone(NexiaThermostatZoneEntity, ClimateEntity): self._signal_thermostat_update() @property - def preset_mode(self): + def preset_mode(self) -> str | None: """Preset that is active.""" return self._zone.get_preset() diff --git a/homeassistant/components/nuheat/climate.py b/homeassistant/components/nuheat/climate.py index 85e24c116f9..6a38bb160be 100644 --- a/homeassistant/components/nuheat/climate.py +++ b/homeassistant/components/nuheat/climate.py @@ -154,7 +154,7 @@ class NuHeatThermostat(CoordinatorEntity, ClimateEntity): return nuheat_to_fahrenheit(self._target_temperature) @property - def preset_mode(self): + def preset_mode(self) -> str: """Return current preset mode.""" return SCHEDULE_MODE_TO_PRESET_MODE_MAP.get(self._schedule_mode, PRESET_RUN) diff --git a/homeassistant/components/vicare/climate.py b/homeassistant/components/vicare/climate.py index 603d82cbf7f..deb053eebc7 100644 --- a/homeassistant/components/vicare/climate.py +++ b/homeassistant/components/vicare/climate.py @@ -282,8 +282,10 @@ class ViCareClimate(ViCareEntity, ClimateEntity): self._attr_target_temperature = temp @property - def preset_mode(self): + def preset_mode(self) -> str | None: """Return the current preset mode, e.g., home, away, temp.""" + if self._current_program is None: + return None return HeatingProgram.to_ha_preset(self._current_program) def set_preset_mode(self, preset_mode: str) -> None: diff --git a/pylint/plugins/hass_enforce_type_hints.py b/pylint/plugins/hass_enforce_type_hints.py index a562ea69d68..889d8ea10a3 100644 --- a/pylint/plugins/hass_enforce_type_hints.py +++ b/pylint/plugins/hass_enforce_type_hints.py @@ -1225,6 +1225,7 @@ _INHERITANCE_MATCH: dict[str, list[ClassTypeHintMatch]] = { TypeHintMatch( function_name="preset_mode", return_type=["str", None], + mandatory=True, ), TypeHintMatch( function_name="preset_modes", @@ -1602,6 +1603,7 @@ _INHERITANCE_MATCH: dict[str, list[ClassTypeHintMatch]] = { TypeHintMatch( function_name="preset_mode", return_type=["str", None], + mandatory=True, ), TypeHintMatch( function_name="preset_modes",