mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-10-13 10:58:02 +00:00
Add device fixture for P316M(US) (#1568)
Some checks failed
CI / Perform linting checks (3.13) (push) Has been cancelled
CodeQL checks / Analyze (python) (push) Has been cancelled
CI / Python 3.11 on macos-latest (push) Has been cancelled
CI / Python 3.12 on macos-latest (push) Has been cancelled
CI / Python 3.13 on macos-latest (push) Has been cancelled
CI / Python 3.11 on ubuntu-latest (push) Has been cancelled
CI / Python 3.12 on ubuntu-latest (push) Has been cancelled
CI / Python 3.13 on ubuntu-latest (push) Has been cancelled
CI / Python 3.11 on windows-latest (push) Has been cancelled
CI / Python 3.12 on windows-latest (push) Has been cancelled
CI / Python 3.13 on windows-latest (push) Has been cancelled
Stale / stale (push) Has been cancelled
Some checks failed
CI / Perform linting checks (3.13) (push) Has been cancelled
CodeQL checks / Analyze (python) (push) Has been cancelled
CI / Python 3.11 on macos-latest (push) Has been cancelled
CI / Python 3.12 on macos-latest (push) Has been cancelled
CI / Python 3.13 on macos-latest (push) Has been cancelled
CI / Python 3.11 on ubuntu-latest (push) Has been cancelled
CI / Python 3.12 on ubuntu-latest (push) Has been cancelled
CI / Python 3.13 on ubuntu-latest (push) Has been cancelled
CI / Python 3.11 on windows-latest (push) Has been cancelled
CI / Python 3.12 on windows-latest (push) Has been cancelled
CI / Python 3.13 on windows-latest (push) Has been cancelled
Stale / stale (push) Has been cancelled
Adds device fixture and updates powerprotection module to accept the changed enabled key. --------- Co-authored-by: komodo <komodo@komo.do> Co-authored-by: Teemu Rytilahti <tpr@iki.fi>
This commit is contained in:
@@ -57,7 +57,9 @@ class PowerProtection(SmartModule):
|
||||
@property
|
||||
def enabled(self) -> bool:
|
||||
"""Return True if child protection is enabled."""
|
||||
return self.data["get_protection_power"]["enabled"]
|
||||
settings = self.data["get_protection_power"]
|
||||
enabled_key = next(k for k in settings if "enabled" in k)
|
||||
return settings[enabled_key]
|
||||
|
||||
async def set_enabled(self, enabled: bool, *, threshold: int | None = None) -> dict:
|
||||
"""Set power protection enabled.
|
||||
@@ -73,7 +75,10 @@ class PowerProtection(SmartModule):
|
||||
"Threshold out of range: %s (%s)", threshold, self.protection_threshold
|
||||
)
|
||||
|
||||
params = {**self.data["get_protection_power"], "enabled": enabled}
|
||||
enabled_key = next(
|
||||
k for k in self.data["get_protection_power"] if "enabled" in k
|
||||
)
|
||||
params = {**self.data["get_protection_power"], enabled_key: enabled}
|
||||
if threshold is not None:
|
||||
params["protection_power"] = threshold
|
||||
return await self.call("set_protection_power", params)
|
||||
|
Reference in New Issue
Block a user