From 313eff7cfbe91d2a2188dd554b7d211e0ae9b1e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ab=C3=ADlio=20Costa?= Date: Thu, 12 Nov 2026 18:12:32 +0000 Subject: [PATCH] Bump whirlpool-sixth-sense to 2.2.0 (#192322) --- .../components/whirlpool/binary_sensor.py | 11 +++-- homeassistant/components/whirlpool/climate.py | 14 +++--- homeassistant/components/whirlpool/entity.py | 2 +- .../components/whirlpool/manifest.json | 2 +- homeassistant/components/whirlpool/number.py | 2 +- homeassistant/components/whirlpool/select.py | 16 ++++--- homeassistant/components/whirlpool/sensor.py | 48 ++++++++++++------- requirements_all.txt | 2 +- script/hassfest/requirements.py | 1 - 9 files changed, 62 insertions(+), 36 deletions(-) diff --git a/homeassistant/components/whirlpool/binary_sensor.py b/homeassistant/components/whirlpool/binary_sensor.py index bc66f114f941..ef1348bc024e 100644 --- a/homeassistant/components/whirlpool/binary_sensor.py +++ b/homeassistant/components/whirlpool/binary_sensor.py @@ -5,7 +5,8 @@ from dataclasses import dataclass from datetime import timedelta from typing import override -from whirlpool.appliance import Appliance +from whirlpool.dryer import Dryer +from whirlpool.washer import Washer from homeassistant.components.binary_sensor import ( BinarySensorDeviceClass, @@ -26,7 +27,7 @@ SCAN_INTERVAL = timedelta(minutes=5) class WhirlpoolBinarySensorEntityDescription(BinarySensorEntityDescription): """Describes a Whirlpool binary sensor entity.""" - value_fn: Callable[[Appliance], bool | None] + value_fn: Callable[[Washer | Dryer], bool | None] WASHER_DRYER_SENSORS: list[WhirlpoolBinarySensorEntityDescription] = [ @@ -64,8 +65,12 @@ async def async_setup_entry( class WhirlpoolBinarySensor(WhirlpoolEntity, BinarySensorEntity): """A class for the Whirlpool binary sensors.""" + _appliance: Washer | Dryer + def __init__( - self, appliance: Appliance, description: WhirlpoolBinarySensorEntityDescription + self, + appliance: Washer | Dryer, + description: WhirlpoolBinarySensorEntityDescription, ) -> None: """Initialize the washer sensor.""" super().__init__(appliance, unique_id_suffix=f"-{description.key}") diff --git a/homeassistant/components/whirlpool/climate.py b/homeassistant/components/whirlpool/climate.py index f846d373d8a7..50416959561a 100644 --- a/homeassistant/components/whirlpool/climate.py +++ b/homeassistant/components/whirlpool/climate.py @@ -82,13 +82,13 @@ class AirConEntity(WhirlpoolEntity, ClimateEntity): @property @override - def native_current_temperature(self) -> float: + def native_current_temperature(self) -> float | None: """Return the current temperature.""" return self._appliance.get_current_temp() @property @override - def native_target_temperature(self) -> float: + def native_target_temperature(self) -> float | None: """Return the temperature we try to reach.""" return self._appliance.get_temp() @@ -96,12 +96,12 @@ class AirConEntity(WhirlpoolEntity, ClimateEntity): async def async_set_temperature(self, **kwargs: Any) -> None: """Set new target temperature.""" AirConEntity._check_service_request( - await self._appliance.set_temp(kwargs.get(ATTR_TEMPERATURE)) + await self._appliance.set_temp(kwargs[ATTR_TEMPERATURE]) ) @property @override - def current_humidity(self) -> int: + def current_humidity(self) -> int | None: """Return the current humidity.""" return self._appliance.get_current_humidity() @@ -112,7 +112,8 @@ class AirConEntity(WhirlpoolEntity, ClimateEntity): if not self._appliance.get_power_on(): return HVACMode.OFF - mode: AirconMode = self._appliance.get_mode() + if (mode := self._appliance.get_mode()) is None: + return None return AIRCON_MODE_MAP.get(mode) @override @@ -135,7 +136,8 @@ class AirConEntity(WhirlpoolEntity, ClimateEntity): @override def fan_mode(self) -> str: """Return the fan setting.""" - fanspeed = self._appliance.get_fanspeed() + if (fanspeed := self._appliance.get_fanspeed()) is None: + return FAN_OFF return AIRCON_FANSPEED_MAP.get(fanspeed, FAN_OFF) @override diff --git a/homeassistant/components/whirlpool/entity.py b/homeassistant/components/whirlpool/entity.py index 1578a2ba8816..61a8c98db55e 100644 --- a/homeassistant/components/whirlpool/entity.py +++ b/homeassistant/components/whirlpool/entity.py @@ -82,7 +82,7 @@ class WhirlpoolOvenEntity(WhirlpoolEntity): if oven.get_oven_cavity_exists( OvenCavity.Upper ) and oven.get_oven_cavity_exists(OvenCavity.Lower): - return "_upper" if cavity == OvenCavity.Upper else "_lower" + return "_upper" if cavity is OvenCavity.Upper else "_lower" return "" def __init__( diff --git a/homeassistant/components/whirlpool/manifest.json b/homeassistant/components/whirlpool/manifest.json index 3dfbfc800ec3..a7a436e376a0 100644 --- a/homeassistant/components/whirlpool/manifest.json +++ b/homeassistant/components/whirlpool/manifest.json @@ -19,5 +19,5 @@ "iot_class": "cloud_push", "loggers": ["whirlpool"], "quality_scale": "silver", - "requirements": ["whirlpool-sixth-sense==2.1.0"] + "requirements": ["whirlpool-sixth-sense==2.2.0"] } diff --git a/homeassistant/components/whirlpool/number.py b/homeassistant/components/whirlpool/number.py index a76c44014504..177eca9081e9 100644 --- a/homeassistant/components/whirlpool/number.py +++ b/homeassistant/components/whirlpool/number.py @@ -64,7 +64,7 @@ class WhirlpoolOvenTargetTemperature(WhirlpoolOvenEntity, NumberEntity): async def async_set_native_value(self, value: float) -> None: """Set a new target temperature, keeping the current cook mode.""" mode = self._appliance.get_cook_mode(self.cavity) - if mode is None or mode == CookMode.Standby: + if mode is None or mode is CookMode.Standby: mode = CookMode.Bake try: WhirlpoolOvenTargetTemperature._check_service_request( diff --git a/homeassistant/components/whirlpool/select.py b/homeassistant/components/whirlpool/select.py index 6df32716ab69..f98640da35d0 100644 --- a/homeassistant/components/whirlpool/select.py +++ b/homeassistant/components/whirlpool/select.py @@ -4,8 +4,8 @@ from collections.abc import Awaitable, Callable from dataclasses import dataclass from typing import Final, override -from whirlpool.appliance import Appliance from whirlpool.oven import Cavity as OvenCavity, CookMode, Oven +from whirlpool.refrigerator import Refrigerator from homeassistant.components.select import SelectEntity, SelectEntityDescription from homeassistant.const import UnitOfTemperature @@ -40,8 +40,8 @@ DEFAULT_OVEN_TEMP = 175 class WhirlpoolSelectDescription(SelectEntityDescription): """Class describing Whirlpool select entities.""" - value_fn: Callable[[Appliance], str | None] - set_fn: Callable[[Appliance, str], Awaitable[bool]] + value_fn: Callable[[Refrigerator], str | None] + set_fn: Callable[[Refrigerator, str], Awaitable[bool]] REFRIGERATOR_DESCRIPTIONS: Final[tuple[WhirlpoolSelectDescription, ...]] = ( @@ -83,8 +83,10 @@ async def async_setup_entry( class WhirlpoolSelectEntity(WhirlpoolEntity, SelectEntity): """Whirlpool select entity.""" + _appliance: Refrigerator + def __init__( - self, appliance: Appliance, description: WhirlpoolSelectDescription + self, appliance: Refrigerator, description: WhirlpoolSelectDescription ) -> None: """Initialize the select entity.""" super().__init__(appliance, unique_id_suffix=f"-{description.key}") @@ -123,14 +125,16 @@ class WhirlpoolOvenCookModeSelect(WhirlpoolOvenEntity, SelectEntity): @property def current_option(self) -> str | None: """Return the current cook mode, if it is a selectable one.""" - return OVEN_COOK_MODES.get(self._appliance.get_cook_mode(self.cavity)) + if (mode := self._appliance.get_cook_mode(self.cavity)) is None: + return None + return OVEN_COOK_MODES.get(mode) @override async def async_select_option(self, option: str) -> None: """Set the cook mode, keeping the current/last target temperature.""" mode = OPTION_TO_OVEN_COOK_MODE[option] try: - if mode == CookMode.Standby: + if mode is CookMode.Standby: # Standby is the idle state: the oven reaches it by cancelling # the current cook, not by starting a "standby" cook. result = await self._appliance.stop_cook(self.cavity) diff --git a/homeassistant/components/whirlpool/sensor.py b/homeassistant/components/whirlpool/sensor.py index 14c695db99fb..4a269ad1a026 100644 --- a/homeassistant/components/whirlpool/sensor.py +++ b/homeassistant/components/whirlpool/sensor.py @@ -119,9 +119,10 @@ OVEN_COOK_MODE = { def washer_state(washer: Washer) -> str | None: """Determine correct states for a washer.""" - machine_state = washer.get_machine_state() + if (machine_state := washer.get_machine_state()) is None: + return None - if machine_state == WasherMachineState.RunningMainCycle: + if machine_state is WasherMachineState.RunningMainCycle: if washer.get_cycle_status_filling(): return STATE_CYCLE_FILLING if washer.get_cycle_status_rinsing(): @@ -141,9 +142,10 @@ def washer_state(washer: Washer) -> str | None: def dryer_state(dryer: Dryer) -> str | None: """Determine correct states for a dryer.""" - machine_state = dryer.get_machine_state() + if (machine_state := dryer.get_machine_state()) is None: + return None - if machine_state == DryerMachineState.RunningMainCycle: + if machine_state is DryerMachineState.RunningMainCycle: if dryer.get_cycle_status_sensing(): return STATE_CYCLE_SENSING @@ -151,10 +153,12 @@ def dryer_state(dryer: Dryer) -> str | None: @dataclass(frozen=True, kw_only=True) -class WhirlpoolSensorEntityDescription(SensorEntityDescription): +class WhirlpoolSensorEntityDescription[_ApplianceT: Washer | Dryer]( + SensorEntityDescription +): """Describes a Whirlpool sensor entity.""" - value_fn: Callable[[Appliance], str | None] + value_fn: Callable[[_ApplianceT], str | None] WASHER_STATE_OPTIONS = [ @@ -172,7 +176,7 @@ DRYER_STATE_OPTIONS = [ STATE_CYCLE_SENSING, ] -WASHER_SENSORS: tuple[WhirlpoolSensorEntityDescription, ...] = ( +WASHER_SENSORS: tuple[WhirlpoolSensorEntityDescription[Washer], ...] = ( WhirlpoolSensorEntityDescription( key="state", translation_key="washer_state", @@ -186,11 +190,15 @@ WASHER_SENSORS: tuple[WhirlpoolSensorEntityDescription, ...] = ( entity_registry_enabled_default=False, device_class=SensorDeviceClass.ENUM, options=[value for value in WASHER_TANK_FILL.values() if value], - value_fn=lambda washer: WASHER_TANK_FILL.get(washer.get_dispense_1_level()), + value_fn=lambda washer: ( + WASHER_TANK_FILL.get(level) + if (level := washer.get_dispense_1_level()) is not None + else None + ), ), ) -DRYER_SENSORS: tuple[WhirlpoolSensorEntityDescription, ...] = ( +DRYER_SENSORS: tuple[WhirlpoolSensorEntityDescription[Dryer], ...] = ( WhirlpoolSensorEntityDescription( key="state", translation_key="dryer_state", @@ -339,15 +347,21 @@ async def async_setup_entry( ) -class WhirlpoolSensor(WhirlpoolEntity, SensorEntity): +class WhirlpoolSensor[_ApplianceT: Washer | Dryer](WhirlpoolEntity, SensorEntity): """A class for the Whirlpool sensors.""" + _appliance: _ApplianceT + def __init__( - self, appliance: Appliance, description: WhirlpoolSensorEntityDescription + self, + appliance: _ApplianceT, + description: WhirlpoolSensorEntityDescription[_ApplianceT], ) -> None: """Initialize the washer sensor.""" super().__init__(appliance, unique_id_suffix=f"-{description.key}") - self.entity_description: WhirlpoolSensorEntityDescription = description + self.entity_description: WhirlpoolSensorEntityDescription[_ApplianceT] = ( + description + ) @property @override @@ -377,7 +391,7 @@ class WhirlpoolTimeSensorBase(WhirlpoolEntity, RestoreSensor, ABC): """Return true if the timer/cycle is in a running state.""" @abstractmethod - def _get_seconds_remaining(self) -> int: + def _get_seconds_remaining(self) -> int | None: """Return the number of seconds remaining.""" @override @@ -404,7 +418,9 @@ class WhirlpoolTimeSensorBase(WhirlpoolEntity, RestoreSensor, ABC): if self._is_running(): self._running = True - new_timestamp = now + timedelta(seconds=self._get_seconds_remaining()) + if (seconds_remaining := self._get_seconds_remaining()) is None: + return self._value + new_timestamp = now + timedelta(seconds=seconds_remaining) if self._value is None or ( isinstance(self._value, datetime) and abs(new_timestamp - self._value) > timedelta(seconds=60) @@ -437,7 +453,7 @@ class WasherTimeSensor(WhirlpoolTimeSensorBase): ) @override - def _get_seconds_remaining(self) -> int: + def _get_seconds_remaining(self) -> int | None: return self._appliance.get_time_remaining() @@ -463,7 +479,7 @@ class DryerTimeSensor(WhirlpoolTimeSensorBase): return self._appliance.get_machine_state() is DryerMachineState.RunningMainCycle @override - def _get_seconds_remaining(self) -> int: + def _get_seconds_remaining(self) -> int | None: return self._appliance.get_time_remaining() diff --git a/requirements_all.txt b/requirements_all.txt index 832cd2d0a352..f9e7d21ab2fe 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -3534,7 +3534,7 @@ webmin-xmlrpc==0.0.2 weheat==2026.9.3 # homeassistant.components.whirlpool -whirlpool-sixth-sense==2.1.0 +whirlpool-sixth-sense==2.2.0 # homeassistant.components.whois whoisdomain==2.20260806.3 diff --git a/script/hassfest/requirements.py b/script/hassfest/requirements.py index 3c6b7b7203db..0006b726685d 100644 --- a/script/hassfest/requirements.py +++ b/script/hassfest/requirements.py @@ -226,7 +226,6 @@ FORBIDDEN_PACKAGE_EXCEPTIONS: dict[str, dict[str, set[str]]] = { "toon": {"toonapi": {"backoff"}}, "volkszaehler": {"volkszaehler": {"async-timeout"}}, "weatherflow_cloud": {"weatherflow4py": {"dataclasses-json"}}, - "whirlpool": {"whirlpool-sixth-sense": {"async-timeout"}}, "zamg": {"zamg": {"async-timeout"}}, "zha": { # https://github.com/waveform80/colorzero/issues/9