mirror of
https://github.com/Andre0512/pyhOn.git
synced 2025-05-14 15:14:28 -04:00
Issue with sync_command (#16)
* Added water heater appliance. Added ability to send only mandatory parameters * fixed build * formatting * cleanup * cleanup * reformatting * Added ability to send specific parameters. Useful in case the command has many not mandatory parameters and you want to send only one/few * cleanup * Fixed code style * sync_command - fixed typos, skip to sync(actually reset) parameters of different types. Improved WaterHeater appliance * cleanup * cleanup * clean code style * check if base parameter is mandatory * Reverted back sync_command, send mandatory parameters beside with specified --------- Co-authored-by: Vadym Melnychuk <vme@primexm.com>
This commit is contained in:
parent
ff8ae160bb
commit
6ae40481e3
3 changed files with 20 additions and 5 deletions
|
@ -277,7 +277,12 @@ class HonAppliance:
|
|||
_LOGGER.info("Can't set %s - %s", key, error)
|
||||
continue
|
||||
|
||||
def sync_command(self, main: str, target: Optional[List[str] | str] = None) -> None:
|
||||
def sync_command(
|
||||
self,
|
||||
main: str,
|
||||
target: Optional[List[str] | str] = None,
|
||||
to_sync: Optional[List[str] | bool] = None,
|
||||
) -> None:
|
||||
base: Optional[HonCommand] = self.commands.get(main)
|
||||
if not base:
|
||||
return
|
||||
|
@ -287,7 +292,12 @@ class HonAppliance:
|
|||
|
||||
for name, target_param in data.parameters.items():
|
||||
if not (base_param := base.parameters.get(name)):
|
||||
return
|
||||
continue
|
||||
if to_sync and (
|
||||
(isinstance(to_sync, list) and name not in to_sync)
|
||||
or not base_param.mandatory
|
||||
):
|
||||
continue
|
||||
self.sync_parameter(base_param, target_param)
|
||||
|
||||
def sync_parameter(self, main: Parameter, target: Parameter) -> None:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue