File tree Expand file tree Collapse file tree 4 files changed +14
-8
lines changed Expand file tree Collapse file tree 4 files changed +14
-8
lines changed Original file line number Diff line number Diff line change 7
7
8
8
from pydantic .v1 import BaseModel
9
9
10
+ from .device import Device
11
+
10
12
11
13
class ColorTempRange (NamedTuple ):
12
14
"""Color temperature range."""
@@ -40,7 +42,7 @@ class BulbPreset(BaseModel):
40
42
mode : Optional [int ] # noqa: UP007
41
43
42
44
43
- class Bulb (ABC ):
45
+ class Bulb (Device , ABC ):
44
46
"""Base class for TP-Link Bulb."""
45
47
46
48
def _raise_for_invalid_brightness (self , value ):
Original file line number Diff line number Diff line change @@ -245,6 +245,11 @@ def is_dimmable(self) -> bool:
245
245
"""Return True if the device is dimmable."""
246
246
return False
247
247
248
+ @property
249
+ def is_fan (self ) -> bool :
250
+ """Return True if the device is a fan."""
251
+ return self .device_type == DeviceType .Fan
252
+
248
253
@property
249
254
def is_variable_color_temp (self ) -> bool :
250
255
"""Return True if the device supports color temperature."""
Original file line number Diff line number Diff line change 4
4
5
5
from abc import ABC , abstractmethod
6
6
7
+ from .device import Device
7
8
8
- class Fan (ABC ):
9
- """Interface for a Fan."""
10
9
11
- @property
12
- @abstractmethod
13
- def is_fan (self ) -> bool :
14
- """Return True if the device is a fan."""
10
+ class Fan (Device , ABC ):
11
+ """Interface for a Fan."""
15
12
16
13
@property
17
14
@abstractmethod
Original file line number Diff line number Diff line change 46
46
}
47
47
48
48
49
- class SmartDevice (Device , Bulb , Fan ):
49
+ # Device must go last as the other interfaces also inherit Device
50
+ # and python needs a consistent method resolution order.
51
+ class SmartDevice (Bulb , Fan , Device ):
50
52
"""Base class to represent a SMART protocol based device."""
51
53
52
54
def __init__ (
You can’t perform that action at this time.
0 commit comments