Skip to content
Draft
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
2 changes: 1 addition & 1 deletion nexia/thermostat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions tests/test_home.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading