Added water heater appliance. Added ability to send only mandatory parameters
This commit is contained in:
parent
e00e147ecd
commit
71cf7a1b8a
8
pyhon/appliances/wh.py
Normal file
8
pyhon/appliances/wh.py
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
from typing import Any, Dict
|
||||||
|
|
||||||
|
from pyhon.appliances.base import ApplianceBase
|
||||||
|
|
||||||
|
class Appliance(ApplianceBase):
|
||||||
|
def attributes(self, data: Dict[str, Any]) -> Dict[str, Any]:
|
||||||
|
data = super().attributes(data)
|
||||||
|
data["active"] = data.get("onOffStatus") == 1
|
@ -75,6 +75,14 @@ class HonCommand:
|
|||||||
for name, parameter in self._parameters.items():
|
for name, parameter in self._parameters.items():
|
||||||
result.setdefault(parameter.group, {})[name] = parameter.intern_value
|
result.setdefault(parameter.group, {})[name] = parameter.intern_value
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@property
|
||||||
|
def mandatory_parameter_groups(self) -> Dict[str, Dict[str, Union[str, float]]]:
|
||||||
|
result: Dict[str, Dict[str, Union[str, float]]] = {}
|
||||||
|
for name, parameter in self._parameters.items():
|
||||||
|
if parameter.mandatory:
|
||||||
|
result.setdefault(parameter.group, {})[name] = parameter.intern_value
|
||||||
|
return result
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def parameter_value(self) -> Dict[str, Union[str, float]]:
|
def parameter_value(self) -> Dict[str, Union[str, float]]:
|
||||||
@ -111,8 +119,9 @@ class HonCommand:
|
|||||||
name = "program" if "PROGRAM" in self._category_name else "category"
|
name = "program" if "PROGRAM" in self._category_name else "category"
|
||||||
self._parameters[name] = HonParameterProgram(name, self, "custom")
|
self._parameters[name] = HonParameterProgram(name, self, "custom")
|
||||||
|
|
||||||
async def send(self) -> bool:
|
async def send(self, onlyMandatory: bool = False) -> bool:
|
||||||
params = self.parameter_groups.get("parameters", {})
|
grouped_params = self.mandatory_parameter_groups if onlyMandatory else self.parameter_groups
|
||||||
|
params = grouped_params.get("parameters", {})
|
||||||
ancillary_params = self.parameter_groups.get("ancillaryParameters", {})
|
ancillary_params = self.parameter_groups.get("ancillaryParameters", {})
|
||||||
ancillary_params.pop("programRules", None)
|
ancillary_params.pop("programRules", None)
|
||||||
self.appliance.sync_command_to_params(self.name)
|
self.appliance.sync_command_to_params(self.name)
|
||||||
|
Loading…
Reference in New Issue
Block a user