conson-xp 1.0.1__py3-none-any.whl → 1.2.0__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.
Files changed (167) hide show
  1. {conson_xp-1.0.1.dist-info → conson_xp-1.2.0.dist-info}/METADATA +1 -1
  2. conson_xp-1.2.0.dist-info/RECORD +181 -0
  3. xp/__init__.py +4 -3
  4. xp/api/main.py +18 -3
  5. xp/api/models/api.py +13 -2
  6. xp/api/models/discover.py +12 -2
  7. xp/api/routers/conbus_blink.py +18 -6
  8. xp/api/routers/conbus_custom.py +11 -3
  9. xp/api/routers/conbus_datapoint.py +10 -3
  10. xp/api/routers/conbus_output.py +29 -9
  11. xp/api/routers/errors.py +6 -5
  12. xp/cli/__init__.py +1 -1
  13. xp/cli/commands/__init__.py +1 -0
  14. xp/cli/commands/api.py +1 -5
  15. xp/cli/commands/api_start_commands.py +14 -8
  16. xp/cli/commands/conbus/conbus.py +9 -37
  17. xp/cli/commands/conbus/conbus_actiontable_commands.py +21 -1
  18. xp/cli/commands/conbus/conbus_autoreport_commands.py +21 -11
  19. xp/cli/commands/conbus/conbus_blink_commands.py +53 -21
  20. xp/cli/commands/conbus/conbus_config_commands.py +7 -4
  21. xp/cli/commands/conbus/conbus_custom_commands.py +13 -4
  22. xp/cli/commands/conbus/conbus_datapoint_commands.py +28 -8
  23. xp/cli/commands/conbus/conbus_discover_commands.py +15 -4
  24. xp/cli/commands/conbus/conbus_lightlevel_commands.py +50 -11
  25. xp/cli/commands/conbus/conbus_linknumber_commands.py +21 -11
  26. xp/cli/commands/conbus/conbus_msactiontable_commands.py +25 -1
  27. xp/cli/commands/conbus/conbus_output_commands.py +46 -12
  28. xp/cli/commands/conbus/conbus_raw_commands.py +17 -6
  29. xp/cli/commands/conbus/conbus_receive_commands.py +15 -7
  30. xp/cli/commands/conbus/conbus_scan_commands.py +35 -102
  31. xp/cli/commands/file_commands.py +26 -15
  32. xp/cli/commands/homekit/homekit.py +14 -8
  33. xp/cli/commands/homekit/homekit_start_commands.py +5 -5
  34. xp/cli/commands/module_commands.py +26 -19
  35. xp/cli/commands/reverse_proxy_commands.py +24 -18
  36. xp/cli/commands/server/server_commands.py +18 -18
  37. xp/cli/commands/telegram/telegram.py +4 -12
  38. xp/cli/commands/telegram/telegram_blink_commands.py +10 -8
  39. xp/cli/commands/telegram/telegram_checksum_commands.py +19 -8
  40. xp/cli/commands/telegram/telegram_discover_commands.py +2 -4
  41. xp/cli/commands/telegram/telegram_linknumber_commands.py +11 -8
  42. xp/cli/commands/telegram/telegram_parse_commands.py +10 -9
  43. xp/cli/commands/telegram/telegram_version_commands.py +8 -4
  44. xp/cli/main.py +5 -1
  45. xp/cli/utils/click_tree.py +23 -3
  46. xp/cli/utils/datapoint_type_choice.py +20 -0
  47. xp/cli/utils/decorators.py +165 -14
  48. xp/cli/utils/error_handlers.py +49 -18
  49. xp/cli/utils/formatters.py +95 -10
  50. xp/cli/utils/serial_number_type.py +18 -0
  51. xp/cli/utils/system_function_choice.py +20 -0
  52. xp/cli/utils/xp_module_type.py +20 -0
  53. xp/connection/__init__.py +1 -1
  54. xp/connection/exceptions.py +5 -5
  55. xp/models/__init__.py +1 -1
  56. xp/models/actiontable/__init__.py +1 -0
  57. xp/models/actiontable/actiontable.py +17 -1
  58. xp/models/actiontable/msactiontable_xp20.py +10 -0
  59. xp/models/actiontable/msactiontable_xp24.py +20 -3
  60. xp/models/actiontable/msactiontable_xp33.py +27 -4
  61. xp/models/conbus/__init__.py +1 -0
  62. xp/models/conbus/conbus.py +34 -4
  63. xp/models/conbus/conbus_autoreport.py +20 -2
  64. xp/models/conbus/conbus_blink.py +22 -2
  65. xp/models/conbus/conbus_client_config.py +22 -1
  66. xp/models/conbus/conbus_connection_status.py +16 -2
  67. xp/models/conbus/conbus_custom.py +21 -2
  68. xp/models/conbus/conbus_datapoint.py +22 -2
  69. xp/models/conbus/conbus_discover.py +18 -2
  70. xp/models/conbus/conbus_lightlevel.py +20 -2
  71. xp/models/conbus/conbus_linknumber.py +20 -2
  72. xp/models/conbus/conbus_output.py +22 -2
  73. xp/models/conbus/conbus_raw.py +17 -2
  74. xp/models/conbus/conbus_receive.py +16 -2
  75. xp/models/homekit/__init__.py +1 -0
  76. xp/models/homekit/homekit_accessory.py +15 -1
  77. xp/models/homekit/homekit_config.py +52 -0
  78. xp/models/homekit/homekit_conson_config.py +32 -0
  79. xp/models/log_entry.py +49 -9
  80. xp/models/protocol/__init__.py +1 -0
  81. xp/models/protocol/conbus_protocol.py +130 -21
  82. xp/models/telegram/__init__.py +1 -0
  83. xp/models/telegram/action_type.py +16 -2
  84. xp/models/telegram/datapoint_type.py +36 -2
  85. xp/models/telegram/event_telegram.py +46 -10
  86. xp/models/telegram/event_type.py +8 -1
  87. xp/models/telegram/input_action_type.py +34 -2
  88. xp/models/telegram/input_type.py +9 -1
  89. xp/models/telegram/module_type.py +69 -19
  90. xp/models/telegram/module_type_code.py +43 -1
  91. xp/models/telegram/output_telegram.py +30 -6
  92. xp/models/telegram/reply_telegram.py +56 -11
  93. xp/models/telegram/system_function.py +35 -3
  94. xp/models/telegram/system_telegram.py +18 -4
  95. xp/models/telegram/telegram.py +12 -3
  96. xp/models/telegram/telegram_type.py +8 -1
  97. xp/models/telegram/timeparam_type.py +27 -0
  98. xp/models/write_config_type.py +17 -2
  99. xp/services/__init__.py +1 -1
  100. xp/services/conbus/__init__.py +1 -0
  101. xp/services/conbus/actiontable/__init__.py +1 -0
  102. xp/services/conbus/actiontable/actiontable_service.py +33 -2
  103. xp/services/conbus/actiontable/msactiontable_service.py +40 -3
  104. xp/services/conbus/actiontable/msactiontable_xp24_serializer.py +36 -4
  105. xp/services/conbus/actiontable/msactiontable_xp33_serializer.py +45 -5
  106. xp/services/conbus/conbus_autoreport_get_service.py +17 -8
  107. xp/services/conbus/conbus_autoreport_set_service.py +29 -16
  108. xp/services/conbus/conbus_blink_all_service.py +40 -21
  109. xp/services/conbus/conbus_blink_service.py +37 -13
  110. xp/services/conbus/conbus_custom_service.py +29 -13
  111. xp/services/conbus/conbus_datapoint_queryall_service.py +40 -16
  112. xp/services/conbus/conbus_datapoint_service.py +33 -12
  113. xp/services/conbus/conbus_discover_service.py +43 -7
  114. xp/services/conbus/conbus_lightlevel_get_service.py +22 -14
  115. xp/services/conbus/conbus_lightlevel_set_service.py +40 -20
  116. xp/services/conbus/conbus_linknumber_get_service.py +18 -10
  117. xp/services/conbus/conbus_linknumber_set_service.py +34 -8
  118. xp/services/conbus/conbus_output_service.py +33 -13
  119. xp/services/conbus/conbus_raw_service.py +36 -16
  120. xp/services/conbus/conbus_receive_service.py +38 -6
  121. xp/services/conbus/conbus_scan_service.py +45 -19
  122. xp/services/homekit/__init__.py +1 -0
  123. xp/services/homekit/homekit_cache_service.py +31 -6
  124. xp/services/homekit/homekit_conbus_service.py +33 -2
  125. xp/services/homekit/homekit_config_validator.py +97 -15
  126. xp/services/homekit/homekit_conson_validator.py +51 -7
  127. xp/services/homekit/homekit_dimminglight.py +47 -1
  128. xp/services/homekit/homekit_dimminglight_service.py +35 -1
  129. xp/services/homekit/homekit_hap_service.py +71 -18
  130. xp/services/homekit/homekit_lightbulb.py +35 -1
  131. xp/services/homekit/homekit_lightbulb_service.py +30 -2
  132. xp/services/homekit/homekit_module_service.py +23 -1
  133. xp/services/homekit/homekit_outlet.py +47 -1
  134. xp/services/homekit/homekit_outlet_service.py +44 -2
  135. xp/services/homekit/homekit_service.py +113 -19
  136. xp/services/log_file_service.py +37 -41
  137. xp/services/module_type_service.py +26 -5
  138. xp/services/protocol/__init__.py +1 -1
  139. xp/services/protocol/conbus_protocol.py +115 -20
  140. xp/services/protocol/protocol_factory.py +40 -0
  141. xp/services/protocol/telegram_protocol.py +38 -7
  142. xp/services/reverse_proxy_service.py +79 -14
  143. xp/services/server/__init__.py +1 -0
  144. xp/services/server/base_server_service.py +102 -14
  145. xp/services/server/cp20_server_service.py +12 -4
  146. xp/services/server/server_service.py +26 -11
  147. xp/services/server/xp130_server_service.py +11 -3
  148. xp/services/server/xp20_server_service.py +11 -3
  149. xp/services/server/xp230_server_service.py +11 -3
  150. xp/services/server/xp24_server_service.py +33 -6
  151. xp/services/server/xp33_server_service.py +41 -8
  152. xp/services/telegram/__init__.py +1 -0
  153. xp/services/telegram/telegram_blink_service.py +19 -31
  154. xp/services/telegram/telegram_checksum_service.py +10 -10
  155. xp/services/telegram/telegram_discover_service.py +58 -29
  156. xp/services/telegram/telegram_link_number_service.py +27 -40
  157. xp/services/telegram/telegram_output_service.py +46 -49
  158. xp/services/telegram/telegram_service.py +41 -41
  159. xp/services/telegram/telegram_version_service.py +4 -2
  160. xp/utils/__init__.py +1 -1
  161. xp/utils/dependencies.py +0 -1
  162. xp/utils/serialization.py +6 -0
  163. xp/utils/time_utils.py +6 -11
  164. conson_xp-1.0.1.dist-info/RECORD +0 -181
  165. {conson_xp-1.0.1.dist-info → conson_xp-1.2.0.dist-info}/WHEEL +0 -0
  166. {conson_xp-1.0.1.dist-info → conson_xp-1.2.0.dist-info}/entry_points.txt +0 -0
  167. {conson_xp-1.0.1.dist-info → conson_xp-1.2.0.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1 @@
1
+ """Action table services for Conbus."""
@@ -30,7 +30,14 @@ class ActionTableService(ConbusProtocol):
30
30
  actiontable_serializer: ActionTableSerializer,
31
31
  telegram_service: TelegramService,
32
32
  ) -> None:
33
- """Initialize the Conbus client send service"""
33
+ """Initialize the Conbus client send service.
34
+
35
+ Args:
36
+ cli_config: Conbus client configuration.
37
+ reactor: Twisted reactor instance.
38
+ actiontable_serializer: Action table serializer.
39
+ telegram_service: Telegram service for parsing.
40
+ """
34
41
  super().__init__(cli_config, reactor)
35
42
  self.serializer = actiontable_serializer
36
43
  self.telegram_service = telegram_service
@@ -43,6 +50,7 @@ class ActionTableService(ConbusProtocol):
43
50
  self.logger = logging.getLogger(__name__)
44
51
 
45
52
  def connection_established(self) -> None:
53
+ """Handle connection established event."""
46
54
  self.logger.debug("Connection established, sending discover telegram")
47
55
  self.send_telegram(
48
56
  telegram_type=TelegramType.SYSTEM,
@@ -52,9 +60,19 @@ class ActionTableService(ConbusProtocol):
52
60
  )
53
61
 
54
62
  def telegram_sent(self, telegram_sent: str) -> None:
63
+ """Handle telegram sent event.
64
+
65
+ Args:
66
+ telegram_sent: The telegram that was sent.
67
+ """
55
68
  self.logger.debug(f"Telegram sent: {telegram_sent}")
56
69
 
57
70
  def telegram_received(self, telegram_received: TelegramReceivedEvent) -> None:
71
+ """Handle telegram received event.
72
+
73
+ Args:
74
+ telegram_received: The telegram received event.
75
+ """
58
76
  self.logger.debug(f"Telegram received: {telegram_received}")
59
77
  if (
60
78
  not telegram_received.checksum_valid
@@ -95,6 +113,11 @@ class ActionTableService(ConbusProtocol):
95
113
  self.finish_callback(actiontable)
96
114
 
97
115
  def failed(self, message: str) -> None:
116
+ """Handle failed connection event.
117
+
118
+ Args:
119
+ message: Failure message.
120
+ """
98
121
  self.logger.debug(f"Failed: {message}")
99
122
  if self.error_callback:
100
123
  self.error_callback(message)
@@ -107,7 +130,15 @@ class ActionTableService(ConbusProtocol):
107
130
  finish_callback: Callable[[ActionTable], None],
108
131
  timeout_seconds: Optional[float] = None,
109
132
  ) -> None:
110
- """Run reactor in dedicated thread with its own event loop"""
133
+ """Run reactor in dedicated thread with its own event loop.
134
+
135
+ Args:
136
+ serial_number: Module serial number.
137
+ progress_callback: Callback for progress updates.
138
+ error_callback: Callback for errors.
139
+ finish_callback: Callback when download completes.
140
+ timeout_seconds: Optional timeout in seconds.
141
+ """
111
142
  self.logger.info("Starting actiontable")
112
143
  self.serial_number = serial_number
113
144
  if timeout_seconds:
@@ -26,7 +26,7 @@ from xp.services.telegram.telegram_service import TelegramService
26
26
 
27
27
 
28
28
  class MsActionTableError(Exception):
29
- """Raised when XP24 action table operations fail"""
29
+ """Raised when XP24 action table operations fail."""
30
30
 
31
31
  pass
32
32
 
@@ -48,7 +48,16 @@ class MsActionTableService(ConbusProtocol):
48
48
  xp33ms_serializer: Xp33MsActionTableSerializer,
49
49
  telegram_service: TelegramService,
50
50
  ) -> None:
51
- """Initialize the Conbus client send service"""
51
+ """Initialize the Conbus client send service.
52
+
53
+ Args:
54
+ cli_config: Conbus client configuration.
55
+ reactor: Twisted reactor instance.
56
+ xp20ms_serializer: XP20 MS action table serializer.
57
+ xp24ms_serializer: XP24 MS action table serializer.
58
+ xp33ms_serializer: XP33 MS action table serializer.
59
+ telegram_service: Telegram service for parsing.
60
+ """
52
61
  super().__init__(cli_config, reactor)
53
62
  self.xp20ms_serializer = xp20ms_serializer
54
63
  self.xp24ms_serializer = xp24ms_serializer
@@ -73,6 +82,7 @@ class MsActionTableService(ConbusProtocol):
73
82
  self.logger = logging.getLogger(__name__)
74
83
 
75
84
  def connection_established(self) -> None:
85
+ """Handle connection established event."""
76
86
  self.logger.debug("Connection established, sending discover telegram")
77
87
  self.send_telegram(
78
88
  telegram_type=TelegramType.SYSTEM,
@@ -82,9 +92,19 @@ class MsActionTableService(ConbusProtocol):
82
92
  )
83
93
 
84
94
  def telegram_sent(self, telegram_sent: str) -> None:
95
+ """Handle telegram sent event.
96
+
97
+ Args:
98
+ telegram_sent: The telegram that was sent.
99
+ """
85
100
  self.logger.debug(f"Telegram sent: {telegram_sent}")
86
101
 
87
102
  def telegram_received(self, telegram_received: TelegramReceivedEvent) -> None:
103
+ """Handle telegram received event.
104
+
105
+ Args:
106
+ telegram_received: The telegram received event.
107
+ """
88
108
  self.logger.debug(f"Telegram received: {telegram_received}")
89
109
  if (
90
110
  not telegram_received.checksum_valid
@@ -124,6 +144,11 @@ class MsActionTableService(ConbusProtocol):
124
144
  self.finish_callback(msactiontable)
125
145
 
126
146
  def failed(self, message: str) -> None:
147
+ """Handle failed connection event.
148
+
149
+ Args:
150
+ message: Failure message.
151
+ """
127
152
  self.logger.debug(f"Failed: {message}")
128
153
  if self.error_callback:
129
154
  self.error_callback(message)
@@ -139,7 +164,19 @@ class MsActionTableService(ConbusProtocol):
139
164
  ],
140
165
  timeout_seconds: Optional[float] = None,
141
166
  ) -> None:
142
- """Run reactor in dedicated thread with its own event loop"""
167
+ """Run reactor in dedicated thread with its own event loop.
168
+
169
+ Args:
170
+ serial_number: Module serial number.
171
+ xpmoduletype: XP module type (xp20, xp24, xp33).
172
+ progress_callback: Callback for progress updates.
173
+ error_callback: Callback for errors.
174
+ finish_callback: Callback when download completes.
175
+ timeout_seconds: Optional timeout in seconds.
176
+
177
+ Raises:
178
+ MsActionTableError: If unsupported module type is provided.
179
+ """
143
180
  self.logger.info("Starting msactiontable")
144
181
  self.serial_number = serial_number
145
182
  self.xpmoduletype = xpmoduletype
