From 18b0ecdd68ac8cd4cc8bae248883487ccb47d96d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20=C3=81ngel?= Date: Sat, 8 Apr 2023 22:24:14 +0200 Subject: [PATCH 1/5] Override Oven attributes when is disconnected --- pyhon/appliances/ov.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pyhon/appliances/ov.py b/pyhon/appliances/ov.py index 0d3fe18..96962cf 100644 --- a/pyhon/appliances/ov.py +++ b/pyhon/appliances/ov.py @@ -8,6 +8,12 @@ class Appliance: self._program_filter = HonParameterEnum("program_filter", data) def data(self, data): + if data["attributes"]["lastConnEvent"]["category"] == "DISCONNECTED": + data["attributes"]["activity"]["attributes"]["temp"] = "0" + data["attributes"]["activity"]["attributes"]["onOffStatus"] = "0" + data["attributes"]["activity"]["attributes"]["remoteCtrValid"] = "0" + data["attributes"]["activity"]["attributes"]["remainingTimeMM"] = "0" + return data def settings(self, settings): From e887371becccb3a1cf1d1ab4d70ef20feb7ff399 Mon Sep 17 00:00:00 2001 From: Andre Basche Date: Sun, 16 Apr 2023 03:29:28 +0200 Subject: [PATCH 2/5] expose ancillary parameter in settings --- pyhon/appliance.py | 8 ++++---- pyhon/commands.py | 12 ++++++------ pyhon/helper.py | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/pyhon/appliance.py b/pyhon/appliance.py index d54df40..ce89187 100644 --- a/pyhon/appliance.py +++ b/pyhon/appliance.py @@ -13,7 +13,7 @@ if TYPE_CHECKING: class HonAppliance: def __init__( - self, api: Optional["HonAPI"], info: Dict[str, Any], zone: int = 0 + self, api: Optional["HonAPI"], info: Dict[str, Any], zone: int = 0 ) -> None: if attributes := info.get("attributes"): info["attributes"] = {v["parName"]: v["parValue"] for v in attributes} @@ -129,8 +129,8 @@ class HonAppliance: command = self.commands[name] for key, data in command.settings.items(): if ( - not isinstance(data, HonParameterFixed) - and parameters.get(key) is not None + not isinstance(data, HonParameterFixed) + and parameters.get(key) is not None ): with suppress(ValueError): data.value = parameters.get(key) @@ -175,7 +175,7 @@ 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 40cc0013a51698d8a0f51b401f77e2244cedcddc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20=C3=81ngel?= Date: Sun, 16 Apr 2023 11:36:10 +0200 Subject: [PATCH 3/5] Override Oven attributes when is disconnected --- pyhon/appliances/ov.py | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/pyhon/appliances/ov.py b/pyhon/appliances/ov.py index 96962cf..75c9a31 100644 --- a/pyhon/appliances/ov.py +++ b/pyhon/appliances/ov.py @@ -1,22 +1,15 @@ -from pyhon.parameter import HonParameterEnum - - class Appliance: - def __init__(self): - filters = ["receipt", "standard, special"] - data = {'defaultValue': filters[0], 'enumValues': filters} - self._program_filter = HonParameterEnum("program_filter", data) def data(self, data): if data["attributes"]["lastConnEvent"]["category"] == "DISCONNECTED": - data["attributes"]["activity"]["attributes"]["temp"] = "0" - data["attributes"]["activity"]["attributes"]["onOffStatus"] = "0" - data["attributes"]["activity"]["attributes"]["remoteCtrValid"] = "0" - data["attributes"]["activity"]["attributes"]["remainingTimeMM"] = "0" + data["attributes"]["parameters"]["temp"] = "0" + data["attributes"]["parameters"]["onOffStatus"] = "0" + data["attributes"]["parameters"]["remoteCtrValid"] = "0" + data["attributes"]["parameters"]["remainingTimeMM"] = "0" + + data["active"] = data["attributes"]["parameters"]["onOffStatus"] == "1" return data def settings(self, settings): - settings["program_filter"] = self._program_filter - settings["startProgram.program"].filter = self._program_filter.value return settings From 191928287fa76f5833c5213cf68d1e02ad1e1452 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20=C3=81ngel?= Date: Wed, 19 Apr 2023 19:29:59 +0200 Subject: [PATCH 4/5] Override Oven attributes when is disconnected --- pyhon/appliances/ov.py | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pyhon/appliances/ov.py b/pyhon/appliances/ov.py index 75c9a31..c3957e2 100644 --- a/pyhon/appliances/ov.py +++ b/pyhon/appliances/ov.py @@ -12,4 +12,4 @@ class Appliance: return data def settings(self, settings): - return settings + return settings \ No newline at end of file diff --git a/setup.py b/setup.py index 3ca2782..0411dbc 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ with open("README.md", "r") as f: setup( name="pyhOn", - version="0.8.0", + version="0.8.1", author="Andre Basche", description="Control hOn devices with python", long_description=long_description, From 78bc85132fe88da345aa3e8e880c4502b993e617 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20=C3=81ngel?= Date: Wed, 19 Apr 2023 20:12:52 +0200 Subject: [PATCH 5/5] Black Style --- pyhon/appliances/ov.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pyhon/appliances/ov.py b/pyhon/appliances/ov.py index c3957e2..bd42630 100644 --- a/pyhon/appliances/ov.py +++ b/pyhon/appliances/ov.py @@ -1,5 +1,4 @@ class Appliance: - def data(self, data): if data["attributes"]["lastConnEvent"]["category"] == "DISCONNECTED": data["attributes"]["parameters"]["temp"] = "0" @@ -12,4 +11,4 @@ class Appliance: return data def settings(self, settings): - return settings \ No newline at end of file + return settings