8000 fix: serve the native climate temperature API by kris-anderson · Pull Request #203 · iprak/winix · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions custom_components/winix/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ class WinixAirConditioner(WinixEntity, ClimateEntity):
"""Representation of a Winix window/portable air conditioner."""

_attr_temperature_unit = UnitOfTemperature.CELSIUS
# Home Assistant 2026.11+ reads the native unit. A class that provides both gets the
# native one and no deprecation warning; older versions keep reading the one above.
_attr_native_temperature_unit = UnitOfTemperature.CELSIUS
_attr_precision = PRECISION_WHOLE
_attr_target_temperature_step = 1
_attr_min_temp = 18
Expand Down Expand Up @@ -101,6 +104,10 @@ def target_temperature(self) -> int | None:
"""Return target temperature."""
return self.device_wrapper.ac_target_temperature

# Home Assistant 2026.11+ reads the native names; older versions read the ones above.
native_current_temperature = current_temperature
native_target_temperature = target_temperature

@property
def fan_mode(self) -> str | None:
"""Return current fan mode."""
Expand Down
17 changes: 17 additions & 0 deletions tests/test_climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from custom_components.winix.const import WINIX_DOMAIN
from custom_components.winix.manager import STATE_REFRESH_DELAY
from homeassistant.components.climate import ClimateEntityFeature, HVACMode
from homeassistant.const import UnitOfTemperature
from homeassistant.core import HomeAssistant

from .common import build_fake_manager # noqa: TID251
Expand Down Expand Up @@ -170,8 +171,24 @@ def test_current_and_target_temperature() -> None:
wrapper.ac_target_temperature = 24

device = WinixAirConditioner(wrapper, Mock())
assert device.native_current_temperature == 26
assert device.native_target_temperature == 24
# The legacy names still serve Home Assistant before 2026.11.
assert device.current_temperature == 26
assert device.target_temperature == 24
unit = WinixAirConditioner._attr_native_temperature_unit # noqa: SLF001
assert unit == UnitOfTemperature.CELSIUS


def test_no_deprecated_temperature_api_warning(
caplog: pytest.LogCaptureFixture,
) -> None:
"""Defining a subclass logs no climate temperature deprecation (HA 2026.11+)."""

class _Probe(WinixAirConditioner):
"""Subclass created here so Home Assistant inspects it under caplog."""

assert "provides the deprecated" not in caplog.text


# ---------------------------------------------------------------------------
Expand Down
Loading
0