From 8a876d953a4520178fe1f655bcca6b479728934f Mon Sep 17 00:00:00 2001 From: Vadym Melnychuk Date: Mon, 24 Jul 2023 16:16:07 +0300 Subject: [PATCH] sync_command - fixed typos, skip to sync(actually reset) parameters of different types. Improved WaterHeater appliance --- pyhon/appliance.py | 7 ++----- pyhon/appliances/wh.py | 8 ++++++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/pyhon/appliance.py b/pyhon/appliance.py index 996c463..f401f1f 100644 --- a/pyhon/appliance.py +++ b/pyhon/appliance.py @@ -13,6 +13,7 @@ from pyhon.commands import HonCommand from pyhon.parameter.base import HonParameter from pyhon.parameter.enum import HonParameterEnum from pyhon.parameter.range import HonParameterRange +from pyhon.parameter.fixed import HonParameterFixed from pyhon.typedefs import Parameter if TYPE_CHECKING: @@ -287,7 +288,7 @@ class HonAppliance: for name, target_param in data.parameters.items(): if not (base_param := base.parameters.get(name)): - return + continue self.sync_parameter(base_param, target_param) def sync_parameter(self, main: Parameter, target: Parameter) -> None: @@ -297,10 +298,6 @@ class HonAppliance: target.max = main.max target.min = main.min target.step = main.step - elif isinstance(target, HonParameterRange): - target.max = int(main.value) - target.min = int(main.value) - target.step = 1 elif isinstance(target, HonParameterEnum): target.values = main.values target.value = main.value diff --git a/pyhon/appliances/wh.py b/pyhon/appliances/wh.py index 4aa1a3c..a3cee95 100644 --- a/pyhon/appliances/wh.py +++ b/pyhon/appliances/wh.py @@ -1,11 +1,15 @@ from typing import Any, Dict from pyhon.appliances.base import ApplianceBase - +from pyhon.parameter.base import HonParameter class Appliance(ApplianceBase): def attributes(self, data: Dict[str, Any]) -> Dict[str, Any]: data = super().attributes(data) - data["active"] = data["parameters"]["onOffStatus"] == "1" + parameter = data["parameters"]["onOffStatus"] + data["active"] = parameter.value == 1 if isinstance(parameter, HonParameter) else parameter == 1 return data + + def settings(self, settings: Dict[str, Any]) -> Dict[str, Any]: + return settings \ No newline at end of file