2023-11-30 12:10:49 +00:00
|
|
|
"""Module for a TAPO Plug."""
|
|
|
|
import logging
|
2024-02-04 15:20:08 +00:00
|
|
|
from typing import Any, Dict, Optional
|
2023-11-30 12:10:49 +00:00
|
|
|
|
2024-02-04 15:20:08 +00:00
|
|
|
from ..device_type import DeviceType
|
2023-12-29 19:17:15 +00:00
|
|
|
from ..deviceconfig import DeviceConfig
|
2024-02-04 15:20:08 +00:00
|
|
|
from ..plug import Plug
|
2024-01-29 16:11:29 +00:00
|
|
|
from ..smartprotocol import SmartProtocol
|
2024-02-04 15:20:08 +00:00
|
|
|
from .smartdevice import SmartDevice
|
2023-11-30 12:10:49 +00:00
|
|
|
|
|
|
|
_LOGGER = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
2024-02-04 15:20:08 +00:00
|
|
|
class SmartPlug(SmartDevice, Plug):
|
2023-11-30 12:10:49 +00:00
|
|
|
"""Class to represent a TAPO Plug."""
|
|
|
|
|
|
|
|
def __init__(
|
|
|
|
self,
|
|
|
|
host: str,
|
|
|
|
*,
|
2023-12-29 19:17:15 +00:00
|
|
|
config: Optional[DeviceConfig] = None,
|
2024-01-29 16:11:29 +00:00
|
|
|
protocol: Optional[SmartProtocol] = None,
|
2023-11-30 12:10:49 +00:00
|
|
|
) -> None:
|
2023-12-29 19:17:15 +00:00
|
|
|
super().__init__(host=host, config=config, protocol=protocol)
|
2023-11-30 12:10:49 +00:00
|
|
|
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"),
|
|
|
|
},
|
|
|
|
}
|