Skip to content

Commit

Permalink
zone: API_SET_POINT is optional on some devices
Browse files Browse the repository at this point in the history
Some devices will stop providing API_SET_POINT when configured in fan_only mode.

Signed-off-by: Álvaro Fernández Rojas <[email protected]>
  • Loading branch information
Noltari committed Aug 10, 2023
1 parent d2fca5a commit b105ce8
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions aioairzone/zone.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def __init__(self, system_id: int, zone_id: int, zone_data: dict[str, Any]):
self.speeds: list[int] = []
self.system_id: int = system_id
self.system_zone_id: str = get_system_zone_id(system_id, zone_id)
self.temp_set: float
self.temp_set: float | None = None

self.name: str = f"Airzone {self.get_system_zone_id()}"

Expand All @@ -162,7 +162,6 @@ def update_data(self, zone_data: dict[str, Any]) -> None:
self.temp = float(zone_data[API_ROOM_TEMP])
self.temp_max = float(zone_data[API_MAX_TEMP])
self.temp_min = float(zone_data[API_MIN_TEMP])
self.temp_set = float(zone_data[API_SET_POINT])
self.temp_step: float | None = None
self.temp_unit = TemperatureUnit(zone_data[API_UNITS])
self.thermostat = Thermostat(zone_data)
Expand Down Expand Up @@ -259,6 +258,8 @@ def update_data(self, zone_data: dict[str, Any]) -> None:
speeds = int(zone_data[API_SPEEDS])
self.speeds = list(range(0, speeds + 1))

if API_SET_POINT in zone_data:
self.temp_set = float(zone_data[API_SET_POINT])
if API_TEMP_STEP in zone_data:
self.temp_step = float(zone_data[API_TEMP_STEP])
else:
Expand Down Expand Up @@ -286,7 +287,6 @@ def data(self) -> dict[str, Any]:
AZD_TEMP: self.get_temp(),
AZD_TEMP_MAX: self.get_temp_max(),
AZD_TEMP_MIN: self.get_temp_min(),
AZD_TEMP_SET: self.get_temp_set(),
AZD_TEMP_UNIT: self.get_temp_unit(),
}

Expand Down Expand Up @@ -384,6 +384,9 @@ def data(self) -> dict[str, Any]:
if modes is not None:
data[AZD_MODES] = modes

temp_set = self.get_temp_set()
if temp_set is not None:
data[AZD_TEMP_SET] = temp_set
temp_step = self.get_temp_step()
if temp_step is not None:
data[AZD_TEMP_STEP] = temp_step
Expand Down Expand Up @@ -694,9 +697,11 @@ def get_temp_min(self) -> float:
"""Return zone minimum temperature."""
return round(self.temp_min, 1)

def get_temp_set(self) -> float:
def get_temp_set(self) -> float | None:
"""Return zone set temperature."""
return round(self.temp_set, 1)
if self.temp_set is not None:
return round(self.temp_set, 1)
return None

def get_temp_step(self) -> float | None:
"""Return zone step temperature."""
Expand Down

0 comments on commit b105ce8

Please sign in to comment.