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,3 +1,5 @@
1
+ """Conbus protocol event models."""
2
+
1
3
  from __future__ import annotations
2
4
 
3
5
  from typing import TYPE_CHECKING, Union
@@ -15,7 +17,11 @@ if TYPE_CHECKING:
15
17
 
16
18
 
17
19
  class ConnectionMadeEvent(BaseEvent):
18
- """Event dispatched when TCP connection is established"""
20
+ """Event dispatched when TCP connection is established.
21
+
22
+ Attributes:
23
+ protocol: Reference to the TelegramProtocol instance.
24
+ """
19
25
 
20
26
  protocol: TelegramProtocol = Field(
21
27
  description="Reference to the TelegramProtocol instance"
@@ -23,12 +29,25 @@ class ConnectionMadeEvent(BaseEvent):
23
29
 
24
30
 
25
31
  class ConnectionFailedEvent(BaseEvent):
26
- """Event dispatched when TCP connection fails"""
32
+ """Event dispatched when TCP connection fails.
33
+
34
+ Attributes:
35
+ reason: Failure reason.
36
+ """
27
37
 
28
38
  reason: str = Field(description="Failure reason")
29
39
 
30
40
 
31
41
  class SendWriteConfigEvent(BaseEvent):
42
+ """Event for sending write config commands.
43
+
44
+ Attributes:
45
+ serial_number: Serial number.
46
+ output_number: Output number.
47
+ datapoint_type: Datapoint type.
48
+ value: Set brightness value.
49
+ """
50
+
32
51
  serial_number: str = Field(description="Serial number")
33
52
  output_number: int = Field(description="Output number")
34
53
  datapoint_type: DataPointType = Field(description="Datapoint type")
@@ -36,25 +55,58 @@ class SendWriteConfigEvent(BaseEvent):
36
55
 
37
56
 
38
57
  class SendActionEvent(BaseEvent):
58
+ """Event for sending action commands.
59
+
60
+ Attributes:
61
+ serial_number: Serial number of the light bulb set.
62
+ output_number: Output number of the light bulb set.
63
+ value: Set light bulb On or Off (True/False).
64
+ """
65
+
39
66
  serial_number: str = Field(description="Serial number of the light bulb set")
40
67
  output_number: int = Field(description="Output number of the light bulb set")
41
68
  value: bool = Field(description="Set light bulb On or Off (True/False)")
42
69
 
43
70
 
44
71
  class DatapointEvent(BaseEvent):
72
+ """Base event for datapoint operations.
73
+
74
+ Attributes:
75
+ serial_number: Serial number of the light bulb set.
76
+ datapoint_type: Datapoint type.
77
+ """
78
+
45
79
  serial_number: str = Field(description="Serial number of the light bulb set")
46
80
  datapoint_type: DataPointType = Field(description="Datapoint type")
47
81
 
48
82
 
49
83
  class OutputStateReceivedEvent(DatapointEvent):
84
+ """Event when output state is received.
85
+
86
+ Attributes:
87
+ data_value: Data value.
88
+ """
89
+
50
90
  data_value: str = Field(description="Data value")
51
91
 
52
92
 
53
93
  class LightLevelReceivedEvent(DatapointEvent):
94
+ """Event when light level is received.
95
+
96
+ Attributes:
97
+ data_value: Data value.
98
+ """
99
+
54
100
  data_value: str = Field(description="Data value")
55
101
 
56
102
 
57
103
  class ReadDatapointEvent(DatapointEvent):
104
+ """Event to read datapoint.
105
+
106
+ Attributes:
107
+ refresh_cache: If True, force cache invalidation and fresh protocol query.
108
+ """
109
+
58
110
  refresh_cache: bool = Field(
59
111
  default=False,
60
112
  description="If True, force cache invalidation and fresh protocol query",
@@ -62,13 +114,20 @@ class ReadDatapointEvent(DatapointEvent):
62
114
 
63
115
 
64
116
  class ReadDatapointFromProtocolEvent(DatapointEvent):
65
- """Internal event for cache service to forward to protocol when cache misses"""
117
+ """Internal event for cache service to forward to protocol when cache misses."""
66
118
 
67
119
  pass
68
120
 
69
121
 
70
122
  class ModuleEvent(BaseEvent):
71
- """Event dispatched when light bulb set is on"""
123
+ """Event dispatched when light bulb set is on.
124
+
125
+ Attributes:
126
+ serial_number: Serial number of the light bulb set.
127
+ output_number: Output number of the light bulb set.
128
+ module: ConsonModuleConfig of the light bulb set.
129
+ accessory: HomekitAccessoryConfig of the light bulb set.
130
+ """
72
131
 
73
132
  serial_number: str = Field(description="Serial number of the light bulb set")
74
133
  output_number: int = Field(description="Output number of the light bulb set")
@@ -81,73 +140,111 @@ class ModuleEvent(BaseEvent):
81
140
 
82
141
 
83
142
  class LightBulbSetOnEvent(ModuleEvent):
84
- """Event dispatched when light bulb set is on"""
143
+ """Event dispatched when light bulb set is on.
144
+
145
+ Attributes:
146
+ value: On or Off the light bulb set.
147
+ """
85
148
 
86
149
  value: bool = Field(description="On or Off the light bulb set")
87
150
 
88
151
 
89
152
  class LightBulbGetOnEvent(ModuleEvent, BaseEvent[bool]):
90
- """Event dispatched when light bulb set is on"""
153
+ """Event dispatched when getting light bulb on state."""
91
154
 
92
155
  pass
93
156
 
94
157
 
95
158
  class OutletSetOnEvent(ModuleEvent):
96
- """Event dispatched when outlet set is on"""
159
+ """Event dispatched when outlet set is on.
160
+
161
+ Attributes:
162
+ value: On or Off the light bulb set.
163
+ """
97
164
 
98
165
  value: bool = Field(description="On or Off the light bulb set")
99
166
 
100
167
 
101
168
  class OutletGetOnEvent(ModuleEvent):
102
- """Event dispatched when outlet set is on"""
169
+ """Event dispatched when getting outlet on state."""
103
170
 
104
171
  pass
105
172
 
106
173
 
107
174
  class OutletGetInUseEvent(ModuleEvent):
108
- """Event dispatched when outlet set is on"""
175
+ """Event dispatched when getting outlet in-use state."""
109
176
 
110
177
  pass
111
178
 
112
179
 
113
180
  class OutletSetInUseEvent(ModuleEvent, BaseEvent[bool]):
114
- """Event dispatched when outlet set is on"""
181
+ """Event dispatched when outlet set is on.
182
+
183
+ Attributes:
184
+ value: On or Off the light bulb set.
185
+ """
115
186
 
116
187
  value: bool = Field(description="On or Off the light bulb set")
117
188
 
118
189
 
119
190
  class DimmingLightSetOnEvent(ModuleEvent):
120
- """Event dispatched when dimming light set is on"""
191
+ """Event dispatched when dimming light set is on.
192
+
193
+ Attributes:
194
+ value: On or Off the light bulb set.
195
+ brightness: Brightness of the light bulb set.
196
+ """
121
197
 
122
198
  value: bool = Field(description="On or Off the light bulb set")
123
199
  brightness: int = Field(description="Brightness of the light bulb set")
124
200
 
125
201
 
126
202
  class DimmingLightGetOnEvent(ModuleEvent):
127
- """Event dispatched when dimming light set is on"""
203
+ """Event dispatched when getting dimming light on state."""
128
204
 
129
205
  pass
130
206
 
131
207
 
132
208
  class DimmingLightSetBrightnessEvent(ModuleEvent):
133
- """Event dispatched when dimming light set is on"""
209
+ """Event dispatched when dimming light set is on.
210
+
211
+ Attributes:
212
+ brightness: Level of brightness of the dimming light.
213
+ """
134
214
 
135
215
  brightness: int = Field(description="Level of brightness of the dimming light")
136
216
 
137
217
 
138
218
  class DimmingLightGetBrightnessEvent(ModuleEvent):
139
- """Event dispatched when dimming light set is on"""
219
+ """Event dispatched when getting dimming light brightness."""
140
220
 
141
221
  pass
142
222
 
143
223
 
144
224
  class ConnectionLostEvent(BaseEvent):
145
- """Event dispatched when TCP connection is lost"""
225
+ """Event dispatched when TCP connection is lost.
226
+
227
+ Attributes:
228
+ reason: Disconnection reason.
229
+ """
146
230
 
147
231
  reason: str = Field(description="Disconnection reason")
148
232
 
149
233
 
150
234
  class TelegramEvent(BaseEvent):
235
+ """Event for telegram operations.
236
+
237
+ Attributes:
238
+ protocol: TelegramProtocol instance.
239
+ frame: Frame <S0123450001F02D12FK>.
240
+ telegram: Telegram S0123450001F02D12FK.
241
+ payload: Payload S0123450001F02D12.
242
+ telegram_type: Telegram type S.
243
+ serial_number: Serial number 0123450001 or empty.
244
+ checksum: Checksum FK.
245
+ checksum_valid: Checksum valid true or false.
246
+ """
247
+
151
248
  protocol: Union[TelegramProtocol, ConbusProtocol] = Field(
152
249
  description="TelegramProtocol instance"
153
250
  )
@@ -163,7 +260,14 @@ class TelegramEvent(BaseEvent):
163
260
 
164
261
 
165
262
  class ModuleStateChangedEvent(BaseEvent):
166
- """Event dispatched when a module's state changes (from event telegram)"""
263
+ """Event dispatched when a module's state changes (from event telegram).
264
+
265
+ Attributes:
266
+ module_type_code: Module type code from event telegram.
267
+ link_number: Link number from event telegram.
268
+ input_number: Input number that triggered the event.
269
+ telegram_event_type: Event type (M=press, B=release).
270
+ """
167
271
 
168
272
  module_type_code: int = Field(description="Module type code from event telegram")
169
273
  link_number: int = Field(description="Link number from event telegram")
@@ -172,27 +276,32 @@ class ModuleStateChangedEvent(BaseEvent):
172
276
 
173
277
 
174
278
  class EventTelegramReceivedEvent(TelegramEvent):
175
- """Event telegram received"""
279
+ """Event telegram received."""
176
280
 
177
281
  pass
178
282
 
179
283
 
180
284
  class ModuleDiscoveredEvent(TelegramEvent):
181
- """Event dispatched when module is discovered"""
285
+ """Event dispatched when module is discovered."""
182
286
 
183
287
  pass
184
288
 
185
289
 
186
290
  class TelegramReceivedEvent(TelegramEvent):
187
- """Event dispatched when a telegram frame is received"""
291
+ """Event dispatched when a telegram frame is received."""
188
292
 
189
293
  pass
190
294
 
191
295
 
192
296
  class InvalidTelegramReceivedEvent(BaseEvent):
193
- """Event dispatched when an invalid telegram frame is received"""
297
+ """Event dispatched when an invalid telegram frame is received.
298
+
299
+ Attributes:
300
+ protocol: TelegramProtocol instance.
301
+ frame: Frame <S0123450001F02D12FK>.
302
+ error: Error with the received telegram.
303
+ """
194
304
 
195
305
  protocol: TelegramProtocol = Field(description="TelegramProtocol instance")
196
306
  frame: str = Field(description="Frame <S0123450001F02D12FK>")
197
307
  error: str = Field(description="Error with the received telegram")
198
- pass
@@ -0,0 +1 @@
1
+ """Telegram models for console bus communication."""
@@ -1,16 +1,30 @@
1
+ """Action type enumeration for XP24 telegrams."""
2
+
1
3
  from enum import Enum
2
4
  from typing import Optional
3
5
 
4
6
 
5
7
  class ActionType(Enum):
6
- """Action types for XP24 telegrams"""
8
+ """Action types for XP24 telegrams.
9
+
10
+ Attributes:
11
+ OFF_PRESS: Make action (activate relay).
12
+ ON_RELEASE: Break action (deactivate relay).
13
+ """
7
14
 
8
15
  OFF_PRESS = "AA" # Make action (activate relay)
9
16
  ON_RELEASE = "AB" # Break action (deactivate relay)
10
17
 
11
18
  @classmethod
12
19
  def from_code(cls, code: str) -> Optional["ActionType"]:
13
- """Get ActionType from code string"""
20
+ """Get ActionType from code string.
21
+
22
+ Args:
23
+ code: Action code string.
24
+
25
+ Returns:
26
+ ActionType instance if found, None otherwise.
27
+ """
14
28
  for action in cls:
15
29
  if action.value == code:
16
30
  return action
@@ -1,9 +1,36 @@
1
+ """Datapoint type enumeration for system telegrams."""
2
+
1
3
  from enum import Enum
2
4
  from typing import Optional
3
5
 
4
6
 
5
7
  class DataPointType(str, Enum):
6
- """Data point types for system telegrams"""
8
+ """Data point types for system telegrams.
9
+
10
+ Attributes:
11
+ MODULE_TYPE: Module type (XP24, XP33, etc).
12
+ HW_VERSION: Hardware version information.
13
+ SW_VERSION: Software version information.
14
+ SERIAL_NUMBER: Serial number.
15
+ LINK_NUMBER: Link number.
16
+ MODULE_NUMBER: Module number.
17
+ SYSTEM_TYPE: System type.
18
+ MODULE_TYPE_CODE: Module type code.
19
+ MODULE_TYPE_ID: Module type ID.
20
+ MODULE_STATE: Module state.
21
+ MODULE_ERROR_CODE: Status query data point.
22
+ MODULE_INPUT_STATE: Module input state.
23
+ MODULE_OUTPUT_STATE: Channel states (XP33).
24
+ MODULE_FW_CRC: Module firmware CRC.
25
+ MODULE_ACTION_TABLE_CRC: Module action table CRC.
26
+ MODULE_LIGHT_LEVEL: Module light level.
27
+ MODULE_OPERATING_HOURS: Module operating hours.
28
+ MODULE_ENERGY_LEVEL: Current data point.
29
+ TEMPERATURE: Temperature data point.
30
+ SW_TOP_VERSION: Software top version.
31
+ VOLTAGE: Voltage data point.
32
+ AUTO_REPORT_STATUS: Auto report status.
33
+ """
7
34
 
8
35
  MODULE_TYPE = "00" # Module type (XP24, XP33, ..)
9
36
  HW_VERSION = "01" # Hardware version information
@@ -41,7 +68,14 @@ class DataPointType(str, Enum):
41
68
 
42
69
  @classmethod
43
70
  def from_code(cls, code: str) -> Optional["DataPointType"]:
44
- """Get DataPointType from code string"""
71
+ """Get DataPointType from code string.
72
+
73
+ Args:
74
+ code: Datapoint type code string.
75
+
76
+ Returns:
77
+ DataPointType instance if found, None otherwise.
78
+ """
45
79
  for dp_type in cls:
46
80
  if dp_type.value == code:
47
81
  return dp_type
@@ -1,3 +1,5 @@
1
+ """Event telegram model for console bus communication."""
2
+
1
3
  from dataclasses import dataclass
2
4
  from datetime import datetime
3
5
  from typing import Any, Optional
@@ -11,14 +13,23 @@ from xp.models.telegram.telegram_type import TelegramType
11
13
 
12
14
  @dataclass
13
15
  class EventTelegram(Telegram):
14
- """
15
- Represents a parsed event telegram from the console bus.
16
+ r"""Represent a parsed event telegram from the console bus.
16
17
 
17
18
  Format: <[EO]{module_type}L{link_number}I{input_number}{event_type}{checksum}>
18
- Examples:
19
19
 
20
- \b
20
+ Examples:
21
21
  <E14L00I02MAK>
22
+
23
+ Attributes:
24
+ event_telegram_type: Event telegram type (E or O).
25
+ module_type: Module type code.
26
+ link_number: Link number.
27
+ input_number: Input number.
28
+ event_type: Type of event (press or release).
29
+ module_info: Module type information if found.
30
+ input_type: Input type based on input number.
31
+ is_button_press: True if this is a button press event.
32
+ is_button_release: True if this is a button release event.
22
33
  """
23
34
 
24
35
  event_telegram_type: str = "E" # E or O
@@ -28,18 +39,27 @@ class EventTelegram(Telegram):
28
39
  event_type: Optional[EventType] = None
29
40
 
30
41
  def __post_init__(self) -> None:
42
+ """Initialize timestamp and telegram type."""
31
43
  if self.timestamp is None:
32
44
  self.timestamp = datetime.now()
33
45
  self.telegram_type = TelegramType.EVENT
34
46
 
35
47
  @property
36
48
  def module_info(self) -> Optional[ModuleType]:
37
- """Get module type information for this telegram"""
49
+ """Get module type information for this telegram.
50
+
51
+ Returns:
52
+ ModuleType instance if found, None otherwise.
53
+ """
38
54
  return ModuleType.from_code(self.module_type)
39
55
 
40
56
  @property
41
57
  def input_type(self) -> InputType:
42
- """Determines the input type based on input number"""
58
+ """Determines the input type based on input number.
59
+
60
+ Returns:
61
+ InputType enum value.
62
+ """
43
63
  if 0 <= self.input_number <= 9:
44
64
  return InputType.PUSH_BUTTON
45
65
  elif 10 <= self.input_number <= 89:
@@ -51,16 +71,28 @@ class EventTelegram(Telegram):
51
71
 
52
72
  @property
53
73
  def is_button_press(self) -> bool:
54
- """True if this is a button press event"""
74
+ """True if this is a button press event.
75
+
76
+ Returns:
77
+ True if event is a button press, False otherwise.
78
+ """
55
79
  return self.event_type == EventType.BUTTON_PRESS
56
80
 
57
81
  @property
58
82
  def is_button_release(self) -> bool:
59
- """True if this is a button release event"""
83
+ """True if this is a button release event.
84
+
85
+ Returns:
86
+ True if event is a button release, False otherwise.
87
+ """
60
88
  return self.event_type == EventType.BUTTON_RELEASE
61
89
 
62
90
  def to_dict(self) -> dict[str, Any]:
63
- """Convert to dictionary for JSON serialization"""
91
+ """Convert to dictionary for JSON serialization.
92
+
93
+ Returns:
94
+ Dictionary representation of the event telegram.
95
+ """
64
96
  result: dict[str, Any] = {
65
97
  "module_type": self.module_type,
66
98
  "link_number": self.link_number,
@@ -90,7 +122,11 @@ class EventTelegram(Telegram):
90
122
  return result
91
123
 
92
124
  def __str__(self) -> str:
93
- """Human-readable string representation"""
125
+ """Human-readable string representation.
126
+
127
+ Returns:
128
+ Formatted string representation.
129
+ """
94
130
  event_desc = "pressed" if self.is_button_press else "released"
95
131
 
96
132
  # Include module name if available
@@ -1,8 +1,15 @@
1
+ """Event type enumeration for telegram events."""
2
+
1
3
  from enum import Enum
2
4
 
3
5
 
4
6
  class EventType(Enum):
5
- """Event types for telegraph events"""
7
+ """Event types for telegraph events.
8
+
9
+ Attributes:
10
+ BUTTON_PRESS: Button make (press) event.
11
+ BUTTON_RELEASE: Button break (release) event.
12
+ """
6
13
 
7
14
  BUTTON_PRESS = "M" # Make
8
15
  BUTTON_RELEASE = "B" # Break
@@ -1,10 +1,42 @@
1
- """Input action types for XP24 module based on Feature-Action-Table.md"""
1
+ """Input action types for XP24 module based on Feature-Action-Table.md."""
2
2
 
3
3
  from enum import IntEnum
4
4
 
5
5
 
6
6
  class InputActionType(IntEnum):
7
- """Input action types for XP24 module (based on Feature-Action-Table.md)"""
7
+ """Input action types for XP24 module (based on Feature-Action-Table.md).
8
+
9
+ Attributes:
10
+ VOID: No action.
11
+ TURNON: Turn on action.
12
+ TURNOFF: Turn off action.
13
+ TOGGLE: Toggle action.
14
+ BLOCK: Block action.
15
+ AUXRELAY: Auxiliary relay action.
16
+ MUTUALEX: Mutual exclusion action.
17
+ LEVELUP: Level up action.
18
+ LEVELDOWN: Level down action.
19
+ LEVELINC: Level increment action.
20
+ LEVELDEC: Level decrement action.
21
+ LEVELSET: Level set action.
22
+ FADETIME: Fade time action.
23
+ SCENESET: Scene set action.
24
+ SCENENEXT: Scene next action.
25
+ SCENEPREV: Scene previous action.
26
+ CTRLMETHOD: Control method action.
27
+ RETURNDATA: Return data action.
28
+ DELAYEDON: Delayed on action.
29
+ EVENTTIMER1: Event timer 1 action.
30
+ EVENTTIMER2: Event timer 2 action.
31
+ EVENTTIMER3: Event timer 3 action.
32
+ EVENTTIMER4: Event timer 4 action.
33
+ STEPCTRL: Step control action.
34
+ STEPCTRLUP: Step control up action.
35
+ STEPCTRLDOWN: Step control down action.
36
+ LEVELSETINTERN: Level set internal action.
37
+ FADE: Fade action.
38
+ LEARN: Learn action.
39
+ """
8
40
 
9
41
  VOID = 0
10
42
  TURNON = 1
@@ -1,8 +1,16 @@
1
+ """Input type enumeration based on input number ranges."""
2
+
1
3
  from enum import Enum
2
4
 
3
5
 
4
6
  class InputType(Enum):
5
- """Input types based on input number ranges"""
7
+ """Input types based on input number ranges.
8
+
9
+ Attributes:
10
+ PUSH_BUTTON: Push button input (range 00-09).
11
+ IR_REMOTE: IR remote input (range 10-89).
12
+ PROXIMITY_SENSOR: Proximity sensor input (input 90).
13
+ """
6
14
 
7
15
  PUSH_BUTTON = "push_button" # Input 00-09
8
16
  IR_REMOTE = "ir_remote" # Input 10-89