pypck 0.9.5__tar.gz → 0.9.7__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.5/pypck.egg-info → pypck-0.9.7}/PKG-INFO +1 -1
  2. pypck-0.9.7/VERSION +1 -0
  3. {pypck-0.9.5 → pypck-0.9.7}/pypck/device.py +31 -7
  4. {pypck-0.9.5 → pypck-0.9.7/pypck.egg-info}/PKG-INFO +1 -1
  5. pypck-0.9.5/VERSION +0 -1
  6. {pypck-0.9.5 → pypck-0.9.7}/LICENSE +0 -0
  7. {pypck-0.9.5 → pypck-0.9.7}/README.md +0 -0
  8. {pypck-0.9.5 → pypck-0.9.7}/pypck/__init__.py +0 -0
  9. {pypck-0.9.5 → pypck-0.9.7}/pypck/connection.py +0 -0
  10. {pypck-0.9.5 → pypck-0.9.7}/pypck/helpers.py +0 -0
  11. {pypck-0.9.5 → pypck-0.9.7}/pypck/inputs.py +0 -0
  12. {pypck-0.9.5 → pypck-0.9.7}/pypck/lcn_addr.py +0 -0
  13. {pypck-0.9.5 → pypck-0.9.7}/pypck/lcn_defs.py +0 -0
  14. {pypck-0.9.5 → pypck-0.9.7}/pypck/pck_commands.py +0 -0
  15. {pypck-0.9.5 → pypck-0.9.7}/pypck/py.typed +0 -0
  16. {pypck-0.9.5 → pypck-0.9.7}/pypck/status_requester.py +0 -0
  17. {pypck-0.9.5 → pypck-0.9.7}/pypck.egg-info/SOURCES.txt +0 -0
  18. {pypck-0.9.5 → pypck-0.9.7}/pypck.egg-info/dependency_links.txt +0 -0
  19. {pypck-0.9.5 → pypck-0.9.7}/pypck.egg-info/not-zip-safe +0 -0
  20. {pypck-0.9.5 → pypck-0.9.7}/pypck.egg-info/top_level.txt +0 -0
  21. {pypck-0.9.5 → pypck-0.9.7}/pyproject.toml +0 -0
  22. {pypck-0.9.5 → pypck-0.9.7}/setup.cfg +0 -0
  23. {pypck-0.9.5 → pypck-0.9.7}/tests/test_commands.py +0 -0
  24. {pypck-0.9.5 → pypck-0.9.7}/tests/test_connection.py +0 -0
  25. {pypck-0.9.5 → pypck-0.9.7}/tests/test_dyn_text.py +0 -0
  26. {pypck-0.9.5 → pypck-0.9.7}/tests/test_input.py +0 -0
  27. {pypck-0.9.5 → pypck-0.9.7}/tests/test_messages.py +0 -0
  28. {pypck-0.9.5 → pypck-0.9.7}/tests/test_module.py +0 -0
  29. {pypck-0.9.5 → pypck-0.9.7}/tests/test_status_requester.py +0 -0
  30. {pypck-0.9.5 → pypck-0.9.7}/tests/test_vars.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pypck
3
- Version: 0.9.5
3
+ Version: 0.9.7
4
4
  Summary: LCN-PCK library
5
5
  Home-page: https://github.com/alengwenus/pypck
6
6
  Author-email: Andre Lengwenus <alengwenus@gmail.com>
pypck-0.9.7/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.9.7
@@ -50,6 +50,8 @@ class DeviceConnection:
50
50
  self._serials_known = asyncio.Event()
51
51
 
52
52
  self.input_callbacks: set[Callable[[inputs.Input], None]] = set()
53
+ self.last_requested_var_without_type_in_response = lcn_defs.Var.UNKNOWN
54
+ self.last_var_lock = asyncio.Lock()
53
55
 
54
56
  # List of queued acknowledge codes from the LCN modules.
55
57
  self.acknowledges: asyncio.Queue[lcn_defs.AcknowledgeErrorCode] = (
@@ -771,9 +773,29 @@ class DeviceConnection:
771
773
  await self.on_ack(inp.code)
772
774
  return None
773
775
 
776
+ # handle typeless variable responses
777
+ if isinstance(inp, inputs.ModStatusVar):
778
+ inp = self.preprocess_modstatusvar(inp)
779
+
774
780
  for input_callback in self.input_callbacks:
775
781
  input_callback(inp)
776
782
 
783
+ def preprocess_modstatusvar(self, inp: inputs.ModStatusVar) -> inputs.Input:
784
+ """Fill typeless response with last requested variable type."""
785
+ if inp.orig_var == lcn_defs.Var.UNKNOWN:
786
+ # Response without type (%Msssaaa.wwwww)
787
+ inp.var = self.last_requested_var_without_type_in_response
788
+
789
+ self.last_requested_var_without_type_in_response = lcn_defs.Var.UNKNOWN
790
+
791
+ if self.last_var_lock.locked():
792
+ self.last_var_lock.release()
793
+ else:
794
+ # Response with variable type (%Msssaaa.Avvvwww)
795
+ inp.var = inp.orig_var
796
+
797
+ return inp
798
+
777
799
  async def dump_details(self) -> dict[str, Any]:
778
800
  """Dump detailed information about this module."""
779
801
  is_local_segment = self.addr.seg_id in (0, self.conn.local_seg_id)
@@ -910,7 +932,14 @@ class DeviceConnection:
910
932
  # do not use buffered response for old modules
911
933
  # (variable response is typeless)
912
934
  if self.serials.software_serial < 0x170206:
913
- max_age = 0
935
+ if not lcn_defs.Var.has_type_in_response(
936
+ variable, self.serials.software_serial
937
+ ):
938
+ try:
939
+ await asyncio.wait_for(self.last_var_lock.acquire(), timeout=3.0)
940
+ except asyncio.TimeoutError:
941
+ pass
942
+ self.last_requested_var_without_type_in_response = variable
914
943
 
915
944
  result = await self.status_requester.request(
916
945
  response_type=inputs.ModStatusVar,
@@ -921,12 +950,7 @@ class DeviceConnection:
921
950
  var=variable,
922
951
  )
923
952
 
924
- result = cast(inputs.ModStatusVar, result)
925
- if result:
926
- if result.orig_var == lcn_defs.Var.UNKNOWN:
927
- # Response without type (%Msssaaa.wwwww)
928
- result.var = variable
929
- return result
953
+ return cast(inputs.ModStatusVar, result)
930
954
 
931
955
  async def request_status_led_and_logic_ops(
932
956
  self, max_age: int = 0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pypck
3
- Version: 0.9.5
3
+ Version: 0.9.7
4
4
  Summary: LCN-PCK library
5
5
  Home-page: https://github.com/alengwenus/pypck
6
6
  Author-email: Andre Lengwenus <alengwenus@gmail.com>
pypck-0.9.5/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.9.5
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes