pypck 0.9.2__tar.gz → 0.9.4__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.
Files changed (30) hide show
  1. {pypck-0.9.2/pypck.egg-info → pypck-0.9.4}/PKG-INFO +2 -2
  2. {pypck-0.9.2 → pypck-0.9.4}/README.md +1 -1
  3. pypck-0.9.4/VERSION +1 -0
  4. {pypck-0.9.2 → pypck-0.9.4}/pypck/__init__.py +5 -3
  5. {pypck-0.9.2 → pypck-0.9.4}/pypck/connection.py +19 -30
  6. pypck-0.9.2/pypck/module.py → pypck-0.9.4/pypck/device.py +180 -342
  7. {pypck-0.9.2 → pypck-0.9.4}/pypck/inputs.py +11 -9
  8. {pypck-0.9.2 → pypck-0.9.4}/pypck/lcn_defs.py +21 -0
  9. pypck-0.9.4/pypck/py.typed +0 -0
  10. pypck-0.9.4/pypck/status_requester.py +160 -0
  11. {pypck-0.9.2 → pypck-0.9.4/pypck.egg-info}/PKG-INFO +2 -2
  12. {pypck-0.9.2 → pypck-0.9.4}/pypck.egg-info/SOURCES.txt +3 -1
  13. {pypck-0.9.2 → pypck-0.9.4}/pyproject.toml +3 -0
  14. {pypck-0.9.2 → pypck-0.9.4}/tests/test_connection.py +8 -6
  15. {pypck-0.9.2 → pypck-0.9.4}/tests/test_dyn_text.py +1 -2
  16. {pypck-0.9.2 → pypck-0.9.4}/tests/test_input.py +2 -3
  17. {pypck-0.9.2 → pypck-0.9.4}/tests/test_messages.py +4 -3
  18. {pypck-0.9.2 → pypck-0.9.4}/tests/test_module.py +14 -14
  19. {pypck-0.9.2 → pypck-0.9.4}/tests/test_status_requester.py +7 -6
  20. pypck-0.9.2/VERSION +0 -1
  21. {pypck-0.9.2 → pypck-0.9.4}/LICENSE +0 -0
  22. {pypck-0.9.2 → pypck-0.9.4}/pypck/helpers.py +0 -0
  23. {pypck-0.9.2 → pypck-0.9.4}/pypck/lcn_addr.py +0 -0
  24. {pypck-0.9.2 → pypck-0.9.4}/pypck/pck_commands.py +0 -0
  25. {pypck-0.9.2 → pypck-0.9.4}/pypck.egg-info/dependency_links.txt +0 -0
  26. {pypck-0.9.2 → pypck-0.9.4}/pypck.egg-info/not-zip-safe +0 -0
  27. {pypck-0.9.2 → pypck-0.9.4}/pypck.egg-info/top_level.txt +0 -0
  28. {pypck-0.9.2 → pypck-0.9.4}/setup.cfg +0 -0
  29. {pypck-0.9.2 → pypck-0.9.4}/tests/test_commands.py +0 -0
  30. {pypck-0.9.2 → pypck-0.9.4}/tests/test_vars.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pypck
3
- Version: 0.9.2
3
+ Version: 0.9.4
4
4
  Summary: LCN-PCK library
5
5
  Home-page: https://github.com/alengwenus/pypck
6
6
  Author-email: Andre Lengwenus <alengwenus@gmail.com>
@@ -55,7 +55,7 @@ async def main():
55
55
  password="lcn",
56
56
  settings={"SK_NUM_TRIES": 0},
57
57
  ) as pck_client:
58
- module = pck_client.get_address_conn(LcnAddr(0, 10, False))
58
+ module = pck_client.get_device_connection(LcnAddr(0, 10, False))
59
59
 
60
60
  await module.dim_output(0, 100, 0)
61
61
  await asyncio.sleep(1)
@@ -33,7 +33,7 @@ async def main():
33
33
  password="lcn",
34
34
  settings={"SK_NUM_TRIES": 0},
35
35
  ) as pck_client:
36
- module = pck_client.get_address_conn(LcnAddr(0, 10, False))
36
+ module = pck_client.get_device_connection(LcnAddr(0, 10, False))
37
37
 
38
38
  await module.dim_output(0, 100, 0)
39
39
  await asyncio.sleep(1)
pypck-0.9.4/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.9.4
@@ -2,20 +2,22 @@
2
2
 
3
3
  from pypck import (
4
4
  connection,
5
+ device,
5
6
  helpers,
6
7
  inputs,
7
8
  lcn_addr,
8
9
  lcn_defs,
9
- module,
10
10
  pck_commands,
11
+ status_requester,
11
12
  )
12
13
 
13
14
  __all__ = [
14
15
  "connection",
15
- "inputs",
16
+ "device",
16
17
  "helpers",
18
+ "inputs",
17
19
  "lcn_addr",
18
20
  "lcn_defs",
19
- "module",
20
21
  "pck_commands",
22
+ "status_requester",
21
23
  ]
@@ -9,10 +9,10 @@ from types import TracebackType
9
9
  from typing import Any
10
10
 
11
11
  from pypck import inputs, lcn_defs
