1
mirror of https://github.com/home-assistant/core synced 2024-08-28 03:36:46 +02:00

Introduce heat area property in moehlenhoff alpha2 (#107488)

This commit is contained in:
Joost Lekkerkerker 2024-01-08 08:17:28 +01:00 committed by GitHub
parent 8b0c96a212
commit eaac01bc76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -35,7 +35,6 @@ async def async_setup_entry(
) )
# https://developers.home-assistant.io/docs/core/entity/climate/
class Alpha2Climate(CoordinatorEntity[Alpha2BaseCoordinator], ClimateEntity): class Alpha2Climate(CoordinatorEntity[Alpha2BaseCoordinator], ClimateEntity):
"""Alpha2 ClimateEntity.""" """Alpha2 ClimateEntity."""
@ -53,34 +52,27 @@ class Alpha2Climate(CoordinatorEntity[Alpha2BaseCoordinator], ClimateEntity):
super().__init__(coordinator) super().__init__(coordinator)
self.heat_area_id = heat_area_id self.heat_area_id = heat_area_id
self._attr_unique_id = heat_area_id self._attr_unique_id = heat_area_id
self._attr_name = self.coordinator.data["heat_areas"][heat_area_id][ self._attr_name = self.heat_area["HEATAREA_NAME"]
"HEATAREA_NAME"
] @property
def heat_area(self) -> dict[str, Any]:
"""Return the heat area."""
return self.coordinator.data["heat_areas"][self.heat_area_id]
@property @property
def min_temp(self) -> float: def min_temp(self) -> float:
"""Return the minimum temperature.""" """Return the minimum temperature."""
return float( return float(self.heat_area.get("T_TARGET_MIN", 0.0))
self.coordinator.data["heat_areas"][self.heat_area_id].get(
"T_TARGET_MIN", 0.0
)
)
@property @property
def max_temp(self) -> float: def max_temp(self) -> float:
"""Return the maximum temperature.""" """Return the maximum temperature."""
return float( return float(self.heat_area.get("T_TARGET_MAX", 30.0))
self.coordinator.data["heat_areas"][self.heat_area_id].get(
"T_TARGET_MAX", 30.0
)
)
@property @property
def current_temperature(self) -> float: def current_temperature(self) -> float:
"""Return the current temperature.""" """Return the current temperature."""
return float( return float(self.heat_area.get("T_ACTUAL", 0.0))
self.coordinator.data["heat_areas"][self.heat_area_id].get("T_ACTUAL", 0.0)
)
@property @property
def hvac_mode(self) -> HVACMode: def hvac_mode(self) -> HVACMode:
@ -96,9 +88,7 @@ class Alpha2Climate(CoordinatorEntity[Alpha2BaseCoordinator], ClimateEntity):
@property @property
def hvac_action(self) -> HVACAction: def hvac_action(self) -> HVACAction:
"""Return the current running hvac operation.""" """Return the current running hvac operation."""
if not self.coordinator.data["heat_areas"][self.heat_area_id][ if not self.heat_area["_HEATCTRL_STATE"]:
"_HEATCTRL_STATE"
]:
return HVACAction.IDLE return HVACAction.IDLE
if self.coordinator.get_cooling(): if self.coordinator.get_cooling():
return HVACAction.COOLING return HVACAction.COOLING
@ -107,9 +97,7 @@ class Alpha2Climate(CoordinatorEntity[Alpha2BaseCoordinator], ClimateEntity):
@property @property
def target_temperature(self) -> float: def target_temperature(self) -> float:
"""Return the temperature we try to reach.""" """Return the temperature we try to reach."""
return float( return float(self.heat_area.get("T_TARGET", 0.0))
self.coordinator.data["heat_areas"][self.heat_area_id].get("T_TARGET", 0.0)
)
async def async_set_temperature(self, **kwargs: Any) -> None: async def async_set_temperature(self, **kwargs: Any) -> None:
"""Set new target temperatures.""" """Set new target temperatures."""
@ -123,9 +111,9 @@ class Alpha2Climate(CoordinatorEntity[Alpha2BaseCoordinator], ClimateEntity):
@property @property
def preset_mode(self) -> str: def preset_mode(self) -> str:
"""Return the current preset mode.""" """Return the current preset mode."""
if self.coordinator.data["heat_areas"][self.heat_area_id]["HEATAREA_MODE"] == 1: if self.heat_area["HEATAREA_MODE"] == 1:
return PRESET_DAY return PRESET_DAY
if self.coordinator.data["heat_areas"][self.heat_area_id]["HEATAREA_MODE"] == 2: if self.heat_area["HEATAREA_MODE"] == 2:
return PRESET_NIGHT return PRESET_NIGHT
return PRESET_AUTO return PRESET_AUTO