sync_command - fixed typos, skip to sync(actually reset) parameters of different types. Improved WaterHeater appliance
This commit is contained in:
parent
3d8011deea
commit
8a876d953a
@ -13,6 +13,7 @@ from pyhon.commands import HonCommand
|
|||||||
from pyhon.parameter.base import HonParameter
|
from pyhon.parameter.base import HonParameter
|
||||||
from pyhon.parameter.enum import HonParameterEnum
|
from pyhon.parameter.enum import HonParameterEnum
|
||||||
from pyhon.parameter.range import HonParameterRange
|
from pyhon.parameter.range import HonParameterRange
|
||||||
|
from pyhon.parameter.fixed import HonParameterFixed
|
||||||
from pyhon.typedefs import Parameter
|
from pyhon.typedefs import Parameter
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
@ -287,7 +288,7 @@ class HonAppliance:
|
|||||||
|
|
||||||
for name, target_param in data.parameters.items():
|
for name, target_param in data.parameters.items():
|
||||||
if not (base_param := base.parameters.get(name)):
|
if not (base_param := base.parameters.get(name)):
|
||||||
return
|
continue
|
||||||
self.sync_parameter(base_param, target_param)
|
self.sync_parameter(base_param, target_param)
|
||||||
|
|
||||||
def sync_parameter(self, main: Parameter, target: Parameter) -> None:
|
def sync_parameter(self, main: Parameter, target: Parameter) -> None:
|
||||||
@ -297,10 +298,6 @@ class HonAppliance:
|
|||||||
target.max = main.max
|
target.max = main.max
|
||||||
target.min = main.min
|
target.min = main.min
|
||||||
target.step = main.step
|
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):
|
elif isinstance(target, HonParameterEnum):
|
||||||
target.values = main.values
|
target.values = main.values
|
||||||
target.value = main.value
|
target.value = main.value
|
||||||
|
@ -1,11 +1,15 @@
|
|||||||
from typing import Any, Dict
|
from typing import Any, Dict
|
||||||
|
|
||||||
from pyhon.appliances.base import ApplianceBase
|
from pyhon.appliances.base import ApplianceBase
|
||||||
|
from pyhon.parameter.base import HonParameter
|
||||||
|
|
||||||
class Appliance(ApplianceBase):
|
class Appliance(ApplianceBase):
|
||||||
def attributes(self, data: Dict[str, Any]) -> Dict[str, Any]:
|
def attributes(self, data: Dict[str, Any]) -> Dict[str, Any]:
|
||||||
data = super().attributes(data)
|
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
|
return data
|
||||||
|
|
||||||
|
def settings(self, settings: Dict[str, Any]) -> Dict[str, Any]:
|
||||||
|
return settings
|
Loading…
Reference in New Issue
Block a user