Skip to content

Commit

Permalink
Report more specific exception when airdehumidifer is off (rytilahti#963
Browse files Browse the repository at this point in the history
)

* Also, fix incorrect variable use for cli
* Fixes rytilahti#960
  • Loading branch information
rytilahti authored and xvlady committed May 9, 2021
1 parent bd587b8 commit fcf26bc
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions miio/airdehumidifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,19 @@ def set_mode(self, mode: OperationMode):

@command(
click.argument("fan_speed", type=EnumType(FanSpeed)),
default_output=format_output("Setting fan level to {fan_level}"),
default_output=format_output("Setting fan level to {fan_speed}"),
)
def set_fan_speed(self, fan_speed: FanSpeed):
"""Set the fan speed."""
return self.send("set_fan_level", [fan_speed.value])
try:
return self.send("set_fan_level", [fan_speed.value])
except DeviceError as ex:
if ex.code == -10000:
raise AirDehumidifierException(
"Unable to set fan speed, this can happen if device is turned off."
) from ex

raise

@command(
click.argument("led", type=bool),
Expand Down

0 comments on commit fcf26bc

Please sign in to comment.