python-kasa 0.10.0__py3-none-any.whl → 0.10.2__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/cli/device.py CHANGED
@@ -48,7 +48,7 @@ async def state(ctx, dev: Device):
48
48
  )
49
49
  echo(
50
50
  f"Firmware: {dev.device_info.firmware_version}"
51
- f" {dev.device_info.firmware_build}"
51
+ f"{' ' + build if (build := dev.device_info.firmware_build) else ''}"
52
52
  )
53
53
  echo(f"MAC (rssi): {dev.mac} ({dev.rssi})")
54
54
  if verbose:
kasa/device.py CHANGED
@@ -161,7 +161,7 @@ class DeviceInfo:
161
161
  device_type: DeviceType
162
162
  hardware_version: str
163
163
  firmware_version: str
164
- firmware_build: str
164
+ firmware_build: str | None
165
165
  requires_auth: bool
166
166
  region: str | None
167
167
 
kasa/interfaces/energy.py CHANGED
@@ -28,7 +28,7 @@ class Energy(Module, ABC):
28
28
 
29
29
  _supported: ModuleFeature = ModuleFeature(0)
30
30
 
31
- def supports(self, module_feature: ModuleFeature) -> bool:
31
+ def supports(self, module_feature: Energy.ModuleFeature) -> bool:
32
32
  """Return True if module supports the feature."""
33
33
  return module_feature in self._supported
34
34
 
@@ -51,6 +51,7 @@ class LightEffect(Module, ABC):
51
51
  """Interface to represent a light effect module."""
52
52
 
53
53
  LIGHT_EFFECTS_OFF = "Off"
54
+ LIGHT_EFFECTS_UNNAMED_CUSTOM = "Custom"
54
55
 
55
56
  def _initialize_features(self) -> None:
56
57
  """Initialize features."""
@@ -77,7 +78,7 @@ class LightEffect(Module, ABC):
77
78
  @property
78
79
  @abstractmethod
79
80
  def effect(self) -> str:
80
- """Return effect state or name."""
81
+ """Return effect name."""
81
82
 
82
83
  @property
83
84
  @abstractmethod
kasa/iot/iotdevice.py CHANGED
@@ -760,7 +760,10 @@ class IotDevice(Device):
760
760
  device_family = sys_info.get("type", sys_info.get("mic_type"))
761
761
  device_type = IotDevice._get_device_type_from_sys_info(info)
762
762
  fw_version_full = sys_info["sw_ver"]
763
- firmware_version, firmware_build = fw_version_full.split(" ", maxsplit=1)
763
+ if " " in fw_version_full:
764
+ firmware_version, firmware_build = fw_version_full.split(" ", maxsplit=1)
765
+ else:
766
+ firmware_version, firmware_build = fw_version_full, None
764
767
  auth = bool(discovery_info and ("mgt_encrypt_schm" in discovery_info))
765
768
 
766
769
  return DeviceInfo(
kasa/iot/iotdimmer.py CHANGED
@@ -11,7 +11,7 @@ from ..module import Module
11
11
  from ..protocols import BaseProtocol
12
12
  from .iotdevice import KasaException, requires_update
13
13
  from .iotplug import IotPlug
14
- from .modules import AmbientLight, Light, Motion
14
+ from .modules import AmbientLight, Dimmer, Light, Motion
15
15
 
16
16
 
17
17
  class ButtonAction(Enum):
@@ -87,6 +87,7 @@ class IotDimmer(IotPlug):
87
87
  # TODO: need to be figured out what's the best approach to detect support
88
88
  self.add_module(Module.IotMotion, Motion(self, "smartlife.iot.PIR"))
89
89
  self.add_module(Module.IotAmbientLight, AmbientLight(self, "smartlife.iot.LAS"))
90
+ self.add_module(Module.IotDimmer, Dimmer(self, "smartlife.iot.dimmer"))
90
91
  self.add_module(Module.Light, Light(self, "light"))
91
92
 
92
93
  @property # type: ignore
@@ -4,6 +4,7 @@ from .ambientlight import AmbientLight
4
4
  from .antitheft import Antitheft
5
5
  from .cloud import Cloud
6
6
  from .countdown import Countdown
7
+ from .dimmer import Dimmer
7
8
  from .emeter import Emeter
8
9
  from .led import Led
9
10
  from .light import Light
@@ -20,6 +21,7 @@ __all__ = [
20
21
  "Antitheft",
21
22
  "Cloud",
22
23
  "Countdown",
24
+ "Dimmer",
23
25
  "Emeter",
24
26
  "Led",
25
27
  "Light",
@@ -0,0 +1,270 @@
1
+ """Implementation of the dimmer config module found in dimmers."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import logging
6
+ from datetime import timedelta
7
+ from typing import Any, Final, cast
8
+
9
+ from ...exceptions import KasaException
10
+ from ...feature import Feature
11
+ from ..iotmodule import IotModule, merge
12
+
13
+ _LOGGER = logging.getLogger(__name__)
14
+
15
+
16
+ def _td_to_ms(td: timedelta) -> int:
17
+ """
18
+ Convert timedelta to integer milliseconds.
19
+
20
+ Uses default float to integer rounding.
21
+ """
22
+ return int(td / timedelta(milliseconds=1))
23
+
24
+
25
+ class Dimmer(IotModule):
26
+ """Implements the dimmer config module."""
27
+
28
+ THRESHOLD_ABS_MIN: Final[int] = 0
29
+ # Strange value, but verified against hardware (KS220).
30
+ THRESHOLD_ABS_MAX: Final[int] = 51
31
+ FADE_TIME_ABS_MIN: Final[timedelta] = timedelta(seconds=0)
32
+ # Arbitrary, but set low intending GENTLE FADE for longer fades.
33
+ FADE_TIME_ABS_MAX: Final[timedelta] = timedelta(seconds=10)
34
+ GENTLE_TIME_ABS_MIN: Final[timedelta] = timedelta(seconds=0)
35
+ # Arbitrary, but reasonable default.
36
+ GENTLE_TIME_ABS_MAX: Final[timedelta] = timedelta(seconds=120)
37
+ # Verified against KS220.
38
+ RAMP_RATE_ABS_MIN: Final[int] = 10
39
+ # Verified against KS220.
40
+ RAMP_RATE_ABS_MAX: Final[int] = 50
41
+
42
+ def _initialize_features(self) -> None:
43
+ """Initialize features after the initial update."""
44
+ self._add_feature(
45
+ Feature(
46
+ device=self._device,
47
+ container=self,
48
+ id="dimmer_threshold_min",
49
+ name="Minimum dimming level",
50
+ icon="mdi:lightbulb-on-20",
51
+ attribute_getter="threshold_min",
52
+ attribute_setter="set_threshold_min",
53
+ range_getter=lambda: (self.THRESHOLD_ABS_MIN, self.THRESHOLD_ABS_MAX),
54
+ type=Feature.Type.Number,
55
+ category=Feature.Category.Config,
56
+ )
57
+ )
58
+
59
+ self._add_feature(
60
+ Feature(
61
+ device=self._device,
62
+ container=self,
63
+ id="dimmer_fade_off_time",
64
+ name="Dimmer fade off time",
65
+ icon="mdi:clock-in",
66
+ attribute_getter="fade_off_time",
67
+ attribute_setter="set_fade_off_time",
68
+ range_getter=lambda: (
69
+ _td_to_ms(self.FADE_TIME_ABS_MIN),
70
+ _td_to_ms(self.FADE_TIME_ABS_MAX),
71
+ ),
72
+ type=Feature.Type.Number,
73
+ category=Feature.Category.Config,
74
+ )
75
+ )
76
+
77
+ self._add_feature(
78
+ Feature(
79
+ device=self._device,
80
+ container=self,
81
+ id="dimmer_fade_on_time",
82
+ name="Dimmer fade on time",
83
+ icon="mdi:clock-out",
84
+ attribute_getter="fade_on_time",
85
+ attribute_setter="set_fade_on_time",
86
+ range_getter=lambda: (
87
+ _td_to_ms(self.FADE_TIME_ABS_MIN),
88
+ _td_to_ms(self.FADE_TIME_ABS_MAX),
89
+ ),
90
+ type=Feature.Type.Number,
91
+ category=Feature.Category.Config,
92
+ )
93
+ )
94
+
95
+ self._add_feature(
96
+ Feature(
97
+ device=self._device,
98
+ container=self,
99
+ id="dimmer_gentle_off_time",
100
+ name="Dimmer gentle off time",
101
+ icon="mdi:clock-in",
102
+ attribute_getter="gentle_off_time",
103
+ attribute_setter="set_gentle_off_time",
104
+ range_getter=lambda: (
105
+ _td_to_ms(self.GENTLE_TIME_ABS_MIN),
106
+ _td_to_ms(self.GENTLE_TIME_ABS_MAX),
107
+ ),
108
+ type=Feature.Type.Number,
109
+ category=Feature.Category.Config,
110
+ )
111
+ )
112
+
113
+ self._add_feature(
114
+ Feature(
115
+ device=self._device,
116
+ container=self,
117
+ id="dimmer_gentle_on_time",
118
+ name="Dimmer gentle on time",
119
+ icon="mdi:clock-out",
120
+ attribute_getter="gentle_on_time",
121
+ attribute_setter="set_gentle_on_time",
122
+ range_getter=lambda: (
123
+ _td_to_ms(self.GENTLE_TIME_ABS_MIN),
124
+ _td_to_ms(self.GENTLE_TIME_ABS_MAX),
125
+ ),
126
+ type=Feature.Type.Number,
127
+ category=Feature.Category.Config,
128
+ )
129
+ )
130
+
131
+ self._add_feature(
132
+ Feature(
133
+ device=self._device,
134
+ container=self,
135
+ id="dimmer_ramp_rate",
136
+ name="Dimmer ramp rate",
137
+ icon="mdi:clock-fast",
138
+ attribute_getter="ramp_rate",
139
+ attribute_setter="set_ramp_rate",
140
+ range_getter=lambda: (self.RAMP_RATE_ABS_MIN, self.RAMP_RATE_ABS_MAX),
141
+ type=Feature.Type.Number,
142
+ category=Feature.Category.Config,
143
+ )
144
+ )
145
+
146
+ def query(self) -> dict:
147
+ """Request Dimming configuration."""
148
+ req = merge(
149
+ self.query_for_command("get_dimmer_parameters"),
150
+ self.query_for_command("get_default_behavior"),
151
+ )
152
+
153
+ return req
154
+
155
+ @property
156
+ def config(self) -> dict[str, Any]:
157
+ """Return current configuration."""
158
+ return self.data["get_dimmer_parameters"]
159
+
160
+ @property
161
+ def threshold_min(self) -> int:
162
+ """Return the minimum dimming level for this dimmer."""
163
+ return self.config["minThreshold"]
164
+
165
+ async def set_threshold_min(self, min: int) -> dict:
166
+ """Set the minimum dimming level for this dimmer.
167
+
168
+ The value will depend on the luminaries connected to the dimmer.
169
+
170
+ :param min: The minimum dimming level, in the range 0-51.
171
+ """
172
+ if min < self.THRESHOLD_ABS_MIN or min > self.THRESHOLD_ABS_MAX:
173
+ raise KasaException(
174
+ "Minimum dimming threshold is outside the supported range: "
175
+ f"{self.THRESHOLD_ABS_MIN}-{self.THRESHOLD_ABS_MAX}"
176
+ )
177
+ return await self.call("calibrate_brightness", {"minThreshold": min})
178
+
179
+ @property
180
+ def fade_off_time(self) -> timedelta:
181
+ """Return the fade off animation duration."""
182
+ return timedelta(milliseconds=cast(int, self.config["fadeOffTime"]))
183
+
184
+ async def set_fade_off_time(self, time: int | timedelta) -> dict:
185
+ """Set the duration of the fade off animation.
186
+
187
+ :param time: The animation duration, in ms.
188
+ """
189
+ if isinstance(time, int):
190
+ time = timedelta(milliseconds=time)
191
+ if time < self.FADE_TIME_ABS_MIN or time > self.FADE_TIME_ABS_MAX:
192
+ raise KasaException(
193
+ "Fade time is outside the bounds of the supported range:"
194
+ f"{self.FADE_TIME_ABS_MIN}-{self.FADE_TIME_ABS_MAX}"
195
+ )
196
+ return await self.call("set_fade_off_time", {"fadeTime": _td_to_ms(time)})
197
+
198
+ @property
199
+ def fade_on_time(self) -> timedelta:
200
+ """Return the fade on animation duration."""
201
+ return timedelta(milliseconds=cast(int, self.config["fadeOnTime"]))
202
+
203
+ async def set_fade_on_time(self, time: int | timedelta) -> dict:
204
+ """Set the duration of the fade on animation.
205
+
206
+ :param time: The animation duration, in ms.
207
+ """
208
+ if isinstance(time, int):
209
+ time = timedelta(milliseconds=time)
210
+ if time < self.FADE_TIME_ABS_MIN or time > self.FADE_TIME_ABS_MAX:
211
+ raise KasaException(
212
+ "Fade time is outside the bounds of the supported range:"
213
+ f"{self.FADE_TIME_ABS_MIN}-{self.FADE_TIME_ABS_MAX}"
214
+ )
215
+ return await self.call("set_fade_on_time", {"fadeTime": _td_to_ms(time)})
216
+
217
+ @property
218
+ def gentle_off_time(self) -> timedelta:
219
+ """Return the gentle fade off animation duration."""
220
+ return timedelta(milliseconds=cast(int, self.config["gentleOffTime"]))
221
+
222
+ async def set_gentle_off_time(self, time: int | timedelta) -> dict:
223
+ """Set the duration of the gentle fade off animation.
224
+
225
+ :param time: The animation duration, in ms.
226
+ """
227
+ if isinstance(time, int):
228
+ time = timedelta(milliseconds=time)
229
+ if time < self.GENTLE_TIME_ABS_MIN or time > self.GENTLE_TIME_ABS_MAX:
230
+ raise KasaException(
231
+ "Gentle off time is outside the bounds of the supported range: "
232
+ f"{self.GENTLE_TIME_ABS_MIN}-{self.GENTLE_TIME_ABS_MAX}."
233
+ )
234
+ return await self.call("set_gentle_off_time", {"duration": _td_to_ms(time)})
235
+
236
+ @property
237
+ def gentle_on_time(self) -> timedelta:
238
+ """Return the gentle fade on animation duration."""
239
+ return timedelta(milliseconds=cast(int, self.config["gentleOnTime"]))
240
+
241
+ async def set_gentle_on_time(self, time: int | timedelta) -> dict:
242
+ """Set the duration of the gentle fade on animation.
243
+
244
+ :param time: The animation duration, in ms.
245
+ """
246
+ if isinstance(time, int):
247
+ time = timedelta(milliseconds=time)
248
+ if time < self.GENTLE_TIME_ABS_MIN or time > self.GENTLE_TIME_ABS_MAX:
249
+ raise KasaException(
250
+ "Gentle off time is outside the bounds of the supported range: "
251
+ f"{self.GENTLE_TIME_ABS_MIN}-{self.GENTLE_TIME_ABS_MAX}."
252
+ )
253
+ return await self.call("set_gentle_on_time", {"duration": _td_to_ms(time)})
254
+
255
+ @property
256
+ def ramp_rate(self) -> int:
257
+ """Return the rate that the dimmer buttons increment the dimmer level."""
258
+ return self.config["rampRate"]
259
+
260
+ async def set_ramp_rate(self, rate: int) -> dict:
261
+ """Set how quickly to ramp the dimming level when using the dimmer buttons.
262
+
263
+ :param rate: The rate to increment the dimming level with each press.
264
+ """
265
+ if rate < self.RAMP_RATE_ABS_MIN or rate > self.RAMP_RATE_ABS_MAX:
266
+ raise KasaException(
267
+ "Gentle off time is outside the bounds of the supported range:"
268
+ f"{self.RAMP_RATE_ABS_MIN}-{self.RAMP_RATE_ABS_MAX}"
269
+ )
270
+ return await self.call("set_button_ramp_rate", {"rampRate": rate})
@@ -12,20 +12,11 @@ class LightEffect(IotModule, LightEffectInterface):
12
12
 
13
13
  @property
14
14
  def effect(self) -> str:
15
- """Return effect state.
16
-
17
- Example:
18
- {'brightness': 50,
19
- 'custom': 0,
20
- 'enable': 0,
21
- 'id': '',
22
- 'name': ''}
23
- """
15
+ """Return effect name."""
24
16
  eff = self.data["lighting_effect_state"]
25
17
  name = eff["name"]
26
18
  if eff["enable"]:
27
- return name
28
-
19
+ return name or self.LIGHT_EFFECTS_UNNAMED_CUSTOM
29
20
  return self.LIGHT_EFFECTS_OFF
30
21
 
31
22
  @property
kasa/module.py CHANGED
@@ -111,6 +111,7 @@ class Module(ABC):
111
111
  IotAmbientLight: Final[ModuleName[iot.AmbientLight]] = ModuleName("ambient")
112
112
  IotAntitheft: Final[ModuleName[iot.Antitheft]] = ModuleName("anti_theft")
113
113
  IotCountdown: Final[ModuleName[iot.Countdown]] = ModuleName("countdown")
114
+ IotDimmer: Final[ModuleName[iot.Dimmer]] = ModuleName("dimmer")
114
115
  IotMotion: Final[ModuleName[iot.Motion]] = ModuleName("motion")
115
116
  IotSchedule: Final[ModuleName[iot.Schedule]] = ModuleName("schedule")
116
117
  IotUsage: Final[ModuleName[iot.Usage]] = ModuleName("usage")
@@ -182,6 +183,11 @@ class Module(ABC):
182
183
  self._module = module
183
184
  self._module_features: dict[str, Feature] = {}
184
185
 
186
+ @property
187
+ def device(self) -> Device:
188
+ """Return the device exposing the module."""
189
+ return self._device
190
+
185
191
  @property
186
192
  def _all_features(self) -> dict[str, Feature]:
187
193
  """Get the features for this module and any sub modules."""
@@ -19,6 +19,8 @@ class Mode(IntEnum):
19
19
  Balanced = 2
20
20
  Max = 3
21
21
 
22
+ Off = -1_000
23
+
22
24
 
23
25
  class Dustbin(SmartModule):
24
26
  """Implementation of vacuum dustbin."""
@@ -91,6 +93,8 @@ class Dustbin(SmartModule):
91
93
  @property
92
94
  def mode(self) -> str:
93
95
  """Return auto-emptying mode."""
96
+ if self.auto_collection is False:
97
+ return Mode.Off.name
94
98
  return Mode(self._settings["dust_collection_mode"]).name
95
99
 
96
100
  async def set_mode(self, mode: str) -> dict:
@@ -101,8 +105,14 @@ class Dustbin(SmartModule):
101
105
  "Invalid auto/emptying mode speed %s, available %s", mode, name_to_value
102
106
  )
103
107
 
108
+ if mode == Mode.Off.name:
109
+ return await self.set_auto_collection(False)
110
+
111
+ # Make a copy just in case, even when we are overriding both settings
104
112
  settings = self._settings.copy()
113
+ settings["auto_dust_collection"] = True
105
114
  settings["dust_collection_mode"] = name_to_value[mode]
115
+
106
116
  return await self.call("setDustCollectionInfo", settings)
107
117
 
108
118
  @property
@@ -37,20 +37,14 @@ class LightStripEffect(SmartModule, SmartLightEffect):
37
37
 
38
38
  @property
39
39
  def effect(self) -> str:
40
- """Return effect state.
41
-
42
- Example:
43
- {'brightness': 50,
44
- 'custom': 0,
45
- 'enable': 0,
46
- 'id': '',
47
- 'name': ''}
48
- """
40
+ """Return effect name."""
49
41
  eff = self.data["lighting_effect"]
50
42
  name = eff["name"]
51
43
  # When devices are unpaired effect name is softAP which is not in our list
52
44
  if eff["enable"] and name in self._effect_list:
53
45
  return name
46
+ if eff["enable"] and eff["custom"]:
47
+ return name or self.LIGHT_EFFECTS_UNNAMED_CUSTOM
54
48
  return self.LIGHT_EFFECTS_OFF
55
49
 
56
50
  @property
kasa/smart/smartdevice.py CHANGED
@@ -913,7 +913,10 @@ class SmartDevice(Device):
913
913
  components, device_family
914
914
  )
915
915
  fw_version_full = di["fw_ver"]
916
- firmware_version, firmware_build = fw_version_full.split(" ", maxsplit=1)
916
+ if " " in fw_version_full:
917
+ firmware_version, firmware_build = fw_version_full.split(" ", maxsplit=1)
918
+ else:
919
+ firmware_version, firmware_build = fw_version_full, None
917
920
  _protocol, devicetype = device_family.split(".")
918
921
  # Brand inferred from SMART.KASAPLUG/SMART.TAPOPLUG etc.
919
922
  brand = devicetype[:4].lower()
kasa/smart/smartmodule.py CHANGED
@@ -3,7 +3,8 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  import logging
6
- from collections.abc import Awaitable, Callable, Coroutine
6
+ from collections.abc import Callable, Coroutine
7
+ from functools import wraps
7
8
  from typing import TYPE_CHECKING, Any, Concatenate, ParamSpec, TypeVar
8
9
 
9
10
  from ..exceptions import DeviceError, KasaException, SmartErrorCode
@@ -20,15 +21,16 @@ _R = TypeVar("_R")
20
21
 
21
22
 
22
23
  def allow_update_after(
23
- func: Callable[Concatenate[_T, _P], Awaitable[dict]],
24
- ) -> Callable[Concatenate[_T, _P], Coroutine[Any, Any, dict]]:
24
+ func: Callable[Concatenate[_T, _P], Coroutine[Any, Any, _R]],
25
+ ) -> Callable[Concatenate[_T, _P], Coroutine[Any, Any, _R]]:
25
26
  """Define a wrapper to set _last_update_time to None.
26
27
 
27
28
  This will ensure that a module is updated in the next update cycle after
28
29
  a value has been changed.
29
30
  """
30
31
 
31
- async def _async_wrap(self: _T, *args: _P.args, **kwargs: _P.kwargs) -> dict:
32
+ @wraps(func)
33
+ async def _async_wrap(self: _T, *args: _P.args, **kwargs: _P.kwargs) -> _R:
32
34
  try:
33
35
  return await func(self, *args, **kwargs)
34
36
  finally:
@@ -40,6 +42,7 @@ def allow_update_after(
40
42
  def raise_if_update_error(func: Callable[[_T], _R]) -> Callable[[_T], _R]:
41
43
  """Define a wrapper to raise an error if the last module update was an error."""
42
44
 
45
+ @wraps(func)
43
46
  def _wrap(self: _T) -> _R:
44
47
  if err := self._last_update_error:
45
48
  raise err
@@ -2,8 +2,11 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
+ from typing import Annotated
6
+
5
7
  from ...feature import Feature
6
8
  from ...interfaces import Alarm as AlarmInterface
9
+ from ...module import FeatureAttribute
7
10
  from ...smart.smartmodule import allow_update_after
8
11
  from ..smartcammodule import SmartCamModule
9
12
 
@@ -105,12 +108,12 @@ class Alarm(SmartCamModule, AlarmInterface):
105
108
  )
106
109
 
107
110
  @property
108
- def alarm_sound(self) -> str:
111
+ def alarm_sound(self) -> Annotated[str, FeatureAttribute()]:
109
112
  """Return current alarm sound."""
110
113
  return self.data["getSirenConfig"]["siren_type"]
111
114
 
112
115
  @allow_update_after
113
- async def set_alarm_sound(self, sound: str) -> dict:
116
+ async def set_alarm_sound(self, sound: str) -> Annotated[dict, FeatureAttribute()]:
114
117
  """Set alarm sound.
115
118
 
116
119
  See *alarm_sounds* for list of available sounds.
@@ -124,7 +127,7 @@ class Alarm(SmartCamModule, AlarmInterface):
124
127
  return self.data["getSirenTypeList"]["siren_type_list"]
125
128
 
126
129
  @property
127
- def alarm_volume(self) -> int:
130
+ def alarm_volume(self) -> Annotated[int, FeatureAttribute()]:
128
131
  """Return alarm volume.
129
132
 
130
133
  Unlike duration the device expects/returns a string for volume.
@@ -132,18 +135,22 @@ class Alarm(SmartCamModule, AlarmInterface):
132
135
  return int(self.data["getSirenConfig"]["volume"])
133
136
 
134
137
  @allow_update_after
135
- async def set_alarm_volume(self, volume: int) -> dict:
138
+ async def set_alarm_volume(
139
+ self, volume: int
140
+ ) -> Annotated[dict, FeatureAttribute()]:
136
141
  """Set alarm volume."""
137
142
  config = self._validate_and_get_config(volume=volume)
138
143
  return await self.call("setSirenConfig", {"siren": config})
139
144
 
140
145
  @property
141
- def alarm_duration(self) -> int:
146
+ def alarm_duration(self) -> Annotated[int, FeatureAttribute()]:
142
147
  """Return alarm duration."""
143
148
  return self.data["getSirenConfig"]["duration"]
144
149
 
145
150
  @allow_update_after
146
- async def set_alarm_duration(self, duration: int) -> dict:
151
+ async def set_alarm_duration(
152
+ self, duration: int
153
+ ) -> Annotated[dict, FeatureAttribute()]:
147
154
  """Set alarm volume."""
148
155
  config = self._validate_and_get_config(duration=duration)
149
156
  return await self.call("setSirenConfig", {"siren": config})
@@ -103,7 +103,10 @@ class SmartCamChild(SmartChildDevice, SmartCamDevice):
103
103
  model = cifp["device_model"]
104
104
  device_type = SmartCamDevice._get_device_type_from_sysinfo(cifp)
105
105
  fw_version_full = cifp["sw_ver"]
106
- firmware_version, firmware_build = fw_version_full.split(" ", maxsplit=1)
106
+ if " " in fw_version_full:
107
+ firmware_version, firmware_build = fw_version_full.split(" ", maxsplit=1)
108
+ else:
109
+ firmware_version, firmware_build = fw_version_full, None
107
110
  return DeviceInfo(
108
111
  short_name=model,
109
112
  long_name=model,
@@ -47,7 +47,10 @@ class SmartCamDevice(SmartDevice):
47
47
  long_name = discovery_info["device_model"] if discovery_info else short_name
48
48
  device_type = SmartCamDevice._get_device_type_from_sysinfo(basic_info)
49
49
  fw_version_full = basic_info["sw_version"]
50
- firmware_version, firmware_build = fw_version_full.split(" ", maxsplit=1)
50
+ if " " in fw_version_full:
51
+ firmware_version, firmware_build = fw_version_full.split(" ", maxsplit=1)
52
+ else:
53
+ firmware_version, firmware_build = fw_version_full, None
51
54
  return DeviceInfo(
52
55
  short_name=basic_info["device_model"],
53
56
  long_name=long_name,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-kasa
3
- Version: 0.10.0
3
+ Version: 0.10.2
4
4
  Summary: Python API for TP-Link Kasa and Tapo devices
5
5
  Project-URL: Homepage, https://github.com/python-kasa/python-kasa
6
6
  Project-URL: Bug Tracker, https://github.com/python-kasa/python-kasa/issues
@@ -236,9 +236,9 @@ The following devices have been tested and confirmed as working. If your device
236
236
  - **Plugs**: P100, P110, P110M, P115, P125M, P135, TP15
237
237
  - **Power Strips**: P210M, P300, P304M, P306, TP25
238
238
  - **Wall Switches**: S210, S220, S500D, S505, S505D
239
- - **Bulbs**: L510B, L510E, L530E, L630
239
+ - **Bulbs**: L510B, L510E, L530B, L530E, L630
240
240
  - **Light Strips**: L900-10, L900-5, L920-5, L930-5
241
- - **Cameras**: C100, C210, C220, C225, C325WB, C520WS, C720, TC65, TC70
241
+ - **Cameras**: C100, C110, C210, C220, C225, C325WB, C520WS, C720, TC65, TC70
242
242
  - **Doorbells and chimes**: D100C, D130, D230
243
243
  - **Vacuums**: RV20 Max Plus, RV30 Max
244
244
  - **Hubs**: H100, H200
@@ -1,7 +1,7 @@
1
1
  kasa/__init__.py,sha256=Bpu9H0z_6vNEIZqtejXSiXU4X_-CdqW841aOG7wJ-6o,4868
2
2
  kasa/cachedzoneinfo.py,sha256=wrttrnBRqbjKDpYeuGkdNSASHABQxHVFzi1811-IkyE,777
3
3
  kasa/credentials.py,sha256=DnNJjcc0KNwTKPklko37yUcOqiLMs78-mheNljDjxaU,926
4
- kasa/device.py,sha256=Kk79KO7it3vfligg3ndX__lp6IyzBaUKVH8j6fEqvFM,20475
4
+ kasa/device.py,sha256=Wh5yGqi5q3uvF82CUX3U_nO8iiH5uMN9tV_h5beTTag,20482
5
5
  kasa/device_factory.py,sha256=Cu87oiMIuVMcwLBc8BYB4QXijB9NgzQwf0N7wuWaJDc,8395
6
6
  kasa/device_type.py,sha256=1PMELn2IuMEfuNrHn8rjTiC5AShYCvQf3x8gYvoMLlA,834
7
7
  kasa/deviceconfig.py,sha256=2rd9Qjwe--SMYqf9Itgg5hx5vpTBMaQeFBJyX7IaC4o,6595
@@ -11,14 +11,14 @@ kasa/exceptions.py,sha256=9qT6eWGT_kULzgCliMr5K4tDETcdjacDMwLJAc1a-jc,5873
11
11
  kasa/feature.py,sha256=WwYgBHfqsiLTjV4rJTOz5n2O888Wid6BTxy28oSZu_Y,11729
12
12
  kasa/httpclient.py,sha256=tb8yZjBtBubvfOtV2F_Gr8qvHkFcXsAc8j5mytoib2Q,6288
13
13
  kasa/json.py,sha256=KMJh-A5nQR2Uny8nKRzJEJc2o-JRewTarok_nqS7hX4,1021
14
- kasa/module.py,sha256=ylaRbEYS-Yaviokum8TdmbGYM6EzTXJRzhV3m0BmCZY,11632
14
+ kasa/module.py,sha256=WvBHr5SB8BU6Ub2iTgnUgaJpTiBCtIK5UBdkqN19jlU,11828
15
15
  kasa/modulemapping.py,sha256=79mtaewNYvhFjn1Jo39xE57aid5gn08A-45bOS0vgMs,499
16
16
  kasa/modulemapping.pyi,sha256=sUntMvhBf6eoFK61aAanXBjEqXlVEaiPS2cvrX-3RAI,3819
17
17
  kasa/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
18
  kasa/cli/__init__.py,sha256=S8z6xs4EPXXtF2wLwuvDLjcuy46c0jWaG0wiqqU5FiY,27
19
19
  kasa/cli/__main__.py,sha256=B5nsKIZhYL1upQHrrKXnqE3t261v8nthD52e8m3DAgY,88
20
20
  kasa/cli/common.py,sha256=3ctHgSAU5RnAujWJtfPc6uPlB9QB5AeseCPHxOsJxJU,9399
21
- kasa/cli/device.py,sha256=b_RlZV9CF04cvtFx6pHfQ4ujwXB0kKiguMoLj27LR48,5828
21
+ kasa/cli/device.py,sha256=wAAENY8Z7Xcb35aKrGKrJspeOyNBCauuTO50nVHRJ5k,5861
22
22
  kasa/cli/discover.py,sha256=SUQ396O-Jr0Gp0jP8yafpS2AsLrtClRn7pTrspr_F18,12598
23
23
  kasa/cli/feature.py,sha256=ThQj-Tg_lauA2l58HVLUvr5WJ8sXHUz2ivTGkg8c-dk,4328
24
24
  kasa/cli/hub.py,sha256=PjzK9DtGE74k30DRv07vulC1tASnpIs-OMh3fHq8PVo,2437
@@ -33,11 +33,11 @@ kasa/cli/wifi.py,sha256=bonxQ3h_Hd6-_kEc3xpwqXl0CnD82bBOGLllgJqg-dw,1108
33
33
  kasa/interfaces/__init__.py,sha256=r_37JMkZhcdsVYL6Nr0JohHReuNACsJyJ83SjchVYOM,550
34
34
  kasa/interfaces/alarm.py,sha256=C_erZxYhEST5u0OYU4dcBsxLeCKW5TZQkE6uHuDYmG8,1955
35
35
  kasa/interfaces/childsetup.py,sha256=M9OwDWdovGiM3FIWmkxFM4wauIumCCnAOzWvdD7g1hw,1944
36
- kasa/interfaces/energy.py,sha256=kDjtP9M2ufKq4syxGbvyRf9cUwvqSiowE-6RK4_ztW4,6308
36
+ kasa/interfaces/energy.py,sha256=VR8KJA1M46Wir6QNPjRj9aJUsAlVfgk_32HWkTHHUqE,6315
37
37
  kasa/interfaces/fan.py,sha256=DtFh3dVk5enXSxQpmPb2cQMRmHiC6ltEgU6HvcF_KjE,542
38
38
  kasa/interfaces/led.py,sha256=Oh9o5RYq4pEMXYzs1Z9Posczk4AEkr9rOYKWXAx3WsA,958
39
39
  kasa/interfaces/light.py,sha256=e5HyoNE77tTzvGNTJyWp0QL-XwtGdnz-nDeueJVUK7Y,6050
40
- kasa/interfaces/lighteffect.py,sha256=kiwv4BA-XsRyrK-gZztnxQHtTKEYqDkN8ixCDSsrta4,3095
40
+ kasa/interfaces/lighteffect.py,sha256=5f3rcA0n1bGzz6Uxcs24urx1OeBZmowU5ifuOuKflFw,3130
41
41
  kasa/interfaces/lightpreset.py,sha256=eZByie5soSMRWB6TCqNX2h4Dm1cub2cEKBGFu8z19BY,4078
42
42
  kasa/interfaces/thermostat.py,sha256=JaP1R7nb7I-w0ICBkqyS-jireisODuVq4SFlP8Knhmw,1660
43
43
  kasa/interfaces/time.py,sha256=MTrhDdzMc4Cad9AB3CC0yhHCif7tIipK4dgcJ-Lt7GA,585
@@ -45,22 +45,23 @@ kasa/iot/__init__.py,sha256=Ib0O2S13k2_JaOlmDe4x16HZCDIK39n3hgdEeton00I,449
45
45
  kasa/iot/effects.py,sha256=au35HDrHso7JRdv9bPSdkepdpR8NbSp-gFGHW2SKZUw,7506
46
46
  kasa/iot/iotbulb.py,sha256=LdeRYOX3gE008nIaE0_bYkVMbhQZW178lKYj4hG-7xI,18541
47
47
  kasa/iot/iotcamera.py,sha256=TmALKJCAqaDz4OxmkWD8lJdTzBf_TLPP8zGESvivKjI,1064
48
- kasa/iot/iotdevice.py,sha256=4YOq8FmTod5mrByDX9plUf90LWe6cMSIDvM823dId-U,27358
49
- kasa/iot/iotdimmer.py,sha256=w9aPeq3qaaZTSZENBPZJWhDci8WKr4blJts7qQrDxe0,7861
48
+ kasa/iot/iotdevice.py,sha256=eWeaJCKiSHEJscQk25866FLjd09K05aFlKWJkBQWV4U,27480
49
+ kasa/iot/iotdimmer.py,sha256=aNKksfI5SW8UdwCpXNAwklqP3hAvJDLH7xSTAUpP7F4,7949
50
50
  kasa/iot/iotlightstrip.py,sha256=tvJua0IcQKgWy1MsrY5PgeXZHIUMJqbdhpVlEJykrw8,2113
51
51
  kasa/iot/iotmodule.py,sha256=CnH0Vy8dSVohSF5c8ikuJapdLZOz6LdINvSjSPAf3u8,2342
52
52
  kasa/iot/iotplug.py,sha256=rAJ-5BXUscDar26FQmVqrzoX-BqTYhxCILqlsULJvzw,3469
53
53
  kasa/iot/iotstrip.py,sha256=0__IHZXtpx0_tDNLce9mWaUemRvTjC_xX7afnbBkwN8,16550
54
54
  kasa/iot/iottimezone.py,sha256=7bGRisFYaNJ5RK-x551XEoPSvBsBzPF6HTvKs7-gtB4,5093
55
- kasa/iot/modules/__init__.py,sha256=Nq49DvOol1DcURsL3ZmXRLOmQRAgA7s3yFA9aiKQkss,751
55
+ kasa/iot/modules/__init__.py,sha256=xPPwKgcyAeUTdL5GkldfWzcq4z8iDxnCNZMPaeo0EI4,792
56
56
  kasa/iot/modules/ambientlight.py,sha256=6n-juaw-Nxqz0PMUXG6opVG54VLRUvYWtp03-TI7GrI,2946
57
57
  kasa/iot/modules/antitheft.py,sha256=XV5NM_zMLMU50KpR-MCFGx-1S4TxB61jcuOh3KZ-9Zc,235
58
58
  kasa/iot/modules/cloud.py,sha256=PyPNuA36e_VLuJDN9klJH34I4hIgzEyeNlSAu0SUJyc,2533
59
59
  kasa/iot/modules/countdown.py,sha256=53PUMGv3L1zMTkx1PBRvMSGzqX6ZnbwmtXHMyBioT4o,159
60
+ kasa/iot/modules/dimmer.py,sha256=XDhlSEDCGiJp68CLypahQhVUADR0pdYeUmvTVIBPoYI,10202
60
61
  kasa/iot/modules/emeter.py,sha256=PbxNv-IDa8gjznsUEU8qU05_J0trAUJoWrfGS1yc2iM,5125
61
62
  kasa/iot/modules/led.py,sha256=VJ0Mia04z5XKDKeuP7GDZEOushHl4rpoCS7cD_jkeyw,986
62
63
  kasa/iot/modules/light.py,sha256=itkx3neFMJyqmPTL9ON5JH0F6WrMa-W7nsqT35sfalM,8761
63
- kasa/iot/modules/lighteffect.py,sha256=221c_yzkvNKsfrnXMBEqP_Lg1CKfapPRB7mfJJgfK9I,4221
64
+ kasa/iot/modules/lighteffect.py,sha256=X0UNXo-jPaeVmFH8M0ctlE2iU654oUQhbV0Zd3wsuic,4098
64
65
  kasa/iot/modules/lightpreset.py,sha256=lyJ0w1ytRRUZ1fY_-JT9V2SPsmf_9np47BLYrjkrN80,5649
65
66
  kasa/iot/modules/motion.py,sha256=lwDOHqb8Au_1I6u8BjdomqzMyfW_xCJemYv9CL02lnk,12624
66
67
  kasa/iot/modules/rulemodule.py,sha256=7PKjtSg_E4OETxIQVLtCVRHxP1M96k3t1LCBhNIguoQ,2105
@@ -75,8 +76,8 @@ kasa/protocols/smartprotocol.py,sha256=NzpKYkYmme19p2iQAJuCB2qXbTbwDWvjDByZLuIR8
75
76
  kasa/smart/__init__.py,sha256=gdmi-Doe7dnv7e8ab_892lr9IdOXeFa3XlU3u_CePCk,198
76
77
  kasa/smart/effects.py,sha256=J_mkX2L-7IJSaL5K4CpBaOdk-humx3cVxg7yioGhtF4,11498
77
78
  kasa/smart/smartchilddevice.py,sha256=nnFbbKES57loQLEFOhABYrmV9a9OzndTCBk6AoAsPhc,5989
78
- kasa/smart/smartdevice.py,sha256=8JYkyLSCtZhGGNtJe_NEsPTaPXGSUq6Vr_mnKlSerjE,34020
79
- kasa/smart/smartmodule.py,sha256=72cLlsSCyuesgn_ikos0LsevtV7CCa1tkvfoI38DNJ8,8931
79
+ kasa/smart/smartdevice.py,sha256=DYPZW7vLkTN8Z5_Lnmq8QTUCWgCtX0h6S74vKG82D7Y,34142
80
+ kasa/smart/smartmodule.py,sha256=8PAh6KCiO4NWCJuevSgxA6CIwZFliDzD2t8CwaYs_Uc,8986
80
81
  kasa/smart/modules/__init__.py,sha256=MHX7SNBL0wc0DyBaSHszA3PB47JLlk--m4ErejzNZR8,2356
81
82
  kasa/smart/modules/alarm.py,sha256=LpeHbgZdG4uTxebNvd0gE_Y5iEJQW9jWQdi5in1QvX4,8556
82
83
  kasa/smart/modules/autooff.py,sha256=TAk-YWRy8EikXesJbDe20HlV-UgtuHD6mCvn3jE0MzA,3285
@@ -94,7 +95,7 @@ kasa/smart/modules/colortemperature.py,sha256=iF57zSPNNZsNvek_B4xy58im0yhvErm56T
94
95
  kasa/smart/modules/consumables.py,sha256=3WNZ7ITGL8YZJcvXbwc_fSl54ETy66eWmlK1oyxI3js,5040
95
96
  kasa/smart/modules/contactsensor.py,sha256=cPuC3XZ6dUOl9infbs5dM9BK8uF6zztWCjHLjfpJTtA,1068
96
97
  kasa/smart/modules/devicemodule.py,sha256=-R1kl8yDbg8l80Bg6Pk2RsZaSSIZ9lzWZALqnOsXLWQ,970
97
- kasa/smart/modules/dustbin.py,sha256=oA9cxMkRvi99UM_b2p6ZZNCl4OBWiM9RP41Nav7bISA,3415
98
+ kasa/smart/modules/dustbin.py,sha256=x79NYj7fEQE69zcRKEDTKTQ16Bl4NV3nsYJCxuxXcxo,3727
98
99
  kasa/smart/modules/energy.py,sha256=QoqF0BrRTnxDcFtRvdzTsXn4DiisMde2UHiNqi1AmT8,5795
99
100
  kasa/smart/modules/fan.py,sha256=8peH-UNDLyZd8zlrcjQAyC4_2gD2nivYWf5qcQlGkBE,2683
100
101
  kasa/smart/modules/firmware.py,sha256=Qm7Vyj7TU3HtElK-3clUtt94tVPS3jcpdmfNNz-GCGo,8504
@@ -105,7 +106,7 @@ kasa/smart/modules/led.py,sha256=1jrxS9b0Zd7Gye07VnApKUT8lcm4bse-6IqjumEcXt8,153
105
106
  kasa/smart/modules/light.py,sha256=OKSdg1N8Hpc961fzaPa6y8BfbWTtdVzcsuj-xHsru_8,5627
106
107
  kasa/smart/modules/lighteffect.py,sha256=Ee90hgehBLCWNTq5qOD-9FNCHgDW4uqt26V0YACwGZo,6341
107
108
  kasa/smart/modules/lightpreset.py,sha256=9foZbzpCx1aUxps5K7_YdLP9tG5wPOyqACGhL-xuTJI,6672
108
- kasa/smart/modules/lightstripeffect.py,sha256=TIRUF-iJM25VhjyAHkuzEYr8vtqyCxMe62TcX95oP0g,6059
109
+ kasa/smart/modules/lightstripeffect.py,sha256=hklF4hbp3p1TeQZlcvuny9vtQuo8AiMocX1uiwZ7mTA,6005
109
110
  kasa/smart/modules/lighttransition.py,sha256=TzQmbeVVy2Slu6ELLrB0KMDJm2KEb2H8l2kHUHKBJqA,8941
110
111
  kasa/smart/modules/matter.py,sha256=8UgNUVXRGqqeD-1Ms7exDHzj1KFYCY5uDCtDF--na_8,1274
111
112
  kasa/smart/modules/mop.py,sha256=-TGdHGFN-hZ2aGD18Y7In1MxaLykZ4Lb2WWXo5w9SDo,2590
@@ -121,11 +122,11 @@ kasa/smart/modules/time.py,sha256=g7wEYeYBqX5RPshwzzcr-6GsrxzOx2klQ-Tslma6f-k,31
121
122
  kasa/smart/modules/triggerlogs.py,sha256=_8-138YuVNDbXsNmbmRn4_a_efE2N4OR_nKCYSRk-zk,897
122
123
  kasa/smart/modules/waterleaksensor.py,sha256=866GzJxGq1NzDPzRMOXdVQx5dW-cc6fQWbufR4-bmfI,2691
123
124
  kasa/smartcam/__init__.py,sha256=4WlKyA-Jvm1WaI28hwDBUkh4YgHiy2rtqKzCTgqEHSE,183
124
- kasa/smartcam/smartcamchild.py,sha256=ikXAwyV_ekVOXKHe43HDu8pVEKLSON_9GsmfOetXlhk,4100
125
- kasa/smartcam/smartcamdevice.py,sha256=LxOgrgcE71z2hGGNfoA_vnhxS1bSmqHk-KmrrvAIiG0,10433
125
+ kasa/smartcam/smartcamchild.py,sha256=WNU8_bRMhVUcRzsojxhADxyL79ovfNT7cBa0NrWShHI,4222
126
+ kasa/smartcam/smartcamdevice.py,sha256=6DLEs4N6AbPC7QPLlVU-S59zWABM0Irg0vq5Nl9JBT8,10555
126
127
  kasa/smartcam/smartcammodule.py,sha256=eqY6xkwO5XzYj2vuLFwr-vA_g1DQl1GHhdAJA1bSvyw,3724
127
128
  kasa/smartcam/modules/__init__.py,sha256=tw3XQUsDNvSBkaHFExVOmw-ThbYZXwxDUJ5-9TStOdo,914
128
- kasa/smartcam/modules/alarm.py,sha256=68Qg0xRpVT5W3AmGEsVV85voH78nWm3iw4EoLL3qpFs,6643
129
+ kasa/smartcam/modules/alarm.py,sha256=dvpok39Yq-UVFWHJboFwRRYLi2aNCWiphXZLXr3nfLE,6926
129
130
  kasa/smartcam/modules/babycrydetection.py,sha256=E8OWlEYnOxy34LnuOd4rbbBgSu2xZyVT0czCVuiMF6I,1513
130
131
  kasa/smartcam/modules/battery.py,sha256=E6EJQyRQtm1t005MGmoBK4Ns-e95WfFpxg5nT4DKjaM,3352
131
132
  kasa/smartcam/modules/camera.py,sha256=sil8Lc8vUc97CxCq0aDkatghfFLpr3xO7-2MDaXAb-E,4114
@@ -150,8 +151,8 @@ kasa/transports/linkietransport.py,sha256=KUGnYdmDV9g6FIt06Lk3y-AsLfWqAsMuo_f7m_
150
151
  kasa/transports/sslaestransport.py,sha256=MzJ7sExaLwUsgcXE3Sy_jVo_1nEnD7lgap9Mv4tMU8U,24276
151
152
  kasa/transports/ssltransport.py,sha256=3F9wZ5eQUWED3rSNh6m5zMFC94DL0JXKR_yj5XLlhmo,7861
152
153
  kasa/transports/xortransport.py,sha256=t2ImPcZIM2MV9EEzeS3RnJxicdEAv009HP0KN3k3oRw,8870
153
- python_kasa-0.10.0.dist-info/METADATA,sha256=DizCg0l91XM_MY8IcgSDH9kLmpxXeS1-BX-XsgWNUSs,12168
154
- python_kasa-0.10.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
155
- python_kasa-0.10.0.dist-info/entry_points.txt,sha256=gTVS_oUcmt4q77WSkppQofMelqufh0zeXvvUkmBPRJA,47
156
- python_kasa-0.10.0.dist-info/licenses/LICENSE,sha256=Klt9aEsei738epLgYqeikhpdBWwMvU1VAli14Bxlc5c,33218
157
- python_kasa-0.10.0.dist-info/RECORD,,
154
+ python_kasa-0.10.2.dist-info/METADATA,sha256=xm-4TSSSb6fYWe99gd23r5m7MdzmZGRnjed-AIUWWic,12181
155
+ python_kasa-0.10.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
156
+ python_kasa-0.10.2.dist-info/entry_points.txt,sha256=gTVS_oUcmt4q77WSkppQofMelqufh0zeXvvUkmBPRJA,47
157
+ python_kasa-0.10.2.dist-info/licenses/LICENSE,sha256=Klt9aEsei738epLgYqeikhpdBWwMvU1VAli14Bxlc5c,33218
158
+ python_kasa-0.10.2.dist-info/RECORD,,