pycomap 2.2.0__tar.gz → 2.3.0__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pycomap
3
- Version: 2.2.0
3
+ Version: 2.3.0
4
4
  Summary: Async Python client for ComAp controllers: LAN discovery and the native ECDH/AES-encrypted control protocol
5
5
  Author: Igor Panteleyev
6
6
  Author-email: Igor Panteleyev <panteleev.igor69@gmail.com>
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "pycomap"
3
- version = "2.2.0"
3
+ version = "2.3.0"
4
4
  description = "Async Python client for ComAp controllers: LAN discovery and the native ECDH/AES-encrypted control protocol"
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -82,12 +82,20 @@ class ComApClient[TransportT: Transport]:
82
82
  await client.authenticate("0")
83
83
  """
84
84
 
85
- def __init__(self, transport: TransportT) -> None:
85
+ def __init__(self, transport: TransportT, addr: int = 1) -> None:
86
86
  """
87
87
  Args:
88
88
  transport: Byte-stream transport to use (typically ``EthernetTransport``).
89
+ addr: Default controller unit address (``ControllerAddress`` setpoint, C.O.
90
+ 24537; range 1-32, factory default ``1``) used for every ``read_object``/
91
+ ``write_object`` call that doesn't override it explicitly. Only matters if
92
+ the target controller's ``ControllerAddress`` has been changed from the
93
+ default -- e.g. multiple units addressed through one gateway/party-line,
94
+ the same address you'd set in InteliMonitor/InteliConfig's connection
95
+ dialog.
89
96
  """
90
97
  self._transport = transport
98
+ self._addr = addr
91
99
  self._identifier = 0
92
100
  self._mode = _Mode.NONE
93
101
  self._cipher: ChainedAesCbc | None = None
@@ -215,12 +223,13 @@ class ComApClient[TransportT: Transport]:
215
223
 
216
224
  # -- communication objects -------------------------------------------------
217
225
 
218
- async def read_object(self, comm_obj: int, addr: int = 1) -> bytes:
226
+ async def read_object(self, comm_obj: int, addr: int | None = None) -> bytes:
219
227
  """Read a communication object, handling ``SendToBlock`` continuation transparently.
220
228
 
221
229
  Args:
222
230
  comm_obj: Communication object number (C.O.).
223
- addr: Controller unit address; ``1`` for the primary unit.
231
+ addr: Controller unit address; defaults to the address passed to
232
+ ``ComApClient.__init__`` (``1`` unless overridden there).
224
233
 
225
234
  Returns:
226
235
  Raw payload bytes.
@@ -229,6 +238,7 @@ class ComApClient[TransportT: Transport]:
229
238
  ComApControllerError: If the controller responds with an error code.
230
239
  ComApProtocolError: If an unexpected message operation is received.
231
240
  """
241
+ addr = self._addr if addr is None else addr
232
242
  ident = self._next_identifier()
233
243
  await self._write_message(Operation.SEND_ME, addr, comm_obj, b"", ident)
234
244
 
@@ -251,13 +261,14 @@ class ComApClient[TransportT: Transport]:
251
261
  f"unexpected operation {message.op!r} while reading {comm_obj}"
252
262
  )
253
263
 
254
- async def write_object(self, comm_obj: int, data: bytes, addr: int = 1) -> bytes:
264
+ async def write_object(self, comm_obj: int, data: bytes, addr: int | None = None) -> bytes:
255
265
  """Write a communication object.
256
266
 
257
267
  Args:
258
268
  comm_obj: Communication object number (C.O.).
259
269
  data: Raw payload bytes to write.
260
- addr: Controller unit address; ``1`` for the primary unit.
270
+ addr: Controller unit address; defaults to the address passed to
271
+ ``ComApClient.__init__`` (``1`` unless overridden there).
261
272
 
262
273
  Returns:
263
274
  Any data carried back on the ``NEXT`` acknowledgment (usually empty).
@@ -265,6 +276,7 @@ class ComApClient[TransportT: Transport]:
265
276
  Raises:
266
277
  ComApControllerError: If the controller responds with an error code.
267
278
  """
279
+ addr = self._addr if addr is None else addr
268
280
  ident = self._next_identifier()
269
281
  await self._write_message(Operation.SEND_TO, addr, comm_obj, data, ident)
270
282
  message = await self._read_message()
File without changes
File without changes
File without changes
File without changes
File without changes