diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9aeb80965..ae2847180 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,7 +2,7 @@ repos: - repo: https://github.com/astral-sh/uv-pre-commit # uv version. - rev: 0.5.24 + rev: 0.5.26 hooks: # Update the uv lockfile - id: uv-lock @@ -22,7 +22,7 @@ repos: - "--indent=4" - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.9.3 + rev: v0.9.4 hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] diff --git a/CHANGELOG.md b/CHANGELOG.md index 53a86b8af..5e40772cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,27 @@ # Changelog +## [0.10.1](https://github.com/python-kasa/python-kasa/tree/0.10.1) (2025-02-02) + +[Full Changelog](https://github.com/python-kasa/python-kasa/compare/0.10.0...0.10.1) + +**Release summary:** + +Small patch release for bugfixes + +**Implemented enhancements:** + +- dustbin\_mode: add 'off' mode for cleaner downstream impl [\#1488](https://github.com/python-kasa/python-kasa/pull/1488) (@rytilahti) +- Add Dimmer Configuration Support [\#1484](https://github.com/python-kasa/python-kasa/pull/1484) (@ryenitcher) + +**Fixed bugs:** + +- Do not return empty string for custom light effect name [\#1491](https://github.com/python-kasa/python-kasa/pull/1491) (@sdb9696) +- Add FeatureAttributes to smartcam Alarm [\#1489](https://github.com/python-kasa/python-kasa/pull/1489) (@sdb9696) + +**Project maintenance:** + +- Add module.device to the public api [\#1478](https://github.com/python-kasa/python-kasa/pull/1478) (@sdb9696) + ## [0.10.0](https://github.com/python-kasa/python-kasa/tree/0.10.0) (2025-01-26) [Full Changelog](https://github.com/python-kasa/python-kasa/compare/0.9.1...0.10.0) @@ -31,11 +53,7 @@ Many thanks to testers and new contributors - @steveredden, @DawidPietrykowski, - Expose more battery sensors for D230 [\#1451](https://github.com/python-kasa/python-kasa/issues/1451) - dumping HTTP POST Body for Tapo Vacuum \(RV30 Plus\) [\#937](https://github.com/python-kasa/python-kasa/issues/937) -- Add common alarm interface [\#1479](https://github.com/python-kasa/python-kasa/pull/1479) (@sdb9696) -- Add common childsetup interface [\#1470](https://github.com/python-kasa/python-kasa/pull/1470) (@sdb9696) -- Add childsetup module to smartcam hubs [\#1469](https://github.com/python-kasa/python-kasa/pull/1469) (@sdb9696) - Add smartcam pet detection toggle module [\#1465](https://github.com/python-kasa/python-kasa/pull/1465) (@DawidPietrykowski) -- Only log one warning per unknown clean error code and status [\#1462](https://github.com/python-kasa/python-kasa/pull/1462) (@rytilahti) - Add childlock module for vacuums [\#1461](https://github.com/python-kasa/python-kasa/pull/1461) (@rytilahti) - Add ultra mode \(fanspeed = 5\) for vacuums [\#1459](https://github.com/python-kasa/python-kasa/pull/1459) (@rytilahti) - Add setting to change carpet clean mode [\#1458](https://github.com/python-kasa/python-kasa/pull/1458) (@rytilahti) @@ -46,49 +64,53 @@ Many thanks to testers and new contributors - @steveredden, @DawidPietrykowski, - Add battery module to smartcam devices [\#1452](https://github.com/python-kasa/python-kasa/pull/1452) (@sdb9696) - Allow update of camera modules after setting values [\#1450](https://github.com/python-kasa/python-kasa/pull/1450) (@sdb9696) - Update hub children on first update and delay subsequent updates [\#1438](https://github.com/python-kasa/python-kasa/pull/1438) (@sdb9696) -- Add support for doorbells and chimes [\#1435](https://github.com/python-kasa/python-kasa/pull/1435) (@steveredden) - Implement vacuum dustbin module \(dust\_bucket\) [\#1423](https://github.com/python-kasa/python-kasa/pull/1423) (@rytilahti) -- Allow https for klaptransport [\#1415](https://github.com/python-kasa/python-kasa/pull/1415) (@rytilahti) - Add smartcam child device support for smartcam hubs [\#1413](https://github.com/python-kasa/python-kasa/pull/1413) (@sdb9696) -- Add powerprotection module [\#1337](https://github.com/python-kasa/python-kasa/pull/1337) (@rytilahti) - Add vacuum speaker controls [\#1332](https://github.com/python-kasa/python-kasa/pull/1332) (@rytilahti) - Add consumables module for vacuums [\#1327](https://github.com/python-kasa/python-kasa/pull/1327) (@rytilahti) - Add ADC Value to PIR Enabled Switches [\#1263](https://github.com/python-kasa/python-kasa/pull/1263) (@ryenitcher) - Add support for cleaning records [\#945](https://github.com/python-kasa/python-kasa/pull/945) (@rytilahti) - Initial support for vacuums \(clean module\) [\#944](https://github.com/python-kasa/python-kasa/pull/944) (@rytilahti) - Add support for pairing devices with hubs [\#859](https://github.com/python-kasa/python-kasa/pull/859) (@rytilahti) +- Add common alarm interface [\#1479](https://github.com/python-kasa/python-kasa/pull/1479) (@sdb9696) +- Add common childsetup interface [\#1470](https://github.com/python-kasa/python-kasa/pull/1470) (@sdb9696) +- Add childsetup module to smartcam hubs [\#1469](https://github.com/python-kasa/python-kasa/pull/1469) (@sdb9696) +- Only log one warning per unknown clean error code and status [\#1462](https://github.com/python-kasa/python-kasa/pull/1462) (@rytilahti) +- Add support for doorbells and chimes [\#1435](https://github.com/python-kasa/python-kasa/pull/1435) (@steveredden) +- Allow https for klaptransport [\#1415](https://github.com/python-kasa/python-kasa/pull/1415) (@rytilahti) +- Add powerprotection module [\#1337](https://github.com/python-kasa/python-kasa/pull/1337) (@rytilahti) **Fixed bugs:** - TP-Link HS300 Wi-Fi Power-Strip - "Parent On/Off" not functioning. [\#637](https://github.com/python-kasa/python-kasa/issues/637) -- Convert carpet\_clean\_mode to carpet\_boost switch [\#1486](https://github.com/python-kasa/python-kasa/pull/1486) (@rytilahti) -- Change category for empty dustbin feature from Primary to Config [\#1485](https://github.com/python-kasa/python-kasa/pull/1485) (@rytilahti) - Report 0 for instead of None for zero current and voltage [\#1483](https://github.com/python-kasa/python-kasa/pull/1483) (@ryenitcher) -- Disable iot camera creation until more complete [\#1480](https://github.com/python-kasa/python-kasa/pull/1480) (@sdb9696) - ssltransport: use debug logger for sending requests [\#1443](https://github.com/python-kasa/python-kasa/pull/1443) (@rytilahti) - Fix discover cli command with host [\#1437](https://github.com/python-kasa/python-kasa/pull/1437) (@sdb9696) - Fallback to is\_low for batterysensor's battery\_low [\#1420](https://github.com/python-kasa/python-kasa/pull/1420) (@rytilahti) +- Convert carpet\_clean\_mode to carpet\_boost switch [\#1486](https://github.com/python-kasa/python-kasa/pull/1486) (@rytilahti) +- Change category for empty dustbin feature from Primary to Config [\#1485](https://github.com/python-kasa/python-kasa/pull/1485) (@rytilahti) +- Disable iot camera creation until more complete [\#1480](https://github.com/python-kasa/python-kasa/pull/1480) (@sdb9696) +- Add error code 7 for clean module [\#1474](https://github.com/python-kasa/python-kasa/pull/1474) (@rytilahti) - Fix iot strip turn on and off from parent [\#639](https://github.com/python-kasa/python-kasa/pull/639) (@Obbay2) **Added support for devices:** -- Add D130\(US\) 1.0 1.1.9 fixture [\#1476](https://github.com/python-kasa/python-kasa/pull/1476) (@sdb9696) -- Add D100C\(US\) 1.0 1.1.3 fixture [\#1475](https://github.com/python-kasa/python-kasa/pull/1475) (@sdb9696) - Add C220\(EU\) 1.0 1.2.2 camera fixture [\#1466](https://github.com/python-kasa/python-kasa/pull/1466) (@DawidPietrykowski) - Add D230\(EU\) 1.20 1.1.19 fixture [\#1448](https://github.com/python-kasa/python-kasa/pull/1448) (@sdb9696) - Add fixture for C720 camera [\#1433](https://github.com/python-kasa/python-kasa/pull/1433) (@steveredden) +- Add D130\(US\) 1.0 1.1.9 fixture [\#1476](https://github.com/python-kasa/python-kasa/pull/1476) (@sdb9696) +- Add D100C\(US\) 1.0 1.1.3 fixture [\#1475](https://github.com/python-kasa/python-kasa/pull/1475) (@sdb9696) **Project maintenance:** -- Update ruff to 0.9 [\#1482](https://github.com/python-kasa/python-kasa/pull/1482) (@sdb9696) -- Cancel in progress CI workflows after new pushes [\#1481](https://github.com/python-kasa/python-kasa/pull/1481) (@sdb9696) -- Update test framework to support smartcam device discovery. [\#1477](https://github.com/python-kasa/python-kasa/pull/1477) (@sdb9696) -- Add error code 7 for clean module [\#1474](https://github.com/python-kasa/python-kasa/pull/1474) (@rytilahti) - Enable CI workflow on PRs to feat/ fix/ and janitor/ [\#1471](https://github.com/python-kasa/python-kasa/pull/1471) (@sdb9696) - Add commit-hook to prettify JSON files [\#1455](https://github.com/python-kasa/python-kasa/pull/1455) (@rytilahti) - Add required sphinx.configuration [\#1446](https://github.com/python-kasa/python-kasa/pull/1446) (@rytilahti) - Add more redactors for smartcams [\#1439](https://github.com/python-kasa/python-kasa/pull/1439) (@sdb9696) - Add KS230\(US\) 2.0 1.0.11 IOT Fixture [\#1430](https://github.com/python-kasa/python-kasa/pull/1430) (@ZeliardM) +- Update ruff to 0.9 [\#1482](https://github.com/python-kasa/python-kasa/pull/1482) (@sdb9696) +- Cancel in progress CI workflows after new pushes [\#1481](https://github.com/python-kasa/python-kasa/pull/1481) (@sdb9696) +- Update test framework to support smartcam device discovery. [\#1477](https://github.com/python-kasa/python-kasa/pull/1477) (@sdb9696) - Add tests for dump\_devinfo parent/child smartcam fixture generation [\#1428](https://github.com/python-kasa/python-kasa/pull/1428) (@sdb9696) - Raise errors on single smartcam child requests [\#1427](https://github.com/python-kasa/python-kasa/pull/1427) (@sdb9696) diff --git a/kasa/interfaces/energy.py b/kasa/interfaces/energy.py index c57a3ed80..b6cc203fa 100644 --- a/kasa/interfaces/energy.py +++ b/kasa/interfaces/energy.py @@ -28,7 +28,7 @@ class ModuleFeature(IntFlag): _supported: ModuleFeature = ModuleFeature(0) - def supports(self, module_feature: ModuleFeature) -> bool: + def supports(self, module_feature: Energy.ModuleFeature) -> bool: """Return True if module supports the feature.""" return module_feature in self._supported diff --git a/kasa/interfaces/lighteffect.py b/kasa/interfaces/lighteffect.py index fa50dd3eb..bfcd9be36 100644 --- a/kasa/interfaces/lighteffect.py +++ b/kasa/interfaces/lighteffect.py @@ -51,6 +51,7 @@ class LightEffect(Module, ABC): """Interface to represent a light effect module.""" LIGHT_EFFECTS_OFF = "Off" + LIGHT_EFFECTS_UNNAMED_CUSTOM = "Custom" def _initialize_features(self) -> None: """Initialize features.""" @@ -77,7 +78,7 @@ def has_custom_effects(self) -> bool: @property @abstractmethod def effect(self) -> str: - """Return effect state or name.""" + """Return effect name.""" @property @abstractmethod diff --git a/kasa/iot/iotdimmer.py b/kasa/iot/iotdimmer.py index 1631fbba9..6b22d640b 100644 --- a/kasa/iot/iotdimmer.py +++ b/kasa/iot/iotdimmer.py @@ -11,7 +11,7 @@ from ..protocols import BaseProtocol from .iotdevice import KasaException, requires_update from .iotplug import IotPlug -from .modules import AmbientLight, Light, Motion +from .modules import AmbientLight, Dimmer, Light, Motion class ButtonAction(Enum): @@ -87,6 +87,7 @@ async def _initialize_modules(self) -> None: # TODO: need to be figured out what's the best approach to detect support self.add_module(Module.IotMotion, Motion(self, "smartlife.iot.PIR")) self.add_module(Module.IotAmbientLight, AmbientLight(self, "smartlife.iot.LAS")) + self.add_module(Module.IotDimmer, Dimmer(self, "smartlife.iot.dimmer")) self.add_module(Module.Light, Light(self, "light")) @property # type: ignore diff --git a/kasa/iot/modules/__init__.py b/kasa/iot/modules/__init__.py index 6fd63a706..ef7adf689 100644 --- a/kasa/iot/modules/__init__.py +++ b/kasa/iot/modules/__init__.py @@ -4,6 +4,7 @@ from .antitheft import Antitheft from .cloud import Cloud from .countdown import Countdown +from .dimmer import Dimmer from .emeter import Emeter from .led import Led from .light import Light @@ -20,6 +21,7 @@ "Antitheft", "Cloud", "Countdown", + "Dimmer", "Emeter", "Led", "Light", diff --git a/kasa/iot/modules/dimmer.py b/kasa/iot/modules/dimmer.py new file mode 100644 index 000000000..42a93ce56 --- /dev/null +++ b/kasa/iot/modules/dimmer.py @@ -0,0 +1,270 @@ +"""Implementation of the dimmer config module found in dimmers.""" + +from __future__ import annotations + +import logging +from datetime import timedelta +from typing import Any, Final, cast + +from ...exceptions import KasaException +from ...feature import Feature +from ..iotmodule import IotModule, merge + +_LOGGER = logging.getLogger(__name__) + + +def _td_to_ms(td: timedelta) -> int: + """ + Convert timedelta to integer milliseconds. + + Uses default float to integer rounding. + """ + return int(td / timedelta(milliseconds=1)) + + +class Dimmer(IotModule): + """Implements the dimmer config module.""" + + THRESHOLD_ABS_MIN: Final[int] = 0 + # Strange value, but verified against hardware (KS220). + THRESHOLD_ABS_MAX: Final[int] = 51 + FADE_TIME_ABS_MIN: Final[timedelta] = timedelta(seconds=0) + # Arbitrary, but set low intending GENTLE FADE for longer fades. + FADE_TIME_ABS_MAX: Final[timedelta] = timedelta(seconds=10) + GENTLE_TIME_ABS_MIN: Final[timedelta] = timedelta(seconds=0) + # Arbitrary, but reasonable default. + GENTLE_TIME_ABS_MAX: Final[timedelta] = timedelta(seconds=120) + # Verified against KS220. + RAMP_RATE_ABS_MIN: Final[int] = 10 + # Verified against KS220. + RAMP_RATE_ABS_MAX: Final[int] = 50 + + def _initialize_features(self) -> None: + """Initialize features after the initial update.""" + self._add_feature( + Feature( + device=self._device, + container=self, + id="dimmer_threshold_min", + name="Minimum dimming level", + icon="mdi:lightbulb-on-20", + attribute_getter="threshold_min", + attribute_setter="set_threshold_min", + range_getter=lambda: (self.THRESHOLD_ABS_MIN, self.THRESHOLD_ABS_MAX), + type=Feature.Type.Number, + category=Feature.Category.Config, + ) + ) + + self._add_feature( + Feature( + device=self._device, + container=self, + id="dimmer_fade_off_time", + name="Dimmer fade off time", + icon="mdi:clock-in", + attribute_getter="fade_off_time", + attribute_setter="set_fade_off_time", + range_getter=lambda: ( + _td_to_ms(self.FADE_TIME_ABS_MIN), + _td_to_ms(self.FADE_TIME_ABS_MAX), + ), + type=Feature.Type.Number, + category=Feature.Category.Config, + ) + ) + + self._add_feature( + Feature( + device=self._device, + container=self, + id="dimmer_fade_on_time", + name="Dimmer fade on time", + icon="mdi:clock-out", + attribute_getter="fade_on_time", + attribute_setter="set_fade_on_time", + range_getter=lambda: ( + _td_to_ms(self.FADE_TIME_ABS_MIN), + _td_to_ms(self.FADE_TIME_ABS_MAX), + ), + type=Feature.Type.Number, + category=Feature.Category.Config, + ) + ) + + self._add_feature( + Feature( + device=self._device, + container=self, + id="dimmer_gentle_off_time", + name="Dimmer gentle off time", + icon="mdi:clock-in", + attribute_getter="gentle_off_time", + attribute_setter="set_gentle_off_time", + range_getter=lambda: ( + _td_to_ms(self.GENTLE_TIME_ABS_MIN), + _td_to_ms(self.GENTLE_TIME_ABS_MAX), + ), + type=Feature.Type.Number, + category=Feature.Category.Config, + ) + ) + + self._add_feature( + Feature( + device=self._device, + container=self, + id="dimmer_gentle_on_time", + name="Dimmer gentle on time", + icon="mdi:clock-out", + attribute_getter="gentle_on_time", + attribute_setter="set_gentle_on_time", + range_getter=lambda: ( + _td_to_ms(self.GENTLE_TIME_ABS_MIN), + _td_to_ms(self.GENTLE_TIME_ABS_MAX), + ), + type=Feature.Type.Number, + category=Feature.Category.Config, + ) + ) + + self._add_feature( + Feature( + device=self._device, + container=self, + id="dimmer_ramp_rate", + name="Dimmer ramp rate", + icon="mdi:clock-fast", + attribute_getter="ramp_rate", + attribute_setter="set_ramp_rate", + range_getter=lambda: (self.RAMP_RATE_ABS_MIN, self.RAMP_RATE_ABS_MAX), + type=Feature.Type.Number, + category=Feature.Category.Config, + ) + ) + + def query(self) -> dict: + """Request Dimming configuration.""" + req = merge( + self.query_for_command("get_dimmer_parameters"), + self.query_for_command("get_default_behavior"), + ) + + return req + + @property + def config(self) -> dict[str, Any]: + """Return current configuration.""" + return self.data["get_dimmer_parameters"] + + @property + def threshold_min(self) -> int: + """Return the minimum dimming level for this dimmer.""" + return self.config["minThreshold"] + + async def set_threshold_min(self, min: int) -> dict: + """Set the minimum dimming level for this dimmer. + + The value will depend on the luminaries connected to the dimmer. + + :param min: The minimum dimming level, in the range 0-51. + """ + if min < self.THRESHOLD_ABS_MIN or min > self.THRESHOLD_ABS_MAX: + raise KasaException( + "Minimum dimming threshold is outside the supported range: " + f"{self.THRESHOLD_ABS_MIN}-{self.THRESHOLD_ABS_MAX}" + ) + return await self.call("calibrate_brightness", {"minThreshold": min}) + + @property + def fade_off_time(self) -> timedelta: + """Return the fade off animation duration.""" + return timedelta(milliseconds=cast(int, self.config["fadeOffTime"])) + + async def set_fade_off_time(self, time: int | timedelta) -> dict: + """Set the duration of the fade off animation. + + :param time: The animation duration, in ms. + """ + if isinstance(time, int): + time = timedelta(milliseconds=time) + if time < self.FADE_TIME_ABS_MIN or time > self.FADE_TIME_ABS_MAX: + raise KasaException( + "Fade time is outside the bounds of the supported range:" + f"{self.FADE_TIME_ABS_MIN}-{self.FADE_TIME_ABS_MAX}" + ) + return await self.call("set_fade_off_time", {"fadeTime": _td_to_ms(time)}) + + @property + def fade_on_time(self) -> timedelta: + """Return the fade on animation duration.""" + return timedelta(milliseconds=cast(int, self.config["fadeOnTime"])) + + async def set_fade_on_time(self, time: int | timedelta) -> dict: + """Set the duration of the fade on animation. + + :param time: The animation duration, in ms. + """ + if isinstance(time, int): + time = timedelta(milliseconds=time) + if time < self.FADE_TIME_ABS_MIN or time > self.FADE_TIME_ABS_MAX: + raise KasaException( + "Fade time is outside the bounds of the supported range:" + f"{self.FADE_TIME_ABS_MIN}-{self.FADE_TIME_ABS_MAX}" + ) + return await self.call("set_fade_on_time", {"fadeTime": _td_to_ms(time)}) + + @property + def gentle_off_time(self) -> timedelta: + """Return the gentle fade off animation duration.""" + return timedelta(milliseconds=cast(int, self.config["gentleOffTime"])) + + async def set_gentle_off_time(self, time: int | timedelta) -> dict: + """Set the duration of the gentle fade off animation. + + :param time: The animation duration, in ms. + """ + if isinstance(time, int): + time = timedelta(milliseconds=time) + if time < self.GENTLE_TIME_ABS_MIN or time > self.GENTLE_TIME_ABS_MAX: + raise KasaException( + "Gentle off time is outside the bounds of the supported range: " + f"{self.GENTLE_TIME_ABS_MIN}-{self.GENTLE_TIME_ABS_MAX}." + ) + return await self.call("set_gentle_off_time", {"duration": _td_to_ms(time)}) + + @property + def gentle_on_time(self) -> timedelta: + """Return the gentle fade on animation duration.""" + return timedelta(milliseconds=cast(int, self.config["gentleOnTime"])) + + async def set_gentle_on_time(self, time: int | timedelta) -> dict: + """Set the duration of the gentle fade on animation. + + :param time: The animation duration, in ms. + """ + if isinstance(time, int): + time = timedelta(milliseconds=time) + if time < self.GENTLE_TIME_ABS_MIN or time > self.GENTLE_TIME_ABS_MAX: + raise KasaException( + "Gentle off time is outside the bounds of the supported range: " + f"{self.GENTLE_TIME_ABS_MIN}-{self.GENTLE_TIME_ABS_MAX}." + ) + return await self.call("set_gentle_on_time", {"duration": _td_to_ms(time)}) + + @property + def ramp_rate(self) -> int: + """Return the rate that the dimmer buttons increment the dimmer level.""" + return self.config["rampRate"] + + async def set_ramp_rate(self, rate: int) -> dict: + """Set how quickly to ramp the dimming level when using the dimmer buttons. + + :param rate: The rate to increment the dimming level with each press. + """ + if rate < self.RAMP_RATE_ABS_MIN or rate > self.RAMP_RATE_ABS_MAX: + raise KasaException( + "Gentle off time is outside the bounds of the supported range:" + f"{self.RAMP_RATE_ABS_MIN}-{self.RAMP_RATE_ABS_MAX}" + ) + return await self.call("set_button_ramp_rate", {"rampRate": rate}) diff --git a/kasa/iot/modules/lighteffect.py b/kasa/iot/modules/lighteffect.py index cdfaaae16..3a41fb5f6 100644 --- a/kasa/iot/modules/lighteffect.py +++ b/kasa/iot/modules/lighteffect.py @@ -12,20 +12,11 @@ class LightEffect(IotModule, LightEffectInterface): @property def effect(self) -> str: - """Return effect state. - - Example: - {'brightness': 50, - 'custom': 0, - 'enable': 0, - 'id': '', - 'name': ''} - """ + """Return effect name.""" eff = self.data["lighting_effect_state"] name = eff["name"] if eff["enable"]: - return name - + return name or self.LIGHT_EFFECTS_UNNAMED_CUSTOM return self.LIGHT_EFFECTS_OFF @property diff --git a/kasa/module.py b/kasa/module.py index 8fdff7c34..afd1e1274 100644 --- a/kasa/module.py +++ b/kasa/module.py @@ -111,6 +111,7 @@ class Module(ABC): IotAmbientLight: Final[ModuleName[iot.AmbientLight]] = ModuleName("ambient") IotAntitheft: Final[ModuleName[iot.Antitheft]] = ModuleName("anti_theft") IotCountdown: Final[ModuleName[iot.Countdown]] = ModuleName("countdown") + IotDimmer: Final[ModuleName[iot.Dimmer]] = ModuleName("dimmer") IotMotion: Final[ModuleName[iot.Motion]] = ModuleName("motion") IotSchedule: Final[ModuleName[iot.Schedule]] = ModuleName("schedule") IotUsage: Final[ModuleName[iot.Usage]] = ModuleName("usage") @@ -182,6 +183,11 @@ def __init__(self, device: Device, module: str) -> None: self._module = module self._module_features: dict[str, Feature] = {} + @property + def device(self) -> Device: + """Return the device exposing the module.""" + return self._device + @property def _all_features(self) -> dict[str, Feature]: """Get the features for this module and any sub modules.""" diff --git a/kasa/smart/modules/dustbin.py b/kasa/smart/modules/dustbin.py index 33aecd8f7..b2b4d1ef4 100644 --- a/kasa/smart/modules/dustbin.py +++ b/kasa/smart/modules/dustbin.py @@ -19,6 +19,8 @@ class Mode(IntEnum): Balanced = 2 Max = 3 + Off = -1_000 + class Dustbin(SmartModule): """Implementation of vacuum dustbin.""" @@ -91,6 +93,8 @@ def _settings(self) -> dict: @property def mode(self) -> str: """Return auto-emptying mode.""" + if self.auto_collection is False: + return Mode.Off.name return Mode(self._settings["dust_collection_mode"]).name async def set_mode(self, mode: str) -> dict: @@ -101,8 +105,14 @@ async def set_mode(self, mode: str) -> dict: "Invalid auto/emptying mode speed %s, available %s", mode, name_to_value ) + if mode == Mode.Off.name: + return await self.set_auto_collection(False) + + # Make a copy just in case, even when we are overriding both settings settings = self._settings.copy() + settings["auto_dust_collection"] = True settings["dust_collection_mode"] = name_to_value[mode] + return await self.call("setDustCollectionInfo", settings) @property diff --git a/kasa/smart/modules/lightstripeffect.py b/kasa/smart/modules/lightstripeffect.py index 91d891887..34c1c20c2 100644 --- a/kasa/smart/modules/lightstripeffect.py +++ b/kasa/smart/modules/lightstripeffect.py @@ -37,20 +37,14 @@ def name(self) -> str: @property def effect(self) -> str: - """Return effect state. - - Example: - {'brightness': 50, - 'custom': 0, - 'enable': 0, - 'id': '', - 'name': ''} - """ + """Return effect name.""" eff = self.data["lighting_effect"] name = eff["name"] # When devices are unpaired effect name is softAP which is not in our list if eff["enable"] and name in self._effect_list: return name + if eff["enable"] and eff["custom"]: + return name or self.LIGHT_EFFECTS_UNNAMED_CUSTOM return self.LIGHT_EFFECTS_OFF @property diff --git a/kasa/smart/smartmodule.py b/kasa/smart/smartmodule.py index 243852e06..91efa33dc 100644 --- a/kasa/smart/smartmodule.py +++ b/kasa/smart/smartmodule.py @@ -3,7 +3,8 @@ from __future__ import annotations import logging -from collections.abc import Awaitable, Callable, Coroutine +from collections.abc import Callable, Coroutine +from functools import wraps from typing import TYPE_CHECKING, Any, Concatenate, ParamSpec, TypeVar from ..exceptions import DeviceError, KasaException, SmartErrorCode @@ -20,15 +21,16 @@ def allow_update_after( - func: Callable[Concatenate[_T, _P], Awaitable[dict]], -) -> Callable[Concatenate[_T, _P], Coroutine[Any, Any, dict]]: + func: Callable[Concatenate[_T, _P], Coroutine[Any, Any, _R]], +) -> Callable[Concatenate[_T, _P], Coroutine[Any, Any, _R]]: """Define a wrapper to set _last_update_time to None. This will ensure that a module is updated in the next update cycle after a value has been changed. """ - async def _async_wrap(self: _T, *args: _P.args, **kwargs: _P.kwargs) -> dict: + @wraps(func) + async def _async_wrap(self: _T, *args: _P.args, **kwargs: _P.kwargs) -> _R: try: return await func(self, *args, **kwargs) finally: @@ -40,6 +42,7 @@ async def _async_wrap(self: _T, *args: _P.args, **kwargs: _P.kwargs) -> dict: def raise_if_update_error(func: Callable[[_T], _R]) -> Callable[[_T], _R]: """Define a wrapper to raise an error if the last module update was an error.""" + @wraps(func) def _wrap(self: _T) -> _R: if err := self._last_update_error: raise err diff --git a/kasa/smartcam/modules/alarm.py b/kasa/smartcam/modules/alarm.py index 18833d822..df1891ecf 100644 --- a/kasa/smartcam/modules/alarm.py +++ b/kasa/smartcam/modules/alarm.py @@ -2,8 +2,11 @@ from __future__ import annotations +from typing import Annotated + from ...feature import Feature from ...interfaces import Alarm as AlarmInterface +from ...module import FeatureAttribute from ...smart.smartmodule import allow_update_after from ..smartcammodule import SmartCamModule @@ -105,12 +108,12 @@ def _initialize_features(self) -> None: ) @property - def alarm_sound(self) -> str: + def alarm_sound(self) -> Annotated[str, FeatureAttribute()]: """Return current alarm sound.""" return self.data["getSirenConfig"]["siren_type"] @allow_update_after - async def set_alarm_sound(self, sound: str) -> dict: + async def set_alarm_sound(self, sound: str) -> Annotated[dict, FeatureAttribute()]: """Set alarm sound. See *alarm_sounds* for list of available sounds. @@ -124,7 +127,7 @@ def alarm_sounds(self) -> list[str]: return self.data["getSirenTypeList"]["siren_type_list"] @property - def alarm_volume(self) -> int: + def alarm_volume(self) -> Annotated[int, FeatureAttribute()]: """Return alarm volume. Unlike duration the device expects/returns a string for volume. @@ -132,18 +135,22 @@ def alarm_volume(self) -> int: return int(self.data["getSirenConfig"]["volume"]) @allow_update_after - async def set_alarm_volume(self, volume: int) -> dict: + async def set_alarm_volume( + self, volume: int + ) -> Annotated[dict, FeatureAttribute()]: """Set alarm volume.""" config = self._validate_and_get_config(volume=volume) return await self.call("setSirenConfig", {"siren": config}) @property - def alarm_duration(self) -> int: + def alarm_duration(self) -> Annotated[int, FeatureAttribute()]: """Return alarm duration.""" return self.data["getSirenConfig"]["duration"] @allow_update_after - async def set_alarm_duration(self, duration: int) -> dict: + async def set_alarm_duration( + self, duration: int + ) -> Annotated[dict, FeatureAttribute()]: """Set alarm volume.""" config = self._validate_and_get_config(duration=duration) return await self.call("setSirenConfig", {"siren": config}) diff --git a/pyproject.toml b/pyproject.toml index cf8fabf7d..c73907767 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "python-kasa" -version = "0.10.0" +version = "0.10.1" description = "Python API for TP-Link Kasa and Tapo devices" license = {text = "GPL-3.0-or-later"} authors = [ { name = "python-kasa developers" }] diff --git a/tests/iot/modules/test_dimmer.py b/tests/iot/modules/test_dimmer.py new file mode 100644 index 000000000..e4b267610 --- /dev/null +++ b/tests/iot/modules/test_dimmer.py @@ -0,0 +1,204 @@ +from datetime import timedelta +from typing import Final + +import pytest +from pytest_mock import MockerFixture + +from kasa import KasaException, Module +from kasa.iot import IotDimmer +from kasa.iot.modules.dimmer import Dimmer + +from ...device_fixtures import dimmer_iot + +_TD_ONE_MS: Final[timedelta] = timedelta(milliseconds=1) + + +@dimmer_iot +def test_dimmer_getters(dev: IotDimmer): + assert Module.IotDimmer in dev.modules + dimmer: Dimmer = dev.modules[Module.IotDimmer] + + assert dimmer.threshold_min == dimmer.config["minThreshold"] + assert int(dimmer.fade_off_time / _TD_ONE_MS) == dimmer.config["fadeOffTime"] + assert int(dimmer.fade_on_time / _TD_ONE_MS) == dimmer.config["fadeOnTime"] + assert int(dimmer.gentle_off_time / _TD_ONE_MS) == dimmer.config["gentleOffTime"] + assert int(dimmer.gentle_on_time / _TD_ONE_MS) == dimmer.config["gentleOnTime"] + assert dimmer.ramp_rate == dimmer.config["rampRate"] + + +@dimmer_iot +async def test_dimmer_setters(dev: IotDimmer, mocker: MockerFixture): + dimmer: Dimmer = dev.modules[Module.IotDimmer] + query_helper = mocker.patch("kasa.iot.IotDimmer._query_helper") + + test_threshold = 10 + await dimmer.set_threshold_min(test_threshold) + query_helper.assert_called_with( + "smartlife.iot.dimmer", "calibrate_brightness", {"minThreshold": test_threshold} + ) + + test_time = 100 + await dimmer.set_fade_off_time(test_time) + query_helper.assert_called_with( + "smartlife.iot.dimmer", "set_fade_off_time", {"fadeTime": test_time} + ) + await dimmer.set_fade_on_time(test_time) + query_helper.assert_called_with( + "smartlife.iot.dimmer", "set_fade_on_time", {"fadeTime": test_time} + ) + + test_time = 1000 + await dimmer.set_gentle_off_time(test_time) + query_helper.assert_called_with( + "smartlife.iot.dimmer", "set_gentle_off_time", {"duration": test_time} + ) + await dimmer.set_gentle_on_time(test_time) + query_helper.assert_called_with( + "smartlife.iot.dimmer", "set_gentle_on_time", {"duration": test_time} + ) + + test_rate = 30 + await dimmer.set_ramp_rate(test_rate) + query_helper.assert_called_with( + "smartlife.iot.dimmer", "set_button_ramp_rate", {"rampRate": test_rate} + ) + + +@dimmer_iot +async def test_dimmer_setter_min(dev: IotDimmer, mocker: MockerFixture): + dimmer: Dimmer = dev.modules[Module.IotDimmer] + query_helper = mocker.patch("kasa.iot.IotDimmer._query_helper") + + test_threshold = dimmer.THRESHOLD_ABS_MIN + await dimmer.set_threshold_min(test_threshold) + query_helper.assert_called_with( + "smartlife.iot.dimmer", "calibrate_brightness", {"minThreshold": test_threshold} + ) + + test_time = int(dimmer.FADE_TIME_ABS_MIN / _TD_ONE_MS) + await dimmer.set_fade_off_time(test_time) + query_helper.assert_called_with( + "smartlife.iot.dimmer", "set_fade_off_time", {"fadeTime": test_time} + ) + await dimmer.set_fade_on_time(test_time) + query_helper.assert_called_with( + "smartlife.iot.dimmer", "set_fade_on_time", {"fadeTime": test_time} + ) + + test_time = int(dimmer.GENTLE_TIME_ABS_MIN / _TD_ONE_MS) + await dimmer.set_gentle_off_time(test_time) + query_helper.assert_called_with( + "smartlife.iot.dimmer", "set_gentle_off_time", {"duration": test_time} + ) + await dimmer.set_gentle_on_time(test_time) + query_helper.assert_called_with( + "smartlife.iot.dimmer", "set_gentle_on_time", {"duration": test_time} + ) + + test_rate = dimmer.RAMP_RATE_ABS_MIN + await dimmer.set_ramp_rate(test_rate) + query_helper.assert_called_with( + "smartlife.iot.dimmer", "set_button_ramp_rate", {"rampRate": test_rate} + ) + + +@dimmer_iot +async def test_dimmer_setter_max(dev: IotDimmer, mocker: MockerFixture): + dimmer: Dimmer = dev.modules[Module.IotDimmer] + query_helper = mocker.patch("kasa.iot.IotDimmer._query_helper") + + test_threshold = dimmer.THRESHOLD_ABS_MAX + await dimmer.set_threshold_min(test_threshold) + query_helper.assert_called_with( + "smartlife.iot.dimmer", "calibrate_brightness", {"minThreshold": test_threshold} + ) + + test_time = int(dimmer.FADE_TIME_ABS_MAX / _TD_ONE_MS) + await dimmer.set_fade_off_time(test_time) + query_helper.assert_called_with( + "smartlife.iot.dimmer", "set_fade_off_time", {"fadeTime": test_time} + ) + await dimmer.set_fade_on_time(test_time) + query_helper.assert_called_with( + "smartlife.iot.dimmer", "set_fade_on_time", {"fadeTime": test_time} + ) + + test_time = int(dimmer.GENTLE_TIME_ABS_MAX / _TD_ONE_MS) + await dimmer.set_gentle_off_time(test_time) + query_helper.assert_called_with( + "smartlife.iot.dimmer", "set_gentle_off_time", {"duration": test_time} + ) + await dimmer.set_gentle_on_time(test_time) + query_helper.assert_called_with( + "smartlife.iot.dimmer", "set_gentle_on_time", {"duration": test_time} + ) + + test_rate = dimmer.RAMP_RATE_ABS_MAX + await dimmer.set_ramp_rate(test_rate) + query_helper.assert_called_with( + "smartlife.iot.dimmer", "set_button_ramp_rate", {"rampRate": test_rate} + ) + + +@dimmer_iot +async def test_dimmer_setters_min_oob(dev: IotDimmer, mocker: MockerFixture): + dimmer: Dimmer = dev.modules[Module.IotDimmer] + query_helper = mocker.patch("kasa.iot.IotDimmer._query_helper") + + test_threshold = dimmer.THRESHOLD_ABS_MIN - 1 + with pytest.raises(KasaException): + await dimmer.set_threshold_min(test_threshold) + query_helper.assert_not_called() + + test_time = dimmer.FADE_TIME_ABS_MIN - _TD_ONE_MS + with pytest.raises(KasaException): + await dimmer.set_fade_off_time(test_time) + query_helper.assert_not_called() + with pytest.raises(KasaException): + await dimmer.set_fade_on_time(test_time) + query_helper.assert_not_called() + + test_time = dimmer.GENTLE_TIME_ABS_MIN - _TD_ONE_MS + with pytest.raises(KasaException): + await dimmer.set_gentle_off_time(test_time) + query_helper.assert_not_called() + with pytest.raises(KasaException): + await dimmer.set_gentle_on_time(test_time) + query_helper.assert_not_called() + + test_rate = dimmer.RAMP_RATE_ABS_MIN - 1 + with pytest.raises(KasaException): + await dimmer.set_ramp_rate(test_rate) + query_helper.assert_not_called() + + +@dimmer_iot +async def test_dimmer_setters_max_oob(dev: IotDimmer, mocker: MockerFixture): + dimmer: Dimmer = dev.modules[Module.IotDimmer] + query_helper = mocker.patch("kasa.iot.IotDimmer._query_helper") + + test_threshold = dimmer.THRESHOLD_ABS_MAX + 1 + with pytest.raises(KasaException): + await dimmer.set_threshold_min(test_threshold) + query_helper.assert_not_called() + + test_time = dimmer.FADE_TIME_ABS_MAX + _TD_ONE_MS + with pytest.raises(KasaException): + await dimmer.set_fade_off_time(test_time) + query_helper.assert_not_called() + with pytest.raises(KasaException): + await dimmer.set_fade_on_time(test_time) + query_helper.assert_not_called() + + test_time = dimmer.GENTLE_TIME_ABS_MAX + _TD_ONE_MS + with pytest.raises(KasaException): + await dimmer.set_gentle_off_time(test_time) + query_helper.assert_not_called() + with pytest.raises(KasaException): + await dimmer.set_gentle_on_time(test_time) + query_helper.assert_not_called() + + test_rate = dimmer.RAMP_RATE_ABS_MAX + 1 + with pytest.raises(KasaException): + await dimmer.set_ramp_rate(test_rate) + query_helper.assert_not_called() diff --git a/tests/iot/test_iotdevice.py b/tests/iot/test_iotdevice.py index 0b8228590..16dac35ff 100644 --- a/tests/iot/test_iotdevice.py +++ b/tests/iot/test_iotdevice.py @@ -277,12 +277,12 @@ async def test_get_modules(): # Modules on device module = dummy_device.modules.get("cloud") assert module - assert module._device == dummy_device + assert module.device == dummy_device assert isinstance(module, Cloud) module = dummy_device.modules.get(Module.IotCloud) assert module - assert module._device == dummy_device + assert module.device == dummy_device assert isinstance(module, Cloud) # Invalid modules diff --git a/tests/smart/modules/test_dustbin.py b/tests/smart/modules/test_dustbin.py index d30d2459b..ecc68b6b2 100644 --- a/tests/smart/modules/test_dustbin.py +++ b/tests/smart/modules/test_dustbin.py @@ -60,6 +60,25 @@ async def test_dustbin_mode(dev: SmartDevice, mocker: MockerFixture): await dustbin.set_mode("invalid") +@dustbin +async def test_dustbin_mode_off(dev: SmartDevice, mocker: MockerFixture): + """Test dustbin_mode == Off.""" + dustbin = next(get_parent_and_child_modules(dev, Module.Dustbin)) + call = mocker.spy(dustbin, "call") + + auto_collection = dustbin._device.features["dustbin_mode"] + await auto_collection.set_value(Mode.Off.name) + + params = dustbin._settings.copy() + params["auto_dust_collection"] = False + + call.assert_called_with("setDustCollectionInfo", params) + + await dev.update() + assert dustbin.auto_collection is False + assert dustbin.mode is Mode.Off.name + + @dustbin async def test_autocollection(dev: SmartDevice, mocker: MockerFixture): """Test autocollection switch.""" diff --git a/tests/smart/modules/test_fan.py b/tests/smart/modules/test_fan.py index 9a6878e5b..5f505e747 100644 --- a/tests/smart/modules/test_fan.py +++ b/tests/smart/modules/test_fan.py @@ -58,7 +58,7 @@ async def test_fan_module(dev: SmartDevice, mocker: MockerFixture): assert isinstance(dev, SmartDevice) fan = next(get_parent_and_child_modules(dev, Module.Fan)) assert fan - device = fan._device + device = fan.device await fan.set_fan_speed_level(1) await dev.update() diff --git a/tests/smart/test_smartdevice.py b/tests/smart/test_smartdevice.py index 2cf87d06b..155c2bdf7 100644 --- a/tests/smart/test_smartdevice.py +++ b/tests/smart/test_smartdevice.py @@ -604,7 +604,7 @@ async def test_get_modules(): # Modules on device module = dummy_device.modules.get("Cloud") assert module - assert module._device == dummy_device + assert module.device == dummy_device assert isinstance(module, Cloud) module = dummy_device.modules.get(Module.Cloud) @@ -617,8 +617,8 @@ async def test_get_modules(): assert module is None module = next(get_parent_and_child_modules(dummy_device, "Fan")) assert module - assert module._device != dummy_device - assert module._device._parent == dummy_device + assert module.device != dummy_device + assert module.device.parent == dummy_device # Invalid modules module = dummy_device.modules.get("DummyModule") diff --git a/tests/test_common_modules.py b/tests/test_common_modules.py index cba1ef878..869ba27d1 100644 --- a/tests/test_common_modules.py +++ b/tests/test_common_modules.py @@ -1,10 +1,16 @@ +import importlib +import inspect +import pkgutil +import sys from datetime import datetime from zoneinfo import ZoneInfo import pytest from pytest_mock import MockerFixture +import kasa.interfaces from kasa import Device, LightState, Module, ThermostatState +from kasa.module import _get_feature_attribute from .device_fixtures import ( bulb_iot, @@ -64,6 +70,57 @@ ) +interfaces = pytest.mark.parametrize("interface", kasa.interfaces.__all__) + + +def _get_subclasses(of_class, package): + """Get all the subclasses of a given class.""" + subclasses = set() + # iter_modules returns ModuleInfo: (module_finder, name, ispkg) + for _, modname, ispkg in pkgutil.iter_modules(package.__path__): + importlib.import_module("." + modname, package=package.__name__) + module = sys.modules[package.__name__ + "." + modname] + for _, obj in inspect.getmembers(module): + if ( + inspect.isclass(obj) + and issubclass(obj, of_class) + and obj is not of_class + ): + subclasses.add(obj) + + if ispkg: + res = _get_subclasses(of_class, module) + subclasses.update(res) + + return subclasses + + +@interfaces +def test_feature_attributes(interface): + """Test that all common derived classes define the FeatureAttributes.""" + klass = getattr(kasa.interfaces, interface) + + package = sys.modules["kasa"] + sub_classes = _get_subclasses(klass, package) + + feat_attributes: set[str] = set() + attribute_names = [ + k + for k, v in vars(klass).items() + if (callable(v) and not inspect.isclass(v)) or isinstance(v, property) + ] + for attr_name in attribute_names: + attribute = getattr(klass, attr_name) + if _get_feature_attribute(attribute): + feat_attributes.add(attr_name) + + for sub_class in sub_classes: + for attr_name in feat_attributes: + attribute = getattr(sub_class, attr_name) + fa = _get_feature_attribute(attribute) + assert fa, f"{attr_name} is not a defined module feature for {sub_class}" + + @led async def test_led_module(dev: Device, mocker: MockerFixture): """Test fan speed feature.""" @@ -176,7 +233,7 @@ async def test_light_brightness(dev: Device): assert light # Test getting the value - feature = light._device.features["brightness"] + feature = light.device.features["brightness"] assert feature.minimum_value == 0 assert feature.maximum_value == 100 @@ -205,7 +262,7 @@ async def test_light_color_temp(dev: Device): ) # Test getting the value - feature = light._device.features["color_temperature"] + feature = light.device.features["color_temperature"] assert isinstance(feature.minimum_value, int) assert isinstance(feature.maximum_value, int) @@ -237,7 +294,7 @@ async def test_light_set_state(dev: Device): light = next(get_parent_and_child_modules(dev, Module.Light)) assert light # For fixtures that have a light effect active switch off - if light_effect := light._device.modules.get(Module.LightEffect): + if light_effect := light.device.modules.get(Module.LightEffect): await light_effect.set_effect(light_effect.LIGHT_EFFECTS_OFF) await light.set_state(LightState(light_on=False)) @@ -264,7 +321,7 @@ async def test_light_preset_module(dev: Device, mocker: MockerFixture): assert preset_mod light_mod = next(get_parent_and_child_modules(dev, Module.Light)) assert light_mod - feat = preset_mod._device.features["light_preset"] + feat = preset_mod.device.features["light_preset"] preset_list = preset_mod.preset_list assert "Not set" in preset_list diff --git a/uv.lock b/uv.lock index 1c57719e4..ec695f50b 100644 --- a/uv.lock +++ b/uv.lock @@ -132,29 +132,29 @@ wheels = [ [[package]] name = "attrs" -version = "24.3.0" +version = "25.1.0" source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/48/c8/6260f8ccc11f0917360fc0da435c5c9c7504e3db174d5a12a1494887b045/attrs-24.3.0.tar.gz", hash = "sha256:8f5c07333d543103541ba7be0e2ce16eeee8130cb0b3f9238ab904ce1e85baff", size = 805984 } +sdist = { url = "https://files.pythonhosted.org/packages/49/7c/fdf464bcc51d23881d110abd74b512a42b3d5d376a55a831b44c603ae17f/attrs-25.1.0.tar.gz", hash = "sha256:1c97078a80c814273a76b2a298a932eb681c87415c11dee0a6921de7f1b02c3e", size = 810562 } wheels = [ - { url = "https://files.pythonhosted.org/packages/89/aa/ab0f7891a01eeb2d2e338ae8fecbe57fcebea1a24dbb64d45801bfab481d/attrs-24.3.0-py3-none-any.whl", hash = "sha256:ac96cd038792094f438ad1f6ff80837353805ac950cd2aa0e0625ef19850c308", size = 63397 }, + { url = "https://files.pythonhosted.org/packages/fc/30/d4986a882011f9df997a55e6becd864812ccfcd821d64aac8570ee39f719/attrs-25.1.0-py3-none-any.whl", hash = "sha256:c75a69e28a550a7e93789579c22aa26b0f5b83b75dc4e08fe092980051e1090a", size = 63152 }, ] [[package]] name = "babel" -version = "2.16.0" +version = "2.17.0" source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/2a/74/f1bc80f23eeba13393b7222b11d95ca3af2c1e28edca18af487137eefed9/babel-2.16.0.tar.gz", hash = "sha256:d1f3554ca26605fe173f3de0c65f750f5a42f924499bf134de6423582298e316", size = 9348104 } +sdist = { url = "https://files.pythonhosted.org/packages/7d/6b/d52e42361e1aa00709585ecc30b3f9684b3ab62530771402248b1b1d6240/babel-2.17.0.tar.gz", hash = "sha256:0c54cffb19f690cdcc52a3b50bcbf71e07a808d1c80d549f2459b9d2cf0afb9d", size = 9951852 } wheels = [ - { url = "https://files.pythonhosted.org/packages/ed/20/bc79bc575ba2e2a7f70e8a1155618bb1301eaa5132a8271373a6903f73f8/babel-2.16.0-py3-none-any.whl", hash = "sha256:368b5b98b37c06b7daf6696391c3240c938b37767d4584413e8438c5c435fa8b", size = 9587599 }, + { url = "https://files.pythonhosted.org/packages/b7/b8/3fe70c75fe32afc4bb507f75563d39bc5642255d1d94f1f23604725780bf/babel-2.17.0-py3-none-any.whl", hash = "sha256:4d0b53093fdfb4b21c92b5213dba5a1b23885afa8383709427046b21c366e5f2", size = 10182537 }, ] [[package]] name = "certifi" -version = "2024.12.14" +version = "2025.1.31" source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/0f/bd/1d41ee578ce09523c81a15426705dd20969f5abf006d1afe8aeff0dd776a/certifi-2024.12.14.tar.gz", hash = "sha256:b650d30f370c2b724812bee08008be0c4163b163ddaec3f2546c1caf65f191db", size = 166010 } +sdist = { url = "https://files.pythonhosted.org/packages/1c/ab/c9f1e32b7b1bf505bf26f0ef697775960db7932abeb7b516de930ba2705f/certifi-2025.1.31.tar.gz", hash = "sha256:3d5da6925056f6f18f119200434a4780a94263f10d1c21d032a6f6b2baa20651", size = 167577 } wheels = [ - { url = "https://files.pythonhosted.org/packages/a5/32/8f6669fc4798494966bf446c8c4a162e0b5d893dff088afddf76414f70e1/certifi-2024.12.14-py3-none-any.whl", hash = "sha256:1275f7a45be9464efc1173084eaa30f866fe2e47d389406136d332ed4967ec56", size = 164927 }, + { url = "https://files.pythonhosted.org/packages/38/fc/bce832fd4fd99766c04d1ee0eead6b0ec6486fb100ae5e74c1d91292b982/certifi-2025.1.31-py3-none-any.whl", hash = "sha256:ca78db4565a652026a4db2bcdf68f2fb589ea80d0be70e03929ed730746b84fe", size = 166393 }, ] [[package]] @@ -993,14 +993,14 @@ wheels = [ [[package]] name = "pytest-asyncio" -version = "0.25.2" +version = "0.25.3" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "pytest" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/72/df/adcc0d60f1053d74717d21d58c0048479e9cab51464ce0d2965b086bd0e2/pytest_asyncio-0.25.2.tar.gz", hash = "sha256:3f8ef9a98f45948ea91a0ed3dc4268b5326c0e7bce73892acc654df4262ad45f", size = 53950 } +sdist = { url = "https://files.pythonhosted.org/packages/f2/a8/ecbc8ede70921dd2f544ab1cadd3ff3bf842af27f87bbdea774c7baa1d38/pytest_asyncio-0.25.3.tar.gz", hash = "sha256:fc1da2cf9f125ada7e710b4ddad05518d4cee187ae9412e9ac9271003497f07a", size = 54239 } wheels = [ - { url = "https://files.pythonhosted.org/packages/61/d8/defa05ae50dcd6019a95527200d3b3980043df5aa445d40cb0ef9f7f98ab/pytest_asyncio-0.25.2-py3-none-any.whl", hash = "sha256:0d0bb693f7b99da304a0634afc0a4b19e49d5e0de2d670f38dc4bfa5727c5075", size = 19400 }, + { url = "https://files.pythonhosted.org/packages/67/17/3493c5624e48fd97156ebaec380dcaafee9506d7e2c46218ceebbb57d7de/pytest_asyncio-0.25.3-py3-none-any.whl", hash = "sha256:9e89518e0f9bd08928f97a3482fdc4e244df17529460bc038291ccaf8f85c7c3", size = 19467 }, ] [[package]] @@ -1106,7 +1106,7 @@ wheels = [ [[package]] name = "python-kasa" -version = "0.10.0" +version = "0.10.1" source = { editable = "." } dependencies = [ { name = "aiohttp" }, @@ -1258,27 +1258,27 @@ wheels = [ [[package]] name = "ruff" -version = "0.9.3" -source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/1e/7f/60fda2eec81f23f8aa7cbbfdf6ec2ca11eb11c273827933fb2541c2ce9d8/ruff-0.9.3.tar.gz", hash = "sha256:8293f89985a090ebc3ed1064df31f3b4b56320cdfcec8b60d3295bddb955c22a", size = 3586740 } -wheels = [ - { url = "https://files.pythonhosted.org/packages/f9/77/4fb790596d5d52c87fd55b7160c557c400e90f6116a56d82d76e95d9374a/ruff-0.9.3-py3-none-linux_armv6l.whl", hash = "sha256:7f39b879064c7d9670197d91124a75d118d00b0990586549949aae80cdc16624", size = 11656815 }, - { url = "https://files.pythonhosted.org/packages/a2/a8/3338ecb97573eafe74505f28431df3842c1933c5f8eae615427c1de32858/ruff-0.9.3-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:a187171e7c09efa4b4cc30ee5d0d55a8d6c5311b3e1b74ac5cb96cc89bafc43c", size = 11594821 }, - { url = "https://files.pythonhosted.org/packages/8e/89/320223c3421962762531a6b2dd58579b858ca9916fb2674874df5e97d628/ruff-0.9.3-py3-none-macosx_11_0_arm64.whl", hash = "sha256:c59ab92f8e92d6725b7ded9d4a31be3ef42688a115c6d3da9457a5bda140e2b4", size = 11040475 }, - { url = "https://files.pythonhosted.org/packages/b2/bd/1d775eac5e51409535804a3a888a9623e87a8f4b53e2491580858a083692/ruff-0.9.3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2dc153c25e715be41bb228bc651c1e9b1a88d5c6e5ed0194fa0dfea02b026439", size = 11856207 }, - { url = "https://files.pythonhosted.org/packages/7f/c6/3e14e09be29587393d188454064a4aa85174910d16644051a80444e4fd88/ruff-0.9.3-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:646909a1e25e0dc28fbc529eab8eb7bb583079628e8cbe738192853dbbe43af5", size = 11420460 }, - { url = "https://files.pythonhosted.org/packages/ef/42/b7ca38ffd568ae9b128a2fa76353e9a9a3c80ef19746408d4ce99217ecc1/ruff-0.9.3-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:5a5a46e09355695fbdbb30ed9889d6cf1c61b77b700a9fafc21b41f097bfbba4", size = 12605472 }, - { url = "https://files.pythonhosted.org/packages/a6/a1/3167023f23e3530fde899497ccfe239e4523854cb874458ac082992d206c/ruff-0.9.3-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:c4bb09d2bbb394e3730d0918c00276e79b2de70ec2a5231cd4ebb51a57df9ba1", size = 13243123 }, - { url = "https://files.pythonhosted.org/packages/d0/b4/3c600758e320f5bf7de16858502e849f4216cb0151f819fa0d1154874802/ruff-0.9.3-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:96a87ec31dc1044d8c2da2ebbed1c456d9b561e7d087734336518181b26b3aa5", size = 12744650 }, - { url = "https://files.pythonhosted.org/packages/be/38/266fbcbb3d0088862c9bafa8b1b99486691d2945a90b9a7316336a0d9a1b/ruff-0.9.3-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:9bb7554aca6f842645022fe2d301c264e6925baa708b392867b7a62645304df4", size = 14458585 }, - { url = "https://files.pythonhosted.org/packages/63/a6/47fd0e96990ee9b7a4abda62de26d291bd3f7647218d05b7d6d38af47c30/ruff-0.9.3-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:cabc332b7075a914ecea912cd1f3d4370489c8018f2c945a30bcc934e3bc06a6", size = 12419624 }, - { url = "https://files.pythonhosted.org/packages/84/5d/de0b7652e09f7dda49e1a3825a164a65f4998175b6486603c7601279baad/ruff-0.9.3-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:33866c3cc2a575cbd546f2cd02bdd466fed65118e4365ee538a3deffd6fcb730", size = 11843238 }, - { url = "https://files.pythonhosted.org/packages/9e/be/3f341ceb1c62b565ec1fb6fd2139cc40b60ae6eff4b6fb8f94b1bb37c7a9/ruff-0.9.3-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:006e5de2621304c8810bcd2ee101587712fa93b4f955ed0985907a36c427e0c2", size = 11484012 }, - { url = "https://files.pythonhosted.org/packages/a3/c8/ff8acbd33addc7e797e702cf00bfde352ab469723720c5607b964491d5cf/ruff-0.9.3-py3-none-musllinux_1_2_i686.whl", hash = "sha256:ba6eea4459dbd6b1be4e6bfc766079fb9b8dd2e5a35aff6baee4d9b1514ea519", size = 12038494 }, - { url = "https://files.pythonhosted.org/packages/73/b1/8d9a2c0efbbabe848b55f877bc10c5001a37ab10aca13c711431673414e5/ruff-0.9.3-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:90230a6b8055ad47d3325e9ee8f8a9ae7e273078a66401ac66df68943ced029b", size = 12473639 }, - { url = "https://files.pythonhosted.org/packages/cb/44/a673647105b1ba6da9824a928634fe23186ab19f9d526d7bdf278cd27bc3/ruff-0.9.3-py3-none-win32.whl", hash = "sha256:eabe5eb2c19a42f4808c03b82bd313fc84d4e395133fb3fc1b1516170a31213c", size = 9834353 }, - { url = "https://files.pythonhosted.org/packages/c3/01/65cadb59bf8d4fbe33d1a750103e6883d9ef302f60c28b73b773092fbde5/ruff-0.9.3-py3-none-win_amd64.whl", hash = "sha256:040ceb7f20791dfa0e78b4230ee9dce23da3b64dd5848e40e3bf3ab76468dcf4", size = 10821444 }, - { url = "https://files.pythonhosted.org/packages/69/cb/b3fe58a136a27d981911cba2f18e4b29f15010623b79f0f2510fd0d31fd3/ruff-0.9.3-py3-none-win_arm64.whl", hash = "sha256:800d773f6d4d33b0a3c60e2c6ae8f4c202ea2de056365acfa519aa48acf28e0b", size = 10038168 }, +version = "0.9.4" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/c0/17/529e78f49fc6f8076f50d985edd9a2cf011d1dbadb1cdeacc1d12afc1d26/ruff-0.9.4.tar.gz", hash = "sha256:6907ee3529244bb0ed066683e075f09285b38dd5b4039370df6ff06041ca19e7", size = 3599458 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/b6/f8/3fafb7804d82e0699a122101b5bee5f0d6e17c3a806dcbc527bb7d3f5b7a/ruff-0.9.4-py3-none-linux_armv6l.whl", hash = "sha256:64e73d25b954f71ff100bb70f39f1ee09e880728efb4250c632ceed4e4cdf706", size = 11668400 }, + { url = "https://files.pythonhosted.org/packages/2e/a6/2efa772d335da48a70ab2c6bb41a096c8517ca43c086ea672d51079e3d1f/ruff-0.9.4-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:6ce6743ed64d9afab4fafeaea70d3631b4d4b28b592db21a5c2d1f0ef52934bf", size = 11628395 }, + { url = "https://files.pythonhosted.org/packages/dc/d7/cd822437561082f1c9d7225cc0d0fbb4bad117ad7ac3c41cd5d7f0fa948c/ruff-0.9.4-py3-none-macosx_11_0_arm64.whl", hash = "sha256:54499fb08408e32b57360f6f9de7157a5fec24ad79cb3f42ef2c3f3f728dfe2b", size = 11090052 }, + { url = "https://files.pythonhosted.org/packages/9e/67/3660d58e893d470abb9a13f679223368ff1684a4ef40f254a0157f51b448/ruff-0.9.4-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:37c892540108314a6f01f105040b5106aeb829fa5fb0561d2dcaf71485021137", size = 11882221 }, + { url = "https://files.pythonhosted.org/packages/79/d1/757559995c8ba5f14dfec4459ef2dd3fcea82ac43bc4e7c7bf47484180c0/ruff-0.9.4-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:de9edf2ce4b9ddf43fd93e20ef635a900e25f622f87ed6e3047a664d0e8f810e", size = 11424862 }, + { url = "https://files.pythonhosted.org/packages/c0/96/7915a7c6877bb734caa6a2af424045baf6419f685632469643dbd8eb2958/ruff-0.9.4-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:87c90c32357c74f11deb7fbb065126d91771b207bf9bfaaee01277ca59b574ec", size = 12626735 }, + { url = "https://files.pythonhosted.org/packages/0e/cc/dadb9b35473d7cb17c7ffe4737b4377aeec519a446ee8514123ff4a26091/ruff-0.9.4-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:56acd6c694da3695a7461cc55775f3a409c3815ac467279dfa126061d84b314b", size = 13255976 }, + { url = "https://files.pythonhosted.org/packages/5f/c3/ad2dd59d3cabbc12df308cced780f9c14367f0321e7800ca0fe52849da4c/ruff-0.9.4-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:e0c93e7d47ed951b9394cf352d6695b31498e68fd5782d6cbc282425655f687a", size = 12752262 }, + { url = "https://files.pythonhosted.org/packages/c7/17/5f1971e54bd71604da6788efd84d66d789362b1105e17e5ccc53bba0289b/ruff-0.9.4-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:1d4c8772670aecf037d1bf7a07c39106574d143b26cfe5ed1787d2f31e800214", size = 14401648 }, + { url = "https://files.pythonhosted.org/packages/30/24/6200b13ea611b83260501b6955b764bb320e23b2b75884c60ee7d3f0b68e/ruff-0.9.4-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bfc5f1d7afeda8d5d37660eeca6d389b142d7f2b5a1ab659d9214ebd0e025231", size = 12414702 }, + { url = "https://files.pythonhosted.org/packages/34/cb/f5d50d0c4ecdcc7670e348bd0b11878154bc4617f3fdd1e8ad5297c0d0ba/ruff-0.9.4-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:faa935fc00ae854d8b638c16a5f1ce881bc3f67446957dd6f2af440a5fc8526b", size = 11859608 }, + { url = "https://files.pythonhosted.org/packages/d6/f4/9c8499ae8426da48363bbb78d081b817b0f64a9305f9b7f87eab2a8fb2c1/ruff-0.9.4-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:a6c634fc6f5a0ceae1ab3e13c58183978185d131a29c425e4eaa9f40afe1e6d6", size = 11485702 }, + { url = "https://files.pythonhosted.org/packages/18/59/30490e483e804ccaa8147dd78c52e44ff96e1c30b5a95d69a63163cdb15b/ruff-0.9.4-py3-none-musllinux_1_2_i686.whl", hash = "sha256:433dedf6ddfdec7f1ac7575ec1eb9844fa60c4c8c2f8887a070672b8d353d34c", size = 12067782 }, + { url = "https://files.pythonhosted.org/packages/3d/8c/893fa9551760b2f8eb2a351b603e96f15af167ceaf27e27ad873570bc04c/ruff-0.9.4-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:d612dbd0f3a919a8cc1d12037168bfa536862066808960e0cc901404b77968f0", size = 12483087 }, + { url = "https://files.pythonhosted.org/packages/23/15/f6751c07c21ca10e3f4a51ea495ca975ad936d780c347d9808bcedbd7182/ruff-0.9.4-py3-none-win32.whl", hash = "sha256:db1192ddda2200671f9ef61d9597fcef89d934f5d1705e571a93a67fb13a4402", size = 9852302 }, + { url = "https://files.pythonhosted.org/packages/12/41/2d2d2c6a72e62566f730e49254f602dfed23019c33b5b21ea8f8917315a1/ruff-0.9.4-py3-none-win_amd64.whl", hash = "sha256:05bebf4cdbe3ef75430d26c375773978950bbf4ee3c95ccb5448940dc092408e", size = 10850051 }, + { url = "https://files.pythonhosted.org/packages/c6/e6/3d6ec3bc3d254e7f005c543a661a41c3e788976d0e52a1ada195bd664344/ruff-0.9.4-py3-none-win_arm64.whl", hash = "sha256:585792f1e81509e38ac5123492f8875fbc36f3ede8185af0a26df348e5154f41", size = 10078251 }, ] [[package]]