From 4888f2b1d08e7b162b8cf399b913d60f4c8a32d4 Mon Sep 17 00:00:00 2001 From: Andre Basche Date: Sun, 28 May 2023 17:34:32 +0200 Subject: [PATCH] Add oven climate support --- pyhon/appliance.py | 11 +++++++++++ pyhon/appliances/ov.py | 4 ++++ pyhon/parameter/range.py | 12 ++++++++++++ setup.py | 2 +- 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/pyhon/appliance.py b/pyhon/appliance.py index 1464780..343f2cb 100644 --- a/pyhon/appliance.py +++ b/pyhon/appliance.py @@ -11,6 +11,7 @@ from pyhon import helper from pyhon.commands import HonCommand from pyhon.parameter.base import HonParameter from pyhon.parameter.fixed import HonParameterFixed +from pyhon.parameter.range import HonParameterRange if TYPE_CHECKING: from pyhon import HonAPI @@ -302,6 +303,16 @@ class HonAppliance: continue for name, parameter in data.parameters.items(): if base_value := base.parameters.get(name): + if isinstance(base_value, HonParameterRange) and isinstance( + parameter, HonParameterRange + ): + parameter.max = base_value.max + parameter.min = base_value.min + parameter.step = base_value.step + elif isinstance(parameter, HonParameterRange): + parameter.max = int(base_value.value) + parameter.min = int(base_value.value) + parameter.step = 1 parameter.value = base_value.value diff --git a/pyhon/appliances/ov.py b/pyhon/appliances/ov.py index c6df1c0..ec57ffd 100644 --- a/pyhon/appliances/ov.py +++ b/pyhon/appliances/ov.py @@ -11,6 +11,10 @@ class Appliance: data["active"] = data["attributes"]["parameters"]["onOffStatus"] == "1" + if program := int(data["attributes"]["parameters"]["prCode"]): + ids = self.parent.settings["startProgram.program"].ids + data["programName"] = ids.get(program, "") + return data def settings(self, settings): diff --git a/pyhon/parameter/range.py b/pyhon/parameter/range.py index 8f35e97..252973e 100644 --- a/pyhon/parameter/range.py +++ b/pyhon/parameter/range.py @@ -26,16 +26,28 @@ class HonParameterRange(HonParameter): def min(self) -> float: return self._min + @min.setter + def min(self, min: float) -> None: + self._min = min + @property def max(self) -> float: return self._max + @max.setter + def max(self, max: float) -> None: + self._max = max + @property def step(self) -> float: if not self._step: return 1 return self._step + @step.setter + def step(self, step: float) -> None: + self._step = step + @property def value(self) -> str | float: return self._value if self._value is not None else self._min diff --git a/setup.py b/setup.py index d2419bd..9e3de1b 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ with open("README.md", "r") as f: setup( name="pyhOn", - version="0.11.2", + version="0.11.3", author="Andre Basche", description="Control hOn devices with python", long_description=long_description,