From 8372c75e304c4456f78ff788afbee6fa9126aee2 Mon Sep 17 00:00:00 2001 From: Andre Basche Date: Sun, 16 Apr 2023 03:29:28 +0200 Subject: [PATCH 1/3] expose ancillary parameter in settings --- pyhon/appliance.py | 4 +++- pyhon/commands.py | 12 ++++++------ pyhon/helper.py | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/pyhon/appliance.py b/pyhon/appliance.py index d54df40..90a7f12 100644 --- a/pyhon/appliance.py +++ b/pyhon/appliance.py @@ -175,7 +175,9 @@ class HonAppliance: def parameters(self): result = {} for name, command in self._commands.items(): - for key, parameter in command.parameters.items(): + for key, parameter in ( + command.parameters | command.ancillary_parameters + ).items(): result.setdefault(name, {})[key] = parameter.value return result diff --git a/pyhon/commands.py b/pyhon/commands.py index 03f70d0..33487a3 100644 --- a/pyhon/commands.py +++ b/pyhon/commands.py @@ -58,11 +58,8 @@ class HonCommand: return self._parameters @property - def ancillary_parameters(self) -> Dict[str, str | float]: - return { - key: parameter.value - for key, parameter in self._ancillary_parameters.items() - } + def ancillary_parameters(self) -> Dict[str, HonParameter]: + return self._ancillary_parameters async def send(self) -> bool: parameters = { @@ -90,7 +87,9 @@ class HonCommand: if command is None: command = self keys = [] - for key, parameter in command._parameters.items(): + for key, parameter in ( + command._parameters | command._ancillary_parameters + ).items(): if isinstance(parameter, HonParameterFixed): continue if key not in keys: @@ -115,4 +114,5 @@ class HonCommand: s: param for s in self.setting_keys if (param := self._parameters.get(s)) is not None + or (param := self._ancillary_parameters.get(s)) is not None } diff --git a/pyhon/helper.py b/pyhon/helper.py index d126b91..c820dd1 100644 --- a/pyhon/helper.py +++ b/pyhon/helper.py @@ -49,7 +49,7 @@ def create_command(commands, concat=False): for name, command in commands.items(): if not concat: result[name] = {} - for parameter, data in command.parameters.items(): + for parameter, data in command.settings.items(): if data.typology == "enum": value = data.values elif data.typology == "range": From 6c44aa895d64db59e11e8508ba5a3b2c8fb0bba9 Mon Sep 17 00:00:00 2001 From: Andre Basche Date: Sun, 16 Apr 2023 13:31:19 +0200 Subject: [PATCH 2/3] Disable zones for devices with just 1 zone, fixes #11 --- pyhon/hon.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pyhon/hon.py b/pyhon/hon.py index 830d510..bffa246 100644 --- a/pyhon/hon.py +++ b/pyhon/hon.py @@ -61,8 +61,9 @@ class Hon: async def setup(self) -> None: appliance: Dict for appliance in (await self.api.load_appliances())["payload"]["appliances"]: - for zone in range(int(appliance.get("zone", "0"))): - await self._create_appliance(appliance.copy(), zone=zone + 1) + if (zones := int(appliance.get("zone", "0"))) > 1: + for zone in range(zones): + await self._create_appliance(appliance.copy(), zone=zone + 1) await self._create_appliance(appliance) async def close(self) -> None: From 69be63df2a52cac4cb3e6ca9b9772cb8f2b61a3c Mon Sep 17 00:00:00 2001 From: Andre Basche Date: Sun, 16 Apr 2023 13:57:40 +0200 Subject: [PATCH 3/3] Bump version to v0.8.0b5 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index caa5d11..8695cd5 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ with open("README.md", "r") as f: setup( name="pyhOn", - version="0.8.0b4", + version="0.8.0b5", author="Andre Basche", description="Control hOn devices with python", long_description=long_description,