Skip to content

Commit 577fa80

Browse files
committed
Use async_update to set horizontal swing as supported
Reimplement async_update in AtaDeviceClimate (from MelCloudClimate) so that when the device information is obtained from the cloud, we check if the device has horizontal vanes to mark SWING_HORIZONTAL_MODE as a supported feature. Note that we can't just check for self._device.vane_horizontal in __init__ since vane_horizontal is only set (or not) after the device data is fetched from the cloud.
1 parent 806ef64 commit 577fa80

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Diff for: homeassistant/components/melcloud/climate.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,14 @@ def __init__(self, device: MelCloudDevice, ata_device: AtaDevice) -> None:
150150
self._attr_unique_id = f"{self.api.device.serial}-{self.api.device.mac}"
151151
self._attr_device_info = self.api.device_info
152152

153+
async def async_update(self) -> None:
154+
"""Update state from MELCloud."""
155+
await super().async_update()
156+
157+
# We can only check for vane_horizontal once we fetch the device data from the cloud
158+
if self._device.vane_horizontal:
159+
self._attr_supported_features |= ClimateEntityFeature.SWING_HORIZONTAL_MODE
160+
153161
@property
154162
def extra_state_attributes(self) -> dict[str, Any] | None:
155163
"""Return the optional state attributes with device specific additions."""
@@ -162,7 +170,6 @@ def extra_state_attributes(self) -> dict[str, Any] | None:
162170
ATTR_VANE_HORIZONTAL_POSITIONS: self._device.vane_horizontal_positions,
163171
}
164172
)
165-
self._attr_supported_features |= ClimateEntityFeature.SWING_HORIZONTAL_MODE
166173

167174
if vane_vertical := self._device.vane_vertical:
168175
attr.update(

0 commit comments

Comments
 (0)