expose ancillary parameter in settings
This commit is contained in:
parent
5b91747ec1
commit
e887371bec
@ -13,7 +13,7 @@ if TYPE_CHECKING:
|
|||||||
|
|
||||||
class HonAppliance:
|
class HonAppliance:
|
||||||
def __init__(
|
def __init__(
|
||||||
self, api: Optional["HonAPI"], info: Dict[str, Any], zone: int = 0
|
self, api: Optional["HonAPI"], info: Dict[str, Any], zone: int = 0
|
||||||
) -> None:
|
) -> None:
|
||||||
if attributes := info.get("attributes"):
|
if attributes := info.get("attributes"):
|
||||||
info["attributes"] = {v["parName"]: v["parValue"] for v in attributes}
|
info["attributes"] = {v["parName"]: v["parValue"] for v in attributes}
|
||||||
@ -129,8 +129,8 @@ class HonAppliance:
|
|||||||
command = self.commands[name]
|
command = self.commands[name]
|
||||||
for key, data in command.settings.items():
|
for key, data in command.settings.items():
|
||||||
if (
|
if (
|
||||||
not isinstance(data, HonParameterFixed)
|
not isinstance(data, HonParameterFixed)
|
||||||
and parameters.get(key) is not None
|
and parameters.get(key) is not None
|
||||||
):
|
):
|
||||||
with suppress(ValueError):
|
with suppress(ValueError):
|
||||||
data.value = parameters.get(key)
|
data.value = parameters.get(key)
|
||||||
@ -175,7 +175,7 @@ class HonAppliance:
|
|||||||
def parameters(self):
|
def parameters(self):
|
||||||
result = {}
|
result = {}
|
||||||
for name, command in self._commands.items():
|
for name, command in self._commands.items():
|
||||||
for key, parameter in command.parameters.items():
|
for key, parameter in (command.parameters | command.ancillary_parameters).items():
|
||||||
result.setdefault(name, {})[key] = parameter.value
|
result.setdefault(name, {})[key] = parameter.value
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -58,11 +58,8 @@ class HonCommand:
|
|||||||
return self._parameters
|
return self._parameters
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def ancillary_parameters(self) -> Dict[str, str | float]:
|
def ancillary_parameters(self) -> Dict[str, HonParameter]:
|
||||||
return {
|
return self._ancillary_parameters
|
||||||
key: parameter.value
|
|
||||||
for key, parameter in self._ancillary_parameters.items()
|
|
||||||
}
|
|
||||||
|
|
||||||
async def send(self) -> bool:
|
async def send(self) -> bool:
|
||||||
parameters = {
|
parameters = {
|
||||||
@ -90,7 +87,9 @@ class HonCommand:
|
|||||||
if command is None:
|
if command is None:
|
||||||
command = self
|
command = self
|
||||||
keys = []
|
keys = []
|
||||||
for key, parameter in command._parameters.items():
|
for key, parameter in (
|
||||||
|
command._parameters | command._ancillary_parameters
|
||||||
|
).items():
|
||||||
if isinstance(parameter, HonParameterFixed):
|
if isinstance(parameter, HonParameterFixed):
|
||||||
continue
|
continue
|
||||||
if key not in keys:
|
if key not in keys:
|
||||||
@ -115,4 +114,5 @@ class HonCommand:
|
|||||||
s: param
|
s: param
|
||||||
for s in self.setting_keys
|
for s in self.setting_keys
|
||||||
if (param := self._parameters.get(s)) is not None
|
if (param := self._parameters.get(s)) is not None
|
||||||
|
or (param := self._ancillary_parameters.get(s)) is not None
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ def create_command(commands, concat=False):
|
|||||||
for name, command in commands.items():
|
for name, command in commands.items():
|
||||||
if not concat:
|
if not concat:
|
||||||
result[name] = {}
|
result[name] = {}
|
||||||
for parameter, data in command.parameters.items():
|
for parameter, data in command.settings.items():
|
||||||
if data.typology == "enum":
|
if data.typology == "enum":
|
||||||
value = data.values
|
value = data.values
|
||||||
elif data.typology == "range":
|
elif data.typology == "range":
|
||||||
|
Loading…
Reference in New Issue
Block a user