@@ -11,7 +11,14 @@ class Xp24MsActionTableSerializer:
11
11
 
12
12
  @staticmethod
13
13
  def to_data(action_table: Xp24MsActionTable) -> str:
14
- """Serialize action table to telegram format."""
14
+ """Serialize action table to telegram format.
15
+
16
+ Args:
17
+ action_table: XP24 MS action table to serialize.
18
+
19
+ Returns:
20
+ Serialized action table data string.
21
+ """
15
22
  data_parts: list[str] = []
16
23
 
17
24
  # Encode all 4 input actions
@@ -46,13 +53,22 @@ class Xp24MsActionTableSerializer:
46
53
 
47
54
  @staticmethod
48
55
  def from_data(msactiontable_rawdata: str) -> Xp24MsActionTable:
49
- """Deserialize action table from raw data parts."""
56
+ """Deserialize action table from raw data parts.
57
+
58
+ Args:
59
+ msactiontable_rawdata: Raw action table data string.
60
+
61
+ Returns:
62
+ Deserialized XP24 MS action table.
50
63
 
64
+ Raises:
65
+ ValueError: If data length is not 68 bytes.
66
+ """
51
67
  raw_length = len(msactiontable_rawdata)
52
68
  if raw_length != 68:
53
69
  raise ValueError(f"Msactiontable is not 68 bytes long ({raw_length})")
54
70
 
55
- # Remove action table count AAAA, AAAB ...
71
+ # Remove action table count AAAA, AAAB .
56
72
  data = msactiontable_rawdata[4:]
57
73
 
58
74
  # Take first 64 chars (32 bytes) as per pseudocode
@@ -84,6 +100,15 @@ class Xp24MsActionTableSerializer:
84
100
 
85
101
  @staticmethod
86
102
  def _decode_input_action(raw_bytes: bytearray, pos: int) -> InputAction:
103
+ """Decode input action from raw bytes.
104
+
105
+ Args:
106
+ raw_bytes: Raw byte array containing action data.
107
+ pos: Position of the action to decode.
108
+
109
+ Returns:
110
+ Decoded input action.
111
+ """
87
112
  function_id = raw_bytes[2 * pos]
88
113
  param_id = raw_bytes[2 * pos + 1]
89
114
 
@@ -95,7 +120,14 @@ class Xp24MsActionTableSerializer:
95
120
 
96
121
  @staticmethod
97
122
  def from_telegrams(ms_telegrams: str) -> Xp24MsActionTable:
98
- """Legacy method for backward compatibility. Use from_data() instead."""
123
+ """Legacy method for backward compatibility. Use from_data() instead.
124
+
125
+ Args:
126
+ ms_telegrams: Telegram data string.
127
+
128
+ Returns:
129
+ Deserialized XP24 MS action table.
130
+ """
99
131
  # For backward compatibility, assume full telegrams and extract data
100
132
  data_parts = ms_telegrams[16:84]
101
133
 
@@ -37,7 +37,14 @@ class Xp33MsActionTableSerializer:
37
37
 
38
38
  @staticmethod
39
39
  def to_data(action_table: Xp33MsActionTable) -> str:
40
- """Serialize action table to telegram format."""
40
+ """Serialize action table to telegram format.
41
+
42
+ Args:
43
+ action_table: XP33 MS action table to serialize.
44
+
45
+ Returns:
46
+ Serialized action table data string.
47
+ """
41
48
  # Create 32-byte array
42
49
  raw_bytes = bytearray(32)
43
50
 
@@ -99,7 +106,17 @@ class Xp33MsActionTableSerializer:
99
106
 
100
107
  @staticmethod
101
108
  def from_data(msactiontable_rawdata: str) -> Xp33MsActionTable:
102
- """Deserialize action table from raw data parts."""
109
+ """Deserialize action table from raw data parts.
110
+
111
+ Args:
112
+ msactiontable_rawdata: Raw action table data string.
113
+
114
+ Returns:
115
+ Deserialized XP33 MS action table.
116
+
117
+ Raises:
118
+ ValueError: If data length is less than 68 characters.
119
+ """
103
120
  raw_length = len(msactiontable_rawdata)
104
121
  if raw_length < 68: # Minimum: 4 char prefix + 64 chars data
105
122
  raise ValueError(
@@ -138,7 +155,15 @@ class Xp33MsActionTableSerializer:
138
155
 
139
156
  @staticmethod
140
157
  def _decode_output(raw_bytes: bytearray, output_index: int) -> Xp33Output:
141
- """Extract output configuration from raw bytes."""
158
+ """Extract output configuration from raw bytes.
159
+
160
+ Args:
161
+ raw_bytes: Raw byte array containing output data.
162
+ output_index: Index of the output to decode.
163
+
164
+ Returns:
165
+ Decoded XP33 output configuration.
166
+ """
142
167
  # Read min/max levels from appropriate offsets
143
168
  min_level = Xp33MsActionTableSerializer._byte_to_percentage(
144
169
  raw_bytes[2 * output_index]
@@ -184,7 +209,15 @@ class Xp33MsActionTableSerializer:
184
209
 
185
210
  @staticmethod
186
211
  def _decode_scene(raw_bytes: bytearray, scene_index: int) -> Xp33Scene:
187
- """Extract scene configuration from raw bytes."""
212
+ """Extract scene configuration from raw bytes.
213
+
214
+ Args:
215
+ raw_bytes: Raw byte array containing scene data.
216
+ scene_index: Index of the scene to decode.
217
+
218
+ Returns:
219
+ Decoded XP33 scene configuration.
220
+ """
188
221
  # Calculate scene offset: 6 + (4 * scene_index)
189
222
  offset = 6 + (4 * scene_index)
190
223
 
@@ -209,7 +242,14 @@ class Xp33MsActionTableSerializer:
209
242
 
210
243
  @staticmethod
211
244
  def from_telegrams(ms_telegrams: str) -> Xp33MsActionTable:
212
- """Legacy method for backward compatibility. Use from_data() instead."""
245
+ """Legacy method for backward compatibility. Use from_data() instead.
246
+
247
+ Args:
248
+ ms_telegrams: Telegram data string.
249
+
250
+ Returns:
251
+ Deserialized XP33 MS action table.
252
+ """
213
253
  # For backward compatibility, assume full telegrams and extract data
214
254
  data_parts = ms_telegrams[16:152] # Adjusted for XP33 length
215
255
 
@@ -17,10 +17,10 @@ from xp.services.telegram.telegram_service import TelegramService
17
17
 
18
18
  class ConbusAutoreportGetService(ConbusDatapointService):
19
19
  """
20
- Service for receiving telegrams from Conbus servers.
20
+ Service for getting auto report status from Conbus modules.
21
21
 
22
- Uses composition with ConbusService to provide receive-only functionality
23
- for collecting waiting event telegrams from the server.
22
+ Uses ConbusProtocol to provide auto report status query functionality
23
+ for reading the current auto report configuration from modules.
24
24
  """
25
25
 
26
26
  def __init__(
@@ -29,7 +29,13 @@ class ConbusAutoreportGetService(ConbusDatapointService):
29
29
  cli_config: ConbusClientConfig,
30
30
  reactor: PosixReactorBase,
31
31
  ) -> None:
32
- """Initialize the Conbus client send service"""
32
+ """Initialize the Conbus autoreport get service.
33
+
34
+ Args:
35
+ telegram_service: Telegram service for parsing.
36
+ cli_config: Conbus client configuration.
37
+ reactor: Twisted reactor instance.
38
+ """
33
39
  super().__init__(telegram_service, cli_config, reactor)
34
40
  self.service_callback: Optional[Callable[[ConbusAutoreportResponse], None]] = (
35
41
  None
@@ -41,7 +47,11 @@ class ConbusAutoreportGetService(ConbusDatapointService):
41
47
  def finish_service_callback(
42
48
  self, datapoint_response: ConbusDatapointResponse
43
49
  ) -> None:
50
+ """Handle finished service callback.
44
51
 
52
+ Args:
53
+ datapoint_response: Datapoint response from service.
54
+ """
45
55
  self.logger.debug("Parsing datapoint response")
46
56
  autoreport_status = ""
47
57
  if datapoint_response.success and datapoint_response.datapoint_telegram:
@@ -70,10 +80,9 @@ class ConbusAutoreportGetService(ConbusDatapointService):
70
80
  Get the current auto report status for a specific module.
71
81
 
72
82
  Args:
73
- :param serial_number: 10-digit module serial number
74
- :param finish_callback: callback function to call when the linknumber status is
75
- :param timeout_seconds: timeout in seconds
76
-
83
+ serial_number: 10-digit module serial number
84
+ finish_callback: callback function to call when the auto report status is received
85
+ timeout_seconds: timeout in seconds
77
86
  """
78
87
  self.logger.info("Starting get_autoreport_status")
79
88
  if timeout_seconds:
@@ -20,10 +20,10 @@ from xp.services.protocol import ConbusProtocol
20
20
 
21
21
  class ConbusAutoreportSetService(ConbusProtocol):
22
22
  """
23
- Service for receiving telegrams from Conbus servers.
23
+ Service for setting auto report status on Conbus modules.
24
24
 
25
- Uses composition with ConbusService to provide receive-only functionality
26
- for collecting waiting event telegrams from the server.
25
+ Uses ConbusProtocol to provide auto report configuration functionality
26
+ for enabling/disabling automatic reporting on modules.
27
27
  """
28
28
 
29
29
  def __init__(
@@ -31,7 +31,12 @@ class ConbusAutoreportSetService(ConbusProtocol):
31
31
  cli_config: ConbusClientConfig,
32
32
  reactor: PosixReactorBase,
33
33
  ) -> None:
34
- """Initialize the Conbus client send service"""
34
+ """Initialize the Conbus autoreport set service.
35
+
36
+ Args:
37
+ cli_config: Conbus client configuration.
38
+ reactor: Twisted reactor instance.
39
+ """
35
40
  super().__init__(cli_config, reactor)
36
41
  self.serial_number: str = ""
37
42
  self.status: bool = False
@@ -47,6 +52,7 @@ class ConbusAutoreportSetService(ConbusProtocol):
47
52
  self.logger = logging.getLogger(__name__)
48
53
 
49
54
  def connection_established(self) -> None:
55
+ """Handle connection established event."""
50
56
  # Convert boolean to appropriate value
51
57
  status_value = "PP" if self.status else "AA"
52
58
  status_text = "on" if self.status else "off"
@@ -60,11 +66,20 @@ class ConbusAutoreportSetService(ConbusProtocol):
60
66
  )
61
67
 
62
68
  def telegram_sent(self, telegram_sent: str) -> None:
69
+ """Handle telegram sent event.
70
+
71
+ Args:
72
+ telegram_sent: The telegram that was sent.
73
+ """
63
74
  self.logger.debug("Autoreport reply telegram sent %s", telegram_sent)
64
75
  self.service_response.sent_telegram = telegram_sent
65
76
 
66
77
  def telegram_received(self, telegram_received: TelegramReceivedEvent) -> None:
78
+ """Handle telegram received event.
67
79
 
80
+ Args:
81
+ telegram_received: The telegram received event.
82
+ """
68
83
  self.logger.debug(f"Telegram received: {telegram_received}")
69
84
  if not self.service_response.received_telegrams:
70
85
  self.service_response.received_telegrams = []
@@ -90,6 +105,11 @@ class ConbusAutoreportSetService(ConbusProtocol):
90
105
  self.finish_callback(self.service_response)
91
106
 
92
107
  def failed(self, message: str) -> None:
108
+ """Handle failed connection event.
109
+
110
+ Args:
111
+ message: Failure message.
112
+ """
93
113
  self.logger.debug(f"Failed with message: {message}")
94
114
  self.service_response.success = False
95
115
  self.service_response.error = message
@@ -104,20 +124,13 @@ class ConbusAutoreportSetService(ConbusProtocol):
104
124
  finish_callback: Callable[[ConbusAutoreportResponse], None],
105
125
  timeout_seconds: Optional[float] = None,
106
126
  ) -> None:
107
- """
108
- Set the auto report status for a specific module.
127
+ """Set the auto report status for a specific module.
109
128
 
110
129
  Args:
111
- serial_number: 10-digit module serial number
112
- status: True for ON, False for OFF
113
- finish_callback: callback function to call when the autoreport status is
114
- timeout_seconds: timeout in seconds
115
-
116
- Returns:
117
- ConbusAutoreportResponse with operation result
118
-
119
- Raises:
120
- ConbusAutoreportError: If parameters are invalid
130
+ serial_number: 10-digit module serial number.
131
+ status: True for ON, False for OFF.
132
+ finish_callback: Callback function to call when operation completes.
133
+ timeout_seconds: Timeout in seconds.
121
134
  """
122
135
  self.logger.info("Starting set_autoreport_status")
123
136
  if timeout_seconds:
@@ -1,7 +1,7 @@
1
- """Conbus Client Send Service for TCP communication with Conbus servers.
1
+ """Conbus Blink All Service for TCP communication with Conbus servers.
2
2
 
3
3
  This service implements a TCP client that connects to Conbus servers and sends
4
- various types of telegrams including discover, version, and sensor data requests.
4
+ blink/unblink telegrams to all discovered modules on the network.
5
5
  """
6
6
 
7
7
  import logging
@@ -21,10 +21,10 @@ from xp.services.telegram.telegram_service import TelegramService
21
21
 
22
22
  class ConbusBlinkAllService(ConbusProtocol):
23
23
  """
24
- Service for receiving telegrams from Conbus servers.
24
+ Service for blinking all modules on Conbus servers.
25
25
 
26
- Uses composition with ConbusService to provide receive-only functionality
27
- for collecting waiting event telegrams from the server.
26
+ Uses ConbusProtocol to provide blink/unblink functionality
27
+ for all discovered modules on the network.
28
28
  """
29
29
 
30
30
  def __init__(
@@ -33,7 +33,13 @@ class ConbusBlinkAllService(ConbusProtocol):
33
33
  cli_config: ConbusClientConfig,
34
34
  reactor: PosixReactorBase,
35
35
  ) -> None:
36
- """Initialize the Conbus client send service"""
36
+ """Initialize the Conbus blink all service.
37
+
38
+ Args:
39
+ telegram_service: Service for parsing telegrams.
40
+ cli_config: Configuration for Conbus client connection.
41
+ reactor: Twisted reactor for event loop.
42
+ """
37
43
  super().__init__(cli_config, reactor)
38
44
  self.telegram_service = telegram_service
39
45
  self.serial_number: str = ""
@@ -51,7 +57,8 @@ class ConbusBlinkAllService(ConbusProtocol):
51
57
  self.logger = logging.getLogger(__name__)
52
58
 
53
59
  def connection_established(self) -> None:
54
- self.logger.debug("Connection established, send discover telegram...")
60
+ """Handle connection established event."""
61
+ self.logger.debug("Connection established, send discover telegram.")
55
62
  self.send_telegram(
56
63
  telegram_type=TelegramType.SYSTEM,
57
64
  serial_number="0000000000",
@@ -62,7 +69,12 @@ class ConbusBlinkAllService(ConbusProtocol):
62
69
  self.progress_callback(".")
63
70
 
64
71
  def send_blink(self, serial_number: str) -> None:
65
- self.logger.debug("Device discovered, send blink...")
72
+ """Send blink or unblink telegram to a discovered module.
73
+
74
+ Args:
75
+ serial_number: 10-digit module serial number.
76
+ """
77
+ self.logger.debug("Device discovered, send blink.")
66
78
 
67
79
  # Blink is 05, Unblink is 06
68
80
  system_function = SystemFunction.UNBLINK
@@ -82,11 +94,20 @@ class ConbusBlinkAllService(ConbusProtocol):
82
94
  self.progress_callback(".")
83
95
 
84
96
  def telegram_sent(self, telegram_sent: str) -> None:
97
+ """Handle telegram sent event.
98
+
99
+ Args:
100
+ telegram_sent: The telegram that was sent.
101
+ """
85
102
  system_telegram = self.telegram_service.parse_system_telegram(telegram_sent)
86
103
  self.service_response.sent_telegram = system_telegram
87
104
 
88
105
  def telegram_received(self, telegram_received: TelegramReceivedEvent) -> None:
106
+ """Handle telegram received event.
89
107
 
108
+ Args:
109
+ telegram_received: The telegram received event.
110
+ """
90
111
  self.logger.debug(f"Telegram received: {telegram_received}")
91
112
  if not self.service_response.received_telegrams:
92
113
  self.service_response.received_telegrams = []
@@ -124,6 +145,11 @@ class ConbusBlinkAllService(ConbusProtocol):
124
145
  self.logger.debug("Received unexpected response")
125
146
 
126
147
  def failed(self, message: str) -> None:
148
+ """Handle failed connection event.
149
+
150
+ Args:
151
+ message: Failure message.
152
+ """
127
153
  self.logger.debug(f"Failed with message: {message}")
128
154
  self.service_response.success = False
129
155
  self.service_response.timestamp = datetime.now()
@@ -138,22 +164,15 @@ class ConbusBlinkAllService(ConbusProtocol):
138
164
  finish_callback: Callable[[ConbusBlinkResponse], None],
139
165
  timeout_seconds: Optional[float] = None,
140
166
  ) -> None:
141
- """
142
- Get the current auto report status for a specific module.
167
+ """Send blink command to all discovered modules.
143
168
 
144
169
  Args:
145
- on_or_off: blink or unblink device
146
- finish_callback: callback function to call when the autoreport status is
147
- timeout_seconds: timeout in seconds
148
-
149
- Returns:
150
- ConbusAutoreportResponse with operation result and auto report status
151
-
152
- Raises:
153
- ConbusAutoreportError: If the operation fails
170
+ on_or_off: "on" to blink or "off" to unblink all devices.
171
+ progress_callback: Callback function to call with progress updates.
172
+ finish_callback: Callback function to call when the operation completes.
173
+ timeout_seconds: Timeout in seconds.
154
174
  """
155
-
156
- self.logger.info("Starting get_autoreport_status")
175
+ self.logger.info("Starting send_blink_all_telegram")
157
176
  if timeout_seconds:
158
177
  self.timeout_seconds = timeout_seconds
159
178
  self.progress_callback = progress_callback