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
@@ -21,7 +21,7 @@ from xp.services.protocol import ConbusProtocol
21
21
 
22
22
 
23
23
  class ConbusLightlevelError(Exception):
24
- """Raised when Conbus lightlevel operations fail"""
24
+ """Raised when Conbus lightlevel operations fail."""
25
25
 
26
26
  pass
27
27
 
@@ -39,7 +39,12 @@ class ConbusLightlevelSetService(ConbusProtocol):
39
39
  cli_config: ConbusClientConfig,
40
40
  reactor: PosixReactorBase,
41
41
  ):
42
- """Initialize the Conbus lightlevel service"""
42
+ """Initialize the Conbus lightlevel service.
43
+
44
+ Args:
45
+ cli_config: Configuration for Conbus client connection.
46
+ reactor: Twisted reactor for event loop.
47
+ """
43
48
  super().__init__(cli_config, reactor)
44
49
  self.serial_number: str = ""
45
50
  self.output_number: int = 0
@@ -59,8 +64,9 @@ class ConbusLightlevelSetService(ConbusProtocol):
59
64
  self.logger = logging.getLogger(__name__)
60
65
 
61
66
  def connection_established(self) -> None:
67
+ """Handle connection established event."""
62
68
  self.logger.debug(
63
- f"Connection established, setting light level for output {self.output_number} to {self.level}%..."
69
+ f"Connection established, setting light level for output {self.output_number} to {self.level}%."
64
70
  )
65
71
 
66
72
  # Format data as output_number:level (e.g., ""15" + "02:050")
@@ -75,9 +81,19 @@ class ConbusLightlevelSetService(ConbusProtocol):
75
81
  )
76
82
 
77
83
  def telegram_sent(self, telegram_sent: str) -> None:
84
+ """Handle telegram sent event.
85
+
86
+ Args:
87
+ telegram_sent: The telegram that was sent.
88
+ """
78
89
  self.service_response.sent_telegram = telegram_sent
79
90
 
80
91
  def telegram_received(self, telegram_received: TelegramReceivedEvent) -> None:
92
+ """Handle telegram received event.
93
+
94
+ Args:
95
+ telegram_received: The telegram received event.
96
+ """
81
97
  self.logger.debug(f"Telegram received: {telegram_received}")
82
98
  if not self.service_response.received_telegrams:
83
99
  self.service_response.received_telegrams = []
@@ -97,6 +113,7 @@ class ConbusLightlevelSetService(ConbusProtocol):
97
113
  self.succeed()
98
114
 
99
115
  def succeed(self) -> None:
116
+ """Handle successful light level set operation."""
100
117
  self.logger.debug("Succeed")
101
118
  self.service_response.success = True
102
119
  self.service_response.serial_number = self.serial_number
@@ -108,6 +125,11 @@ class ConbusLightlevelSetService(ConbusProtocol):
108
125
  self.finish_callback(self.service_response)
109
126
 
110
127
  def failed(self, message: str) -> None:
128
+ """Handle failed connection event.
129
+
130
+ Args:
131
+ message: Failure message.
132
+ """
111
133
  self.logger.debug(f"Failed with message: {message}")
112
134
  self.service_response.success = False
113
135
  self.service_response.serial_number = self.serial_number
@@ -130,18 +152,16 @@ class ConbusLightlevelSetService(ConbusProtocol):
130
152
  """Set light level for a specific output on a module.
131
153
 
132
154
  Args:
133
- serial_number: Module serial number
134
- output_number: Output number (0-based, 0-8)
135
- level: Light level percentage (0-100)
136
- finish_callback: Callback function to call when operation completes
137
- timeout_seconds: Optional timeout in seconds
155
+ serial_number: Module serial number.
156
+ output_number: Output number (0-based, 0-8).
157
+ level: Light level percentage (0-100).
158
+ finish_callback: Callback function to call when operation completes.
159
+ timeout_seconds: Optional timeout in seconds.
138
160
 
139
161
  Examples:
140
- \b
141
- xp conbus lightlevel set 0012345008 2 50
142
- xp conbus lightlevel set 0012345008 0 100
162
+ xp conbus lightlevel set 0012345008 2 50
163
+ xp conbus lightlevel set 0012345008 0 100
143
164
  """
