python-kasa 0.7.0.dev5__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.
Files changed (48) hide show
  1. kasa/aestransport.py +6 -2
  2. kasa/cli.py +60 -45
  3. kasa/device.py +105 -2
  4. kasa/discover.py +2 -1
  5. kasa/feature.py +85 -10
  6. kasa/httpclient.py +1 -1
  7. kasa/interfaces/energy.py +6 -0
  8. kasa/interfaces/light.py +61 -1
  9. kasa/interfaces/lighteffect.py +41 -1
  10. kasa/interfaces/lightpreset.py +70 -2
  11. kasa/iot/iotdevice.py +6 -1
  12. kasa/iot/iotstrip.py +14 -3
  13. kasa/iot/modules/lightpreset.py +2 -1
  14. kasa/module.py +39 -1
  15. kasa/smart/modules/alarm.py +1 -0
  16. kasa/smart/modules/autooff.py +3 -1
  17. kasa/smart/modules/childdevice.py +39 -1
  18. kasa/smart/modules/firmware.py +4 -1
  19. kasa/smart/modules/frostprotection.py +0 -22
  20. kasa/smart/modules/humiditysensor.py +1 -0
  21. kasa/smart/modules/led.py +1 -1
  22. kasa/smart/modules/lightpreset.py +2 -1
  23. kasa/smart/modules/lighttransition.py +5 -7
  24. kasa/smart/modules/reportmode.py +2 -0
  25. kasa/smart/modules/temperaturecontrol.py +3 -2
  26. kasa/smart/modules/temperaturesensor.py +3 -2
  27. kasa/smart/modules/time.py +3 -2
  28. kasa/smart/modules/waterleaksensor.py +2 -0
  29. kasa/smart/smartdevice.py +10 -5
  30. kasa/tests/device_fixtures.py +1 -1
  31. kasa/tests/discovery_fixtures.py +3 -1
  32. kasa/tests/fakeprotocol_smart.py +2 -2
  33. kasa/tests/smart/modules/test_firmware.py +12 -1
  34. kasa/tests/test_cli.py +18 -3
  35. kasa/tests/test_device.py +2 -1
  36. kasa/tests/test_emeter.py +8 -8
  37. kasa/tests/test_feature.py +6 -2
  38. kasa/tests/test_httpclient.py +2 -2
  39. kasa/tests/test_iotdevice.py +5 -4
  40. kasa/tests/test_readme_examples.py +59 -0
  41. kasa/tests/test_smartdevice.py +4 -3
  42. kasa/tests/test_strip.py +15 -2
  43. kasa/xortransport.py +3 -3
  44. {python_kasa-0.7.0.dev5.dist-info → python_kasa-0.7.0.1.dist-info}/METADATA +102 -129
  45. {python_kasa-0.7.0.dev5.dist-info → python_kasa-0.7.0.1.dist-info}/RECORD +48 -48
  46. {python_kasa-0.7.0.dev5.dist-info → python_kasa-0.7.0.1.dist-info}/LICENSE +0 -0
  47. {python_kasa-0.7.0.dev5.dist-info → python_kasa-0.7.0.1.dist-info}/WHEEL +0 -0
  48. {python_kasa-0.7.0.dev5.dist-info → python_kasa-0.7.0.1.dist-info}/entry_points.txt +0 -0
@@ -1,4 +1,44 @@
1
- """Module for base light effect module."""
1
+ """Interact with a TPLink Light Effect.
2
+
3
+ >>> from kasa import Discover, Module, LightState
4
+ >>>
5
+ >>> dev = await Discover.discover_single(
6
+ >>> "127.0.0.3",
7
+ >>> username="user@example.com",
8
+ >>> password="great_password"
9
+ >>> )
10
+ >>> await dev.update()
11
+ >>> print(dev.alias)
12
+ Living Room Bulb
13
+
14
+ Light effects are accessed via the LightPreset module. To list available presets
15
+
16
+ >>> if dev.modules[Module.Light].has_effects:
17
+ >>> light_effect = dev.modules[Module.LightEffect]
18
+ >>> light_effect.effect_list
19
+ ['Off', 'Party', 'Relax']
20
+
21
+ To view the currently selected effect:
22
+
23
+ >>> light_effect.effect
24
+ Off
25
+
26
+ To activate a light effect:
27
+
28
+ >>> await light_effect.set_effect("Party")
29
+ >>> await dev.update()
30
+ >>> light_effect.effect
31
+ Party
32
+
33
+ If the device supports it you can set custom effects:
34
+
35
+ >>> if light_effect.has_custom_effects:
36
+ >>> effect_list = { "brightness", 50 }
37
+ >>> await light_effect.set_custom_effect(effect_list)
38
+ >>> light_effect.has_custom_effects # The device in this examples does not support \
39
+ custom effects
40
+ False
41
+ """
2
42
 
