Add oven climate support

This commit is contained in:
Andre Basche 2023-05-28 17:34:32 +02:00
parent 7c6ac15901
commit 4888f2b1d0
4 changed files with 28 additions and 1 deletions

View file

@ -11,6 +11,7 @@ from pyhon import helper
from pyhon.commands import HonCommand from pyhon.commands import HonCommand
from pyhon.parameter.base import HonParameter from pyhon.parameter.base import HonParameter
from pyhon.parameter.fixed import HonParameterFixed from pyhon.parameter.fixed import HonParameterFixed
from pyhon.parameter.range import HonParameterRange
if TYPE_CHECKING: if TYPE_CHECKING:
from pyhon import HonAPI from pyhon import HonAPI
@ -302,6 +303,16 @@ class HonAppliance:
continue continue
for name, parameter in data.parameters.items(): for name, parameter in data.parameters.items():
if base_value := base.parameters.get(name): 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 parameter.value = base_value.value

View file

@ -11,6 +11,10 @@ class Appliance:
data["active"] = data["attributes"]["parameters"]["onOffStatus"] == "1" 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 return data
def settings(self, settings): def settings(self, settings):

View file

@ -26,16 +26,28 @@ class HonParameterRange(HonParameter):
def min(self) -> float: def min(self) -> float:
return self._min return self._min
@min.setter
def min(self, min: float) -> None:
self._min = min
@property @property
def max(self) -> float: def max(self) -> float:
return self._max return self._max
@max.setter
def max(self, max: float) -> None:
self._max = max
@property @property
def step(self) -> float: def step(self) -> float:
if not self._step: if not self._step:
return 1 return 1
return self._step return self._step
@step.setter
def step(self, step: float) -> None:
self._step = step
@property @property
def value(self) -> str | float: def value(self) -> str | float:
return self._value if self._value is not None else self._min return self._value if self._value is not None else self._min

View file

@ -7,7 +7,7 @@ with open("README.md", "r") as f:
setup( setup(
name="pyhOn", name="pyhOn",
version="0.11.2", version="0.11.3",
author="Andre Basche", author="Andre Basche",
description="Control hOn devices with python", description="Control hOn devices with python",
long_description=long_description, long_description=long_description,