Skip to content

Commit

Permalink
perf: remove permanent true statement
Browse files Browse the repository at this point in the history
  • Loading branch information
SusanPhevos committed Dec 17, 2024
1 parent dbf9433 commit da58d4c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions custom_components/xiaomi_home/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,15 +255,15 @@ 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 hvac_mode == HVACMode.OFF:
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(
elif not self.get_prop_value(
prop=self._prop_on):
await self.set_property_async(prop=self._prop_on, value=True)
# set mode
Expand Down Expand Up @@ -372,7 +372,7 @@ def current_humidity(self) -> Optional[int]:
@ property
def hvac_mode(self) -> Optional[HVACMode]:
"""Return the hvac mode. e.g., heat, cool mode."""
if self._prop_on and self.get_prop_value(prop=self._prop_on) is False:
if not self.get_prop_value(prop=self._prop_on):
return HVACMode.OFF
return self.get_map_description(
map_=self._hvac_mode_map,
Expand Down

0 comments on commit da58d4c

Please sign in to comment.