144
-
145
165
  self.logger.info(
146
166
  f"Setting light level for {serial_number} output {output_number} to {level}%"
147
167
  )
@@ -176,10 +196,10 @@ class ConbusLightlevelSetService(ConbusProtocol):
176
196
  """Turn off light (set level to 0) for a specific output.
177
197
 
178
198
  Args:
179
- serial_number: Module serial number
180
- output_number: Output number (0-8)
181
- finish_callback: Callback function to call when operation completes
182
- timeout_seconds: Optional timeout in seconds
199
+ serial_number: Module serial number.
200
+ output_number: Output number (0-8).
201
+ finish_callback: Callback function to call when operation completes.
202
+ timeout_seconds: Optional timeout in seconds.
183
203
  """
184
204
  self.set_lightlevel(
185
205
  serial_number, output_number, 0, finish_callback, timeout_seconds
@@ -195,10 +215,10 @@ class ConbusLightlevelSetService(ConbusProtocol):
195
215
  """Turn on light (set level to 80%) for a specific output.
196
216
 
197
217
  Args:
198
- serial_number: Module serial number
199
- output_number: Output number (0-8)
200
- finish_callback: Callback function to call when operation completes
201
- timeout_seconds: Optional timeout in seconds
218
+ serial_number: Module serial number.
219
+ output_number: Output number (0-8).
220
+ finish_callback: Callback function to call when operation completes.
221
+ timeout_seconds: Optional timeout in seconds.
202
222
  """
203
223
  self.set_lightlevel(
204
224
  serial_number, output_number, 80, finish_callback, timeout_seconds
@@ -17,10 +17,10 @@ from xp.services.telegram.telegram_service import TelegramService
17
17
 
18
18
  class ConbusLinknumberGetService(ConbusDatapointService):
19
19
  """
20
- Service for receiving telegrams from Conbus servers.
20
+ Service for getting link numbers 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 link number query functionality
23
+ for reading the current link number configuration from modules.
24
24
  """
25
25
 
26
26
  def __init__(
@@ -29,7 +29,13 @@ class ConbusLinknumberGetService(ConbusDatapointService):
29
29
  cli_config: ConbusClientConfig,
30
30
  reactor: PosixReactorBase,
31
31
  ) -> None:
32
- """Initialize the Conbus client send service"""
32
+ """Initialize the Conbus linknumber get service.
33
+
34
+ Args:
35
+ telegram_service: Service for parsing telegrams.
36
+ cli_config: Configuration for Conbus client connection.
37
+ reactor: Twisted reactor for event loop.
38
+ """
33
39
  super().__init__(telegram_service, cli_config, reactor)
34
40
  self.service_callback: Optional[Callable[[ConbusLinknumberResponse], None]] = (
35
41
  None
@@ -41,7 +47,11 @@ class ConbusLinknumberGetService(ConbusDatapointService):
41
47
  def finish_service_callback(
42
48
  self, datapoint_response: ConbusDatapointResponse
43
49
  ) -> None:
50
+ """Process datapoint response and extract link number.
44
51
 
52
+ Args:
53
+ datapoint_response: The datapoint response from the module.
54
+ """
45
55
  self.logger.debug("Parsing datapoint response")
46
56
  link_number_value = 0
47
57
  if datapoint_response.success and datapoint_response.datapoint_telegram:
@@ -67,14 +77,12 @@ class ConbusLinknumberGetService(ConbusDatapointService):
67
77
  finish_callback: Callable[[ConbusLinknumberResponse], None],
68
78
  timeout_seconds: Optional[float] = None,
69
79
  ) -> None:
70
- """
71
- Get the current auto report status for a specific module.
80
+ """Get the current link number for a specific module.
72
81
 
73
82
  Args:
74
- :param serial_number: 10-digit module serial number
75
- :param finish_callback: callback function to call when the linknumber status is
76
- :param timeout_seconds: timeout in seconds
77
-
83
+ serial_number: 10-digit module serial number.
84
+ finish_callback: Callback function to call when the link number is received.
85
+ timeout_seconds: Timeout in seconds.
78
86
  """
79
87
  self.logger.info("Starting get_linknumber")
80
88
  if timeout_seconds:
@@ -33,7 +33,13 @@ class ConbusLinknumberSetService(ConbusProtocol):
33
33
  cli_config: ConbusClientConfig,
34
34
  reactor: PosixReactorBase,
35
35
  ) -> None:
36
- """Initialize the Conbus link number set service"""
36
+ """Initialize the Conbus link number set 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 ConbusLinknumberSetService(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, setting link number {self.link_number}..."
60
+ f"Connection established, setting link number {self.link_number}."
54
61
  )
55
62
 
56
63
  # Validate parameters before sending
@@ -72,9 +79,19 @@ class ConbusLinknumberSetService(ConbusProtocol):
72
79
  )
73
80
 
74
81
  def telegram_sent(self, telegram_sent: str) -> None:
82
+ """Handle telegram sent event.
83
+
84
+ Args:
85
+ telegram_sent: The telegram that was sent.
86
+ """
75
87
  self.service_response.sent_telegram = telegram_sent
76
88
 
77
89
  def telegram_received(self, telegram_received: TelegramReceivedEvent) -> None:
90
+ """Handle telegram received event.
91
+
92
+ Args:
93
+ telegram_received: The telegram received event.
94
+ """
78
95
  self.logger.debug(f"Telegram received: {telegram_received}")
79
96
 
80
97
  if not self.service_response.received_telegrams:
@@ -111,6 +128,11 @@ class ConbusLinknumberSetService(ConbusProtocol):
111
128
  )
