From bff5b3bf4455de3260642dded4655a41fa19d093 Mon Sep 17 00:00:00 2001 From: LiShuzhen Date: Tue, 17 Dec 2024 16:31:08 +0800 Subject: [PATCH] fix: air-conditioner switch on --- custom_components/xiaomi_home/climate.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/custom_components/xiaomi_home/climate.py b/custom_components/xiaomi_home/climate.py index 860afac..baedf61 100644 --- a/custom_components/xiaomi_home/climate.py +++ b/custom_components/xiaomi_home/climate.py @@ -254,6 +254,7 @@ class AirConditioner(MIoTServiceEntity, ClimateEntity): async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None: """Set new target hvac mode.""" + # set air-conditioner off if hvac_mode == HVACMode.OFF and self._prop_on: if not await self.set_property_async( prop=self._prop_on, value=False): @@ -261,6 +262,11 @@ class AirConditioner(MIoTServiceEntity, ClimateEntity): f'set climate prop.on failed, {hvac_mode}, ' f'{self.entity_id}') return + # set air-conditioner on + if hvac_mode != HVACMode.OFF and not self.get_prop_value( + prop=self._prop_on): + await self.async_turn_on() + # set mode mode_value = self.get_map_value( map_=self._hvac_mode_map, description=hvac_mode) if (