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.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

View File

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

View File

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

View File

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