conson-xp 1.1.0__py3-none-any.whl → 1.3.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 (174) hide show
  1. {conson_xp-1.1.0.dist-info → conson_xp-1.3.0.dist-info}/METADATA +1 -5
  2. conson_xp-1.3.0.dist-info/RECORD +164 -0
  3. xp/__init__.py +4 -3
  4. xp/cli/__init__.py +1 -1
  5. xp/cli/commands/__init__.py +1 -2
  6. xp/cli/commands/conbus/conbus.py +9 -37
  7. xp/cli/commands/conbus/conbus_actiontable_commands.py +26 -4
  8. xp/cli/commands/conbus/conbus_autoreport_commands.py +58 -30
  9. xp/cli/commands/conbus/conbus_blink_commands.py +61 -29
  10. xp/cli/commands/conbus/conbus_config_commands.py +10 -5
  11. xp/cli/commands/conbus/conbus_custom_commands.py +16 -5
  12. xp/cli/commands/conbus/conbus_datapoint_commands.py +32 -10
  13. xp/cli/commands/conbus/conbus_discover_commands.py +20 -7
  14. xp/cli/commands/conbus/conbus_lightlevel_commands.py +114 -39
  15. xp/cli/commands/conbus/conbus_linknumber_commands.py +50 -25
  16. xp/cli/commands/conbus/conbus_msactiontable_commands.py +36 -5
  17. xp/cli/commands/conbus/conbus_output_commands.py +52 -14
  18. xp/cli/commands/conbus/conbus_raw_commands.py +17 -6
  19. xp/cli/commands/conbus/conbus_receive_commands.py +20 -10
  20. xp/cli/commands/conbus/conbus_scan_commands.py +17 -4
  21. xp/cli/commands/file_commands.py +35 -18
  22. xp/cli/commands/homekit/homekit.py +14 -8
  23. xp/cli/commands/homekit/homekit_start_commands.py +8 -6
  24. xp/cli/commands/module_commands.py +38 -23
  25. xp/cli/commands/reverse_proxy_commands.py +27 -19
  26. xp/cli/commands/server/server_commands.py +18 -18
  27. xp/cli/commands/telegram/telegram.py +4 -12
  28. xp/cli/commands/telegram/telegram_blink_commands.py +10 -8
  29. xp/cli/commands/telegram/telegram_checksum_commands.py +19 -8
  30. xp/cli/commands/telegram/telegram_discover_commands.py +2 -4
  31. xp/cli/commands/telegram/telegram_linknumber_commands.py +11 -8
  32. xp/cli/commands/telegram/telegram_parse_commands.py +10 -9
  33. xp/cli/commands/telegram/telegram_version_commands.py +8 -4
  34. xp/cli/main.py +5 -3
  35. xp/cli/utils/click_tree.py +23 -3
  36. xp/cli/utils/datapoint_type_choice.py +20 -0
  37. xp/cli/utils/decorators.py +165 -14
  38. xp/cli/utils/error_handlers.py +49 -18
  39. xp/cli/utils/formatters.py +95 -10
  40. xp/cli/utils/serial_number_type.py +18 -0
  41. xp/cli/utils/system_function_choice.py +20 -0
  42. xp/cli/utils/xp_module_type.py +20 -0
  43. xp/connection/__init__.py +1 -1
  44. xp/connection/exceptions.py +5 -5
  45. xp/models/__init__.py +1 -1
  46. xp/models/actiontable/__init__.py +1 -0
  47. xp/models/actiontable/actiontable.py +17 -1
  48. xp/models/actiontable/msactiontable_xp20.py +10 -0
  49. xp/models/actiontable/msactiontable_xp24.py +20 -3
  50. xp/models/actiontable/msactiontable_xp33.py +27 -4
  51. xp/models/conbus/__init__.py +1 -0
  52. xp/models/conbus/conbus.py +34 -4
  53. xp/models/conbus/conbus_autoreport.py +20 -2
  54. xp/models/conbus/conbus_blink.py +22 -2
  55. xp/models/conbus/conbus_client_config.py +22 -1
  56. xp/models/conbus/conbus_connection_status.py +16 -2
  57. xp/models/conbus/conbus_custom.py +21 -2
  58. xp/models/conbus/conbus_datapoint.py +25 -2
  59. xp/models/conbus/conbus_discover.py +18 -2
  60. xp/models/conbus/conbus_lightlevel.py +20 -2
  61. xp/models/conbus/conbus_linknumber.py +20 -2
  62. xp/models/conbus/conbus_output.py +22 -2
  63. xp/models/conbus/conbus_raw.py +17 -2
  64. xp/models/conbus/conbus_receive.py +16 -2
  65. xp/models/conbus/conbus_writeconfig.py +60 -0
  66. xp/models/homekit/__init__.py +1 -0
  67. xp/models/homekit/homekit_accessory.py +15 -1
  68. xp/models/homekit/homekit_config.py +52 -0
  69. xp/models/homekit/homekit_conson_config.py +32 -0
  70. xp/models/log_entry.py +49 -9
  71. xp/models/protocol/__init__.py +1 -0
  72. xp/models/protocol/conbus_protocol.py +130 -21
  73. xp/models/telegram/__init__.py +1 -0
  74. xp/models/telegram/action_type.py +16 -2
  75. xp/models/telegram/datapoint_type.py +36 -2
  76. xp/models/telegram/event_telegram.py +46 -10
  77. xp/models/telegram/event_type.py +8 -1
  78. xp/models/telegram/input_action_type.py +34 -2
  79. xp/models/telegram/input_type.py +9 -1
  80. xp/models/telegram/module_type.py +69 -19
  81. xp/models/telegram/module_type_code.py +43 -1
  82. xp/models/telegram/output_telegram.py +30 -6
  83. xp/models/telegram/reply_telegram.py +56 -11
  84. xp/models/telegram/system_function.py +35 -3
  85. xp/models/telegram/system_telegram.py +18 -4
  86. xp/models/telegram/telegram.py +12 -3
  87. xp/models/telegram/telegram_type.py +8 -1
  88. xp/models/telegram/timeparam_type.py +27 -0
  89. xp/models/write_config_type.py +17 -2
  90. xp/services/__init__.py +1 -1
  91. xp/services/conbus/__init__.py +1 -0
  92. xp/services/conbus/actiontable/__init__.py +1 -0
  93. xp/services/conbus/actiontable/actiontable_service.py +33 -2
  94. xp/services/conbus/actiontable/msactiontable_service.py +40 -3
  95. xp/services/conbus/actiontable/msactiontable_xp24_serializer.py +36 -4
  96. xp/services/conbus/actiontable/msactiontable_xp33_serializer.py +45 -5
  97. xp/services/conbus/conbus_blink_all_service.py +40 -21
  98. xp/services/conbus/conbus_blink_service.py +37 -13
  99. xp/services/conbus/conbus_custom_service.py +29 -13
  100. xp/services/conbus/conbus_datapoint_queryall_service.py +40 -16
  101. xp/services/conbus/conbus_datapoint_service.py +42 -18
  102. xp/services/conbus/conbus_discover_service.py +43 -7
  103. xp/services/conbus/conbus_output_service.py +33 -13
  104. xp/services/conbus/conbus_raw_service.py +36 -16
  105. xp/services/conbus/conbus_receive_service.py +38 -6
  106. xp/services/conbus/conbus_scan_service.py +44 -18
  107. xp/services/conbus/write_config_service.py +193 -0
  108. xp/services/homekit/__init__.py +1 -0
  109. xp/services/homekit/homekit_cache_service.py +31 -6
  110. xp/services/homekit/homekit_conbus_service.py +33 -2
  111. xp/services/homekit/homekit_config_validator.py +97 -15
  112. xp/services/homekit/homekit_conson_validator.py +51 -7
  113. xp/services/homekit/homekit_dimminglight.py +47 -1
  114. xp/services/homekit/homekit_dimminglight_service.py +35 -1
  115. xp/services/homekit/homekit_hap_service.py +71 -18
  116. xp/services/homekit/homekit_lightbulb.py +35 -1
  117. xp/services/homekit/homekit_lightbulb_service.py +30 -2
  118. xp/services/homekit/homekit_module_service.py +23 -1
  119. xp/services/homekit/homekit_outlet.py +47 -1
  120. xp/services/homekit/homekit_outlet_service.py +44 -2
  121. xp/services/homekit/homekit_service.py +113 -19
  122. xp/services/log_file_service.py +37 -41
  123. xp/services/module_type_service.py +26 -5
  124. xp/services/protocol/__init__.py +1 -1
  125. xp/services/protocol/conbus_protocol.py +110 -16
  126. xp/services/protocol/protocol_factory.py +40 -0
  127. xp/services/protocol/telegram_protocol.py +38 -7
  128. xp/services/reverse_proxy_service.py +79 -14
  129. xp/services/server/__init__.py +1 -0
  130. xp/services/server/base_server_service.py +102 -14
  131. xp/services/server/cp20_server_service.py +12 -4
  132. xp/services/server/server_service.py +26 -11
  133. xp/services/server/xp130_server_service.py +11 -3
  134. xp/services/server/xp20_server_service.py +11 -3
  135. xp/services/server/xp230_server_service.py +11 -3
  136. xp/services/server/xp24_server_service.py +33 -6
  137. xp/services/server/xp33_server_service.py +41 -8
  138. xp/services/telegram/__init__.py +1 -0
  139. xp/services/telegram/telegram_blink_service.py +19 -31
  140. xp/services/telegram/telegram_checksum_service.py +10 -10
  141. xp/services/telegram/telegram_datapoint_service.py +70 -0
  142. xp/services/telegram/telegram_discover_service.py +58 -29
  143. xp/services/telegram/telegram_link_number_service.py +27 -40
  144. xp/services/telegram/telegram_output_service.py +46 -49
  145. xp/services/telegram/telegram_service.py +41 -41
  146. xp/services/telegram/telegram_version_service.py +4 -2
  147. xp/utils/__init__.py +1 -1
  148. xp/utils/dependencies.py +4 -47
  149. xp/utils/serialization.py +6 -0
  150. xp/utils/time_utils.py +6 -11
  151. conson_xp-1.1.0.dist-info/RECORD +0 -181
  152. xp/api/__init__.py +0 -1
  153. xp/api/main.py +0 -110
  154. xp/api/models/__init__.py +0 -1
  155. xp/api/models/api.py +0 -20
  156. xp/api/models/discover.py +0 -21
  157. xp/api/routers/__init__.py +0 -17
  158. xp/api/routers/conbus.py +0 -5
  159. xp/api/routers/conbus_blink.py +0 -105
  160. xp/api/routers/conbus_custom.py +0 -63
  161. xp/api/routers/conbus_datapoint.py +0 -67
  162. xp/api/routers/conbus_output.py +0 -147
  163. xp/api/routers/errors.py +0 -37
  164. xp/cli/commands/api.py +0 -16
  165. xp/cli/commands/api_start_commands.py +0 -126
  166. xp/services/conbus/conbus_autoreport_get_service.py +0 -85
  167. xp/services/conbus/conbus_autoreport_set_service.py +0 -128
  168. xp/services/conbus/conbus_lightlevel_get_service.py +0 -101
  169. xp/services/conbus/conbus_lightlevel_set_service.py +0 -205
  170. xp/services/conbus/conbus_linknumber_get_service.py +0 -86
  171. xp/services/conbus/conbus_linknumber_set_service.py +0 -155
  172. {conson_xp-1.1.0.dist-info → conson_xp-1.3.0.dist-info}/WHEEL +0 -0
  173. {conson_xp-1.1.0.dist-info → conson_xp-1.3.0.dist-info}/entry_points.txt +0 -0
  174. {conson_xp-1.1.0.dist-info → conson_xp-1.3.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
 
@@ -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
@@ -1,7 +1,7 @@
1
- """Conbus Client Send Service for TCP communication with Conbus servers.
1
+ """Conbus Blink 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 control module LED indicators.
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 ConbusBlinkService(ConbusProtocol):
23
23
  """
24
- Service for receiving telegrams from Conbus servers.
24
+ Service for blinking module LEDs 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 controlling module LED indicators.
28
28
  """
29
29
 
30
30
  def __init__(
@@ -33,7 +33,13 @@ class ConbusBlinkService(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 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 = ""
@@ -50,7 +56,8 @@ class ConbusBlinkService(ConbusProtocol):
50
56
  self.logger = logging.getLogger(__name__)
51
57
 
52
58
  def connection_established(self) -> None:
53
- self.logger.debug("Connection established, retrieving autoreport status...")
59
+ """Handle connection established event."""
60
+ self.logger.debug("Connection established, sending blink command.")
54
61
  # Blink is 05, Unblink is 06
55
62
  system_function = SystemFunction.UNBLINK
56
63
  if self.on_or_off.lower() == "on":
@@ -66,11 +73,20 @@ class ConbusBlinkService(ConbusProtocol):
66
73
  self.service_response.operation = self.on_or_off
67
74
 
68
75
  def telegram_sent(self, telegram_sent: str) -> None:
76
+ """Handle telegram sent event.
77
+
78
+ Args:
79
+ telegram_sent: The telegram that was sent.
80
+ """
69
81
  system_telegram = self.telegram_service.parse_system_telegram(telegram_sent)
70
82
  self.service_response.sent_telegram = system_telegram
71
83
 
72
84
  def telegram_received(self, telegram_received: TelegramReceivedEvent) -> None:
85
+ """Handle telegram received event.
73
86
 
87
+ Args:
88
+ telegram_received: The telegram received event.
89
+ """
74
90
  self.logger.debug(f"Telegram received: {telegram_received}")
75
91
  if not self.service_response.received_telegrams:
76
92
  self.service_response.received_telegrams = []
@@ -101,6 +117,11 @@ class ConbusBlinkService(ConbusProtocol):
101
117
  self.finish_callback(self.service_response)
102
118
 
103
119
  def failed(self, message: str) -> None:
120
+ """Handle failed connection event.
121
+
122
+ Args:
123
+ message: Failure message.
124
+ """
104
125
  self.logger.debug(f"Failed with message: {message}")
105
126
  self.service_response.success = False
106
127
  self.service_response.timestamp = datetime.now()
@@ -115,17 +136,20 @@ class ConbusBlinkService(ConbusProtocol):
115
136
  finish_callback: Callable[[ConbusBlinkResponse], None],
116
137
  timeout_seconds: Optional[float] = None,
117
138
  ) -> None:
118
- """
119
- Send blink command to start blinking module LED.
139
+ r"""Send blink command to start blinking module LED.
120
140
 
121
- Examples:
141
+ Args:
142
+ serial_number: 10-digit module serial number.
143
+ on_or_off: "on" to blink or "off" to unblink.
144
+ finish_callback: Callback function to call when the reply is received.
145
+ timeout_seconds: Timeout in seconds.
122
146
 
123
- \b
147
+ Examples:
148
+ \b
124
149
  xp conbus blink 0012345008 on
125
150
  xp conbus blink 0012345008 off
126
151
  """
127
-
128
- self.logger.info("Starting get_autoreport_status")
152
+ self.logger.info("Starting send_blink_telegram")
129
153
  if timeout_seconds:
130
154
  self.timeout_seconds = timeout_seconds
131
155
  self.finish_callback = finish_callback
@@ -33,7 +33,13 @@ class ConbusCustomService(ConbusProtocol):
33
33
  cli_config: ConbusClientConfig,
34
34
  reactor: PosixReactorBase,
35
35
  ) -> None:
36
- """Initialize the Conbus custom service"""
36
+ """Initialize the Conbus custom 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 = ""
@@ -49,8 +55,9 @@ class ConbusCustomService(ConbusProtocol):
49
55
  self.logger = logging.getLogger(__name__)
50
56
 
51
57
  def connection_established(self) -> None:
58
+ """Handle connection established event."""
52
59
  self.logger.debug(
53
- f"Connection established, sending custom telegram F{self.function_code}D{self.data}..."
60
+ f"Connection established, sending custom telegram F{self.function_code}D{self.data}."
54
61
  )
55
62
  system_function = SystemFunction.from_code(self.function_code)
56
63
  if not system_function:
@@ -66,10 +73,19 @@ class ConbusCustomService(ConbusProtocol):
66
73
  )
67
74
 
68
75
  def telegram_sent(self, telegram_sent: str) -> None:
76
+ """Handle telegram sent event.
77
+
78
+ Args:
79
+ telegram_sent: The telegram that was sent.
80
+ """
69
81
  self.service_response.sent_telegram = telegram_sent
70
82
 
71
83
  def telegram_received(self, telegram_received: TelegramReceivedEvent) -> None:
84
+ """Handle telegram received event.
72
85
 
86
+ Args:
87
+ telegram_received: The telegram received event.
88
+ """
73
89
  self.logger.debug(f"Telegram received: {telegram_received}")
74
90
  if not self.service_response.received_telegrams:
75
91
  self.service_response.received_telegrams = []
@@ -101,6 +117,11 @@ class ConbusCustomService(ConbusProtocol):
101
117
  self.finish_callback(self.service_response)
102
118
 
103
119
  def failed(self, message: str) -> None:
120
+ """Handle failed connection event.
121
+
122
+ Args:
123
+ message: Failure message.
124
+ """
104
125
  self.logger.debug(f"Failed with message: {message}")
105
126
  self.service_response.success = False
106
127
  self.service_response.timestamp = datetime.now()
@@ -116,20 +137,15 @@ class ConbusCustomService(ConbusProtocol):
116
137
  finish_callback: Callable[[ConbusCustomResponse], None],
117
138
  timeout_seconds: Optional[float] = None,
118
139
  ) -> None:
119
- """
120
- Send a custom telegram to a module.
140
+ """Send a custom telegram to a module.
121
141
 
122
142
  Args:
123
- serial_number: 10-digit module serial number
124
- function_code: Function code (e.g., "02", "17")
125
- data: Data code (e.g., "E2", "AA")
126
- finish_callback: callback function to call when the reply is received
127
- timeout_seconds: timeout in seconds
128
-
129
- Returns:
130
- ConbusCustomResponse with operation result
143
+ serial_number: 10-digit module serial number.
144
+ function_code: Function code (e.g., "02", "17").
145
+ data: Data code (e.g., "E2", "AA").
146
+ finish_callback: Callback function to call when the reply is received.
147
+ timeout_seconds: Timeout in seconds.
131
148
  """
132
-
133
149
  self.logger.info("Starting send_custom_telegram")
134
150
  if timeout_seconds:
135
151
  self.timeout_seconds = timeout_seconds