python-kasa 0.8.1__py3-none-any.whl → 0.9.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- kasa/__init__.py +4 -1
- kasa/cli/common.py +17 -0
- kasa/cli/device.py +8 -2
- kasa/cli/discover.py +70 -13
- kasa/cli/light.py +9 -5
- kasa/cli/main.py +1 -0
- kasa/credentials.py +1 -0
- kasa/device.py +17 -5
- kasa/device_factory.py +28 -3
- kasa/device_type.py +1 -0
- kasa/deviceconfig.py +2 -0
- kasa/discover.py +134 -35
- kasa/exceptions.py +1 -0
- kasa/feature.py +3 -1
- kasa/httpclient.py +16 -3
- kasa/interfaces/light.py +7 -6
- kasa/interfaces/lighteffect.py +1 -2
- kasa/iot/__init__.py +2 -0
- kasa/iot/iotcamera.py +42 -0
- kasa/iot/iotdevice.py +33 -22
- kasa/iot/modules/light.py +16 -14
- kasa/iot/modules/lightpreset.py +10 -8
- kasa/json.py +10 -4
- kasa/module.py +7 -0
- kasa/protocols/__init__.py +2 -0
- kasa/protocols/iotprotocol.py +31 -1
- kasa/protocols/protocol.py +2 -0
- kasa/protocols/smartcamprotocol.py +12 -7
- kasa/protocols/smartprotocol.py +81 -24
- kasa/smart/modules/__init__.py +6 -0
- kasa/smart/modules/contactsensor.py +1 -1
- kasa/smart/modules/energy.py +45 -23
- kasa/smart/modules/homekit.py +32 -0
- kasa/smart/modules/light.py +12 -11
- kasa/smart/modules/lightpreset.py +9 -4
- kasa/smart/modules/matter.py +43 -0
- kasa/smart/modules/overheatprotection.py +41 -0
- kasa/smart/smartchilddevice.py +24 -5
- kasa/smart/smartdevice.py +34 -47
- kasa/smart/smartmodule.py +38 -7
- kasa/smartcam/modules/__init__.py +14 -0
- kasa/smartcam/modules/babycrydetection.py +47 -0
- kasa/smartcam/modules/camera.py +57 -29
- kasa/smartcam/modules/device.py +44 -1
- kasa/smartcam/modules/homekit.py +16 -0
- kasa/smartcam/modules/lensmask.py +31 -0
- kasa/smartcam/modules/matter.py +44 -0
- kasa/smartcam/modules/motiondetection.py +47 -0
- kasa/smartcam/modules/persondetection.py +47 -0
- kasa/smartcam/modules/tamperdetection.py +47 -0
- kasa/smartcam/smartcamdevice.py +32 -24
- kasa/smartcam/smartcammodule.py +20 -3
- kasa/transports/__init__.py +6 -0
- kasa/transports/klaptransport.py +8 -5
- kasa/transports/linkietransport.py +143 -0
- kasa/transports/sslaestransport.py +205 -17
- kasa/transports/ssltransport.py +233 -0
- kasa/transports/xortransport.py +13 -0
- {python_kasa-0.8.1.dist-info → python_kasa-0.9.1.dist-info}/METADATA +13 -6
- {python_kasa-0.8.1.dist-info → python_kasa-0.9.1.dist-info}/RECORD +63 -50
- {python_kasa-0.8.1.dist-info → python_kasa-0.9.1.dist-info}/WHEEL +1 -1
- {python_kasa-0.8.1.dist-info → python_kasa-0.9.1.dist-info}/entry_points.txt +0 -0
- {python_kasa-0.8.1.dist-info → python_kasa-0.9.1.dist-info}/licenses/LICENSE +0 -0
kasa/__init__.py
CHANGED
|
@@ -38,8 +38,9 @@ from kasa.feature import Feature
|
|
|
38
38
|
from kasa.interfaces.light import HSV, ColorTempRange, Light, LightState
|
|
39
39
|
from kasa.interfaces.thermostat import Thermostat, ThermostatState
|
|
40
40
|
from kasa.module import Module
|
|
41
|
-
from kasa.protocols import BaseProtocol, IotProtocol, SmartProtocol
|
|
41
|
+
from kasa.protocols import BaseProtocol, IotProtocol, SmartCamProtocol, SmartProtocol
|
|
42
42
|
from kasa.protocols.iotprotocol import _deprecated_TPLinkSmartHomeProtocol # noqa: F401
|
|
43
|
+
from kasa.smartcam.modules.camera import StreamResolution
|
|
43
44
|
from kasa.transports import BaseTransport
|
|
44
45
|
|
|
45
46
|
__version__ = version("python-kasa")
|
|
@@ -51,6 +52,7 @@ __all__ = [
|
|
|
51
52
|
"BaseTransport",
|
|
52
53
|
"IotProtocol",
|
|
53
54
|
"SmartProtocol",
|
|
55
|
+
"SmartCamProtocol",
|
|
54
56
|
"LightState",
|
|
55
57
|
"TurnOnBehaviors",
|
|
56
58
|
"TurnOnBehavior",
|
|
@@ -75,6 +77,7 @@ __all__ = [
|
|
|
75
77
|
"DeviceFamily",
|
|
76
78
|
"ThermostatState",
|
|
77
79
|
"Thermostat",
|
|
80
|
+
"StreamResolution",
|
|
78
81
|
]
|
|
79
82
|
|
|
80
83
|
from . import iot
|
kasa/cli/common.py
CHANGED
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
+
import asyncio
|
|
5
6
|
import json
|
|
6
7
|
import re
|
|
7
8
|
import sys
|
|
8
9
|
from collections.abc import Callable
|
|
9
10
|
from contextlib import contextmanager
|
|
10
11
|
from functools import singledispatch, update_wrapper, wraps
|
|
12
|
+
from gettext import gettext
|
|
11
13
|
from typing import TYPE_CHECKING, Any, Final
|
|
12
14
|
|
|
13
15
|
import asyncclick as click
|
|
@@ -238,4 +240,19 @@ def CatchAllExceptions(cls):
|
|
|
238
240
|
except Exception as exc:
|
|
239
241
|
_handle_exception(self._debug, exc)
|
|
240
242
|
|
|
243
|
+
def __call__(self, *args, **kwargs):
|
|
244
|
+
"""Run the coroutine in the event loop and print any exceptions.
|
|
245
|
+
|
|
246
|
+
python click catches KeyboardInterrupt in main, raises Abort()
|
|
247
|
+
and does sys.exit. asyncclick doesn't properly handle a coroutine
|
|
248
|
+
receiving CancelledError on a KeyboardInterrupt, so we catch the
|
|
249
|
+
KeyboardInterrupt here once asyncio.run has re-raised it. This
|
|
250
|
+
avoids large stacktraces when a user presses Ctrl-C.
|
|
251
|
+
"""
|
|
252
|
+
try:
|
|
253
|
+
asyncio.run(self.main(*args, **kwargs))
|
|
254
|
+
except KeyboardInterrupt:
|
|
255
|
+
click.echo(gettext("\nAborted!"), file=sys.stderr)
|
|
256
|
+
sys.exit(1)
|
|
257
|
+
|
|
241
258
|
return _CommandCls
|
kasa/cli/device.py
CHANGED
|
@@ -41,8 +41,14 @@ async def state(ctx, dev: Device):
|
|
|
41
41
|
echo(f"Device state: {dev.is_on}")
|
|
42
42
|
|
|
43
43
|
echo(f"Time: {dev.time} (tz: {dev.timezone})")
|
|
44
|
-
echo(
|
|
45
|
-
|
|
44
|
+
echo(
|
|
45
|
+
f"Hardware: {dev.device_info.hardware_version}"
|
|
46
|
+
f"{' (' + dev.region + ')' if dev.region else ''}"
|
|
47
|
+
)
|
|
48
|
+
echo(
|
|
49
|
+
f"Firmware: {dev.device_info.firmware_version}"
|
|
50
|
+
f" {dev.device_info.firmware_build}"
|
|
51
|
+
)
|
|
46
52
|
echo(f"MAC (rssi): {dev.mac} ({dev.rssi})")
|
|
47
53
|
if verbose:
|
|
48
54
|
echo(f"Location: {dev.location}")
|
kasa/cli/discover.py
CHANGED
|
@@ -14,8 +14,17 @@ from kasa import (
|
|
|
14
14
|
Discover,
|
|
15
15
|
UnsupportedDeviceError,
|
|
16
16
|
)
|
|
17
|
-
from kasa.discover import
|
|
17
|
+
from kasa.discover import (
|
|
18
|
+
NEW_DISCOVERY_REDACTORS,
|
|
19
|
+
ConnectAttempt,
|
|
20
|
+
DiscoveredRaw,
|
|
21
|
+
DiscoveryResult,
|
|
22
|
+
)
|
|
23
|
+
from kasa.iot.iotdevice import _extract_sys_info
|
|
24
|
+
from kasa.protocols.iotprotocol import REDACTORS as IOT_REDACTORS
|
|
25
|
+
from kasa.protocols.protocol import redact_data
|
|
18
26
|
|
|
27
|
+
from ..json import dumps as json_dumps
|
|
19
28
|
from .common import echo, error
|
|
20
29
|
|
|
21
30
|
|
|
@@ -63,7 +72,9 @@ async def detail(ctx):
|
|
|
63
72
|
await ctx.parent.invoke(state)
|
|
64
73
|
echo()
|
|
65
74
|
|
|
66
|
-
discovered = await _discover(
|
|
75
|
+
discovered = await _discover(
|
|
76
|
+
ctx, print_discovered=print_discovered, print_unsupported=print_unsupported
|
|
77
|
+
)
|
|
67
78
|
if ctx.parent.parent.params["host"]:
|
|
68
79
|
return discovered
|
|
69
80
|
|
|
@@ -76,6 +87,33 @@ async def detail(ctx):
|
|
|
76
87
|
return discovered
|
|
77
88
|
|
|
78
89
|
|
|
90
|
+
@discover.command()
|
|
91
|
+
@click.option(
|
|
92
|
+
"--redact/--no-redact",
|
|
93
|
+
default=False,
|
|
94
|
+
is_flag=True,
|
|
95
|
+
type=bool,
|
|
96
|
+
help="Set flag to redact sensitive data from raw output.",
|
|
97
|
+
)
|
|
98
|
+
@click.pass_context
|
|
99
|
+
async def raw(ctx, redact: bool):
|
|
100
|
+
"""Return raw discovery data returned from devices."""
|
|
101
|
+
|
|
102
|
+
def print_raw(discovered: DiscoveredRaw):
|
|
103
|
+
if redact:
|
|
104
|
+
redactors = (
|
|
105
|
+
NEW_DISCOVERY_REDACTORS
|
|
106
|
+
if discovered["meta"]["port"] == Discover.DISCOVERY_PORT_2
|
|
107
|
+
else IOT_REDACTORS
|
|
108
|
+
)
|
|
109
|
+
discovered["discovery_response"] = redact_data(
|
|
110
|
+
discovered["discovery_response"], redactors
|
|
111
|
+
)
|
|
112
|
+
echo(json_dumps(discovered, indent=True))
|
|
113
|
+
|
|
114
|
+
return await _discover(ctx, print_raw=print_raw, do_echo=False)
|
|
115
|
+
|
|
116
|
+
|
|
79
117
|
@discover.command()
|
|
80
118
|
@click.pass_context
|
|
81
119
|
async def list(ctx):
|
|
@@ -85,14 +123,19 @@ async def list(ctx):
|
|
|
85
123
|
async def print_discovered(dev: Device):
|
|
86
124
|
cparams = dev.config.connection_type
|
|
87
125
|
infostr = (
|
|
88
|
-
f"{dev.host:<15} {cparams.device_family.value:<20} "
|
|
89
|
-
f"{cparams.encryption_type.value:<7}"
|
|
126
|
+
f"{dev.host:<15} {dev.model:<9} {cparams.device_family.value:<20} "
|
|
127
|
+
f"{cparams.encryption_type.value:<7} {cparams.https:<5} "
|
|
128
|
+
f"{cparams.login_version or '-':<3}"
|
|
90
129
|
)
|
|
91
130
|
async with sem:
|
|
92
131
|
try:
|
|
93
132
|
await dev.update()
|
|
94
133
|
except AuthenticationError:
|
|
95
134
|
echo(f"{infostr} - Authentication failed")
|
|
135
|
+
except TimeoutError:
|
|
136
|
+
echo(f"{infostr} - Timed out")
|
|
137
|
+
except Exception as ex:
|
|
138
|
+
echo(f"{infostr} - Error: {ex}")
|
|
96
139
|
else:
|
|
97
140
|
echo(f"{infostr} {dev.alias}")
|
|
98
141
|
|
|
@@ -100,11 +143,21 @@ async def list(ctx):
|
|
|
100
143
|
if host := unsupported_exception.host:
|
|
101
144
|
echo(f"{host:<15} UNSUPPORTED DEVICE")
|
|
102
145
|
|
|
103
|
-
echo(
|
|
104
|
-
|
|
146
|
+
echo(
|
|
147
|
+
f"{'HOST':<15} {'MODEL':<9} {'DEVICE FAMILY':<20} {'ENCRYPT':<7} "
|
|
148
|
+
f"{'HTTPS':<5} {'LV':<3} {'ALIAS'}"
|
|
149
|
+
)
|
|
150
|
+
return await _discover(
|
|
151
|
+
ctx,
|
|
152
|
+
print_discovered=print_discovered,
|
|
153
|
+
print_unsupported=print_unsupported,
|
|
154
|
+
do_echo=False,
|
|
155
|
+
)
|
|
105
156
|
|
|
106
157
|
|
|
107
|
-
async def _discover(
|
|
158
|
+
async def _discover(
|
|
159
|
+
ctx, *, print_discovered=None, print_unsupported=None, print_raw=None, do_echo=True
|
|
160
|
+
):
|
|
108
161
|
params = ctx.parent.parent.params
|
|
109
162
|
target = params["target"]
|
|
110
163
|
username = params["username"]
|
|
@@ -125,6 +178,7 @@ async def _discover(ctx, print_discovered, print_unsupported, *, do_echo=True):
|
|
|
125
178
|
timeout=timeout,
|
|
126
179
|
discovery_timeout=discovery_timeout,
|
|
127
180
|
on_unsupported=print_unsupported,
|
|
181
|
+
on_discovered_raw=print_raw,
|
|
128
182
|
)
|
|
129
183
|
if do_echo:
|
|
130
184
|
echo(f"Discovering devices on {target} for {discovery_timeout} seconds")
|
|
@@ -136,6 +190,7 @@ async def _discover(ctx, print_discovered, print_unsupported, *, do_echo=True):
|
|
|
136
190
|
port=port,
|
|
137
191
|
timeout=timeout,
|
|
138
192
|
credentials=credentials,
|
|
193
|
+
on_discovered_raw=print_raw,
|
|
139
194
|
)
|
|
140
195
|
|
|
141
196
|
for device in discovered_devices.values():
|
|
@@ -201,8 +256,8 @@ def _echo_discovery_info(discovery_info) -> None:
|
|
|
201
256
|
if discovery_info is None:
|
|
202
257
|
return
|
|
203
258
|
|
|
204
|
-
if
|
|
205
|
-
_echo_dictionary(
|
|
259
|
+
if sysinfo := _extract_sys_info(discovery_info):
|
|
260
|
+
_echo_dictionary(sysinfo)
|
|
206
261
|
return
|
|
207
262
|
|
|
208
263
|
try:
|
|
@@ -228,12 +283,14 @@ def _echo_discovery_info(discovery_info) -> None:
|
|
|
228
283
|
_conditional_echo("HW Ver", dr.hw_ver)
|
|
229
284
|
_conditional_echo("HW Ver", dr.hardware_version)
|
|
230
285
|
_conditional_echo("Supports IOT Cloud", dr.is_support_iot_cloud)
|
|
231
|
-
_conditional_echo("OBD Src", dr.
|
|
286
|
+
_conditional_echo("OBD Src", dr.obd_src)
|
|
232
287
|
_conditional_echo("Factory Default", dr.factory_default)
|
|
233
|
-
_conditional_echo("Encrypt Type", dr.mgt_encrypt_schm.encrypt_type)
|
|
234
288
|
_conditional_echo("Encrypt Type", dr.encrypt_type)
|
|
235
|
-
|
|
236
|
-
|
|
289
|
+
if mgt_encrypt_schm := dr.mgt_encrypt_schm:
|
|
290
|
+
_conditional_echo("Encrypt Type", mgt_encrypt_schm.encrypt_type)
|
|
291
|
+
_conditional_echo("Supports HTTPS", mgt_encrypt_schm.is_support_https)
|
|
292
|
+
_conditional_echo("HTTP Port", mgt_encrypt_schm.http_port)
|
|
293
|
+
_conditional_echo("Login version", mgt_encrypt_schm.lv)
|
|
237
294
|
_conditional_echo("Encrypt info", pf(dr.encrypt_info) if dr.encrypt_info else None)
|
|
238
295
|
_conditional_echo("Decrypted", pf(dr.decrypted_data) if dr.decrypted_data else None)
|
|
239
296
|
|
kasa/cli/light.py
CHANGED
|
@@ -25,7 +25,9 @@ def light(dev) -> None:
|
|
|
25
25
|
@pass_dev_or_child
|
|
26
26
|
async def brightness(dev: Device, brightness: int, transition: int):
|
|
27
27
|
"""Get or set brightness."""
|
|
28
|
-
if not (light := dev.modules.get(Module.Light)) or not light.
|
|
28
|
+
if not (light := dev.modules.get(Module.Light)) or not light.has_feature(
|
|
29
|
+
"brightness"
|
|
30
|
+
):
|
|
29
31
|
error("This device does not support brightness.")
|
|
30
32
|
return
|
|
31
33
|
|
|
@@ -45,13 +47,15 @@ async def brightness(dev: Device, brightness: int, transition: int):
|
|
|
45
47
|
@pass_dev_or_child
|
|
46
48
|
async def temperature(dev: Device, temperature: int, transition: int):
|
|
47
49
|
"""Get or set color temperature."""
|
|
48
|
-
if not (light := dev.modules.get(Module.Light)) or not
|
|
50
|
+
if not (light := dev.modules.get(Module.Light)) or not (
|
|
51
|
+
color_temp_feat := light.get_feature("color_temp")
|
|
52
|
+
):
|
|
49
53
|
error("Device does not support color temperature")
|
|
50
54
|
return
|
|
51
55
|
|
|
52
56
|
if temperature is None:
|
|
53
57
|
echo(f"Color temperature: {light.color_temp}")
|
|
54
|
-
valid_temperature_range =
|
|
58
|
+
valid_temperature_range = color_temp_feat.range
|
|
55
59
|
if valid_temperature_range != (0, 0):
|
|
56
60
|
echo("(min: {}, max: {})".format(*valid_temperature_range))
|
|
57
61
|
else:
|
|
@@ -59,7 +63,7 @@ async def temperature(dev: Device, temperature: int, transition: int):
|
|
|
59
63
|
"Temperature range unknown, please open a github issue"
|
|
60
64
|
f" or a pull request for model '{dev.model}'"
|
|
61
65
|
)
|
|
62
|
-
return
|
|
66
|
+
return color_temp_feat.range
|
|
63
67
|
else:
|
|
64
68
|
echo(f"Setting color temperature to {temperature}")
|
|
65
69
|
return await light.set_color_temp(temperature, transition=transition)
|
|
@@ -99,7 +103,7 @@ async def effect(dev: Device, ctx, effect):
|
|
|
99
103
|
@pass_dev_or_child
|
|
100
104
|
async def hsv(dev: Device, ctx, h, s, v, transition):
|
|
101
105
|
"""Get or set color in HSV."""
|
|
102
|
-
if not (light := dev.modules.get(Module.Light)) or not light.
|
|
106
|
+
if not (light := dev.modules.get(Module.Light)) or not light.has_feature("hsv"):
|
|
103
107
|
error("Device does not support colors")
|
|
104
108
|
return
|
|
105
109
|
|
kasa/cli/main.py
CHANGED
kasa/credentials.py
CHANGED
|
@@ -25,6 +25,7 @@ def get_default_credentials(tuple: tuple[str, str]) -> Credentials:
|
|
|
25
25
|
|
|
26
26
|
DEFAULT_CREDENTIALS = {
|
|
27
27
|
"KASA": ("a2FzYUB0cC1saW5rLm5ldA==", "a2FzYVNldHVw"),
|
|
28
|
+
"KASACAMERA": ("YWRtaW4=", "MjEyMzJmMjk3YTU3YTVhNzQzODk0YTBlNGE4MDFmYzM="),
|
|
28
29
|
"TAPO": ("dGVzdEB0cC1saW5rLm5ldA==", "dGVzdA=="),
|
|
29
30
|
"TAPOCAMERA": ("YWRtaW4=", "YWRtaW4="),
|
|
30
31
|
}
|
kasa/device.py
CHANGED
|
@@ -29,7 +29,7 @@ All devices provide several informational properties:
|
|
|
29
29
|
>>> dev.alias
|
|
30
30
|
Bedroom Lamp Plug
|
|
31
31
|
>>> dev.model
|
|
32
|
-
HS110
|
|
32
|
+
HS110
|
|
33
33
|
>>> dev.rssi
|
|
34
34
|
-71
|
|
35
35
|
>>> dev.mac
|
|
@@ -151,7 +151,7 @@ _LOGGER = logging.getLogger(__name__)
|
|
|
151
151
|
|
|
152
152
|
|
|
153
153
|
@dataclass
|
|
154
|
-
class
|
|
154
|
+
class DeviceInfo:
|
|
155
155
|
"""Device Model Information."""
|
|
156
156
|
|
|
157
157
|
short_name: str
|
|
@@ -208,7 +208,7 @@ class Device(ABC):
|
|
|
208
208
|
self.protocol: BaseProtocol = protocol or IotProtocol(
|
|
209
209
|
transport=XorTransport(config=config or DeviceConfig(host=host)),
|
|
210
210
|
)
|
|
211
|
-
self._last_update: Any =
|
|
211
|
+
self._last_update: dict[str, Any] = {}
|
|
212
212
|
_LOGGER.debug("Initializing %s of type %s", host, type(self))
|
|
213
213
|
self._device_type = DeviceType.Unknown
|
|
214
214
|
# TODO: typing Any is just as using dict | None would require separate
|
|
@@ -334,9 +334,21 @@ class Device(ABC):
|
|
|
334
334
|
"""Returns the device model."""
|
|
335
335
|
|
|
336
336
|
@property
|
|
337
|
+
def region(self) -> str | None:
|
|
338
|
+
"""Returns the device region."""
|
|
339
|
+
return self.device_info.region
|
|
340
|
+
|
|
341
|
+
@property
|
|
342
|
+
def device_info(self) -> DeviceInfo:
|
|
343
|
+
"""Return device info."""
|
|
344
|
+
return self._get_device_info(self._last_update, self._discovery_info)
|
|
345
|
+
|
|
346
|
+
@staticmethod
|
|
337
347
|
@abstractmethod
|
|
338
|
-
def
|
|
339
|
-
|
|
348
|
+
def _get_device_info(
|
|
349
|
+
info: dict[str, Any], discovery_info: dict[str, Any] | None
|
|
350
|
+
) -> DeviceInfo:
|
|
351
|
+
"""Get device info."""
|
|
340
352
|
|
|
341
353
|
@property
|
|
342
354
|
@abstractmethod
|
kasa/device_factory.py
CHANGED
|
@@ -8,10 +8,11 @@ from typing import Any
|
|
|
8
8
|
|
|
9
9
|
from .device import Device
|
|
10
10
|
from .device_type import DeviceType
|
|
11
|
-
from .deviceconfig import DeviceConfig
|
|
11
|
+
from .deviceconfig import DeviceConfig, DeviceFamily
|
|
12
12
|
from .exceptions import KasaException, UnsupportedDeviceError
|
|
13
13
|
from .iot import (
|
|
14
14
|
IotBulb,
|
|
15
|
+
IotCamera,
|
|
15
16
|
IotDevice,
|
|
16
17
|
IotDimmer,
|
|
17
18
|
IotLightStrip,
|
|
@@ -32,6 +33,8 @@ from .transports import (
|
|
|
32
33
|
BaseTransport,
|
|
33
34
|
KlapTransport,
|
|
34
35
|
KlapTransportV2,
|
|
36
|
+
LinkieTransportV2,
|
|
37
|
+
SslTransport,
|
|
35
38
|
XorTransport,
|
|
36
39
|
)
|
|
37
40
|
from .transports.sslaestransport import SslAesTransport
|
|
@@ -137,6 +140,7 @@ def get_device_class_from_sys_info(sysinfo: dict[str, Any]) -> type[IotDevice]:
|
|
|
137
140
|
DeviceType.Strip: IotStrip,
|
|
138
141
|
DeviceType.WallSwitch: IotWallSwitch,
|
|
139
142
|
DeviceType.LightStrip: IotLightStrip,
|
|
143
|
+
DeviceType.Camera: IotCamera,
|
|
140
144
|
}
|
|
141
145
|
return TYPE_TO_CLASS[IotDevice._get_device_type_from_sys_info(sysinfo)]
|
|
142
146
|
|
|
@@ -155,8 +159,10 @@ def get_device_class_from_family(
|
|
|
155
159
|
"SMART.KASAHUB": SmartDevice,
|
|
156
160
|
"SMART.KASASWITCH": SmartDevice,
|
|
157
161
|
"SMART.IPCAMERA.HTTPS": SmartCamDevice,
|
|
162
|
+
"SMART.TAPOROBOVAC": SmartDevice,
|
|
158
163
|
"IOT.SMARTPLUGSWITCH": IotPlug,
|
|
159
164
|
"IOT.SMARTBULB": IotBulb,
|
|
165
|
+
"IOT.IPCAMERA": IotCamera,
|
|
160
166
|
}
|
|
161
167
|
lookup_key = f"{device_type}{'.HTTPS' if https else ''}"
|
|
162
168
|
if (
|
|
@@ -173,15 +179,32 @@ def get_device_class_from_family(
|
|
|
173
179
|
def get_protocol(
|
|
174
180
|
config: DeviceConfig,
|
|
175
181
|
) -> BaseProtocol | None:
|
|
176
|
-
"""Return the protocol from the connection name.
|
|
177
|
-
|
|
182
|
+
"""Return the protocol from the connection name.
|
|
183
|
+
|
|
184
|
+
For cameras and vacuums the device family is a simple mapping to
|
|
185
|
+
the protocol/transport. For other device types the transport varies
|
|
186
|
+
based on the discovery information.
|
|
187
|
+
"""
|
|
178
188
|
ctype = config.connection_type
|
|
189
|
+
protocol_name = ctype.device_family.value.split(".")[0]
|
|
190
|
+
|
|
191
|
+
if ctype.device_family is DeviceFamily.SmartIpCamera:
|
|
192
|
+
return SmartCamProtocol(transport=SslAesTransport(config=config))
|
|
193
|
+
|
|
194
|
+
if ctype.device_family is DeviceFamily.IotIpCamera:
|
|
195
|
+
return IotProtocol(transport=LinkieTransportV2(config=config))
|
|
196
|
+
|
|
197
|
+
if ctype.device_family is DeviceFamily.SmartTapoRobovac:
|
|
198
|
+
return SmartProtocol(transport=SslTransport(config=config))
|
|
199
|
+
|
|
179
200
|
protocol_transport_key = (
|
|
180
201
|
protocol_name
|
|
181
202
|
+ "."
|
|
182
203
|
+ ctype.encryption_type.value
|
|
183
204
|
+ (".HTTPS" if ctype.https else "")
|
|
184
205
|
)
|
|
206
|
+
|
|
207
|
+
_LOGGER.debug("Finding transport for %s", protocol_transport_key)
|
|
185
208
|
supported_device_protocols: dict[
|
|
186
209
|
str, tuple[type[BaseProtocol], type[BaseTransport]]
|
|
187
210
|
] = {
|
|
@@ -189,6 +212,8 @@ def get_protocol(
|
|
|
189
212
|
"IOT.KLAP": (IotProtocol, KlapTransport),
|
|
190
213
|
"SMART.AES": (SmartProtocol, AesTransport),
|
|
191
214
|
"SMART.KLAP": (SmartProtocol, KlapTransportV2),
|
|
215
|
+
# H200 is device family SMART.TAPOHUB and uses SmartCamProtocol so use
|
|
216
|
+
# https to distuingish from SmartProtocol devices
|
|
192
217
|
"SMART.AES.HTTPS": (SmartCamProtocol, SslAesTransport),
|
|
193
218
|
}
|
|
194
219
|
if not (prot_tran_cls := supported_device_protocols.get(protocol_transport_key)):
|
kasa/device_type.py
CHANGED
kasa/deviceconfig.py
CHANGED
|
@@ -69,6 +69,7 @@ class DeviceFamily(Enum):
|
|
|
69
69
|
|
|
70
70
|
IotSmartPlugSwitch = "IOT.SMARTPLUGSWITCH"
|
|
71
71
|
IotSmartBulb = "IOT.SMARTBULB"
|
|
72
|
+
IotIpCamera = "IOT.IPCAMERA"
|
|
72
73
|
SmartKasaPlug = "SMART.KASAPLUG"
|
|
73
74
|
SmartKasaSwitch = "SMART.KASASWITCH"
|
|
74
75
|
SmartTapoPlug = "SMART.TAPOPLUG"
|
|
@@ -77,6 +78,7 @@ class DeviceFamily(Enum):
|
|
|
77
78
|
SmartTapoHub = "SMART.TAPOHUB"
|
|
78
79
|
SmartKasaHub = "SMART.KASAHUB"
|
|
79
80
|
SmartIpCamera = "SMART.IPCAMERA"
|
|
81
|
+
SmartTapoRobovac = "SMART.TAPOROBOVAC"
|
|
80
82
|
|
|
81
83
|
|
|
82
84
|
class _DeviceConfigBaseMixin(DataClassJSONMixin):
|