mirror of
https://github.com/home-assistant/core.git
synced 2025-07-26 22:57:17 +00:00
Update Airzone Cloud to v0.5.2 and add fan speeds to Zones (#119314)
* Update aioairzone-cloud to v0.5.2 * airzone_cloud: climate: add zone fan speeds support Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
This commit is contained in:
parent
b30a924e03
commit
632f136c02
@ -193,6 +193,12 @@ class AirzoneClimate(AirzoneEntity, ClimateEntity):
|
|||||||
ClimateEntityFeature.TARGET_TEMPERATURE_RANGE
|
ClimateEntityFeature.TARGET_TEMPERATURE_RANGE
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (
|
||||||
|
self.get_airzone_value(AZD_SPEED) is not None
|
||||||
|
and self.get_airzone_value(AZD_SPEEDS) is not None
|
||||||
|
):
|
||||||
|
self._initialize_fan_speeds()
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def _handle_coordinator_update(self) -> None:
|
def _handle_coordinator_update(self) -> None:
|
||||||
"""Update attributes when the coordinator updates."""
|
"""Update attributes when the coordinator updates."""
|
||||||
@ -207,6 +213,8 @@ class AirzoneClimate(AirzoneEntity, ClimateEntity):
|
|||||||
self._attr_hvac_action = HVAC_ACTION_LIB_TO_HASS[
|
self._attr_hvac_action = HVAC_ACTION_LIB_TO_HASS[
|
||||||
self.get_airzone_value(AZD_ACTION)
|
self.get_airzone_value(AZD_ACTION)
|
||||||
]
|
]
|
||||||
|
if self.supported_features & ClimateEntityFeature.FAN_MODE:
|
||||||
|
self._attr_fan_mode = self._speeds.get(self.get_airzone_value(AZD_SPEED))
|
||||||
if self.get_airzone_value(AZD_POWER):
|
if self.get_airzone_value(AZD_POWER):
|
||||||
self._attr_hvac_mode = HVAC_MODE_LIB_TO_HASS[
|
self._attr_hvac_mode = HVAC_MODE_LIB_TO_HASS[
|
||||||
self.get_airzone_value(AZD_MODE)
|
self.get_airzone_value(AZD_MODE)
|
||||||
@ -234,6 +242,37 @@ class AirzoneDeviceClimate(AirzoneClimate):
|
|||||||
| ClimateEntityFeature.TURN_OFF
|
| ClimateEntityFeature.TURN_OFF
|
||||||
| ClimateEntityFeature.TURN_ON
|
| ClimateEntityFeature.TURN_ON
|
||||||
)
|
)
|
||||||
|
_speeds: dict[int, str]
|
||||||
|
_speeds_reverse: dict[str, int]
|
||||||
|
|
||||||
|
def _initialize_fan_speeds(self) -> None:
|
||||||
|
"""Initialize fan speeds."""
|
||||||
|
azd_speeds: dict[int, int] = self.get_airzone_value(AZD_SPEEDS)
|
||||||
|
max_speed = max(azd_speeds)
|
||||||
|
|
||||||
|
fan_speeds: dict[int, str]
|
||||||
|
if speeds_map := FAN_SPEED_MAPS.get(max_speed):
|
||||||
|
fan_speeds = speeds_map
|
||||||
|
else:
|
||||||
|
fan_speeds = {}
|
||||||
|
|
||||||
|
for speed in azd_speeds:
|
||||||
|
if speed != 0:
|
||||||
|
fan_speeds[speed] = f"{int(round((speed * 100) / max_speed, 0))}%"
|
||||||
|
|
||||||
|
if 0 in azd_speeds:
|
||||||
|
fan_speeds = FAN_SPEED_AUTO | fan_speeds
|
||||||
|
|
||||||
|
self._speeds = {}
|
||||||
|
for key, value in fan_speeds.items():
|
||||||
|
_key = azd_speeds.get(key)
|
||||||
|
if _key is not None:
|
||||||
|
self._speeds[_key] = value
|
||||||
|
|
||||||
|
self._speeds_reverse = {v: k for k, v in self._speeds.items()}
|
||||||
|
self._attr_fan_modes = list(self._speeds_reverse)
|
||||||
|
|
||||||
|
self._attr_supported_features |= ClimateEntityFeature.FAN_MODE
|
||||||
|
|
||||||
async def async_turn_on(self) -> None:
|
async def async_turn_on(self) -> None:
|
||||||
"""Turn the entity on."""
|
"""Turn the entity on."""
|
||||||
@ -253,6 +292,15 @@ class AirzoneDeviceClimate(AirzoneClimate):
|
|||||||
}
|
}
|
||||||
await self._async_update_params(params)
|
await self._async_update_params(params)
|
||||||
|
|
||||||
|
async def async_set_fan_mode(self, fan_mode: str) -> None:
|
||||||
|
"""Set new fan mode."""
|
||||||
|
params: dict[str, Any] = {
|
||||||
|
API_SPEED_CONF: {
|
||||||
|
API_VALUE: self._speeds_reverse.get(fan_mode),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await self._async_update_params(params)
|
||||||
|
|
||||||
async def async_set_temperature(self, **kwargs: Any) -> None:
|
async def async_set_temperature(self, **kwargs: Any) -> None:
|
||||||
"""Set new target temperature."""
|
"""Set new target temperature."""
|
||||||
params: dict[str, Any] = {}
|
params: dict[str, Any] = {}
|
||||||
@ -341,9 +389,6 @@ class AirzoneDeviceGroupClimate(AirzoneClimate):
|
|||||||
class AirzoneAidooClimate(AirzoneAidooEntity, AirzoneDeviceClimate):
|
class AirzoneAidooClimate(AirzoneAidooEntity, AirzoneDeviceClimate):
|
||||||
"""Define an Airzone Cloud Aidoo climate."""
|
"""Define an Airzone Cloud Aidoo climate."""
|
||||||
|
|
||||||
_speeds: dict[int, str]
|
|
||||||
_speeds_reverse: dict[str, int]
|
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
coordinator: AirzoneUpdateCoordinator,
|
coordinator: AirzoneUpdateCoordinator,
|
||||||
@ -355,52 +400,9 @@ class AirzoneAidooClimate(AirzoneAidooEntity, AirzoneDeviceClimate):
|
|||||||
|
|
||||||
self._attr_unique_id = aidoo_id
|
self._attr_unique_id = aidoo_id
|
||||||
self._init_attributes()
|
self._init_attributes()
|
||||||
if (
|
|
||||||
self.get_airzone_value(AZD_SPEED) is not None
|
|
||||||
and self.get_airzone_value(AZD_SPEEDS) is not None
|
|
||||||
):
|
|
||||||
self._initialize_fan_speeds()
|
|
||||||
|
|
||||||
self._async_update_attrs()
|
self._async_update_attrs()
|
||||||
|
|
||||||
def _initialize_fan_speeds(self) -> None:
|
|
||||||
"""Initialize Aidoo fan speeds."""
|
|
||||||
azd_speeds: dict[int, int] = self.get_airzone_value(AZD_SPEEDS)
|
|
||||||
max_speed = max(azd_speeds)
|
|
||||||
|
|
||||||
fan_speeds: dict[int, str]
|
|
||||||
if speeds_map := FAN_SPEED_MAPS.get(max_speed):
|
|
||||||
fan_speeds = speeds_map
|
|
||||||
else:
|
|
||||||
fan_speeds = {}
|
|
||||||
|
|
||||||
for speed in azd_speeds:
|
|
||||||
if speed != 0:
|
|
||||||
fan_speeds[speed] = f"{int(round((speed * 100) / max_speed, 0))}%"
|
|
||||||
|
|
||||||
if 0 in azd_speeds:
|
|
||||||
fan_speeds = FAN_SPEED_AUTO | fan_speeds
|
|
||||||
|
|
||||||
self._speeds = {}
|
|
||||||
for key, value in fan_speeds.items():
|
|
||||||
_key = azd_speeds.get(key)
|
|
||||||
if _key is not None:
|
|
||||||
self._speeds[_key] = value
|
|
||||||
|
|
||||||
self._speeds_reverse = {v: k for k, v in self._speeds.items()}
|
|
||||||
self._attr_fan_modes = list(self._speeds_reverse)
|
|
||||||
|
|
||||||
self._attr_supported_features |= ClimateEntityFeature.FAN_MODE
|
|
||||||
|
|
||||||
async def async_set_fan_mode(self, fan_mode: str) -> None:
|
|
||||||
"""Set Aidoo fan mode."""
|
|
||||||
params: dict[str, Any] = {
|
|
||||||
API_SPEED_CONF: {
|
|
||||||
API_VALUE: self._speeds_reverse.get(fan_mode),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
await self._async_update_params(params)
|
|
||||||
|
|
||||||
async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
|
async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
|
||||||
"""Set hvac mode."""
|
"""Set hvac mode."""
|
||||||
params: dict[str, Any] = {}
|
params: dict[str, Any] = {}
|
||||||
@ -418,14 +420,6 @@ class AirzoneAidooClimate(AirzoneAidooEntity, AirzoneDeviceClimate):
|
|||||||
}
|
}
|
||||||
await self._async_update_params(params)
|
await self._async_update_params(params)
|
||||||
|
|
||||||
@callback
|
|
||||||
def _async_update_attrs(self) -> None:
|
|
||||||
"""Update Aidoo climate attributes."""
|
|
||||||
super()._async_update_attrs()
|
|
||||||
|
|
||||||
if self.supported_features & ClimateEntityFeature.FAN_MODE:
|
|
||||||
self._attr_fan_mode = self._speeds.get(self.get_airzone_value(AZD_SPEED))
|
|
||||||
|
|
||||||
|
|
||||||
class AirzoneGroupClimate(AirzoneGroupEntity, AirzoneDeviceGroupClimate):
|
class AirzoneGroupClimate(AirzoneGroupEntity, AirzoneDeviceGroupClimate):
|
||||||
"""Define an Airzone Cloud Group climate."""
|
"""Define an Airzone Cloud Group climate."""
|
||||||
|
@ -6,5 +6,5 @@
|
|||||||
"documentation": "https://www.home-assistant.io/integrations/airzone_cloud",
|
"documentation": "https://www.home-assistant.io/integrations/airzone_cloud",
|
||||||
"iot_class": "cloud_push",
|
"iot_class": "cloud_push",
|
||||||
"loggers": ["aioairzone_cloud"],
|
"loggers": ["aioairzone_cloud"],
|
||||||
"requirements": ["aioairzone-cloud==0.5.1"]
|
"requirements": ["aioairzone-cloud==0.5.2"]
|
||||||
}
|
}
|
||||||
|
@ -179,7 +179,7 @@ aio-georss-gdacs==0.9
|
|||||||
aioairq==0.3.2
|
aioairq==0.3.2
|
||||||
|
|
||||||
# homeassistant.components.airzone_cloud
|
# homeassistant.components.airzone_cloud
|
||||||
aioairzone-cloud==0.5.1
|
aioairzone-cloud==0.5.2
|
||||||
|
|
||||||
# homeassistant.components.airzone
|
# homeassistant.components.airzone
|
||||||
aioairzone==0.7.6
|
aioairzone==0.7.6
|
||||||
|
@ -158,7 +158,7 @@ aio-georss-gdacs==0.9
|
|||||||
aioairq==0.3.2
|
aioairq==0.3.2
|
||||||
|
|
||||||
# homeassistant.components.airzone_cloud
|
# homeassistant.components.airzone_cloud
|
||||||
aioairzone-cloud==0.5.1
|
aioairzone-cloud==0.5.2
|
||||||
|
|
||||||
# homeassistant.components.airzone
|
# homeassistant.components.airzone
|
||||||
aioairzone==0.7.6
|
aioairzone==0.7.6
|
||||||
|
Loading…
x
Reference in New Issue
Block a user