112
129
 
113
130
  def succeed(self, system_function: SystemFunction) -> None:
131
+ """Handle successful link number set operation.
132
+
133
+ Args:
134
+ system_function: The system function from the reply telegram.
135
+ """
114
136
  self.logger.debug("Successfully set link number")
115
137
  self.service_response.success = True
116
138
  self.service_response.timestamp = datetime.now()
@@ -121,6 +143,11 @@ class ConbusLinknumberSetService(ConbusProtocol):
121
143
  self.finish_callback(self.service_response)
122
144
 
123
145
  def failed(self, message: str) -> None:
146
+ """Handle failed connection event.
147
+
148
+ Args:
149
+ message: Failure message.
150
+ """
124
151
  self.logger.debug(f"Failed with message: {message}")
125
152
  self.service_response.success = False
126
153
  self.service_response.timestamp = datetime.now()
@@ -137,14 +164,13 @@ class ConbusLinknumberSetService(ConbusProtocol):
137
164
  finish_callback: Callable[[ConbusLinknumberResponse], None],
138
165
  timeout_seconds: Optional[float] = None,
139
166
  ) -> None:
140
- """
141
- Set the link number for a specific module.
167
+ """Set the link number for a specific module.
142
168
 
143
169
  Args:
144
- serial_number: 10-digit module serial number
145
- link_number: Link number to set (0-99)
146
- finish_callback: Callback function to call when operation completes
147
- timeout_seconds: Optional timeout in seconds
170
+ serial_number: 10-digit module serial number.
171
+ link_number: Link number to set (0-99).
172
+ finish_callback: Callback function to call when operation completes.
173
+ timeout_seconds: Optional timeout in seconds.
148
174
  """
149
175
  self.logger.info("Starting set_linknumber")
150
176
  if timeout_seconds:
@@ -25,7 +25,7 @@ from xp.services.telegram.telegram_output_service import (
25
25
 
26
26
 
27
27
  class ConbusOutputError(Exception):
28
- """Raised when Conbus output operations fail"""
28
+ """Raised when Conbus output operations fail."""
29
29
 
30
30
  pass
31
31
 
@@ -44,12 +44,12 @@ class ConbusOutputService(ConbusProtocol):
44
44
  cli_config: ConbusClientConfig,
45
45
  reactor: PosixReactorBase,
46
46
  ):
47
- """Initialize the Conbus output service
47
+ """Initialize the Conbus output service.
48
48
 
49
49
  Args:
50
- telegram_output_service: TelegramOutputService for telegram generation/parsing
51
- cli_config: Conbus client configuration
52
- reactor: Twisted reactor for async operations
50
+ telegram_output_service: TelegramOutputService for telegram generation/parsing.
51
+ cli_config: Conbus client configuration.
52
+ reactor: Twisted reactor for async operations.
53
53
  """
54
54
  super().__init__(cli_config, reactor)
55
55
  self.telegram_output_service = telegram_output_service
@@ -69,8 +69,9 @@ class ConbusOutputService(ConbusProtocol):
69
69
  self.logger = logging.getLogger(__name__)
70
70
 
71
71
  def connection_established(self) -> None:
72
+ """Handle connection established event."""
72
73
  self.logger.debug(
73
- f"Connection established, sending action {self.action_type} to output {self.output_number}..."
74
+ f"Connection established, sending action {self.action_type} to output {self.output_number}."
74
75
  )
75
76
 
76
77
  # Validate parameters before sending
@@ -91,9 +92,19 @@ class ConbusOutputService(ConbusProtocol):
91
92
  )
92
93
 
93
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
+ """
94
100
  self.service_response.sent_telegram = telegram_sent
95
101
 
96
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
+ """
97
108
  self.logger.debug(f"Telegram received: {telegram_received}")
98
109
 
99
110
  if not self.service_response.received_telegrams:
@@ -125,6 +136,11 @@ class ConbusOutputService(ConbusProtocol):
125
136
  )
126
137
 
127
138
  def succeed(self, output_telegram: OutputTelegram) -> None:
139
+ """Handle successful output action.
140
+
141
+ Args:
142
+ output_telegram: The output telegram received as response.
143
+ """
128
144
  self.logger.debug("Successfully sent action to output")
129
145
  self.service_response.success = True
130
146
  self.service_response.timestamp = datetime.now()
@@ -136,6 +152,11 @@ class ConbusOutputService(ConbusProtocol):
136
152
  self.finish_callback(self.service_response)
137
153
 
138
154
  def failed(self, message: str) -> None:
155
+ """Handle failed connection event.
156
+
157
+ Args:
158
+ message: Failure message.
159
+ """
139
160
  self.logger.debug(f"Failed with message: {message}")
140
161
  self.service_response.success = False
141
162
  self.service_response.timestamp = datetime.now()
@@ -154,15 +175,14 @@ class ConbusOutputService(ConbusProtocol):
154
175
  finish_callback: Callable[[ConbusOutputResponse], None],
155
176
  timeout_seconds: Optional[float] = None,
156
177
  ) -> None:
157
- """
158
- Send an action telegram to a module output.
178
+ """Send an action telegram to a module output.
159
179
 
160
180
  Args:
161
- serial_number: 10-digit module serial number
162
- output_number: Output number (0-99)
163
- action_type: Action to perform (ON_RELEASE, OFF_PRESS, etc.)
164
- finish_callback: Callback function to call when operation completes
165
- timeout_seconds: Optional timeout in seconds
181
+ serial_number: 10-digit module serial number.
182
+ output_number: Output number (0-99).
183
+ action_type: Action to perform (ON_RELEASE, OFF_PRESS, etc.).
184
+ finish_callback: Callback function to call when operation completes.
185
+ timeout_seconds: Optional timeout in seconds.
166
186
  """
167
187
  self.logger.info("Starting send_action")
168
188
  if timeout_seconds:
@@ -17,10 +17,10 @@ from xp.services.protocol import ConbusProtocol
17
17
 
18
18
  class ConbusRawService(ConbusProtocol):
19
19
  """
20
- Service for querying datapoints from Conbus modules.
20
+ Service for sending raw telegram sequences to Conbus modules.
21
21
 
