From 151976bb043a07085f5fc20e297312721192882c Mon Sep 17 00:00:00 2001 From: Teemu R Date: Tue, 21 Sep 2021 13:25:14 +0200 Subject: [PATCH] Add own device type for smartstrip children (#201) --- kasa/smartdevice.py | 18 ++++++++++++------ kasa/smartstrip.py | 1 + 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/kasa/smartdevice.py b/kasa/smartdevice.py index 44eff056..fa227358 100755 --- a/kasa/smartdevice.py +++ b/kasa/smartdevice.py @@ -16,7 +16,7 @@ import inspect import logging from dataclasses import dataclass from datetime import datetime, timedelta -from enum import Enum +from enum import Enum, auto from typing import Any, Dict, List, Optional from .exceptions import SmartDeviceException @@ -28,11 +28,12 @@ _LOGGER = logging.getLogger(__name__) class DeviceType(Enum): """Device type enum.""" - Plug = 1 - Bulb = 2 - Strip = 3 - Dimmer = 4 - LightStrip = 5 + Plug = auto() + Bulb = auto() + Strip = auto() + StripSocket = auto() + Dimmer = auto() + LightStrip = auto() Unknown = -1 @@ -743,6 +744,11 @@ class SmartDevice: """Return True if the device is a 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 def is_dimmer(self) -> bool: """Return True if the device is a dimmer.""" diff --git a/kasa/smartstrip.py b/kasa/smartstrip.py index a052c0d0..a5351c5b 100755 --- a/kasa/smartstrip.py +++ b/kasa/smartstrip.py @@ -211,6 +211,7 @@ class SmartStripPlug(SmartPlug): self.child_id = child_id self._last_update = parent._last_update self._sys_info = parent._sys_info + self._device_type = DeviceType.StripSocket async def update(self): """Override the update to no-op and inform the user."""