pypck 0.8.1__py3-none-any.whl → 0.8.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
pypck/module.py CHANGED
@@ -468,18 +468,23 @@ class AbstractConnection:
468
468
  PckGenerator.var_rel(var, value_ref, value.to_native(), software_serial),
469
469
  )
470
470
 
471
- async def lock_regulator(self, reg_id: int, state: bool) -> bool:
471
+ async def lock_regulator(
472
+ self, reg_id: int, state: bool, target_value: float = -1
473
+ ) -> bool:
472
474
  """Send a command to lock a regulator.
473
475
 
474
476
  :param int reg_id: Regulator id
475
477
  :param bool state: Lock state (locked=True,
476
478
  unlocked=False)
477
-
479
+ :param float target_value: Target value in percent (use -1 to ignore)
478
480
  :returns: True if command was sent successfully, False otherwise
479
481
  :rtype: bool
480
482
  """
481
483
  return await self.send_command(
482
- self.wants_ack, PckGenerator.lock_regulator(reg_id, state)
484
+ self.wants_ack,
485
+ PckGenerator.lock_regulator(
486
+ reg_id, state, self.software_serial, target_value
487
+ ),
483
488
  )
484
489
 
485
490
  async def control_led(
pypck/pck_commands.py CHANGED
@@ -1029,16 +1029,29 @@ class PckGenerator:
1029
1029
  return f"GTDT{row_id + 1}{part_id + 1}".encode() + part
1030
1030
 
1031
1031
  @staticmethod
1032
- def lock_regulator(reg_id: int, state: bool) -> str:
1032
+ def lock_regulator(
1033
+ reg_id: int,
1034
+ state: bool,
1035
+ software_serial: int,
1036
+ target_value: float = -1,
1037
+ ) -> str:
1033
1038
  """Generate a command to lock a regulator.
1034
1039
 
1035
1040
  :param int reg_id: Regulator id 0..1
1036
1041
  :param bool state: The lock state
1042
+ :param int software_serial: The expected firmware version of all
1043
+ receiving modules.
1044
+ :param foat target_value: The target value in percent (use -1 to ignore)
1037
1045
  :return: The PCK command (without address header) as text
1038
1046
  :rtype: str
1039
1047
  """
1040
1048
  if (reg_id < 0) or (reg_id > 1):
1041
1049
  raise ValueError("Wrong reg_id.")
1050
+ if ((target_value < 0) or (target_value > 100)) and (target_value != -1):
1051
+ raise ValueError("Wrong target_value.")
1052
+ if (target_value != -1) and (software_serial >= 0x120301) and state:
1053
+ reg_byte = reg_id * 0x40 + 0x07
1054
+ return f"X2{0x1E:03d}{reg_byte:03d}{int(2*target_value):03d}"
1042
1055
  return f"RE{'A' if reg_id == 0 else 'B'}X{'S' if state else 'A'}"
1043
1056
 
1044
1057
  @staticmethod
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pypck
3
- Version: 0.8.1
3
+ Version: 0.8.2
4
4
  Summary: LCN-PCK library
5
5
  Home-page: https://github.com/alengwenus/pypck
6
6
  Author-email: Andre Lengwenus <alengwenus@gmail.com>
@@ -4,12 +4,12 @@ pypck/helpers.py,sha256=hEGId1pQ4wOJgIwNKDx17qKBlxvNxvspSrI0gSY3wCQ,1267
4
4
  pypck/inputs.py,sha256=QBpdGpHKa2iQdrXMai_mbO_MGRmPCk4BWiNb_ta8-DU,40227
5
5
  pypck/lcn_addr.py,sha256=N2Od8KuANOglqKjf596hJVH1SRcG7MhESKA5YYlDnbw,1946
6
6
  pypck/lcn_defs.py,sha256=sU0uGYyCLrnl-1aaHe5BtPE1kExESiPGmJFGdv9FWCk,40610
7
- pypck/module.py,sha256=NnIaH0iZOrzeNtkCg0vJKQwZBG__673RlNowM8LyIPY,37107
8
- pypck/pck_commands.py,sha256=dZG74ue2AiyjTAEg2vRn-y6JWXnNAjuqNQYfDnL4Czo,46157
7
+ pypck/module.py,sha256=o9SB-Gr2w6ZioJa0lpzOWW5IFtWsd1ojV3qgIVjJIxw,37314
8
+ pypck/pck_commands.py,sha256=nR3LAdWbLD7yrtHfQigIIdMYPAIGM36A1fDAc2AD9Dk,46801
9
9
  pypck/request_handlers.py,sha256=VUeYcqG4QyL1eNHn1o3w4CgQS-vWL45SGTE4v6LEOL8,24165
10
10
  pypck/timeout_retry.py,sha256=5KiTDPzegym-6qi_mM4I8ChJbJjg9HXECFyAZt4c02w,3944
11
- pypck-0.8.1.dist-info/LICENSE,sha256=iYB6zyMJvShfAzQE7nhYFgLzzZuBmhasLw5fYP9KRz4,1023
12
- pypck-0.8.1.dist-info/METADATA,sha256=ciAiPdsW5br6cTvAgOWEhivboLjv5nZi8dZj15e1K3c,5581
13
- pypck-0.8.1.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
14
- pypck-0.8.1.dist-info/top_level.txt,sha256=59ried49iFueDa5mQ_5BGVZcESjjzi4MZZKLcganvQA,6
15
- pypck-0.8.1.dist-info/RECORD,,
11
+ pypck-0.8.2.dist-info/LICENSE,sha256=iYB6zyMJvShfAzQE7nhYFgLzzZuBmhasLw5fYP9KRz4,1023
12
+ pypck-0.8.2.dist-info/METADATA,sha256=KZQbN-QApqDFuO7aCkj_Csz-KLjoeRUcc40TGjAfkkc,5581
13
+ pypck-0.8.2.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
14
+ pypck-0.8.2.dist-info/top_level.txt,sha256=59ried49iFueDa5mQ_5BGVZcESjjzi4MZZKLcganvQA,6
15
+ pypck-0.8.2.dist-info/RECORD,,
File without changes
File without changes