22
- Uses ConbusProtocol to provide datapoint query functionality
23
- for reading sensor data and module information.
22
+ Uses ConbusProtocol to provide raw telegram functionality
23
+ for sending arbitrary telegram strings without validation.
24
24
  """
25
25
 
26
26
  def __init__(
@@ -28,7 +28,12 @@ class ConbusRawService(ConbusProtocol):
28
28
  cli_config: ConbusClientConfig,
29
29
  reactor: PosixReactorBase,
30
30
  ) -> None:
31
- """Initialize the Conbus datapoint service"""
31
+ """Initialize the Conbus raw service.
32
+
33
+ Args:
34
+ cli_config: Configuration for Conbus client connection.
35
+ reactor: Twisted reactor for event loop.
36
+ """
32
37
  super().__init__(cli_config, reactor)
33
38
  self.raw_input: str = ""
34
39
  self.progress_callback: Optional[Callable[[str], None]] = None
@@ -40,17 +45,27 @@ class ConbusRawService(ConbusProtocol):
40
45
  self.logger = logging.getLogger(__name__)
41
46
 
42
47
  def connection_established(self) -> None:
48
+ """Handle connection established event."""
43
49
  self.logger.debug(f"Connection established, sending {self.raw_input}")
44
50
  self.sendFrame(self.raw_input.encode())
45
51
 
46
52
  def telegram_sent(self, telegram_sent: str) -> None:
53
+ """Handle telegram sent event.
54
+
55
+ Args:
56
+ telegram_sent: The telegram that was sent.
57
+ """
47
58
  self.service_response.success = True
48
59
  self.service_response.sent_telegrams = telegram_sent
49
60
  self.service_response.timestamp = datetime.now()
50
61
  self.service_response.received_telegrams = []
51
- pass
52
62
 
53
63
  def telegram_received(self, telegram_received: TelegramReceivedEvent) -> None:
64
+ """Handle telegram received event.
65
+
66
+ Args:
67
+ telegram_received: The telegram received event.
68
+ """
54
69
  self.logger.debug(f"Telegram received: {telegram_received}")
55
70
  if not self.service_response.received_telegrams:
56
71
  self.service_response.received_telegrams = []
@@ -60,12 +75,22 @@ class ConbusRawService(ConbusProtocol):
60
75
  self.progress_callback(telegram_received.frame)
61
76
 
62
77
  def timeout(self) -> bool:
78
+ """Handle timeout event.
79
+
80
+ Returns:
81
+ False to indicate connection should be closed.
82
+ """
63
83
  self.logger.debug(f"Timeout: {self.timeout_seconds}s")
64
84
  if self.finish_callback:
65
85
  self.finish_callback(self.service_response)
66
86
  return False
67
87
 
68
88
  def failed(self, message: str) -> None:
89
+ """Handle failed connection event.
90
+
91
+ Args:
92
+ message: Failure message.
93
+ """
69
94
  self.logger.debug(f"Failed with message: {message}")
70
95
  self.service_response.success = False
71
96
  self.service_response.timestamp = datetime.now()
@@ -80,20 +105,15 @@ class ConbusRawService(ConbusProtocol):
80
105
  finish_callback: Callable[[ConbusRawResponse], None],
81
106
  timeout_seconds: Optional[float] = None,
82
107
  ) -> None:
83
- """
84
- Query a specific datapoint from a module.
108
+ """Send a raw telegram string to the Conbus server.
85
109
 
86
110
  Args:
87
- serial_number: 10-digit module serial number
88
- datapoint_type: Type of datapoint to query
89
- finish_callback: callback function to call when the datapoint is received
90
- timeout_seconds: timeout in seconds
91
-
92
- Returns:
93
- ConbusDatapointResponse with operation result and datapoint value
111
+ raw_input: Raw telegram string to send.
112
+ progress_callback: Callback to handle progress updates.
113
+ finish_callback: Callback function to call when the operation is complete.
114
+ timeout_seconds: Timeout in seconds.
94
115
  """
95
-
96
- self.logger.info("Starting query_datapoint")
116
+ self.logger.info("Starting send_raw_telegram")
97
117
  if timeout_seconds:
98
118
  self.timeout_seconds = timeout_seconds
99
119
  self.progress_callback = progress_callback
@@ -1,6 +1,6 @@
1
1
  """Conbus Receive Service for receiving telegrams from Conbus servers.
2
2
 
3
- This service uses composition with ConbusService to provide receive-only functionality,
3
+ This service uses ConbusProtocol to provide receive-only functionality,
4
4
  allowing clients to receive waiting event telegrams using empty telegram sends.
5
5
  """