3
43
  from __future__ import annotations
4
44
 
@@ -1,9 +1,77 @@
1
- """Module for LightPreset base class."""
1
+ """Interact with TPLink Light Presets.
2
+
3
+ >>> from kasa import Discover, Module, LightState
4
+ >>>
5
+ >>> dev = await Discover.discover_single(
6
+ >>> "127.0.0.3",
7
+ >>> username="user@example.com",
8
+ >>> password="great_password"
9
+ >>> )
10
+ >>> await dev.update()
11
+ >>> print(dev.alias)
12
+ Living Room Bulb
13
+
14
+ Light presets are accessed via the LightPreset module. To list available presets
15
+
16
+ >>> light_preset = dev.modules[Module.LightPreset]
17
+ >>> light_preset.preset_list
18
+ ['Not set', 'Light preset 1', 'Light preset 2', 'Light preset 3',\
19
+ 'Light preset 4', 'Light preset 5', 'Light preset 6', 'Light preset 7']
20
+
21
+ To view the currently selected preset:
22
+
23
+ >>> light_preset.preset
24
+ Not set
25
+
26
+ To view the actual light state for the presets:
27
+
28
+ >>> len(light_preset.preset_states_list)
29
+ 7
30
+
31
+ >>> light_preset.preset_states_list[0]
32
+ LightState(light_on=None, brightness=50, hue=0,\
33
+ saturation=100, color_temp=2700, transition=None)
34
+
35
+ To set a preset as active:
36
+
37
+ >>> dev.modules[Module.Light].state # This is only needed to show the example working
38
+ LightState(light_on=True, brightness=100, hue=0,\
39
+ saturation=100, color_temp=2700, transition=None)
40
+ >>> await light_preset.set_preset("Light preset 1")
41
+ >>> await dev.update()
42
+ >>> light_preset.preset
43
+ Light preset 1
44
+ >>> dev.modules[Module.Light].state # This is only needed to show the example working
45
+ LightState(light_on=True, brightness=50, hue=0,\
46
+ saturation=100, color_temp=2700, transition=None)
47
+
48
+ You can save a new preset state if the device supports it:
49
+
50
+ >>> if light_preset.has_save_preset:
51
+ >>> new_preset_state = LightState(light_on=True, brightness=75, hue=0,\
52
+ saturation=100, color_temp=2700, transition=None)
53
+ >>> await light_preset.save_preset("Light preset 1", new_preset_state)
54
+ >>> await dev.update()
55
+ >>> light_preset.preset # Saving updates the preset state for the preset, it does not \
56
+ set the preset
57
+ Not set
58
+ >>> light_preset.preset_states_list[0]
59
+ LightState(light_on=None, brightness=75, hue=0,\
60
+ saturation=100, color_temp=2700, transition=None)
61
+
62
+ If you manually set the light state to a preset state it will show that preset as \
63
+ active:
64
+
65
+ >>> await dev.modules[Module.Light].set_brightness(75)
66
+ >>> await dev.update()
67
+ >>> light_preset.preset
68
+ Light preset 1
69
+ """
2
70
 
3
71
  from __future__ import annotations
4
72
 
5
73
  from abc import abstractmethod
6
- from typing import Sequence
74
+ from collections.abc import Sequence
7
75
 
8
76
  from ..feature import Feature
9
77
  from ..module import Module
kasa/iot/iotdevice.py CHANGED
@@ -18,8 +18,9 @@ import collections.abc
18
18
  import functools
19
19
  import inspect
20
20
  import logging
21
+ from collections.abc import Mapping, Sequence
21
22
  from datetime import datetime, timedelta, timezone
22
- from typing import TYPE_CHECKING, Any, Mapping, Sequence, cast
23
+ from typing import TYPE_CHECKING, Any, cast
23
24
 
24
25
  from ..device import Device, WifiNetwork
25
26
  from ..deviceconfig import DeviceConfig
@@ -339,7 +340,9 @@ class IotDevice(Device):
339
340
  name="RSSI",
340
341
  attribute_getter="rssi",
341
342
  icon="mdi:signal",
343
+ unit="dBm",
342
344
  category=Feature.Category.Debug,
345
+ type=Feature.Type.Sensor,
343
346
  )
344
347
  )
345
348
  # iot strips calculate on_since from the children
@@ -351,6 +354,8 @@ class IotDevice(Device):
351
354
  name="On since",
352
355
  attribute_getter="on_since",
353
356
  icon="mdi:clock",
357
+ category=Feature.Category.Info,
358
+ type=Feature.Type.Sensor,
354
359
  )
355
360
  )
356
361
 
kasa/iot/iotstrip.py CHANGED
@@ -21,7 +21,7 @@ from .iotdevice import (
21
21
  )
22
22
  from .iotmodule import IotModule
23
23
  from .iotplug import IotPlug
24
- from .modules import Antitheft, Countdown, Schedule, Time, Usage
24
+ from .modules import Antitheft, Cloud, Countdown, Emeter, Led, Schedule, Time, Usage
25
25
 
26
26
  _LOGGER = logging.getLogger(__name__)
27
27
 
@@ -107,6 +107,8 @@ class IotStrip(IotDevice):
107
107
  self.add_module(Module.IotUsage, Usage(self, "schedule"))
108
108
  self.add_module(Module.IotTime, Time(self, "time"))
109
109
  self.add_module(Module.IotCountdown, Countdown(self, "countdown"))
110
+ self.add_module(Module.Led, Led(self, "system"))
111
+ self.add_module(Module.IotCloud, Cloud(self, "cnCloud"))
110
112
  if self.has_emeter:
111
113
  _LOGGER.debug(
112
114
  "The device has emeter, querying its information along sysinfo"
@@ -317,8 +319,12 @@ class IotStripPlug(IotPlug):
317
319
 
318
320
  async def _initialize_modules(self):
319
321
  """Initialize modules not added in init."""
320
- await super()._initialize_modules()
321
- self.add_module("time", Time(self, "time"))
322
+ if self.has_emeter:
323
+ self.add_module(Module.Energy, Emeter(self, self.emeter_type))
324
+ self.add_module(Module.IotUsage, Usage(self, "schedule"))
325
+ self.add_module(Module.IotAntitheft, Antitheft(self, "anti_theft"))
326
+ self.add_module(Module.IotSchedule, Schedule(self, "schedule"))
327
+ self.add_module(Module.IotCountdown, Countdown(self, "countdown"))
322
328
 
323
329
  async def _initialize_features(self):
324
330
  """Initialize common features."""
@@ -340,6 +346,8 @@ class IotStripPlug(IotPlug):
340
346
  name="On since",
341
347
  attribute_getter="on_since",
342
348
  icon="mdi:clock",
349
+ category=Feature.Category.Info,
350
+ type=Feature.Type.Sensor,
343
351
  )
344
352
  )
345
353
  for module in self._supported_modules.values():
@@ -353,6 +361,9 @@ class IotStripPlug(IotPlug):
353
361
  Needed for properties that are decorated with `requires_update`.
354
362
  """
355
363
  await self._modular_update({})
364
+ for module in self._modules.values():
365
+ module._post_update_hook()
366
+
356
367
  if not self._features:
357
368
  await self._initialize_features()
358
369
 
@@ -2,8 +2,9 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
+ from collections.abc import Sequence
5
6
  from dataclasses import asdict
6
- from typing import TYPE_CHECKING, Optional, Sequence
7
+ from typing import TYPE_CHECKING, Optional
7
8
 
8
9
  from pydantic.v1 import BaseModel, Field
9
10
 
kasa/module.py CHANGED
@@ -1,4 +1,42 @@
1
- """Base class for all module implementations."""
1
+ """Interact with modules.
2
+
3
+ Modules are implemented by devices to encapsulate sets of functionality like
4
+ Light, AutoOff, Firmware etc.
5
+
6
+ >>> from kasa import Discover, Module
7
+ >>>
8
+ >>> dev = await Discover.discover_single(
9
+ >>> "127.0.0.3",
10
+ >>> username="user@example.com",
11
+ >>> password="great_password"
12
+ >>> )
13
+ >>> await dev.update()
14
+ >>> print(dev.alias)
15
+ Living Room Bulb
16
+
17
+ To see whether a device supports functionality check for the existence of the module:
18
+
19
+ >>> if light := dev.modules.get("Light"):
20
+ >>> print(light.hsv)
21
+ HSV(hue=0, saturation=100, value=100)
22
+
23
+ If you know or expect the module to exist you can access by index:
24
+
25
+ >>> light_preset = dev.modules["LightPreset"]
26
+ >>> print(light_preset.preset_list)
27
+ ['Not set', 'Light preset 1', 'Light preset 2', 'Light preset 3',\
28
+ 'Light preset 4', 'Light preset 5', 'Light preset 6', 'Light preset 7']
29
+
30
+ Modules support typing via the Module names in Module:
31
+
32
+ >>> from typing_extensions import reveal_type, TYPE_CHECKING
33
+ >>> light_effect = dev.modules.get("LightEffect")
34
+ >>> light_effect_typed = dev.modules.get(Module.LightEffect)
35
+ >>> if TYPE_CHECKING:
36
+ >>> reveal_type(light_effect) # Static checker will reveal: str
37
+ >>> reveal_type(light_effect_typed) # Static checker will reveal: LightEffect
38
+
39
+ """
2
40
 
3
41
  from __future__ import annotations
4
42
 
@@ -43,6 +43,7 @@ class Alarm(SmartModule):
43
43
  container=self,
44
44
  attribute_getter="source",
45
45
  icon="mdi:bell",
46
+ type=Feature.Type.Sensor,
46
47
  )
47
48
  )
48
49
  self._add_feature(
@@ -40,11 +40,12 @@ class AutoOff(SmartModule):
40
40
  Feature(
41
41
  self._device,
42
42
  id="auto_off_minutes",
43
- name="Auto off minutes",
43
+ name="Auto off in",
44
44
  container=self,
45
45
  attribute_getter="delay",
46
46
  attribute_setter="set_delay",
47
47
  type=Feature.Type.Number,
48
+ unit="min", # ha-friendly unit, see UnitOfTime.MINUTES
48
49
  )
49
50
  )
50
51
  self._add_feature(
@@ -55,6 +56,7 @@ class AutoOff(SmartModule):
55
56
  container=self,
56
57
  attribute_getter="auto_off_at",
57
58
  category=Feature.Category.Info,
59
+ type=Feature.Type.Sensor,
58
60
  )
59
61
  )
60
62
 
@@ -1,4 +1,42 @@
1
- """Implementation for child devices."""
1
+ """Interact with child devices.
2
+
3
+ >>> from kasa import Discover
4
+ >>>
5
+ >>> dev = await Discover.discover_single(
6
+ >>> "127.0.0.1",
7
+ >>> username="user@example.com",
8
+ >>> password="great_password"
9
+ >>> )
10
+ >>> await dev.update()
11
+ >>> print(dev.alias)
12
+ Bedroom Power Strip
13
+
14
+ All methods act on the whole strip:
15
+
16
+ >>> for plug in dev.children:
17
+ >>> print(f"{plug.alias}: {plug.is_on}")
18
+ Plug 1: True
19
+ Plug 2: False
20
+ Plug 3: False
21
+ >>> dev.is_on
22
+ True
23
+ >>> await dev.turn_off()
24
+ >>> await dev.update()
25
+
26
+ Accessing individual plugs can be done using the `children` property:
27
+
28
+ >>> len(dev.children)
29
+ 3
30
+ >>> for plug in dev.children:
31
+ >>> print(f"{plug.alias}: {plug.is_on}")
32
+ Plug 1: False
33
+ Plug 2: False
34
+ Plug 3: False
35
+ >>> await dev.children[1].turn_on()
36
+ >>> await dev.update()
37
+ >>> dev.is_on
38
+ True
39
+ """
2
40
 
3
41
  from ..smartmodule import SmartModule
4
42
 
@@ -4,8 +4,9 @@ from __future__ import annotations
4
4
 
5
5
  import asyncio
6
6
  import logging
7
+ from collections.abc import Coroutine
7
8
  from datetime import date
8
- from typing import TYPE_CHECKING, Any, Callable, Coroutine, Optional
9
+ from typing import TYPE_CHECKING, Any, Callable, Optional
9
10
 
10
11
  # When support for cpython older than 3.11 is dropped
11
12
  # async_timeout can be replaced with asyncio.timeout
@@ -100,6 +101,7 @@ class Firmware(SmartModule):
100
101
  container=self,
101
102
  attribute_getter="current_firmware",
102
103
  category=Feature.Category.Debug,
104
+ type=Feature.Type.Sensor,
103
105
  )
104
106
  )
105
107
  self._add_feature(
@@ -110,6 +112,7 @@ class Firmware(SmartModule):
110
112
  container=self,
111
113
  attribute_getter="latest_firmware",
112
114
  category=Feature.Category.Debug,
115
+ type=Feature.Type.Sensor,
113
116
  )
114
117
  )
115
118
 
@@ -2,15 +2,8 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
- from typing import TYPE_CHECKING
6
-
7
- from ...feature import Feature
8
5
  from ..smartmodule import SmartModule
9
6
 
10
- # TODO: this may not be necessary with __future__.annotations
11
- if TYPE_CHECKING:
12
- from ..smartdevice import SmartDevice
13
-
14
7
 
15
8
  class FrostProtection(SmartModule):
16
9
  """Implementation for frost protection module.
@@ -19,23 +12,8 @@ class FrostProtection(SmartModule):
19
12
  """
20
13
 
21
14
  REQUIRED_COMPONENT = "frost_protection"
22
- # TODO: the information required for current features do not require this query
23
15
  QUERY_GETTER_NAME = "get_frost_protection"
24
16
 
25
- def __init__(self, device: SmartDevice, module: str):
26
- super().__init__(device, module)
27
- self._add_feature(
28
- Feature(
29
- device,
30
- "frost_protection_enabled",
31
- name="Frost protection enabled",
32
- container=self,
33
- attribute_getter="enabled",
34
- attribute_setter="set_enabled",
35
- type=Feature.Type.Switch,
36
- )
37
- )
38
-
39
17
  @property
40
18
  def enabled(self) -> bool:
41
19
  """Return True if frost protection is on."""
@@ -29,6 +29,7 @@ class HumiditySensor(SmartModule):
29
29
  icon="mdi:water-percent",
30
30
  unit="%",
31
31
  category=Feature.Category.Primary,
32
+ type=Feature.Type.Sensor,
32
33
  )
33
34
  )
34
35
  self._add_feature(
kasa/smart/modules/led.py CHANGED
@@ -27,7 +27,7 @@ class Led(SmartModule, LedInterface):
27
27
  @property
28
28
  def led(self):
29
29
  """Return current led status."""
30
- return self.data["led_status"]
30
+ return self.data["led_rule"] != "never"
31
31
 
32
32
  async def set_led(self, enable: bool):
33
33
  """Set led.
@@ -2,8 +2,9 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
+ from collections.abc import Sequence
5
6
  from dataclasses import asdict
6
- from typing import TYPE_CHECKING, Sequence
7
+ from typing import TYPE_CHECKING
7
8
 
8
9
  from ...interfaces import LightPreset as LightPresetInterface
9
10
  from ...interfaces import LightState
@@ -183,11 +183,9 @@ class LightTransition(SmartModule):
183
183
  return {self.QUERY_GETTER_NAME: None}
184
184
 
185
185
  async def _check_supported(self):
186
- """Additional check to see if the module is supported by the device.
187
-
188
- Parent devices that report components of children such as ks240 will not have
189
- the brightness value is sysinfo.
190
- """
191
- # Look in _device.sys_info here because self.data is either sys_info or
192
- # get_preset_rules depending on whether it's a child device or not.
186
+ """Additional check to see if the module is supported by the device."""
187
+ # TODO Temporarily disabled on child light devices until module fixed
188
+ # to support updates
189
+ if self._device._parent is not None:
190
+ return False
193
191
  return "brightness" in self._device.sys_info
@@ -26,7 +26,9 @@ class ReportMode(SmartModule):
26
26
  name="Report interval",
27
27
  container=self,
28
28
  attribute_getter="report_interval",
29
+ unit="s",
29
30
  category=Feature.Category.Debug,
31
+ type=Feature.Type.Sensor,
30
32
  )
31
33
  )
32
34
 
@@ -79,11 +79,12 @@ class TemperatureControl(SmartModule):
79
79
  self._add_feature(
80
80
  Feature(
81
81
  device,
82
- id="mode",
83
- name="Mode",
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
 
@@ -25,11 +25,12 @@ class Time(SmartModule):
25
25
  self._add_feature(
26
26
  Feature(
27
27
  device=device,
28
- id="time",
29
- name="Time",
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
 
@@ -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,8 +4,9 @@ from __future__ import annotations
4
4
 
5
5
  import base64
6
6
  import logging
7
+ from collections.abc import Mapping, Sequence
7
8
  from datetime import datetime, timedelta, timezone
8
- from typing import TYPE_CHECKING, Any, Mapping, Sequence, cast
9
+ from typing import Any, cast
9
10
 
10
11
  from ..aestransport import AesTransport
11
12
  from ..device import Device, WifiNetwork
@@ -97,9 +98,7 @@ class SmartDevice(Device):
97
98
  @property
98
99
  def modules(self) -> ModuleMapping[SmartModule]:
99
100
  """Return the device modules."""
100
- if TYPE_CHECKING: # Needed for python 3.8
101
- return cast(ModuleMapping[SmartModule], self._modules)
102
- return self._modules
101
+ return cast(ModuleMapping[SmartModule], self._modules)
103
102
 
104
103
  def _try_get_response(self, responses: dict, request: str, default=None) -> dict:
105
104
  response = responses.get(request)
@@ -243,6 +242,7 @@ class SmartDevice(Device):
243
242
  name="Device ID",
244
243
  attribute_getter="device_id",
245
244
  category=Feature.Category.Debug,
245
+ type=Feature.Type.Sensor,
246
246
  )
247
247
  )
248
248
  if "device_on" in self._info:
@@ -267,6 +267,7 @@ class SmartDevice(Device):
267
267
  attribute_getter=lambda x: x._info["signal_level"],
268
268
  icon="mdi:signal",
269
269
  category=Feature.Category.Info,
270
+ type=Feature.Type.Sensor,
270
271
  )
271
272
  )
272
273
 
@@ -278,7 +279,9 @@ class SmartDevice(Device):
278
279
  name="RSSI",
279
280
  attribute_getter=lambda x: x._info["rssi"],
280
281
  icon="mdi:signal",
282
+ unit="dBm",
281
283
  category=Feature.Category.Debug,
284
+ type=Feature.Type.Sensor,
282
285
  )
283
286
  )
284
287
 
@@ -291,6 +294,7 @@ class SmartDevice(Device):
291
294
  attribute_getter="ssid",
292
295
  icon="mdi:wifi",
293
296
  category=Feature.Category.Debug,
297
+ type=Feature.Type.Sensor,
294
298
  )
295
299
  )
296
300
 
@@ -317,7 +321,8 @@ class SmartDevice(Device):
317
321
  name="On since",
318
322
  attribute_getter="on_since",
319
323
  icon="mdi:clock",
320
- category=Feature.Category.Info,
324
+ category=Feature.Category.Debug,
325
+ type=Feature.Type.Sensor,
321
326
  )
322
327
  )
323
328
 
@@ -1,6 +1,6 @@
1
1
  from __future__ import annotations
2
2
 
3
- from typing import AsyncGenerator
3
+ from collections.abc import AsyncGenerator
4
4
 
5
5
  import pytest
6
6
 
@@ -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(params=UNSUPPORTED_DEVICES.values(), ids=UNSUPPORTED_DEVICES.keys())
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
@@ -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
@@ -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
- extras = {"reboot_time": 5, "upgrade_time": upgrade_time, "auto_upgrade": False}
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),