From 37240e811bd2655f77365cc0612b0163ddd08919 Mon Sep 17 00:00:00 2001 From: Antonio Larrosa <antonio.larrosa@gmail.com> Date: Mon, 24 Feb 2025 13:57:21 +0100 Subject: [PATCH] Add melcloud standard horizontal vane modes (#136654) Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> --- homeassistant/components/melcloud/climate.py | 22 ++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/homeassistant/components/melcloud/climate.py b/homeassistant/components/melcloud/climate.py index 03bb4babf1c..9c2ee60b12c 100644 --- a/homeassistant/components/melcloud/climate.py +++ b/homeassistant/components/melcloud/climate.py @@ -152,6 +152,14 @@ class AtaDeviceClimate(MelCloudClimate): self._attr_unique_id = f"{self.api.device.serial}-{self.api.device.mac}" self._attr_device_info = self.api.device_info + async def async_added_to_hass(self) -> None: + """When entity is added to hass.""" + await super().async_added_to_hass() + + # We can only check for vane_horizontal once we fetch the device data from the cloud + if self._device.vane_horizontal: + self._attr_supported_features |= ClimateEntityFeature.SWING_HORIZONTAL_MODE + @property def extra_state_attributes(self) -> dict[str, Any] | None: """Return the optional state attributes with device specific additions.""" @@ -274,15 +282,29 @@ class AtaDeviceClimate(MelCloudClimate): """Return vertical vane position or mode.""" return self._device.vane_vertical + @property + def swing_horizontal_mode(self) -> str | None: + """Return horizontal vane position or mode.""" + return self._device.vane_horizontal + async def async_set_swing_mode(self, swing_mode: str) -> None: """Set vertical vane position or mode.""" await self.async_set_vane_vertical(swing_mode) + async def async_set_swing_horizontal_mode(self, swing_horizontal_mode: str) -> None: + """Set horizontal vane position or mode.""" + await self.async_set_vane_horizontal(swing_horizontal_mode) + @property def swing_modes(self) -> list[str] | None: """Return a list of available vertical vane positions and modes.""" return self._device.vane_vertical_positions + @property + def swing_horizontal_modes(self) -> list[str] | None: + """Return a list of available horizontal vane positions and modes.""" + return self._device.vane_horizontal_positions + async def async_turn_on(self) -> None: """Turn the entity on.""" await self._device.set({"power": True}) -- GitLab