12
+ from pypck.device import DeviceConnection
12
13
  from pypck.helpers import TaskRegistry
13
14
  from pypck.lcn_addr import LcnAddr
14
15
  from pypck.lcn_defs import LcnEvent
15
- from pypck.module import GroupConnection, ModuleConnection
16
16
  from pypck.pck_commands import PckGenerator
17
17
 
18
18
  _LOGGER = logging.getLogger(__name__)
@@ -131,7 +131,7 @@ class PchkConnectionManager:
131
131
  # stored in this dictionary. Communication to groups is handled by
132
132
  # GroupConnection object that are created on the fly and not stored
133
133
  # permanently.
134
- self.address_conns: dict[LcnAddr, ModuleConnection] = {}
134
+ self.device_connections: dict[LcnAddr, DeviceConnection] = {}
135
135
  self.segment_coupler_ids: list[int] = []
136
136
 
137
137
  self.input_callbacks: set[Callable[[inputs.Input], None]] = set()
@@ -360,15 +360,15 @@ class PchkConnectionManager:
360
360
  old_local_seg_id = self.local_seg_id
361
361
 
362
362
  self.local_seg_id = local_seg_id
363
- # replace all address_conns with current local_seg_id with new
363
+ # replace all device_connections with current local_seg_id with new
364
364
  # local_seg_id
365
- for addr in list(self.address_conns):
365
+ for addr in list(self.device_connections):
366
366
  if addr.seg_id == old_local_seg_id:
367
- address_conn = self.address_conns.pop(addr)
367
+ address_conn = self.device_connections.pop(addr)
368
368
  address_conn.addr = LcnAddr(
369
369
  self.local_seg_id, addr.addr_id, addr.is_group
370
370
  )
371
- self.address_conns[address_conn.addr] = address_conn
371
+ self.device_connections[address_conn.addr] = address_conn
372
372
 
373
373
  def physical_to_logical(self, addr: LcnAddr) -> LcnAddr:
374
374
  """Convert the physical segment id of an address to the logical one."""
@@ -378,39 +378,28 @@ class PchkConnectionManager:
378
378
  addr.is_group,
379
379
  )
380
380
 
381
- def get_module_conn(self, addr: LcnAddr) -> ModuleConnection:
382
- """Create and/or return the given LCN module."""
383
- assert not addr.is_group
381
+ def get_device_connection(self, addr: LcnAddr) -> DeviceConnection:
382
+ """Create and/or return a connection to the given module or group."""
384
383
  if addr.seg_id == 0 and self.local_seg_id != -1:
385
384
  addr = LcnAddr(self.local_seg_id, addr.addr_id, addr.is_group)
386
- address_conn = self.address_conns.get(addr, None)
387
- if address_conn is None:
388
- address_conn = ModuleConnection(
389
- self, addr, wants_ack=self.settings["ACKNOWLEDGE"]
390
- )
391
- self.address_conns[addr] = address_conn
392
385
 
393
- return address_conn
394
-
395
- def get_group_conn(self, addr: LcnAddr) -> GroupConnection:
396
- """Create and return the GroupConnection for the given group."""
397
- assert addr.is_group
398
- if addr.seg_id == 0 and self.local_seg_id != -1:
399
- addr = LcnAddr(self.local_seg_id, addr.addr_id, addr.is_group)
400
- return GroupConnection(self, addr)
386
+ device_connection = self.device_connections.get(addr, None)
387
+ if device_connection is None:
388
+ device_connection = DeviceConnection(
389
+ self,
390
+ addr,
391
+ wants_ack=False if addr.is_group else self.settings["ACKNOWLEDGE"],
392
+ )
393
+ self.device_connections[addr] = device_connection
401
394
 
402
- def get_address_conn(self, addr: LcnAddr) -> ModuleConnection | GroupConnection:
403
- """Create and/or return a connection to the given module or group."""
404
- if addr.is_group:
405
- return self.get_group_conn(addr)
406
- return self.get_module_conn(addr)
395
+ return device_connection
407
396
 
408
397
  # Other
409
398
 
410
399
  async def dump_modules(self) -> dict[str, dict[str, dict[str, Any]]]:
411
400
  """Dump all modules and information about them in a JSON serializable dict."""
412
401
  dump: dict[str, dict[str, dict[str, Any]]] = {}
413
- for address_conn in self.address_conns.values():
402
+ for address_conn in self.device_connections.values():
414
403
  seg = f"{address_conn.addr.seg_id:d}"
415
404
  addr = f"{address_conn.addr.addr_id}"
416
405
  if seg not in dump:
@@ -484,7 +473,7 @@ class PchkConnectionManager:
484
473
  if isinstance(inp, inputs.ModInput):
485
474
  logical_source_addr = self.physical_to_logical(inp.physical_source_addr)
486
475
  if not logical_source_addr.is_group:
487
- module_conn = self.get_module_conn(logical_source_addr)
476
+ module_conn = self.get_device_connection(logical_source_addr)
488
477
  if isinstance(inp, inputs.ModSn):
489
478
  # used to extend scan_modules() timeout
490
479
  if self.module_serial_number_received.locked():