Skip to content

Commit

Permalink
fix: air-conditioner switch on
Browse files Browse the repository at this point in the history
  • Loading branch information
SusanPhevos committed Dec 17, 2024
1 parent 507018d commit bff5b3b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions custom_components/xiaomi_home/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,13 +254,19 @@ async def async_turn_off(self) -> None:

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):
raise RuntimeError(
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 (
Expand Down

0 comments on commit bff5b3b

Please sign in to comment.