Skip to content

Commit

Permalink
Remove redundant checks in async_set_fan_mode()
Browse files Browse the repository at this point in the history
self._attr_fan_modes already contains values rewritten to FAN_HIGH and
HVAC_FAN_MAX. `if fan_mode not in self._attr_fan_modes`, it's impossible
to fail the `fan_mode != FAN_HIGH and fan_mode != HVAC_FAN_MAX` check.

Also fix a typo: "swing mode" -> "fan mode".
  • Loading branch information
gentoo-root committed Aug 11, 2024
1 parent 1111d11 commit 8e4a1b7
Showing 1 changed file with 6 additions and 18 deletions.
24 changes: 6 additions & 18 deletions custom_components/tasmota_irhvac/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -933,24 +933,12 @@ async def async_set_temperature(self, **kwargs):
async def async_set_fan_mode(self, fan_mode):
"""Set new target fan mode."""
if fan_mode not in (self._attr_fan_modes or []):
# tweak for some ELECTRA_AC devices
if HVAC_FAN_MAX_HIGH in (
self._attr_fan_modes or []
) and HVAC_FAN_AUTO_MAX in (self._attr_fan_modes or []):
if fan_mode != FAN_HIGH and fan_mode != HVAC_FAN_MAX:
_LOGGER.error(
"Invalid swing mode selected. Got '%s'. Allowed modes are:",
fan_mode,
)
_LOGGER.error(self._attr_fan_modes)
return
else:
_LOGGER.error(
"Invalid swing mode selected. Got '%s'. Allowed modes are:",
fan_mode,
)
_LOGGER.error(self._attr_fan_modes)
return
_LOGGER.error(
"Invalid fan mode selected. Got '%s'. Allowed modes are:",
fan_mode,
)
_LOGGER.error(self._attr_fan_modes)
return
self._attr_fan_mode = fan_mode
if not self._attr_hvac_mode == HVACMode.OFF:
self.power_mode = STATE_ON
Expand Down

0 comments on commit 8e4a1b7

Please sign in to comment.