Skip to content

Commit

Permalink
zhimi_miot: Rename fan_speed to speed (#1439)
Browse files Browse the repository at this point in the history
* Rename fan_speed to speed

* Fix import

* Test deprecation
  • Loading branch information
syssi authored Jun 19, 2022
1 parent 85e30f6 commit 27aab3f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
6 changes: 5 additions & 1 deletion miio/integrations/fan/zhimi/test_zhimi_miot.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def mode():

def test_set_speed(self):
def speed():
return self.device.status().fan_speed
return self.device.status().speed

for s in range(1, 101):
self.device.set_speed(s)
Expand All @@ -89,6 +89,10 @@ def speed():
with pytest.raises(FanException):
self.device.set_speed(s)

def test_fan_speed_deprecation(self):
with pytest.deprecated_call():
self.device.status().fan_speed

def test_set_angle(self):
def angle():
return self.device.status().angle
Expand Down
9 changes: 8 additions & 1 deletion miio/integrations/fan/zhimi/zhimi_miot.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from miio import DeviceStatus, MiotDevice
from miio.click_common import EnumType, command, format_output
from miio.fan_common import FanException, MoveDirection, OperationMode
from miio.utils import deprecated

MODEL_FAN_ZA5 = "zhimi.fan.za5"

Expand Down Expand Up @@ -107,8 +108,14 @@ def fan_level(self) -> int:
"""Fan level (1-4)."""
return self.data["fan_level"]

@property
@property # type: ignore
@deprecated("Use speed()")
def fan_speed(self) -> int:
"""Fan speed (1-100)."""
return self.speed

@property
def speed(self) -> int:
"""Fan speed (1-100)."""
return self.data["fan_speed"]

Expand Down

0 comments on commit 27aab3f

Please sign in to comment.