python-kasa 0.7.0.dev4__py3-none-any.whl → 0.7.0.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/aestransport.py +6 -2
- kasa/cli.py +117 -66
- kasa/device.py +126 -33
- kasa/discover.py +2 -1
- kasa/feature.py +90 -14
- kasa/httpclient.py +1 -1
- kasa/interfaces/__init__.py +2 -0
- kasa/interfaces/energy.py +187 -0
- kasa/interfaces/light.py +61 -1
- kasa/interfaces/lighteffect.py +41 -1
- kasa/interfaces/lightpreset.py +70 -2
- kasa/iot/iotbulb.py +1 -1
- kasa/iot/iotdevice.py +32 -102
- kasa/iot/iotstrip.py +125 -62
- kasa/iot/modules/emeter.py +30 -89
- kasa/iot/modules/led.py +5 -0
- kasa/iot/modules/lightpreset.py +2 -1
- kasa/module.py +41 -4
- kasa/smart/modules/alarm.py +1 -0
- kasa/smart/modules/autooff.py +3 -1
- kasa/smart/modules/childdevice.py +39 -1
- kasa/smart/modules/energy.py +58 -60
- kasa/smart/modules/firmware.py +4 -1
- kasa/smart/modules/frostprotection.py +0 -22
- kasa/smart/modules/humiditysensor.py +1 -0
- kasa/smart/modules/led.py +1 -1
- kasa/smart/modules/lightpreset.py +2 -1
- kasa/smart/modules/lightstripeffect.py +14 -4
- kasa/smart/modules/lighttransition.py +8 -0
- kasa/smart/modules/reportmode.py +2 -0
- kasa/smart/modules/temperaturecontrol.py +3 -2
- kasa/smart/modules/temperaturesensor.py +3 -2
- kasa/smart/modules/time.py +10 -3
- kasa/smart/modules/waterleaksensor.py +2 -0
- kasa/smart/smartdevice.py +29 -51
- kasa/tests/device_fixtures.py +1 -1
- kasa/tests/discovery_fixtures.py +3 -1
- kasa/tests/fakeprotocol_smart.py +2 -2
- kasa/tests/fixtures/smart/L920-5(EU)_1.0_1.0.7.json +350 -0
- kasa/tests/smart/modules/test_firmware.py +12 -1
- kasa/tests/test_cli.py +55 -8
- kasa/tests/test_device.py +16 -7
- kasa/tests/test_emeter.py +44 -16
- kasa/tests/test_feature.py +6 -2
- kasa/tests/test_httpclient.py +2 -2
- kasa/tests/test_iotdevice.py +14 -6
- kasa/tests/test_readme_examples.py +59 -0
- kasa/tests/test_smartdevice.py +4 -3
- kasa/tests/test_strip.py +15 -2
- kasa/xortransport.py +3 -3
- {python_kasa-0.7.0.dev4.dist-info → python_kasa-0.7.0.1.dist-info}/METADATA +102 -129
- {python_kasa-0.7.0.dev4.dist-info → python_kasa-0.7.0.1.dist-info}/RECORD +55 -53
- {python_kasa-0.7.0.dev4.dist-info → python_kasa-0.7.0.1.dist-info}/LICENSE +0 -0
- {python_kasa-0.7.0.dev4.dist-info → python_kasa-0.7.0.1.dist-info}/WHEEL +0 -0
- {python_kasa-0.7.0.dev4.dist-info → python_kasa-0.7.0.1.dist-info}/entry_points.txt +0 -0
|
@@ -79,11 +79,12 @@ class TemperatureControl(SmartModule):
|
|
|
79
79
|
self._add_feature(
|
|
80
80
|
Feature(
|
|
81
81
|
device,
|
|
82
|
-
id="
|
|
83
|
-
name="
|
|
82
|
+
id="thermostat_mode",
|
|
83
|
+
name="Thermostat mode",
|
|
84
84
|
container=self,
|
|
85
85
|
attribute_getter="mode",
|
|
86
86
|
category=Feature.Category.Primary,
|
|
87
|
+
type=Feature.Type.Sensor,
|
|
87
88
|
)
|
|
88
89
|
)
|
|
89
90
|
|
|
@@ -28,6 +28,8 @@ class TemperatureSensor(SmartModule):
|
|
|
28
28
|
attribute_getter="temperature",
|
|
29
29
|
icon="mdi:thermometer",
|
|
30
30
|
category=Feature.Category.Primary,
|
|
31
|
+
unit_getter="temperature_unit",
|
|
32
|
+
type=Feature.Type.Sensor,
|
|
31
33
|
)
|
|
32
34
|
)
|
|
33
35
|
if "current_temp_exception" in device.sys_info:
|
|
@@ -55,7 +57,6 @@ class TemperatureSensor(SmartModule):
|
|
|
55
57
|
choices=["celsius", "fahrenheit"],
|
|
56
58
|
)
|
|
57
59
|
)
|
|
58
|
-
# TODO: use temperature_unit for feature creation
|
|
59
60
|
|
|
60
61
|
@property
|
|
61
62
|
def temperature(self):
|
|
@@ -68,7 +69,7 @@ class TemperatureSensor(SmartModule):
|
|
|
68
69
|
return self._device.sys_info.get("current_temp_exception", 0) != 0
|
|
69
70
|
|
|
70
71
|
@property
|
|
71
|
-
def temperature_unit(self):
|
|
72
|
+
def temperature_unit(self) -> Literal["celsius", "fahrenheit"]:
|
|
72
73
|
"""Return current temperature unit."""
|
|
73
74
|
return self._device.sys_info["temp_unit"]
|
|
74
75
|
|
kasa/smart/modules/time.py
CHANGED
|
@@ -25,11 +25,12 @@ class Time(SmartModule):
|
|
|
25
25
|
self._add_feature(
|
|
26
26
|
Feature(
|
|
27
27
|
device=device,
|
|
28
|
-
id="
|
|
29
|
-
name="
|
|
28
|
+
id="device_time",
|
|
29
|
+
name="Device time",
|
|
30
30
|
attribute_getter="time",
|
|
31
31
|
container=self,
|
|
32
32
|
category=Feature.Category.Debug,
|
|
33
|
+
type=Feature.Type.Sensor,
|
|
33
34
|
)
|
|
34
35
|
)
|
|
35
36
|
|
|
@@ -51,7 +52,13 @@ class Time(SmartModule):
|
|
|
51
52
|
async def set_time(self, dt: datetime):
|
|
52
53
|
"""Set device time."""
|
|
53
54
|
unixtime = mktime(dt.timetuple())
|
|
55
|
+
offset = cast(timedelta, dt.utcoffset())
|
|
56
|
+
diff = offset / timedelta(minutes=1)
|
|
54
57
|
return await self.call(
|
|
55
58
|
"set_device_time",
|
|
56
|
-
{
|
|
59
|
+
{
|
|
60
|
+
"timestamp": int(unixtime),
|
|
61
|
+
"time_diff": int(diff),
|
|
62
|
+
"region": dt.tzname(),
|
|
63
|
+
},
|
|
57
64
|
)
|
|
@@ -36,6 +36,7 @@ class WaterleakSensor(SmartModule):
|
|
|
36
36
|
attribute_getter="status",
|
|
37
37
|
icon="mdi:water",
|
|
38
38
|
category=Feature.Category.Debug,
|
|
39
|
+
type=Feature.Type.Sensor,
|
|
39
40
|
)
|
|
40
41
|
)
|
|
41
42
|
self._add_feature(
|
|
@@ -47,6 +48,7 @@ class WaterleakSensor(SmartModule):
|
|
|
47
48
|
attribute_getter="alert",
|
|
48
49
|
icon="mdi:water-alert",
|
|
49
50
|
category=Feature.Category.Primary,
|
|
51
|
+
type=Feature.Type.BinarySensor,
|
|
50
52
|
)
|
|
51
53
|
)
|
|
52
54
|
|
kasa/smart/smartdevice.py
CHANGED
|
@@ -4,14 +4,14 @@ from __future__ import annotations
|
|
|
4
4
|
|
|
5
5
|
import base64
|
|
6
6
|
import logging
|
|
7
|
-
from
|
|
8
|
-
from
|
|
7
|
+
from collections.abc import Mapping, Sequence
|
|
8
|
+
from datetime import datetime, timedelta, timezone
|
|
9
|
+
from typing import Any, cast
|
|
9
10
|
|
|
10
11
|
from ..aestransport import AesTransport
|
|
11
12
|
from ..device import Device, WifiNetwork
|
|
12
13
|
from ..device_type import DeviceType
|
|
13
14
|
from ..deviceconfig import DeviceConfig
|
|
14
|
-
from ..emeterstatus import EmeterStatus
|
|
15
15
|
from ..exceptions import AuthenticationError, DeviceError, KasaException, SmartErrorCode
|
|
16
16
|
from ..feature import Feature
|
|
17
17
|
from ..module import Module
|
|
@@ -98,9 +98,7 @@ class SmartDevice(Device):
|
|
|
98
98
|
@property
|
|
99
99
|
def modules(self) -> ModuleMapping[SmartModule]:
|
|
100
100
|
"""Return the device modules."""
|
|
101
|
-
|
|
102
|
-
return cast(ModuleMapping[SmartModule], self._modules)
|
|
103
|
-
return self._modules
|
|
101
|
+
return cast(ModuleMapping[SmartModule], self._modules)
|
|
104
102
|
|
|
105
103
|
def _try_get_response(self, responses: dict, request: str, default=None) -> dict:
|
|
106
104
|
response = responses.get(request)
|
|
@@ -244,6 +242,7 @@ class SmartDevice(Device):
|
|
|
244
242
|
name="Device ID",
|
|
245
243
|
attribute_getter="device_id",
|
|
246
244
|
category=Feature.Category.Debug,
|
|
245
|
+
type=Feature.Type.Sensor,
|
|
247
246
|
)
|
|
248
247
|
)
|
|
249
248
|
if "device_on" in self._info:
|
|
@@ -268,6 +267,7 @@ class SmartDevice(Device):
|
|
|
268
267
|
attribute_getter=lambda x: x._info["signal_level"],
|
|
269
268
|
icon="mdi:signal",
|
|
270
269
|
category=Feature.Category.Info,
|
|
270
|
+
type=Feature.Type.Sensor,
|
|
271
271
|
)
|
|
272
272
|
)
|
|
273
273
|
|
|
@@ -279,7 +279,9 @@ class SmartDevice(Device):
|
|
|
279
279
|
name="RSSI",
|
|
280
280
|
attribute_getter=lambda x: x._info["rssi"],
|
|
281
281
|
icon="mdi:signal",
|
|
282
|
+
unit="dBm",
|
|
282
283
|
category=Feature.Category.Debug,
|
|
284
|
+
type=Feature.Type.Sensor,
|
|
283
285
|
)
|
|
284
286
|
)
|
|
285
287
|
|
|
@@ -292,6 +294,7 @@ class SmartDevice(Device):
|
|
|
292
294
|
attribute_getter="ssid",
|
|
293
295
|
icon="mdi:wifi",
|
|
294
296
|
category=Feature.Category.Debug,
|
|
297
|
+
type=Feature.Type.Sensor,
|
|
295
298
|
)
|
|
296
299
|
)
|
|
297
300
|
|
|
@@ -318,7 +321,8 @@ class SmartDevice(Device):
|
|
|
318
321
|
name="On since",
|
|
319
322
|
attribute_getter="on_since",
|
|
320
323
|
icon="mdi:clock",
|
|
321
|
-
category=Feature.Category.
|
|
324
|
+
category=Feature.Category.Debug,
|
|
325
|
+
type=Feature.Type.Sensor,
|
|
322
326
|
)
|
|
323
327
|
)
|
|
324
328
|
|
|
@@ -357,12 +361,25 @@ class SmartDevice(Device):
|
|
|
357
361
|
@property
|
|
358
362
|
def time(self) -> datetime:
|
|
359
363
|
"""Return the time."""
|
|
360
|
-
if self._parent and
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
+
if (self._parent and (time_mod := self._parent.modules.get(Module.Time))) or (
|
|
365
|
+
time_mod := self.modules.get(Module.Time)
|
|
366
|
+
):
|
|
367
|
+
return time_mod.time
|
|
368
|
+
|
|
369
|
+
# We have no device time, use current local time.
|
|
370
|
+
return datetime.now(timezone.utc).astimezone().replace(microsecond=0)
|
|
371
|
+
|
|
372
|
+
@property
|
|
373
|
+
def on_since(self) -> datetime | None:
|
|
374
|
+
"""Return the time that the device was turned on or None if turned off."""
|
|
375
|
+
if (
|
|
376
|
+
not self._info.get("device_on")
|
|
377
|
+
or (on_time := self._info.get("on_time")) is None
|
|
378
|
+
):
|
|
379
|
+
return None
|
|
364
380
|
|
|
365
|
-
|
|
381
|
+
on_time = cast(float, on_time)
|
|
382
|
+
return self.time - timedelta(seconds=on_time)
|
|
366
383
|
|
|
367
384
|
@property
|
|
368
385
|
def timezone(self) -> dict:
|
|
@@ -464,45 +481,6 @@ class SmartDevice(Device):
|
|
|
464
481
|
self._discovery_info = info
|
|
465
482
|
self._info = info
|
|
466
483
|
|
|
467
|
-
async def get_emeter_realtime(self) -> EmeterStatus:
|
|
468
|
-
"""Retrieve current energy readings."""
|
|
469
|
-
_LOGGER.warning("Deprecated, use `emeter_realtime`.")
|
|
470
|
-
if not self.has_emeter:
|
|
471
|
-
raise KasaException("Device has no emeter")
|
|
472
|
-
return self.emeter_realtime
|
|
473
|
-
|
|
474
|
-
@property
|
|
475
|
-
def emeter_realtime(self) -> EmeterStatus:
|
|
476
|
-
"""Get the emeter status."""
|
|
477
|
-
energy = self.modules[Module.Energy]
|
|
478
|
-
return energy.emeter_realtime
|
|
479
|
-
|
|
480
|
-
@property
|
|
481
|
-
def emeter_this_month(self) -> float | None:
|
|
482
|
-
"""Get the emeter value for this month."""
|
|
483
|
-
energy = self.modules[Module.Energy]
|
|
484
|
-
return energy.emeter_this_month
|
|
485
|
-
|
|
486
|
-
@property
|
|
487
|
-
def emeter_today(self) -> float | None:
|
|
488
|
-
"""Get the emeter value for today."""
|
|
489
|
-
energy = self.modules[Module.Energy]
|
|
490
|
-
return energy.emeter_today
|
|
491
|
-
|
|
492
|
-
@property
|
|
493
|
-
def on_since(self) -> datetime | None:
|
|
494
|
-
"""Return the time that the device was turned on or None if turned off."""
|
|
495
|
-
if (
|
|
496
|
-
not self._info.get("device_on")
|
|
497
|
-
or (on_time := self._info.get("on_time")) is None
|
|
498
|
-
):
|
|
499
|
-
return None
|
|
500
|
-
on_time = cast(float, on_time)
|
|
501
|
-
if (timemod := self.modules.get(Module.Time)) is not None:
|
|
502
|
-
return timemod.time - timedelta(seconds=on_time)
|
|
503
|
-
else: # We have no device time, use current local time.
|
|
504
|
-
return datetime.now().replace(microsecond=0) - timedelta(seconds=on_time)
|
|
505
|
-
|
|
506
484
|
async def wifi_scan(self) -> list[WifiNetwork]:
|
|
507
485
|
"""Scan for available wifi networks."""
|
|
508
486
|
|
kasa/tests/device_fixtures.py
CHANGED
kasa/tests/discovery_fixtures.py
CHANGED
|
@@ -231,7 +231,9 @@ def discovery_data(request, mocker):
|
|
|
231
231
|
return {"system": {"get_sysinfo": fixture_data["system"]["get_sysinfo"]}}
|
|
232
232
|
|
|
233
233
|
|
|
234
|
-
@pytest.fixture(
|
|
234
|
+
@pytest.fixture(
|
|
235
|
+
params=UNSUPPORTED_DEVICES.values(), ids=list(UNSUPPORTED_DEVICES.keys())
|
|
236
|
+
)
|
|
235
237
|
def unsupported_device_info(request, mocker):
|
|
236
238
|
"""Return unsupported devices for cli and discovery tests."""
|
|
237
239
|
discovery_data = request.param
|
kasa/tests/fakeprotocol_smart.py
CHANGED
|
@@ -276,7 +276,7 @@ class FakeSmartTransport(BaseTransport):
|
|
|
276
276
|
):
|
|
277
277
|
result["sum"] = len(result[list_key])
|
|
278
278
|
if self.warn_fixture_missing_methods:
|
|
279
|
-
pytest.fixtures_missing_methods.setdefault(
|
|
279
|
+
pytest.fixtures_missing_methods.setdefault( # type: ignore[attr-defined]
|
|
280
280
|
self.fixture_name, set()
|
|
281
281
|
).add(f"{method} (incomplete '{list_key}' list)")
|
|
282
282
|
|
|
@@ -305,7 +305,7 @@ class FakeSmartTransport(BaseTransport):
|
|
|
305
305
|
}
|
|
306
306
|
# Reduce warning spam by consolidating and reporting at the end of the run
|
|
307
307
|
if self.warn_fixture_missing_methods:
|
|
308
|
-
pytest.fixtures_missing_methods.setdefault(
|
|
308
|
+
pytest.fixtures_missing_methods.setdefault( # type: ignore[attr-defined]
|
|
309
309
|
self.fixture_name, set()
|
|
310
310
|
).add(method)
|
|
311
311
|
return retval
|
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
{
|
|
2
|
+
"component_nego": {
|
|
3
|
+
"component_list": [
|
|
4
|
+
{
|
|
5
|
+
"id": "device",
|
|
6
|
+
"ver_code": 2
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"id": "light_strip",
|
|
10
|
+
"ver_code": 1
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"id": "light_strip_lighting_effect",
|
|
14
|
+
"ver_code": 1
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"id": "firmware",
|
|
18
|
+
"ver_code": 1
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"id": "quick_setup",
|
|
22
|
+
"ver_code": 3
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"id": "inherit",
|
|
26
|
+
"ver_code": 1
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"id": "time",
|
|
30
|
+
"ver_code": 1
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"id": "wireless",
|
|
34
|
+
"ver_code": 1
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"id": "schedule",
|
|
38
|
+
"ver_code": 2
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"id": "countdown",
|
|
42
|
+
"ver_code": 2
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"id": "antitheft",
|
|
46
|
+
"ver_code": 1
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"id": "account",
|
|
50
|
+
"ver_code": 1
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"id": "synchronize",
|
|
54
|
+
"ver_code": 1
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"id": "sunrise_sunset",
|
|
58
|
+
"ver_code": 1
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"id": "brightness",
|
|
62
|
+
"ver_code": 1
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"id": "cloud_connect",
|
|
66
|
+
"ver_code": 1
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"id": "color_temperature",
|
|
70
|
+
"ver_code": 1
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"id": "default_states",
|
|
74
|
+
"ver_code": 1
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"id": "preset",
|
|
78
|
+
"ver_code": 3
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"id": "color",
|
|
82
|
+
"ver_code": 1
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"id": "on_off_gradually",
|
|
86
|
+
"ver_code": 1
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"id": "device_local_time",
|
|
90
|
+
"ver_code": 1
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"id": "iot_cloud",
|
|
94
|
+
"ver_code": 1
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"id": "music_rhythm",
|
|
98
|
+
"ver_code": 2
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"id": "segment",
|
|
102
|
+
"ver_code": 1
|
|
103
|
+
}
|
|
104
|
+
]
|
|
105
|
+
},
|
|
106
|
+
"discovery_result": {
|
|
107
|
+
"device_id": "00000000000000000000000000000000",
|
|
108
|
+
"device_model": "L920-5(EU)",
|
|
109
|
+
"device_type": "SMART.TAPOBULB",
|
|
110
|
+
"factory_default": true,
|
|
111
|
+
"ip": "127.0.0.123",
|
|
112
|
+
"is_support_iot_cloud": true,
|
|
113
|
+
"mac": "1C-61-B4-00-00-00",
|
|
114
|
+
"mgt_encrypt_schm": {
|
|
115
|
+
"encrypt_type": "AES",
|
|
116
|
+
"http_port": 80,
|
|
117
|
+
"is_support_https": false
|
|
118
|
+
},
|
|
119
|
+
"obd_src": "tplink",
|
|
120
|
+
"owner": ""
|
|
121
|
+
},
|
|
122
|
+
"get_antitheft_rules": {
|
|
123
|
+
"antitheft_rule_max_count": 1,
|
|
124
|
+
"enable": false,
|
|
125
|
+
"rule_list": []
|
|
126
|
+
},
|
|
127
|
+
"get_auto_update_info": {
|
|
128
|
+
"enable": true,
|
|
129
|
+
"random_range": 120,
|
|
130
|
+
"time": 180
|
|
131
|
+
},
|
|
132
|
+
"get_connect_cloud_state": {
|
|
133
|
+
"status": 1
|
|
134
|
+
},
|
|
135
|
+
"get_countdown_rules": {
|
|
136
|
+
"countdown_rule_max_count": 1,
|
|
137
|
+
"enable": false,
|
|
138
|
+
"rule_list": []
|
|
139
|
+
},
|
|
140
|
+
"get_device_info": {
|
|
141
|
+
"avatar": "",
|
|
142
|
+
"brightness": 100,
|
|
143
|
+
"color_temp": 9000,
|
|
144
|
+
"color_temp_range": [
|
|
145
|
+
9000,
|
|
146
|
+
9000
|
|
147
|
+
],
|
|
148
|
+
"default_states": {
|
|
149
|
+
"state": {
|
|
150
|
+
"brightness": 100,
|
|
151
|
+
"color_temp": 9000,
|
|
152
|
+
"hue": 0,
|
|
153
|
+
"saturation": 100
|
|
154
|
+
},
|
|
155
|
+
"type": "last_states"
|
|
156
|
+
},
|
|
157
|
+
"device_id": "0000000000000000000000000000000000000000",
|
|
158
|
+
"device_on": true,
|
|
159
|
+
"fw_id": "00000000000000000000000000000000",
|
|
160
|
+
"fw_ver": "1.0.7 Build 220119 Rel.221439",
|
|
161
|
+
"has_set_location_info": false,
|
|
162
|
+
"hue": 0,
|
|
163
|
+
"hw_id": "00000000000000000000000000000000",
|
|
164
|
+
"hw_ver": "1.0",
|
|
165
|
+
"ip": "127.0.0.123",
|
|
166
|
+
"lang": "",
|
|
167
|
+
"latitude": 0,
|
|
168
|
+
"lighting_effect": {
|
|
169
|
+
"brightness": 0,
|
|
170
|
+
"custom": 0,
|
|
171
|
+
"display_colors": [],
|
|
172
|
+
"enable": 1,
|
|
173
|
+
"id": "",
|
|
174
|
+
"name": "softAP"
|
|
175
|
+
},
|
|
176
|
+
"longitude": 0,
|
|
177
|
+
"mac": "1C-61-B4-00-00-00",
|
|
178
|
+
"model": "L920",
|
|
179
|
+
"music_rhythm_enable": false,
|
|
180
|
+
"music_rhythm_mode": "single_lamp",
|
|
181
|
+
"nickname": "I01BU0tFRF9OQU1FIw==",
|
|
182
|
+
"oem_id": "00000000000000000000000000000000",
|
|
183
|
+
"overheated": false,
|
|
184
|
+
"region": "",
|
|
185
|
+
"rssi": -46,
|
|
186
|
+
"saturation": 100,
|
|
187
|
+
"signal_level": 3,
|
|
188
|
+
"specs": "",
|
|
189
|
+
"ssid": "I01BU0tFRF9TU0lEIw==",
|
|
190
|
+
"time_diff": 0,
|
|
191
|
+
"type": "SMART.TAPOBULB"
|
|
192
|
+
},
|
|
193
|
+
"get_device_segment": {
|
|
194
|
+
"segment": 50
|
|
195
|
+
},
|
|
196
|
+
"get_device_time": {
|
|
197
|
+
"region": "",
|
|
198
|
+
"time_diff": 0,
|
|
199
|
+
"timestamp": 946771372
|
|
200
|
+
},
|
|
201
|
+
"get_fw_download_state": {
|
|
202
|
+
"download_progress": 0,
|
|
203
|
+
"reboot_time": 5,
|
|
204
|
+
"status": 0,
|
|
205
|
+
"upgrade_time": 5
|
|
206
|
+
},
|
|
207
|
+
"get_inherit_info": null,
|
|
208
|
+
"get_lighting_effect": {
|
|
209
|
+
"brightness": 0,
|
|
210
|
+
"custom": 0,
|
|
211
|
+
"direction": 1,
|
|
212
|
+
"display_colors": [],
|
|
213
|
+
"duration": 0,
|
|
214
|
+
"enable": 1,
|
|
215
|
+
"expansion_strategy": 0,
|
|
216
|
+
"id": "",
|
|
217
|
+
"name": "softAP",
|
|
218
|
+
"repeat_times": 0,
|
|
219
|
+
"segment_length": 1,
|
|
220
|
+
"sequence": [
|
|
221
|
+
[
|
|
222
|
+
30,
|
|
223
|
+
100,
|
|
224
|
+
0
|
|
225
|
+
],
|
|
226
|
+
[
|
|
227
|
+
30,
|
|
228
|
+
100,
|
|
229
|
+
50
|
|
230
|
+
],
|
|
231
|
+
[
|
|
232
|
+
30,
|
|
233
|
+
100,
|
|
234
|
+
0
|
|
235
|
+
],
|
|
236
|
+
[
|
|
237
|
+
120,
|
|
238
|
+
100,
|
|
239
|
+
0
|
|
240
|
+
],
|
|
241
|
+
[
|
|
242
|
+
120,
|
|
243
|
+
100,
|
|
244
|
+
50
|
|
245
|
+
],
|
|
246
|
+
[
|
|
247
|
+
120,
|
|
248
|
+
100,
|
|
249
|
+
0
|
|
250
|
+
]
|
|
251
|
+
],
|
|
252
|
+
"spread": 8,
|
|
253
|
+
"transition": 400,
|
|
254
|
+
"type": "sequence"
|
|
255
|
+
},
|
|
256
|
+
"get_next_event": {},
|
|
257
|
+
"get_on_off_gradually_info": {
|
|
258
|
+
"enable": false
|
|
259
|
+
},
|
|
260
|
+
"get_preset_rules": {
|
|
261
|
+
"start_index": 0,
|
|
262
|
+
"states": [
|
|
263
|
+
{
|
|
264
|
+
"brightness": 50,
|
|
265
|
+
"color_temp": 9000,
|
|
266
|
+
"hue": 0,
|
|
267
|
+
"saturation": 100
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
"brightness": 100,
|
|
271
|
+
"color_temp": 0,
|
|
272
|
+
"hue": 240,
|
|
273
|
+
"saturation": 100
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
"brightness": 100,
|
|
277
|
+
"color_temp": 0,
|
|
278
|
+
"hue": 0,
|
|
279
|
+
"saturation": 100
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
"brightness": 100,
|
|
283
|
+
"color_temp": 0,
|
|
284
|
+
"hue": 120,
|
|
285
|
+
"saturation": 100
|
|
286
|
+
},
|
|
287
|
+
{
|
|
288
|
+
"brightness": 100,
|
|
289
|
+
"color_temp": 0,
|
|
290
|
+
"hue": 277,
|
|
291
|
+
"saturation": 86
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
"brightness": 100,
|
|
295
|
+
"color_temp": 0,
|
|
296
|
+
"hue": 60,
|
|
297
|
+
"saturation": 100
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
"brightness": 100,
|
|
301
|
+
"color_temp": 0,
|
|
302
|
+
"hue": 300,
|
|
303
|
+
"saturation": 100
|
|
304
|
+
}
|
|
305
|
+
],
|
|
306
|
+
"sum": 7
|
|
307
|
+
},
|
|
308
|
+
"get_schedule_rules": {
|
|
309
|
+
"enable": false,
|
|
310
|
+
"rule_list": [],
|
|
311
|
+
"schedule_rule_max_count": 24,
|
|
312
|
+
"start_index": 0,
|
|
313
|
+
"sum": 0
|
|
314
|
+
},
|
|
315
|
+
"get_wireless_scan_info": {
|
|
316
|
+
"ap_list": [
|
|
317
|
+
{
|
|
318
|
+
"bssid": "000000000000",
|
|
319
|
+
"channel": 0,
|
|
320
|
+
"cipher_type": 2,
|
|
321
|
+
"key_type": "wpa2_psk",
|
|
322
|
+
"signal_level": 2,
|
|
323
|
+
"ssid": "I01BU0tFRF9TU0lEIw=="
|
|
324
|
+
}
|
|
325
|
+
],
|
|
326
|
+
"start_index": 0,
|
|
327
|
+
"sum": 1,
|
|
328
|
+
"wep_supported": false
|
|
329
|
+
},
|
|
330
|
+
"qs_component_nego": {
|
|
331
|
+
"component_list": [
|
|
332
|
+
{
|
|
333
|
+
"id": "quick_setup",
|
|
334
|
+
"ver_code": 3
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
"id": "sunrise_sunset",
|
|
338
|
+
"ver_code": 1
|
|
339
|
+
},
|
|
340
|
+
{
|
|
341
|
+
"id": "inherit",
|
|
342
|
+
"ver_code": 1
|
|
343
|
+
}
|
|
344
|
+
],
|
|
345
|
+
"extra_info": {
|
|
346
|
+
"device_model": "L920",
|
|
347
|
+
"device_type": "SMART.TAPOBULB"
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
@@ -2,6 +2,7 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
import asyncio
|
|
4
4
|
import logging
|
|
5
|
+
from typing import TypedDict
|
|
5
6
|
|
|
6
7
|
import pytest
|
|
7
8
|
from pytest_mock import MockerFixture
|
|
@@ -71,7 +72,17 @@ async def test_firmware_update(
|
|
|
71
72
|
assert fw
|
|
72
73
|
|
|
73
74
|
upgrade_time = 5
|
|
74
|
-
|
|
75
|
+
|
|
76
|
+
class Extras(TypedDict):
|
|
77
|
+
reboot_time: int
|
|
78
|
+
upgrade_time: int
|
|
79
|
+
auto_upgrade: bool
|
|
80
|
+
|
|
81
|
+
extras: Extras = {
|
|
82
|
+
"reboot_time": 5,
|
|
83
|
+
"upgrade_time": upgrade_time,
|
|
84
|
+
"auto_upgrade": False,
|
|
85
|
+
}
|
|
75
86
|
update_states = [
|
|
76
87
|
# Unknown 1
|
|
77
88
|
DownloadState(status=1, download_progress=0, **extras),
|