6
6
 
@@ -19,7 +19,7 @@ class ConbusReceiveService(ConbusProtocol):
19
19
  """
20
20
  Service for receiving telegrams from Conbus servers.
21
21
 
22
- Uses composition with ConbusService to provide receive-only functionality
22
+ Uses ConbusProtocol to provide receive-only functionality
23
23
  for collecting waiting event telegrams from the server.
24
24
  """
25
25
 
@@ -28,7 +28,12 @@ class ConbusReceiveService(ConbusProtocol):
28
28
  cli_config: ConbusClientConfig,
29
29
  reactor: PosixReactorBase,
30
30
  ) -> None:
31
- """Initialize the Conbus client send service"""
31
+ """Initialize the Conbus receive service.
32
+
33
+ Args:
34
+ cli_config: Conbus client configuration.
35
+ reactor: Twisted reactor instance.
36
+ """
32
37
  super().__init__(cli_config, reactor)
33
38
  self.progress_callback: Optional[Callable[[str], None]] = None
34
39
  self.finish_callback: Optional[Callable[[ConbusReceiveResponse], None]] = None
@@ -40,12 +45,23 @@ class ConbusReceiveService(ConbusProtocol):
40
45
  self.logger = logging.getLogger(__name__)
41
46
 
42
47
  def connection_established(self) -> None:
43
- self.logger.debug("Connection established, waiting for telegrams...")
48
+ """Handle connection established event."""
49
+ self.logger.debug("Connection established, waiting for telegrams.")
44
50
 
45
51
  def telegram_sent(self, telegram_sent: str) -> None:
52
+ """Handle telegram sent event.
53
+
54
+ Args:
55
+ telegram_sent: The telegram that was sent.
56
+ """
46
57
  pass
47
58
 
48
59
  def telegram_received(self, telegram_received: TelegramReceivedEvent) -> None:
60
+ """Handle telegram received event.
61
+
62
+ Args:
63
+ telegram_received: The telegram received event.
64
+ """
49
65
  self.logger.debug(f"Telegram received: {telegram_received}")
50
66
  if self.progress_callback:
51
67
  self.progress_callback(telegram_received.frame)
@@ -55,6 +71,11 @@ class ConbusReceiveService(ConbusProtocol):
55
71
  self.receive_response.received_telegrams.append(telegram_received.frame)
56
72
 
57
73
  def timeout(self) -> bool:
74
+ """Handle timeout event to stop receiving.
75
+
76
+ Returns:
77
+ False to stop the reactor.
78
+ """
58
79
  self.logger.info("Receive stopped after: %ss", self.timeout_seconds)
59
80
  self.receive_response.success = True
60
81
  if self.finish_callback:
@@ -62,6 +83,11 @@ class ConbusReceiveService(ConbusProtocol):
62
83
  return False
63
84
 
64
85
  def failed(self, message: str) -> None:
86
+ """Handle failed connection event.
87
+
88
+ Args:
89
+ message: Failure message.
90
+ """
65
91
  self.logger.debug("Failed %s:", message)
66
92
  self.receive_response.success = False
67
93
  self.receive_response.error = message
@@ -74,8 +100,14 @@ class ConbusReceiveService(ConbusProtocol):
74
100
  finish_callback: Callable[[ConbusReceiveResponse], None],
75
101
  timeout_seconds: Optional[float] = None,
76
102
  ) -> None:
77
- """Run reactor in dedicated thread with its own event loop"""
78
- self.logger.info("Starting discovery")
103
+ """Run reactor in dedicated thread with its own event loop.
104
+
105
+ Args:
106
+ progress_callback: Callback for each received telegram.
107
+ finish_callback: Callback when receiving completes.
108
+ timeout_seconds: Optional timeout in seconds.
109
+ """
110
+ self.logger.info("Starting receive")
79
111
  if timeout_seconds:
80
112
  self.timeout_seconds = timeout_seconds
81
113
  self.progress_callback = progress_callback