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
@@ -1,22 +1,22 @@
1
- """
2
- Connection-related exceptions for XP CLI tool.
1
+ """Connection-related exceptions for XP CLI tool.
2
+
3
3
  Following the architecture requirement for structured error handling.
4
4
  """
5
5
 
6
6
 
7
7
  class XPError(Exception):
8
- """Base exception for XP CLI tool"""
8
+ """Base exception for XP CLI tool."""
9
9
 
10
10
  pass
11
11
 
12
12
 
13
13
  class ProtocolError(XPError):
14
- """Console bus protocol errors"""
14
+ """Console bus protocol errors."""
15
15
 
16
16
  pass
17
17
 
18
18
 
19
19
  class ValidationError(XPError):
20
- """Input validation errors"""
20
+ """Input validation errors."""
21
21
 
22
22
  pass
xp/models/__init__.py CHANGED
@@ -1,4 +1,4 @@
1
- """Data models for XP CLI tool"""
1
+ """Data models for XP CLI tool."""
2
2
 
3
3
  from xp.models.conbus.conbus import ConbusRequest, ConbusResponse
4
4
  from xp.models.conbus.conbus_client_config import ConbusClientConfig
@@ -0,0 +1 @@
1
+ """Action table models for XP protocol."""
@@ -11,6 +11,18 @@ from xp.models.telegram.timeparam_type import TimeParam
11
11
  # CP20 0 0 > 1 ~ON;
12
12
  @dataclass
13
13
  class ActionTableEntry:
14
+ """Entry in an action table mapping input events to output actions.
15
+
16
+ Attributes:
17
+ module_type: Type code of the module.
18
+ link_number: Link number for the action.
19
+ module_input: Input number on the module.
20
+ module_output: Output number on the module.
21
+ command: Action type to perform.
22
+ parameter: Time parameter for the action.
23
+ inverted: Whether the action is inverted.
24
+ """
25
+
14
26
  module_type: ModuleTypeCode = ModuleTypeCode.CP20
15
27
  link_number: int = 0
16
28
  module_input: int = 0
@@ -22,6 +34,10 @@ class ActionTableEntry:
22
34
 
23
35
  @dataclass
24
36
  class ActionTable:
25
- """Action Table for managing action on events."""
37
+ """Action Table for managing action on events.
38
+
39
+ Attributes:
40
+ entries: List of action table entries.
41
+ """
26
42
 
27
43
  entries: list[ActionTableEntry] = field(default_factory=list)
@@ -31,6 +31,16 @@ class Xp20MsActionTable:
31
31
  Contains configuration for 8 input channels (input1 through input8),
32
32
  each with flags for inversion, short/long press detection, group functions,
33
33
  AND functions, SA functions, and TA functions.
34
+
35
+ Attributes:
36
+ input1: Configuration for input channel 1.
37
+ input2: Configuration for input channel 2.
38
+ input3: Configuration for input channel 3.
39
+ input4: Configuration for input channel 4.
40
+ input5: Configuration for input channel 5.
41
+ input6: Configuration for input channel 6.
42
+ input7: Configuration for input channel 7.
43
+ input8: Configuration for input channel 8.
34
44
  """
35
45
 
36
46
  input1: InputChannel = field(default_factory=InputChannel)
@@ -8,7 +8,12 @@ from xp.models.telegram.timeparam_type import TimeParam
8
8
 
9
9
  @dataclass
10
10
  class InputAction:
11
- """Represents an input action with type and parameter"""
11
+ """Represents an input action with type and parameter.
12
+
13
+ Attributes:
14
+ type: The input action type.
15
+ param: Time parameter for the action.
16
+ """
12
17
 
13
18
  type: InputActionType = InputActionType.TOGGLE
14
19
  param: TimeParam = TimeParam.NONE
@@ -16,11 +21,23 @@ class InputAction:
16
21
 
17
22
  @dataclass
18
23
  class Xp24MsActionTable:
19
- """
20
- XP24 Action Table for managing input actions and settings.
24
+ """XP24 Action Table for managing input actions and settings.
21
25
 
22
26
  Each input has an action type (TOGGLE, TURNON, LEVELSET, etc.)
23
27
  with an optional parameter string.
28
+
29
+ Attributes:
30
+ MS300: Timing constant for 300ms.
31
+ MS500: Timing constant for 500ms.
32
+ input1_action: Action configuration for input 1.
33
+ input2_action: Action configuration for input 2.
34
+ input3_action: Action configuration for input 3.
35
+ input4_action: Action configuration for input 4.
36
+ mutex12: Mutual exclusion between inputs 1-2.
37
+ mutex34: Mutual exclusion between inputs 3-4.
38
+ curtain12: Curtain setting for inputs 1-2.
39
+ curtain34: Curtain setting for inputs 3-4.
40
+ mutual_deadtime: Master timing (MS300=12 or MS500=20).
24
41
  """
25
42
 
26
43
  # MS timing constants
@@ -7,7 +7,15 @@ from xp.models.telegram.timeparam_type import TimeParam
7
7
 
8
8
  @dataclass
9
9
  class Xp33Output:
10
- """Represents an XP33 output configuration"""
10
+ """Represents an XP33 output configuration.
11
+
12
+ Attributes:
13
+ min_level: Minimum output level (0-100).
14
+ max_level: Maximum output level (0-100).
15
+ scene_outputs: Enable scene outputs.
16
+ start_at_full: Start at full brightness.
17
+ leading_edge: Use leading edge dimming.
18
+ """
11
19
 
12
20
  min_level: int = 0
13
21
  max_level: int = 100
@@ -18,7 +26,14 @@ class Xp33Output:
18
26
 
19
27
  @dataclass
20
28
  class Xp33Scene:
21
- """Represents a scene configuration"""
29
+ """Represents a scene configuration.
30
+
31
+ Attributes:
32
+ output1_level: Output level for output 1 (0-100).
33
+ output2_level: Output level for output 2 (0-100).
34
+ output3_level: Output level for output 3 (0-100).
35
+ time: Time parameter for scene transition.
36
+ """
22
37
 
23
38
  output1_level: int = 0
24
39
  output2_level: int = 0
@@ -28,8 +43,16 @@ class Xp33Scene:
28
43
 
29
44
  @dataclass
30
45
  class Xp33MsActionTable:
31
- """
32
- XP33 Action Table for managing outputs and scenes
46
+ """XP33 Action Table for managing outputs and scenes.
47
+
48
+ Attributes:
49
+ output1: Configuration for output 1.
50
+ output2: Configuration for output 2.
51
+ output3: Configuration for output 3.
52
+ scene1: Configuration for scene 1.
53
+ scene2: Configuration for scene 2.
54
+ scene3: Configuration for scene 3.
55
+ scene4: Configuration for scene 4.
33
56
  """
34
57
 
35
58
  output1: Xp33Output = field(default_factory=Xp33Output)
@@ -0,0 +1 @@
1
+ """Conbus communication models."""
@@ -1,3 +1,5 @@
1
+ """Conbus request and response models."""
2
+
1
3
  from dataclasses import dataclass
2
4
  from datetime import datetime
3
5
  from typing import Any, Dict, Optional
@@ -5,7 +7,15 @@ from typing import Any, Dict, Optional
5
7
 
6
8
  @dataclass
7
9
  class ConbusRequest:
8
- """Represents a Conbus send request"""
10
+ """Represents a Conbus send request.
11
+
12
+ Attributes:
13
+ serial_number: Serial number of the target device.
14
+ function_code: Function code for the operation.
15
+ data: Data payload for the request.
16
+ telegram: Raw telegram string.
17
+ timestamp: Timestamp of the request.
18
+ """
9
19
 
10
20
  serial_number: Optional[str] = None
11
21
  function_code: Optional[str] = None
@@ -14,11 +24,16 @@ class ConbusRequest:
14
24
  timestamp: Optional[datetime] = None
15
25
 
16
26
  def __post_init__(self) -> None:
27
+ """Initialize timestamp if not provided."""
17
28
  if self.timestamp is None:
18
29
  self.timestamp = datetime.now()
19
30
 
20
31
  def to_dict(self) -> Dict[str, Any]:
21
- """Convert to dictionary for JSON serialization"""
32
+ """Convert to dictionary for JSON serialization.
33
+
34
+ Returns:
35
+ Dictionary representation of the request.
36
+ """
22
37
  return {
23
38
  "serial_number": self.serial_number,
24
39
  "function_code": self.function_code,
@@ -29,7 +44,17 @@ class ConbusRequest:
29
44
 
30
45
  @dataclass
31
46
  class ConbusResponse:
32
- """Represents a response from Conbus send operation"""
47
+ """Represents a response from Conbus send operation.
48
+
49
+ Attributes:
50
+ success: Whether the operation was successful.
51
+ sent_telegrams: List of telegrams sent.
52
+ received_telegrams: List of telegrams received.
53
+ timestamp: Timestamp of the response.
54
+ error: Error message if operation failed.
55
+ serial_number: Serial number of the device.
56
+ function_code: Function code used.
57
+ """
33
58
 
34
59
  success: bool
35
60
  sent_telegrams: list[str]
@@ -40,12 +65,17 @@ class ConbusResponse:
40
65
  function_code: str = ""
41
66
 
42
67
  def __post_init__(self) -> None:
68
+ """Initialize timestamp and telegram lists."""
43
69
  self.timestamp = datetime.now()
44
70
  self.sent_telegrams = []
45
71
  self.received_telegrams = []
46
72
 
47
73
  def to_dict(self) -> Dict[str, Any]:
48
- """Convert to dictionary for JSON serialization"""
74
+ """Convert to dictionary for JSON serialization.
75
+
76
+ Returns:
77
+ Dictionary representation of the response.
78
+ """
49
79
  return {
50
80
  "success": self.success,
51
81
  "serial_number": self.serial_number,
@@ -1,3 +1,5 @@
1
+ """Conbus auto report response model."""
2
+
1
3
  from dataclasses import dataclass
2
4
  from datetime import datetime
3
5
  from typing import Any, Dict, Optional
@@ -5,7 +7,18 @@ from typing import Any, Dict, Optional
5
7
 
6
8
  @dataclass
7
9
  class ConbusAutoreportResponse:
8
- """Represents a response from Conbus auto report operations (get/set)"""
10
+ """Represents a response from Conbus auto report operations (get/set).
11
+
12
+ Attributes:
13
+ success: Whether the operation was successful.
14
+ serial_number: Serial number of the device.
15
+ auto_report_status: Current auto report status.
16
+ result: Result message from set operation.
17
+ sent_telegram: Telegram sent to device.
18
+ received_telegrams: List of telegrams received.
19
+ error: Error message if operation failed.
20
+ timestamp: Timestamp of the response.
21
+ """
9
22
 
10
23
  success: bool
11
24
  serial_number: str
@@ -17,13 +30,18 @@ class ConbusAutoreportResponse:
17
30
  timestamp: Optional[datetime] = None
18
31
 
19
32
  def __post_init__(self) -> None:
33
+ """Initialize timestamp and received_telegrams if not provided."""
20
34
  if self.timestamp is None:
21
35
  self.timestamp = datetime.now()
22
36
  if self.received_telegrams is None:
23
37
  self.received_telegrams = []
24
38
 
25
39
  def to_dict(self) -> Dict[str, Any]:
26
- """Convert to dictionary for JSON serialization"""
40
+ """Convert to dictionary for JSON serialization.
41
+
42
+ Returns:
43
+ Dictionary representation of the response.
44
+ """
27
45
  result_dict: Dict[str, Any] = {
28
46
  "success": self.success,
29
47
  "serial_number": self.serial_number,
@@ -1,3 +1,5 @@
1
+ """Conbus blink response model."""
2
+
1
3
  from dataclasses import dataclass
2
4
  from datetime import datetime
3
5
  from typing import Any, Dict, Optional
@@ -10,7 +12,20 @@ from xp.models.telegram.system_telegram import SystemTelegram
10
12
 
11
13
  @dataclass
12
14
  class ConbusBlinkResponse:
13
- """Represents a response from Conbus send operation"""
15
+ """Represents a response from Conbus send operation.
16
+
17
+ Attributes:
18
+ success: Whether the operation was successful.
19
+ serial_number: Serial number of the device.
20
+ operation: Operation type (get or set).
21
+ system_function: System function used.
22
+ response: Response from Conbus operation.
23
+ reply_telegram: Reply telegram received.
24
+ sent_telegram: System telegram sent.
25
+ received_telegrams: List of telegrams received.
26
+ error: Error message if operation failed.
27
+ timestamp: Timestamp of the response.
28
+ """
14
29
 
15
30
  success: bool
16
31
  serial_number: str
@@ -24,13 +39,18 @@ class ConbusBlinkResponse:
24
39
  timestamp: Optional[datetime] = None
25
40
 
26
41
  def __post_init__(self) -> None:
42
+ """Initialize timestamp and received_telegrams if not provided."""
27
43
  if self.timestamp is None:
28
44
  self.timestamp = datetime.now()
29
45
  if self.received_telegrams is None:
30
46
  self.received_telegrams = []
31
47
 
32
48
  def to_dict(self) -> Dict[str, Any]:
33
- """Convert to dictionary for JSON serialization"""
49
+ """Convert to dictionary for JSON serialization.
50
+
51
+ Returns:
52
+ Dictionary representation of the response.
53
+ """
34
54
  result = {
35
55
  "success": self.success,
36
56
  "serial_number": self.serial_number,
@@ -1,3 +1,5 @@
1
+ """Conbus client configuration models."""
2
+
1
3
  import logging
2
4
  from pathlib import Path
3
5
 
@@ -6,19 +8,38 @@ from pydantic import BaseModel, Field
6
8
 
7
9
 
8
10
  class ClientConfig(BaseModel):
11
+ """Client connection configuration.
12
+
13
+ Attributes:
14
+ ip: IP address of the Conbus server.
15
+ port: Port number for the connection.
16
+ timeout: Connection timeout in seconds.
17
+ """
18
+
9
19
  ip: str = "192.168.1.100"
10
20
  port: int = 10001
11
21
  timeout: float = 0.1
12
22
 
13
23
 
14
24
  class ConbusClientConfig(BaseModel):
15
- """Configuration for Conbus client connection"""
25
+ """Configuration for Conbus client connection.
26
+
27
+ Attributes:
28
+ conbus: Client configuration settings.
29
+ """
16
30
 
17
31
  conbus: ClientConfig = Field(default_factory=ClientConfig)
18
32
 
19
33
  @classmethod
20
34
  def from_yaml(cls, file_path: str) -> "ConbusClientConfig":
35
+ """Load configuration from YAML file.
36
+
37
+ Args:
38
+ file_path: Path to the YAML configuration file.
21
39
 
40
+ Returns:
41
+ ConbusClientConfig instance loaded from file or default config.
42
+ """
22
43
  logger = logging.getLogger(__name__)
23
44
  try:
24
45
  with Path(file_path).open("r") as file:
@@ -1,3 +1,5 @@
1
+ """Conbus connection status model."""
2
+
1
3
  from dataclasses import dataclass
2
4
  from datetime import datetime
3
5
  from typing import Any, Dict, Optional
@@ -5,7 +7,15 @@ from typing import Any, Dict, Optional
5
7
 
6
8
  @dataclass
7
9
  class ConbusConnectionStatus:
8
- """Represents the current connection status"""
10
+ """Represents the current connection status.
11
+
12
+ Attributes:
13
+ connected: Whether currently connected.
14
+ ip: IP address of the connection.
15
+ port: Port number of the connection.
16
+ last_activity: Timestamp of last activity.
17
+ error: Error message if connection failed.
18
+ """
9
19
 
10
20
  connected: bool
11
21
  ip: str
@@ -14,7 +24,11 @@ class ConbusConnectionStatus:
14
24
  error: Optional[str] = None
15
25
 
16
26
  def to_dict(self) -> Dict[str, Any]:
17
- """Convert to dictionary for JSON serialization"""
27
+ """Convert to dictionary for JSON serialization.
28
+
29
+ Returns:
30
+ Dictionary representation of the connection status.
31
+ """
18
32
  return {
19
33
  "connected": self.connected,
20
34
  "ip": self.ip,
@@ -1,3 +1,5 @@
1
+ """Conbus custom response model."""
2
+
1
3
  from dataclasses import dataclass
2
4
  from datetime import datetime
3
5
  from typing import Any, Dict, Optional
@@ -7,7 +9,19 @@ from xp.models.telegram.reply_telegram import ReplyTelegram
7
9
 
8
10
  @dataclass
9
11
  class ConbusCustomResponse:
10
- """Represents a response from Conbus send operation"""
12
+ """Represents a response from Conbus send operation.
13
+
14
+ Attributes:
15
+ success: Whether the operation was successful.
16
+ serial_number: Serial number of the device.
17
+ function_code: Function code used.
18
+ data: Data payload.
19
+ sent_telegram: Telegram sent to device.
20
+ received_telegrams: List of telegrams received.
21
+ reply_telegram: Parsed reply telegram.
22
+ error: Error message if operation failed.
23
+ timestamp: Timestamp of the response.
24
+ """
11
25
 
12
26
  success: bool
13
27
  serial_number: Optional[str] = None
@@ -20,13 +34,18 @@ class ConbusCustomResponse:
20
34
  timestamp: Optional[datetime] = None
21
35
 
22
36
  def __post_init__(self) -> None:
37
+ """Initialize timestamp and received_telegrams if not provided."""
23
38
  if self.timestamp is None:
24
39
  self.timestamp = datetime.now()
25
40
  if self.received_telegrams is None:
26
41
  self.received_telegrams = []
27
42
 
28
43
  def to_dict(self) -> Dict[str, Any]:
29
- """Convert to dictionary for JSON serialization"""
44
+ """Convert to dictionary for JSON serialization.
45
+
46
+ Returns:
47
+ Dictionary representation of the response.
48
+ """
30
49
  return {
31
50
  "success": self.success,
32
51
  "serial_number": self.serial_number,
@@ -1,3 +1,5 @@
1
+ """Conbus datapoint response model."""
2
+
1
3
  from dataclasses import dataclass
2
4
  from datetime import datetime
3
5
  from typing import Any, Dict, List, Optional
@@ -9,7 +11,21 @@ from xp.models.telegram.system_function import SystemFunction
9
11
 
10
12
  @dataclass
11
13
  class ConbusDatapointResponse:
12
- """Represents a response from Conbus send operation"""
14
+ """Represents a response from Conbus send operation.
15
+
16
+ Attributes:
17
+ success: Whether the operation was successful.
18
+ serial_number: Serial number of the device.
19
+ system_function: System function used for query.
20
+ datapoint_type: Type of datapoint queried.
21
+ sent_telegram: Telegram sent to device.
22
+ received_telegrams: List of telegrams received.
23
+ datapoint_telegram: Parsed datapoint telegram.
24
+ data_value: Value of the datapoint telegram.
25
+ datapoints: List of datapoint values.
26
+ error: Error message if operation failed.
27
+ timestamp: Timestamp of the response.
28
+ """
13
29
 
14
30
  success: bool
15
31
  serial_number: Optional[str] = None
@@ -18,11 +34,13 @@ class ConbusDatapointResponse:
18
34
  sent_telegram: Optional[str] = None
19
35
  received_telegrams: Optional[list] = None
20
36
  datapoint_telegram: Optional[ReplyTelegram] = None
37
+ data_value: str = ""
21
38
  datapoints: Optional[List[Dict[str, str]]] = None
22
39
  error: Optional[str] = None
23
40
  timestamp: Optional[datetime] = None
24
41
 
25
42
  def __post_init__(self) -> None:
43
+ """Initialize timestamp, received_telegrams, and datapoints if not provided."""
26
44
  if self.timestamp is None:
27
45
  self.timestamp = datetime.now()
28
46
  if self.received_telegrams is None:
@@ -31,10 +49,15 @@ class ConbusDatapointResponse:
31
49
  self.datapoints = []
32
50
 
33
51
  def to_dict(self) -> Dict[str, Any]:
34
- """Convert to dictionary for JSON serialization"""
52
+ """Convert to dictionary for JSON serialization.
53
+
54
+ Returns:
55
+ Dictionary representation of the response.
56
+ """
35
57
  result: Dict[str, Any] = {
36
58
  "success": self.success,
37
59
  "serial_number": self.serial_number,
60
+ "data_value": self.data_value,
38
61
  "error": self.error,
39
62
  "timestamp": self.timestamp.isoformat() if self.timestamp else None,
40
63
  }
@@ -1,3 +1,5 @@
1
+ """Conbus discover response model."""
2
+
1
3
  from dataclasses import dataclass
2
4
  from datetime import datetime
3
5
  from typing import Any, Dict, Optional
@@ -5,7 +7,16 @@ from typing import Any, Dict, Optional
5
7
 
6
8
  @dataclass
7
9
  class ConbusDiscoverResponse:
8
- """Represents a response from Conbus send operation"""
10
+ """Represents a response from Conbus send operation.
11
+
12
+ Attributes:
13
+ success: Whether the operation was successful.
14
+ sent_telegram: Telegram sent to discover devices.
15
+ received_telegrams: List of telegrams received.
16
+ discovered_devices: List of discovered device serial numbers.
17
+ error: Error message if operation failed.
18
+ timestamp: Timestamp of the response.
19
+ """
9
20
 
10
21
  success: bool
11
22
  sent_telegram: Optional[str] = None
@@ -15,13 +26,18 @@ class ConbusDiscoverResponse:
15
26
  timestamp: Optional[datetime] = None
16
27
 
17
28
  def __post_init__(self) -> None:
29
+ """Initialize timestamp and received_telegrams if not provided."""
18
30
  if self.timestamp is None:
19
31
  self.timestamp = datetime.now()
20
32
  if self.received_telegrams is None:
21
33
  self.received_telegrams = []
22
34
 
23
35
  def to_dict(self) -> Dict[str, Any]:
24
- """Convert to dictionary for JSON serialization"""
36
+ """Convert to dictionary for JSON serialization.
37
+
38
+ Returns:
39
+ Dictionary representation of the response.
40
+ """
25
41
  return {
26
42
  "success": self.success,
27
43
  "sent_telegram": self.sent_telegram,
@@ -1,3 +1,5 @@
1
+ """Conbus light level response model."""
2
+
1
3
  from dataclasses import dataclass
2
4
  from datetime import datetime
3
5
  from typing import Any, Dict, Optional
@@ -5,7 +7,18 @@ from typing import Any, Dict, Optional
5
7
 
6
8
  @dataclass
7
9
  class ConbusLightlevelResponse:
8
- """Represents a response from Conbus lightlevel operation"""
10
+ """Represents a response from Conbus lightlevel operation.
11
+
12
+ Attributes:
13
+ success: Whether the operation was successful.
14
+ serial_number: Serial number of the device.
15
+ output_number: Output number queried.
16
+ level: Light level value (0-100).
17
+ timestamp: Timestamp of the response.
18
+ sent_telegram: Telegram sent to device.
19
+ received_telegrams: List of telegrams received.
20
+ error: Error message if operation failed.
21
+ """
9
22
 
10
23
  success: bool
11
24
  serial_number: str
@@ -17,11 +30,16 @@ class ConbusLightlevelResponse:
17
30
  error: Optional[str] = None
18
31
 
19
32
  def __post_init__(self) -> None:
33
+ """Initialize received_telegrams if not provided."""
20
34
  if self.received_telegrams is None:
21
35
  self.received_telegrams = []
22
36
 
23
37
  def to_dict(self) -> Dict[str, Any]:
24
- """Convert to dictionary for JSON serialization"""
38
+ """Convert to dictionary for JSON serialization.
39
+
40
+ Returns:
41
+ Dictionary representation of the response.
42
+ """
25
43
  return {
26
44
  "success": self.success,
27
45
  "serial_number": self.serial_number,
@@ -1,3 +1,5 @@
1
+ """Conbus link number response model."""
2
+
1
3
  from dataclasses import dataclass
2
4
  from datetime import datetime
3
5
  from typing import Any, Dict, Optional
@@ -5,7 +7,18 @@ from typing import Any, Dict, Optional
5
7
 
6
8
  @dataclass
7
9
  class ConbusLinknumberResponse:
8
- """Represents a response from Conbus link number operations (set/get)"""
10
+ """Represents a response from Conbus link number operations (set/get).
11
+
12
+ Attributes:
13
+ success: Whether the operation was successful.
14
+ serial_number: Serial number of the device.
15
+ result: Result message from operation.
16
+ sent_telegram: Telegram sent to device.
17
+ received_telegrams: List of telegrams received.
18
+ link_number: Link number value.
19
+ error: Error message if operation failed.
20
+ timestamp: Timestamp of the response.
21
+ """
9
22
 
10
23
  success: bool
11
24
  serial_number: str
@@ -17,13 +30,18 @@ class ConbusLinknumberResponse:
17
30
  timestamp: Optional[datetime] = None
18
31
 
19
32
  def __post_init__(self) -> None:
33
+ """Initialize timestamp and received_telegrams if not provided."""
20
34
  if self.timestamp is None:
21
35
  self.timestamp = datetime.now()
22
36
  if self.received_telegrams is None:
23
37
  self.received_telegrams = []
24
38
 
25
39
  def to_dict(self) -> Dict[str, Any]:
26
- """Convert to dictionary for JSON serialization"""
40
+ """Convert to dictionary for JSON serialization.
41
+
42
+ Returns:
43
+ Dictionary representation of the response.
44
+ """
27
45
  return {
28
46
  "success": self.success,
29
47
  "result": self.result,