2019-11-11 21:14:34 +00:00
|
|
|
"""Python interface for TP-Link's smart home devices.
|
2017-05-26 14:11:03 +00:00
|
|
|
|
|
|
|
All common, shared functionalities are available through `SmartDevice` class::
|
|
|
|
|
|
|
|
x = SmartDevice("192.168.1.1")
|
|
|
|
print(x.sys_info)
|
|
|
|
|
2019-11-11 21:14:34 +00:00
|
|
|
For device type specific actions `SmartBulb`, `SmartPlug`, or `SmartStrip`
|
|
|
|
should be used instead.
|
2017-05-26 14:11:03 +00:00
|
|
|
|
|
|
|
Module-specific errors are raised as `SmartDeviceException` and are expected
|
|
|
|
to be handled by the user of the library.
|
|
|
|
"""
|
2023-05-17 18:33:02 +00:00
|
|
|
from importlib.metadata import version
|
2024-01-26 09:11:31 +00:00
|
|
|
from warnings import warn
|
2021-03-18 18:22:10 +00:00
|
|
|
|
2023-09-13 13:46:38 +00:00
|
|
|
from kasa.credentials import Credentials
|
2023-12-29 19:17:15 +00:00
|
|
|
from kasa.deviceconfig import (
|
|
|
|
ConnectionType,
|
|
|
|
DeviceConfig,
|
|
|
|
DeviceFamilyType,
|
|
|
|
EncryptType,
|
|
|
|
)
|
2019-12-18 08:11:18 +00:00
|
|
|
from kasa.discover import Discover
|
2021-09-23 15:58:19 +00:00
|
|
|
from kasa.emeterstatus import EmeterStatus
|
2023-09-13 13:46:38 +00:00
|
|
|
from kasa.exceptions import (
|
|
|
|
AuthenticationException,
|
|
|
|
SmartDeviceException,
|
2024-01-11 15:13:44 +00:00
|
|
|
TimeoutException,
|
2023-09-13 13:46:38 +00:00
|
|
|
UnsupportedDeviceException,
|
|
|
|
)
|
2024-01-26 09:11:31 +00:00
|
|
|
from kasa.iotprotocol import (
|
|
|
|
IotProtocol,
|
|
|
|
_deprecated_TPLinkSmartHomeProtocol, # noqa: F401
|
|
|
|
)
|
|
|
|
from kasa.protocol import BaseProtocol
|
2022-10-27 15:40:54 +00:00
|
|
|
from kasa.smartbulb import SmartBulb, SmartBulbPreset, TurnOnBehavior, TurnOnBehaviors
|
2021-09-23 15:58:19 +00:00
|
|
|
from kasa.smartdevice import DeviceType, SmartDevice
|
2020-04-18 21:35:39 +00:00
|
|
|
from kasa.smartdimmer import SmartDimmer
|
2020-07-19 20:32:17 +00:00
|
|
|
from kasa.smartlightstrip import SmartLightStrip
|
2019-12-18 08:11:18 +00:00
|
|
|
from kasa.smartplug import SmartPlug
|
2023-12-04 18:50:05 +00:00
|
|
|
from kasa.smartprotocol import SmartProtocol
|
2019-12-18 08:11:18 +00:00
|
|
|
from kasa.smartstrip import SmartStrip
|
2019-11-11 18:26:06 +00:00
|
|
|
|
2020-05-12 10:11:47 +00:00
|
|
|
__version__ = version("python-kasa")
|
|
|
|
|
|
|
|
|
2019-11-11 18:26:06 +00:00
|
|
|
__all__ = [
|
|
|
|
"Discover",
|
2024-01-22 15:28:30 +00:00
|
|
|
"BaseProtocol",
|
2023-12-04 18:50:05 +00:00
|
|
|
"IotProtocol",
|
|
|
|
"SmartProtocol",
|
2019-11-11 18:26:06 +00:00
|
|
|
"SmartBulb",
|
2022-10-22 22:15:47 +00:00
|
|
|
"SmartBulbPreset",
|
2022-10-27 15:40:54 +00:00
|
|
|
"TurnOnBehaviors",
|
|
|
|
"TurnOnBehavior",
|
2019-11-11 18:26:06 +00:00
|
|
|
"DeviceType",
|
|
|
|
"EmeterStatus",
|
|
|
|
"SmartDevice",
|
|
|
|
"SmartDeviceException",
|
|
|
|
"SmartPlug",
|
|
|
|
"SmartStrip",
|
2020-04-18 21:35:39 +00:00
|
|
|
"SmartDimmer",
|
2020-07-19 20:32:17 +00:00
|
|
|
"SmartLightStrip",
|
2023-09-13 13:46:38 +00:00
|
|
|
"AuthenticationException",
|
|
|
|
"UnsupportedDeviceException",
|
2024-01-11 15:13:44 +00:00
|
|
|
"TimeoutException",
|
2023-09-13 13:46:38 +00:00
|
|
|
"Credentials",
|
2023-12-29 19:17:15 +00:00
|
|
|
"DeviceConfig",
|
|
|
|
"ConnectionType",
|
|
|
|
"EncryptType",
|
|
|
|
"DeviceFamilyType",
|
2019-11-11 18:26:06 +00:00
|
|
|
]
|
2024-01-26 09:11:31 +00:00
|
|
|
|
|
|
|
deprecated_names = ["TPLinkSmartHomeProtocol"]
|
|
|
|
|
|
|
|
|
|
|
|
def __getattr__(name):
|
|
|
|
if name in deprecated_names:
|
|
|
|
warn(f"{name} is deprecated", DeprecationWarning, stacklevel=1)
|
|
|
|
return globals()[f"_deprecated_{name}"]
|
|
|
|
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|