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

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:
Giovanni
2025-08-30 10:42:53 -04:00
committed by GitHub
parent 08e7ab5120
commit 2b881cfd7b
6 changed files with 3524 additions and 24 deletions

View File

@@ -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)