mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-08-06 18:54:08 +00:00
Remove SmartPlug in favor of SmartDevice (#781)
With the move towards autodetecting available features, there is no reason to keep SmartPlug around. kasa.smart.SmartPlug is removed in favor of kasa.smart.SmartDevice which offers the same functionality. Information about auto_off can be accessed using Features of the AutoOffModule on supported devices. Co-authored-by: Steven B. <51370195+sdb9696@users.noreply.github.com>
This commit is contained in:
@@ -2,6 +2,5 @@
|
||||
from .smartbulb import SmartBulb
|
||||
from .smartchilddevice import SmartChildDevice
|
||||
from .smartdevice import SmartDevice
|
||||
from .smartplug import SmartPlug
|
||||
|
||||
__all__ = ["SmartDevice", "SmartPlug", "SmartBulb", "SmartChildDevice"]
|
||||
__all__ = ["SmartDevice", "SmartBulb", "SmartChildDevice"]
|
||||
|
@@ -485,3 +485,28 @@ class SmartDevice(Device):
|
||||
Note, this does not downgrade the firmware.
|
||||
"""
|
||||
await self.protocol.query("device_reset")
|
||||
|
||||
@property
|
||||
def device_type(self) -> DeviceType:
|
||||
"""Return the device type."""
|
||||
if self._device_type is not DeviceType.Unknown:
|
||||
return self._device_type
|
||||
|
||||
if self.children:
|
||||
if "SMART.TAPOHUB" in self.sys_info["type"]:
|
||||
pass # TODO: placeholder for future hub PR
|
||||
else:
|
||||
self._device_type = DeviceType.Strip
|
||||
elif "light_strip" in self._components:
|
||||
self._device_type = DeviceType.LightStrip
|
||||
elif "dimmer_calibration" in self._components:
|
||||
self._device_type = DeviceType.Dimmer
|
||||
elif "brightness" in self._components:
|
||||
self._device_type = DeviceType.Bulb
|
||||
elif "PLUG" in self.sys_info["type"]:
|
||||
self._device_type = DeviceType.Plug
|
||||
else:
|
||||
_LOGGER.warning("Unknown device type, falling back to plug")
|
||||
self._device_type = DeviceType.Plug
|
||||
|
||||
return self._device_type
|
||||
|
@@ -1,37 +0,0 @@
|
||||
"""Module for a TAPO Plug."""
|
||||
import logging
|
||||
from typing import Any, Dict, Optional
|
||||
|
||||
from ..device_type import DeviceType
|
||||
from ..deviceconfig import DeviceConfig
|
||||
from ..plug import Plug
|
||||
from ..smartprotocol import SmartProtocol
|
||||
from .smartdevice import SmartDevice
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class SmartPlug(SmartDevice, Plug):
|
||||
"""Class to represent a TAPO Plug."""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
host: str,
|
||||
*,
|
||||
config: Optional[DeviceConfig] = None,
|
||||
protocol: Optional[SmartProtocol] = None,
|
||||
) -> None:
|
||||
super().__init__(host=host, config=config, protocol=protocol)
|
||||
self._device_type = DeviceType.Plug
|
||||
|
||||
@property
|
||||
def state_information(self) -> Dict[str, Any]:
|
||||
"""Return the key state information."""
|
||||
return {
|
||||
**super().state_information,
|
||||
**{
|
||||
"On since": self.on_since,
|
||||
"auto_off_status": self._info.get("auto_off_status"),
|
||||
"auto_off_remain_time": self._info.get("auto_off_remain_time"),
|
||||
},
|
||||
}
|
Reference in New Issue
Block a user