mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-04-27 17:16:24 +00:00
Add own device type for smartstrip children (#201)
This commit is contained in:
parent
2c83d8ee6d
commit
151976bb04
@ -16,7 +16,7 @@ import inspect
|
|||||||
import logging
|
import logging
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from enum import Enum
|
from enum import Enum, auto
|
||||||
from typing import Any, Dict, List, Optional
|
from typing import Any, Dict, List, Optional
|
||||||
|
|
||||||
from .exceptions import SmartDeviceException
|
from .exceptions import SmartDeviceException
|
||||||
@ -28,11 +28,12 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
class DeviceType(Enum):
|
class DeviceType(Enum):
|
||||||
"""Device type enum."""
|
"""Device type enum."""
|
||||||
|
|
||||||
Plug = 1
|
Plug = auto()
|
||||||
Bulb = 2
|
Bulb = auto()
|
||||||
Strip = 3
|
Strip = auto()
|
||||||
Dimmer = 4
|
StripSocket = auto()
|
||||||
LightStrip = 5
|
Dimmer = auto()
|
||||||
|
LightStrip = auto()
|
||||||
Unknown = -1
|
Unknown = -1
|
||||||
|
|
||||||
|
|
||||||
@ -743,6 +744,11 @@ class SmartDevice:
|
|||||||
"""Return True if the device is a strip."""
|
"""Return True if the device is a strip."""
|
||||||
return self._device_type == DeviceType.Strip
|
return self._device_type == DeviceType.Strip
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_strip_socket(self) -> bool:
|
||||||
|
"""Return True if the device is a strip socket."""
|
||||||
|
return self._device_type == DeviceType.StripSocket
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_dimmer(self) -> bool:
|
def is_dimmer(self) -> bool:
|
||||||
"""Return True if the device is a dimmer."""
|
"""Return True if the device is a dimmer."""
|
||||||
|
@ -211,6 +211,7 @@ class SmartStripPlug(SmartPlug):
|
|||||||
self.child_id = child_id
|
self.child_id = child_id
|
||||||
self._last_update = parent._last_update
|
self._last_update = parent._last_update
|
||||||
self._sys_info = parent._sys_info
|
self._sys_info = parent._sys_info
|
||||||
|
self._device_type = DeviceType.StripSocket
|
||||||
|
|
||||||
async def update(self):
|
async def update(self):
|
||||||
"""Override the update to no-op and inform the user."""
|
"""Override the update to no-op and inform the user."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user