From 496ee41ac1f8e9a96070b48bead2ed38333ea8cf Mon Sep 17 00:00:00 2001 From: Bluetooth Devices Bot Date: Tue, 23 Jun 2026 05:22:00 +0000 Subject: [PATCH] fix: has_outdoor_temperature must return bool, not raw JSON value has_outdoor_temperature returned the raw thermostat_json value (or None when the key is absent), violating its declared -> bool return type. Every sibling capability predicate (has_relative_humidity, has_emergency_heat, etc.) wraps the lookup in bool(); this one did not. Since py.typed shipped (#203), the annotation is a downstream contract, so a None return where False is expected is a real type-accuracy defect. Wrap the lookup in bool() to match the siblings and the annotation. --- nexia/thermostat.py | 2 +- tests/test_home.py | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/nexia/thermostat.py b/nexia/thermostat.py index c8f9dc4..6b520ca 100644 --- a/nexia/thermostat.py +++ b/nexia/thermostat.py @@ -207,7 +207,7 @@ def has_outdoor_temperature(self) -> bool: temperature sensor :return: bool. """ - return self._get_thermostat_key_or_none("has_outdoor_temperature") + return bool(self._get_thermostat_key_or_none("has_outdoor_temperature")) def has_relative_humidity(self) -> bool: """Capability indication of whether the thermostat has a relative diff --git a/tests/test_home.py b/tests/test_home.py index 029a3d4..b2c32ba 100644 --- a/tests/test_home.py +++ b/tests/test_home.py @@ -2490,3 +2490,22 @@ async def test_check_heat_cool_setpoints_accepts_in_range( zone.check_heat_cool_setpoints(heat_temperature=69, cool_temperature=78) # Boundary values (exactly at the limits) are allowed. zone.check_heat_cool_setpoints(heat_temperature=55, cool_temperature=99) + + +async def test_has_outdoor_temperature_returns_bool( + aiohttp_session: aiohttp.ClientSession, +) -> None: + """has_outdoor_temperature must honor its -> bool contract (py.typed). + + When the thermostat JSON omits the key it must return False, not None. + """ + nexia = NexiaHome(aiohttp_session) + + missing = NexiaThermostat(nexia, {"id": 1}) + assert missing.has_outdoor_temperature() is False + + present = NexiaThermostat(nexia, {"id": 2, "has_outdoor_temperature": True}) + assert present.has_outdoor_temperature() is True + + absent = NexiaThermostat(nexia, {"id": 3, "has_outdoor_temperature": False}) + assert absent.has_outdoor_temperature() is False