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.
- {conson_xp-1.0.1.dist-info → conson_xp-1.2.0.dist-info}/METADATA +1 -1
- conson_xp-1.2.0.dist-info/RECORD +181 -0
- xp/__init__.py +4 -3
- xp/api/main.py +18 -3
- xp/api/models/api.py +13 -2
- xp/api/models/discover.py +12 -2
- xp/api/routers/conbus_blink.py +18 -6
- xp/api/routers/conbus_custom.py +11 -3
- xp/api/routers/conbus_datapoint.py +10 -3
- xp/api/routers/conbus_output.py +29 -9
- xp/api/routers/errors.py +6 -5
- xp/cli/__init__.py +1 -1
- xp/cli/commands/__init__.py +1 -0
- xp/cli/commands/api.py +1 -5
- xp/cli/commands/api_start_commands.py +14 -8
- xp/cli/commands/conbus/conbus.py +9 -37
- xp/cli/commands/conbus/conbus_actiontable_commands.py +21 -1
- xp/cli/commands/conbus/conbus_autoreport_commands.py +21 -11
- xp/cli/commands/conbus/conbus_blink_commands.py +53 -21
- xp/cli/commands/conbus/conbus_config_commands.py +7 -4
- xp/cli/commands/conbus/conbus_custom_commands.py +13 -4
- xp/cli/commands/conbus/conbus_datapoint_commands.py +28 -8
- xp/cli/commands/conbus/conbus_discover_commands.py +15 -4
- xp/cli/commands/conbus/conbus_lightlevel_commands.py +50 -11
- xp/cli/commands/conbus/conbus_linknumber_commands.py +21 -11
- xp/cli/commands/conbus/conbus_msactiontable_commands.py +25 -1
- xp/cli/commands/conbus/conbus_output_commands.py +46 -12
- xp/cli/commands/conbus/conbus_raw_commands.py +17 -6
- xp/cli/commands/conbus/conbus_receive_commands.py +15 -7
- xp/cli/commands/conbus/conbus_scan_commands.py +35 -102
- xp/cli/commands/file_commands.py +26 -15
- xp/cli/commands/homekit/homekit.py +14 -8
- xp/cli/commands/homekit/homekit_start_commands.py +5 -5
- xp/cli/commands/module_commands.py +26 -19
- xp/cli/commands/reverse_proxy_commands.py +24 -18
- xp/cli/commands/server/server_commands.py +18 -18
- xp/cli/commands/telegram/telegram.py +4 -12
- xp/cli/commands/telegram/telegram_blink_commands.py +10 -8
- xp/cli/commands/telegram/telegram_checksum_commands.py +19 -8
- xp/cli/commands/telegram/telegram_discover_commands.py +2 -4
- xp/cli/commands/telegram/telegram_linknumber_commands.py +11 -8
- xp/cli/commands/telegram/telegram_parse_commands.py +10 -9
- xp/cli/commands/telegram/telegram_version_commands.py +8 -4
- xp/cli/main.py +5 -1
- xp/cli/utils/click_tree.py +23 -3
- xp/cli/utils/datapoint_type_choice.py +20 -0
- xp/cli/utils/decorators.py +165 -14
- xp/cli/utils/error_handlers.py +49 -18
- xp/cli/utils/formatters.py +95 -10
- xp/cli/utils/serial_number_type.py +18 -0
- xp/cli/utils/system_function_choice.py +20 -0
- xp/cli/utils/xp_module_type.py +20 -0
- xp/connection/__init__.py +1 -1
- xp/connection/exceptions.py +5 -5
- xp/models/__init__.py +1 -1
- xp/models/actiontable/__init__.py +1 -0
- xp/models/actiontable/actiontable.py +17 -1
- xp/models/actiontable/msactiontable_xp20.py +10 -0
- xp/models/actiontable/msactiontable_xp24.py +20 -3
- xp/models/actiontable/msactiontable_xp33.py +27 -4
- xp/models/conbus/__init__.py +1 -0
- xp/models/conbus/conbus.py +34 -4
- xp/models/conbus/conbus_autoreport.py +20 -2
- xp/models/conbus/conbus_blink.py +22 -2
- xp/models/conbus/conbus_client_config.py +22 -1
- xp/models/conbus/conbus_connection_status.py +16 -2
- xp/models/conbus/conbus_custom.py +21 -2
- xp/models/conbus/conbus_datapoint.py +22 -2
- xp/models/conbus/conbus_discover.py +18 -2
- xp/models/conbus/conbus_lightlevel.py +20 -2
- xp/models/conbus/conbus_linknumber.py +20 -2
- xp/models/conbus/conbus_output.py +22 -2
- xp/models/conbus/conbus_raw.py +17 -2
- xp/models/conbus/conbus_receive.py +16 -2
- xp/models/homekit/__init__.py +1 -0
- xp/models/homekit/homekit_accessory.py +15 -1
- xp/models/homekit/homekit_config.py +52 -0
- xp/models/homekit/homekit_conson_config.py +32 -0
- xp/models/log_entry.py +49 -9
- xp/models/protocol/__init__.py +1 -0
- xp/models/protocol/conbus_protocol.py +130 -21
- xp/models/telegram/__init__.py +1 -0
- xp/models/telegram/action_type.py +16 -2
- xp/models/telegram/datapoint_type.py +36 -2
- xp/models/telegram/event_telegram.py +46 -10
- xp/models/telegram/event_type.py +8 -1
- xp/models/telegram/input_action_type.py +34 -2
- xp/models/telegram/input_type.py +9 -1
- xp/models/telegram/module_type.py +69 -19
- xp/models/telegram/module_type_code.py +43 -1
- xp/models/telegram/output_telegram.py +30 -6
- xp/models/telegram/reply_telegram.py +56 -11
- xp/models/telegram/system_function.py +35 -3
- xp/models/telegram/system_telegram.py +18 -4
- xp/models/telegram/telegram.py +12 -3
- xp/models/telegram/telegram_type.py +8 -1
- xp/models/telegram/timeparam_type.py +27 -0
- xp/models/write_config_type.py +17 -2
- xp/services/__init__.py +1 -1
- xp/services/conbus/__init__.py +1 -0
- xp/services/conbus/actiontable/__init__.py +1 -0
- xp/services/conbus/actiontable/actiontable_service.py +33 -2
- xp/services/conbus/actiontable/msactiontable_service.py +40 -3
- xp/services/conbus/actiontable/msactiontable_xp24_serializer.py +36 -4
- xp/services/conbus/actiontable/msactiontable_xp33_serializer.py +45 -5
- xp/services/conbus/conbus_autoreport_get_service.py +17 -8
- xp/services/conbus/conbus_autoreport_set_service.py +29 -16
- xp/services/conbus/conbus_blink_all_service.py +40 -21
- xp/services/conbus/conbus_blink_service.py +37 -13
- xp/services/conbus/conbus_custom_service.py +29 -13
- xp/services/conbus/conbus_datapoint_queryall_service.py +40 -16
- xp/services/conbus/conbus_datapoint_service.py +33 -12
- xp/services/conbus/conbus_discover_service.py +43 -7
- xp/services/conbus/conbus_lightlevel_get_service.py +22 -14
- xp/services/conbus/conbus_lightlevel_set_service.py +40 -20
- xp/services/conbus/conbus_linknumber_get_service.py +18 -10
- xp/services/conbus/conbus_linknumber_set_service.py +34 -8
- xp/services/conbus/conbus_output_service.py +33 -13
- xp/services/conbus/conbus_raw_service.py +36 -16
- xp/services/conbus/conbus_receive_service.py +38 -6
- xp/services/conbus/conbus_scan_service.py +45 -19
- xp/services/homekit/__init__.py +1 -0
- xp/services/homekit/homekit_cache_service.py +31 -6
- xp/services/homekit/homekit_conbus_service.py +33 -2
- xp/services/homekit/homekit_config_validator.py +97 -15
- xp/services/homekit/homekit_conson_validator.py +51 -7
- xp/services/homekit/homekit_dimminglight.py +47 -1
- xp/services/homekit/homekit_dimminglight_service.py +35 -1
- xp/services/homekit/homekit_hap_service.py +71 -18
- xp/services/homekit/homekit_lightbulb.py +35 -1
- xp/services/homekit/homekit_lightbulb_service.py +30 -2
- xp/services/homekit/homekit_module_service.py +23 -1
- xp/services/homekit/homekit_outlet.py +47 -1
- xp/services/homekit/homekit_outlet_service.py +44 -2
- xp/services/homekit/homekit_service.py +113 -19
- xp/services/log_file_service.py +37 -41
- xp/services/module_type_service.py +26 -5
- xp/services/protocol/__init__.py +1 -1
- xp/services/protocol/conbus_protocol.py +115 -20
- xp/services/protocol/protocol_factory.py +40 -0
- xp/services/protocol/telegram_protocol.py +38 -7
- xp/services/reverse_proxy_service.py +79 -14
- xp/services/server/__init__.py +1 -0
- xp/services/server/base_server_service.py +102 -14
- xp/services/server/cp20_server_service.py +12 -4
- xp/services/server/server_service.py +26 -11
- xp/services/server/xp130_server_service.py +11 -3
- xp/services/server/xp20_server_service.py +11 -3
- xp/services/server/xp230_server_service.py +11 -3
- xp/services/server/xp24_server_service.py +33 -6
- xp/services/server/xp33_server_service.py +41 -8
- xp/services/telegram/__init__.py +1 -0
- xp/services/telegram/telegram_blink_service.py +19 -31
- xp/services/telegram/telegram_checksum_service.py +10 -10
- xp/services/telegram/telegram_discover_service.py +58 -29
- xp/services/telegram/telegram_link_number_service.py +27 -40
- xp/services/telegram/telegram_output_service.py +46 -49
- xp/services/telegram/telegram_service.py +41 -41
- xp/services/telegram/telegram_version_service.py +4 -2
- xp/utils/__init__.py +1 -1
- xp/utils/dependencies.py +0 -1
- xp/utils/serialization.py +6 -0
- xp/utils/time_utils.py +6 -11
- conson_xp-1.0.1.dist-info/RECORD +0 -181
- {conson_xp-1.0.1.dist-info → conson_xp-1.2.0.dist-info}/WHEEL +0 -0
- {conson_xp-1.0.1.dist-info → conson_xp-1.2.0.dist-info}/entry_points.txt +0 -0
- {conson_xp-1.0.1.dist-info → conson_xp-1.2.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -22,15 +22,15 @@ from xp.services.conbus.conbus_linknumber_set_service import ConbusLinknumberSet
|
|
|
22
22
|
def set_linknumber_command(
|
|
23
23
|
ctx: click.Context, serial_number: str, link_number: int
|
|
24
24
|
) -> None:
|
|
25
|
-
"""
|
|
26
|
-
Set the link number for a specific module.
|
|
25
|
+
r"""Set the link number for a specific module.
|
|
27
26
|
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
Args:
|
|
28
|
+
ctx: Click context object.
|
|
29
|
+
serial_number: 10-digit module serial number.
|
|
30
|
+
link_number: Link number to set (0-99).
|
|
30
31
|
|
|
31
32
|
Examples:
|
|
32
|
-
|
|
33
|
-
\b
|
|
33
|
+
\b
|
|
34
34
|
xp conbus linknumber set 0123450001 25
|
|
35
35
|
"""
|
|
36
36
|
service = (
|
|
@@ -38,6 +38,11 @@ def set_linknumber_command(
|
|
|
38
38
|
)
|
|
39
39
|
|
|
40
40
|
def on_finish(response: ConbusLinknumberResponse) -> None:
|
|
41
|
+
"""Handle successful completion of link number set command.
|
|
42
|
+
|
|
43
|
+
Args:
|
|
44
|
+
response: Link number response object.
|
|
45
|
+
"""
|
|
41
46
|
click.echo(json.dumps(response.to_dict(), indent=2))
|
|
42
47
|
|
|
43
48
|
with service:
|
|
@@ -53,14 +58,14 @@ def set_linknumber_command(
|
|
|
53
58
|
@click.pass_context
|
|
54
59
|
@connection_command()
|
|
55
60
|
def get_linknumber_command(ctx: click.Context, serial_number: str) -> None:
|
|
56
|
-
"""
|
|
57
|
-
Get the current link number for a specific module.
|
|
61
|
+
r"""Get the current link number for a specific module.
|
|
58
62
|
|
|
59
|
-
|
|
63
|
+
Args:
|
|
64
|
+
ctx: Click context object.
|
|
65
|
+
serial_number: 10-digit module serial number.
|
|
60
66
|
|
|
61
67
|
Examples:
|
|
62
|
-
|
|
63
|
-
\b
|
|
68
|
+
\b
|
|
64
69
|
xp conbus linknumber get 0123450001
|
|
65
70
|
"""
|
|
66
71
|
service = (
|
|
@@ -68,6 +73,11 @@ def get_linknumber_command(ctx: click.Context, serial_number: str) -> None:
|
|
|
68
73
|
)
|
|
69
74
|
|
|
70
75
|
def on_finish(response: ConbusLinknumberResponse) -> None:
|
|
76
|
+
"""Handle successful completion of link number get command.
|
|
77
|
+
|
|
78
|
+
Args:
|
|
79
|
+
response: Link number response object.
|
|
80
|
+
"""
|
|
71
81
|
click.echo(json.dumps(response.to_dict(), indent=2))
|
|
72
82
|
|
|
73
83
|
with service:
|
|
@@ -26,13 +26,29 @@ from xp.services.conbus.actiontable.msactiontable_service import (
|
|
|
26
26
|
def conbus_download_msactiontable(
|
|
27
27
|
ctx: Context, serial_number: str, xpmoduletype: str
|
|
28
28
|
) -> None:
|
|
29
|
-
"""Download MS action table from XP24 module
|
|
29
|
+
"""Download MS action table from XP24 module.
|
|
30
|
+
|
|
31
|
+
Args:
|
|
32
|
+
ctx: Click context object.
|
|
33
|
+
serial_number: 10-digit module serial number.
|
|
34
|
+
xpmoduletype: XP module type.
|
|
35
|
+
"""
|
|
30
36
|
service = ctx.obj.get("container").get_container().resolve(MsActionTableService)
|
|
31
37
|
|
|
32
38
|
def progress_callback(progress: str) -> None:
|
|
39
|
+
"""Handle progress updates during MS action table download.
|
|
40
|
+
|
|
41
|
+
Args:
|
|
42
|
+
progress: Progress message string.
|
|
43
|
+
"""
|
|
33
44
|
click.echo(progress, nl=False)
|
|
34
45
|
|
|
35
46
|
def finish_callback(action_table: ActionTable) -> None:
|
|
47
|
+
"""Handle successful completion of MS action table download.
|
|
48
|
+
|
|
49
|
+
Args:
|
|
50
|
+
action_table: Downloaded MS action table object.
|
|
51
|
+
"""
|
|
36
52
|
output = {
|
|
37
53
|
"serial_number": serial_number,
|
|
38
54
|
"xpmoduletype": xpmoduletype,
|
|
@@ -41,6 +57,14 @@ def conbus_download_msactiontable(
|
|
|
41
57
|
click.echo(json.dumps(output, indent=2, default=str))
|
|
42
58
|
|
|
43
59
|
def error_callback(error: str) -> None:
|
|
60
|
+
"""Handle errors during MS action table download.
|
|
61
|
+
|
|
62
|
+
Args:
|
|
63
|
+
error: Error message string.
|
|
64
|
+
|
|
65
|
+
Raises:
|
|
66
|
+
Abort: Always raised to abort the command on error.
|
|
67
|
+
"""
|
|
44
68
|
click.echo(f"Error: {error}")
|
|
45
69
|
raise click.Abort()
|
|
46
70
|
|
|
@@ -23,16 +23,25 @@ from xp.services.conbus.conbus_output_service import ConbusOutputService
|
|
|
23
23
|
@click.pass_context
|
|
24
24
|
@connection_command()
|
|
25
25
|
def xp_output_on(ctx: click.Context, serial_number: str, output_number: int) -> None:
|
|
26
|
-
"""Send ON command for output_number XP module serial_number
|
|
26
|
+
r"""Send ON command for output_number XP module serial_number.
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
Args:
|
|
29
|
+
ctx: Click context object.
|
|
30
|
+
serial_number: 10-digit module serial number.
|
|
31
|
+
output_number: Output number.
|
|
29
32
|
|
|
30
|
-
|
|
33
|
+
Examples:
|
|
34
|
+
\b
|
|
31
35
|
xp conbus output on 0011223344 0 # Turn on output 0
|
|
32
36
|
"""
|
|
33
37
|
service = ctx.obj.get("container").get_container().resolve(ConbusOutputService)
|
|
34
38
|
|
|
35
39
|
def on_finish(response: ConbusOutputResponse) -> None:
|
|
40
|
+
"""Handle successful completion of output on command.
|
|
41
|
+
|
|
42
|
+
Args:
|
|
43
|
+
response: Output response object.
|
|
44
|
+
"""
|
|
36
45
|
click.echo(json.dumps(response.to_dict(), indent=2))
|
|
37
46
|
|
|
38
47
|
with service:
|
|
@@ -50,16 +59,25 @@ def xp_output_on(ctx: click.Context, serial_number: str, output_number: int) ->
|
|
|
50
59
|
@click.pass_context
|
|
51
60
|
@connection_command()
|
|
52
61
|
def xp_output_off(ctx: click.Context, serial_number: str, output_number: int) -> None:
|
|
53
|
-
"""Send OFF command for output_number XP module serial_number
|
|
62
|
+
r"""Send OFF command for output_number XP module serial_number.
|
|
54
63
|
|
|
55
|
-
|
|
64
|
+
Args:
|
|
65
|
+
ctx: Click context object.
|
|
66
|
+
serial_number: 10-digit module serial number.
|
|
67
|
+
output_number: Output number.
|
|
56
68
|
|
|
57
|
-
|
|
69
|
+
Examples:
|
|
70
|
+
\b
|
|
58
71
|
xp conbus output off 0011223344 1 # Turn off output 1
|
|
59
72
|
"""
|
|
60
73
|
service = ctx.obj.get("container").get_container().resolve(ConbusOutputService)
|
|
61
74
|
|
|
62
75
|
def on_finish(response: ConbusOutputResponse) -> None:
|
|
76
|
+
"""Handle successful completion of output off command.
|
|
77
|
+
|
|
78
|
+
Args:
|
|
79
|
+
response: Output response object.
|
|
80
|
+
"""
|
|
63
81
|
click.echo(json.dumps(response.to_dict(), indent=2))
|
|
64
82
|
|
|
65
83
|
with service:
|
|
@@ -76,11 +94,14 @@ def xp_output_off(ctx: click.Context, serial_number: str, output_number: int) ->
|
|
|
76
94
|
@click.pass_context
|
|
77
95
|
@connection_command()
|
|
78
96
|
def xp_output_status(ctx: click.Context, serial_number: str) -> None:
|
|
79
|
-
"""Query output state command to XP module serial_number.
|
|
97
|
+
r"""Query output state command to XP module serial_number.
|
|
80
98
|
|
|
81
|
-
|
|
99
|
+
Args:
|
|
100
|
+
ctx: Click context object.
|
|
101
|
+
serial_number: 10-digit module serial number.
|
|
82
102
|
|
|
83
|
-
|
|
103
|
+
Examples:
|
|
104
|
+
\b
|
|
84
105
|
xp conbus output status 0011223344 # Query output status
|
|
85
106
|
"""
|
|
86
107
|
service: ConbusDatapointService = (
|
|
@@ -88,6 +109,11 @@ def xp_output_status(ctx: click.Context, serial_number: str) -> None:
|
|
|
88
109
|
)
|
|
89
110
|
|
|
90
111
|
def on_finish(response: ConbusDatapointResponse) -> None:
|
|
112
|
+
"""Handle successful completion of output status query.
|
|
113
|
+
|
|
114
|
+
Args:
|
|
115
|
+
response: Datapoint response object.
|
|
116
|
+
"""
|
|
91
117
|
click.echo(json.dumps(response.to_dict(), indent=2))
|
|
92
118
|
|
|
93
119
|
with service:
|
|
@@ -103,11 +129,14 @@ def xp_output_status(ctx: click.Context, serial_number: str) -> None:
|
|
|
103
129
|
@click.pass_context
|
|
104
130
|
@connection_command()
|
|
105
131
|
def xp_module_state(ctx: click.Context, serial_number: str) -> None:
|
|
106
|
-
"""Query module state of the XP module serial_number
|
|
132
|
+
r"""Query module state of the XP module serial_number.
|
|
107
133
|
|
|
108
|
-
|
|
134
|
+
Args:
|
|
135
|
+
ctx: Click context object.
|
|
136
|
+
serial_number: 10-digit module serial number.
|
|
109
137
|
|
|
110
|
-
|
|
138
|
+
Examples:
|
|
139
|
+
\b
|
|
111
140
|
xp conbus output state 0011223344 # Query module state
|
|
112
141
|
"""
|
|
113
142
|
service: ConbusDatapointService = (
|
|
@@ -115,6 +144,11 @@ def xp_module_state(ctx: click.Context, serial_number: str) -> None:
|
|
|
115
144
|
)
|
|
116
145
|
|
|
117
146
|
def on_finish(response: ConbusDatapointResponse) -> None:
|
|
147
|
+
"""Handle successful completion of module state query.
|
|
148
|
+
|
|
149
|
+
Args:
|
|
150
|
+
response: Datapoint response object.
|
|
151
|
+
"""
|
|
118
152
|
click.echo(json.dumps(response.to_dict(), indent=2))
|
|
119
153
|
|
|
120
154
|
with service:
|
|
@@ -18,28 +18,39 @@ from xp.services.conbus.conbus_raw_service import ConbusRawService
|
|
|
18
18
|
@click.pass_context
|
|
19
19
|
@connection_command()
|
|
20
20
|
def send_raw_telegrams(ctx: Context, raw_telegrams: str) -> None:
|
|
21
|
-
"""
|
|
22
|
-
Send raw telegram sequence to Conbus server.
|
|
21
|
+
r"""Send raw telegram sequence to Conbus server.
|
|
23
22
|
|
|
24
23
|
Accepts a string containing one or more telegrams in format <...>.
|
|
25
24
|
Multiple telegrams should be concatenated without separators.
|
|
26
25
|
|
|
27
|
-
|
|
26
|
+
Args:
|
|
27
|
+
ctx: Click context object.
|
|
28
|
+
raw_telegrams: Raw telegram string(s).
|
|
28
29
|
|
|
29
|
-
|
|
30
|
+
Examples:
|
|
31
|
+
\b
|
|
30
32
|
xp conbus raw '<S2113010000F02D12>'
|
|
31
33
|
xp conbus raw '<S2113010000F02D12><S2113010001F02D12><S2113010002F02D12>'
|
|
32
|
-
xp conbus raw '<S0012345003F02D12FM
|
|
34
|
+
xp conbus raw '<S0012345003F02D12FM>...<S0012345009F02D12FF>'
|
|
33
35
|
"""
|
|
34
36
|
service: ConbusRawService = (
|
|
35
37
|
ctx.obj.get("container").get_container().resolve(ConbusRawService)
|
|
36
38
|
)
|
|
37
39
|
|
|
38
40
|
def on_progress(message: str) -> None:
|
|
41
|
+
"""Handle progress updates during raw telegram sending.
|
|
42
|
+
|
|
43
|
+
Args:
|
|
44
|
+
message: Progress message string.
|
|
45
|
+
"""
|
|
39
46
|
click.echo(message)
|
|
40
|
-
pass
|
|
41
47
|
|
|
42
48
|
def on_finish(service_response: ConbusRawResponse) -> None:
|
|
49
|
+
"""Handle successful completion of raw telegram sending.
|
|
50
|
+
|
|
51
|
+
Args:
|
|
52
|
+
service_response: Raw response object.
|
|
53
|
+
"""
|
|
43
54
|
click.echo(json.dumps(service_response.to_dict(), indent=2))
|
|
44
55
|
|
|
45
56
|
with service:
|
|
@@ -20,29 +20,37 @@ from xp.services.conbus.conbus_receive_service import (
|
|
|
20
20
|
@connection_command()
|
|
21
21
|
@click.pass_context
|
|
22
22
|
def receive_telegrams(ctx: Context, timeout: float) -> None:
|
|
23
|
-
"""
|
|
24
|
-
Receive waiting event telegrams from Conbus server.
|
|
23
|
+
r"""Receive waiting event telegrams from Conbus server.
|
|
25
24
|
|
|
26
25
|
Connects to the Conbus server and receives any waiting event telegrams
|
|
27
26
|
without sending any data first. Useful for collecting pending notifications
|
|
28
27
|
or events from the server.
|
|
29
28
|
|
|
30
|
-
|
|
31
|
-
:
|
|
29
|
+
Args:
|
|
30
|
+
ctx: Click context object.
|
|
31
|
+
timeout: Timeout in seconds for receiving telegrams (default: 2.0).
|
|
32
32
|
|
|
33
33
|
Examples:
|
|
34
|
-
|
|
35
|
-
\b
|
|
34
|
+
\b
|
|
36
35
|
xp conbus receive
|
|
37
36
|
xp conbus receive 5.0
|
|
38
37
|
"""
|
|
39
38
|
|
|
40
39
|
def finish(response_received: ConbusReceiveResponse) -> None:
|
|
40
|
+
"""Handle successful completion of telegram receive operation.
|
|
41
|
+
|
|
42
|
+
Args:
|
|
43
|
+
response_received: Receive response object with telegrams.
|
|
44
|
+
"""
|
|
41
45
|
click.echo(json.dumps(response_received.to_dict(), indent=2))
|
|
42
46
|
|
|
43
47
|
def progress(telegram_received: str) -> None:
|
|
48
|
+
"""Handle progress updates during telegram receive operation.
|
|
49
|
+
|
|
50
|
+
Args:
|
|
51
|
+
telegram_received: Received telegram string.
|
|
52
|
+
"""
|
|
44
53
|
click.echo(telegram_received)
|
|
45
|
-
pass
|
|
46
54
|
|
|
47
55
|
service = ctx.obj.get("container").get_container().resolve(ConbusReceiveService)
|
|
48
56
|
with service:
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"""Conbus client operations CLI commands."""
|
|
2
2
|
|
|
3
3
|
import json
|
|
4
|
-
import threading
|
|
5
4
|
|
|
6
5
|
import click
|
|
7
6
|
from click import Context
|
|
@@ -16,110 +15,44 @@ from xp.services.conbus.conbus_scan_service import ConbusScanService
|
|
|
16
15
|
@conbus.command("scan")
|
|
17
16
|
@click.argument("serial_number", type=SERIAL)
|
|
18
17
|
@click.argument("function_code", type=str)
|
|
19
|
-
@click.option(
|
|
20
|
-
"--background",
|
|
21
|
-
"-b",
|
|
22
|
-
default=True,
|
|
23
|
-
is_flag=True,
|
|
24
|
-
help="Run scan in background with live output",
|
|
25
|
-
)
|
|
26
18
|
@click.pass_context
|
|
27
19
|
@connection_command()
|
|
28
|
-
def scan_module(
|
|
29
|
-
|
|
30
|
-
) -> None:
|
|
31
|
-
"""
|
|
32
|
-
Scan all datapoints of a function_code for a module.
|
|
20
|
+
def scan_module(ctx: Context, serial_number: str, function_code: str) -> None:
|
|
21
|
+
r"""Scan all datapoints of a function_code for a module.
|
|
33
22
|
|
|
34
|
-
|
|
23
|
+
Args:
|
|
24
|
+
ctx: Click context object.
|
|
25
|
+
serial_number: 10-digit module serial number.
|
|
26
|
+
function_code: Function code.
|
|
35
27
|
|
|
36
|
-
|
|
28
|
+
Examples:
|
|
29
|
+
\b
|
|
37
30
|
xp conbus scan 0012345011 02 # Scan all datapoints of function Read data points (02)
|
|
38
31
|
"""
|
|
39
|
-
service =
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
def background_scan() -> None:
|
|
68
|
-
try:
|
|
69
|
-
service.scan_module(
|
|
70
|
-
serial_number, function_code, progress_callback
|
|
71
|
-
)
|
|
72
|
-
except (ValueError, KeyError, ConnectionError):
|
|
73
|
-
pass # Will be handled by outer error handling
|
|
74
|
-
finally:
|
|
75
|
-
scan_complete.set()
|
|
76
|
-
|
|
77
|
-
# Start background thread
|
|
78
|
-
scan_thread = threading.Thread(target=background_scan, daemon=True)
|
|
79
|
-
scan_thread.start()
|
|
80
|
-
|
|
81
|
-
# Wait for completion or user interrupt
|
|
82
|
-
try:
|
|
83
|
-
while not scan_complete.is_set():
|
|
84
|
-
scan_complete.wait(1.0) # Check every second
|
|
85
|
-
except KeyboardInterrupt:
|
|
86
|
-
# Output partial results in JSON format
|
|
87
|
-
output = {
|
|
88
|
-
"serial_number": serial_number,
|
|
89
|
-
"total_scans": len(results),
|
|
90
|
-
"successful_scans": successful_count,
|
|
91
|
-
"failed_scans": failed_count,
|
|
92
|
-
"background_mode": background,
|
|
93
|
-
"interrupted": True,
|
|
94
|
-
"results": [result.to_dict() for result in results],
|
|
95
|
-
}
|
|
96
|
-
click.echo(json.dumps(output, indent=2))
|
|
97
|
-
raise click.Abort()
|
|
98
|
-
|
|
99
|
-
# Wait for thread to complete
|
|
100
|
-
scan_thread.join(timeout=1.0)
|
|
101
|
-
|
|
102
|
-
else:
|
|
103
|
-
# Traditional synchronous scanning
|
|
104
|
-
results = service.scan_module(
|
|
105
|
-
serial_number,
|
|
106
|
-
function_code,
|
|
107
|
-
progress_callback,
|
|
108
|
-
)
|
|
109
|
-
successful_count = len([r for r in results if r.success])
|
|
110
|
-
failed_count = len([r for r in results if not r.success])
|
|
111
|
-
|
|
112
|
-
# Final output
|
|
113
|
-
output = {
|
|
114
|
-
"serial_number": serial_number,
|
|
115
|
-
"total_scans": len(results),
|
|
116
|
-
"successful_scans": successful_count,
|
|
117
|
-
"failed_scans": failed_count,
|
|
118
|
-
"background_mode": background,
|
|
119
|
-
"results": [result.to_dict() for result in results],
|
|
120
|
-
}
|
|
121
|
-
click.echo(json.dumps(output, indent=2))
|
|
122
|
-
|
|
123
|
-
except click.Abort:
|
|
124
|
-
# User interrupted the scan
|
|
125
|
-
raise
|
|
32
|
+
service: ConbusScanService = (
|
|
33
|
+
ctx.obj.get("container").get_container().resolve(ConbusScanService)
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
def on_progress(progress: str) -> None:
|
|
37
|
+
"""Handle progress updates during module scan.
|
|
38
|
+
|
|
39
|
+
Args:
|
|
40
|
+
progress: Progress message string.
|
|
41
|
+
"""
|
|
42
|
+
click.echo(progress)
|
|
43
|
+
|
|
44
|
+
def on_finish(service_response: ConbusResponse) -> None:
|
|
45
|
+
"""Handle successful completion of module scan.
|
|
46
|
+
|
|
47
|
+
Args:
|
|
48
|
+
service_response: Scan response object.
|
|
49
|
+
"""
|
|
50
|
+
click.echo(json.dumps(service_response.to_dict(), indent=2))
|
|
51
|
+
|
|
52
|
+
with service:
|
|
53
|
+
service.scan_module(
|
|
54
|
+
serial_number=serial_number,
|
|
55
|
+
function_code=function_code,
|
|
56
|
+
progress_callback=on_progress,
|
|
57
|
+
finish_callback=on_finish,
|
|
58
|
+
)
|
xp/cli/commands/file_commands.py
CHANGED
|
@@ -18,9 +18,7 @@ from xp.cli.utils.formatters import OutputFormatter, StatisticsFormatter
|
|
|
18
18
|
cls=HelpColorsGroup, help_headers_color="yellow", help_options_color="green"
|
|
19
19
|
)
|
|
20
20
|
def file() -> None:
|
|
21
|
-
"""
|
|
22
|
-
File operations for console bus logs
|
|
23
|
-
"""
|
|
21
|
+
"""Perform file operations for console bus logs."""
|
|
24
22
|
pass
|
|
25
23
|
|
|
26
24
|
|
|
@@ -38,13 +36,22 @@ def decode_log_file(
|
|
|
38
36
|
time_range: str,
|
|
39
37
|
summary: bool,
|
|
40
38
|
) -> None:
|
|
41
|
-
"""
|
|
42
|
-
Decode and parse console bus log file.
|
|
39
|
+
r"""Decode and parse console bus log file.
|
|
43
40
|
|
|
44
|
-
|
|
41
|
+
Args:
|
|
42
|
+
ctx: Click context object.
|
|
43
|
+
log_file_path: Path to the log file to decode.
|
|
44
|
+
filter_type: Filter by telegram type.
|
|
45
|
+
filter_direction: Filter by telegram direction.
|
|
46
|
+
time_range: Filter by time range.
|
|
47
|
+
summary: Show summary statistics only.
|
|
45
48
|
|
|
46
|
-
|
|
49
|
+
Examples:
|
|
50
|
+
\b
|
|
47
51
|
xp file decode conbus.log
|
|
52
|
+
|
|
53
|
+
Raises:
|
|
54
|
+
SystemExit: If time range is invalid or log file cannot be parsed.
|
|
48
55
|
"""
|
|
49
56
|
from xp.services.log_file_service import LogFileService
|
|
50
57
|
from xp.utils.time_utils import TimeParsingError, parse_time_range
|
|
@@ -105,12 +112,14 @@ def decode_log_file(
|
|
|
105
112
|
@click.pass_context
|
|
106
113
|
@handle_service_errors(Exception)
|
|
107
114
|
def analyze_log_file(ctx: Context, log_file_path: str) -> None:
|
|
108
|
-
"""
|
|
109
|
-
Analyze console bus log file for patterns and statistics.
|
|
115
|
+
r"""Analyze console bus log file for patterns and statistics.
|
|
110
116
|
|
|
111
|
-
|
|
117
|
+
Args:
|
|
118
|
+
ctx: Click context object.
|
|
119
|
+
log_file_path: Path to the log file to analyze.
|
|
112
120
|
|
|
113
|
-
|
|
121
|
+
Examples:
|
|
122
|
+
\b
|
|
114
123
|
xp file analyze conbus.log
|
|
115
124
|
"""
|
|
116
125
|
from xp.services.log_file_service import LogFileService
|
|
@@ -135,12 +144,14 @@ def analyze_log_file(ctx: Context, log_file_path: str) -> None:
|
|
|
135
144
|
@click.pass_context
|
|
136
145
|
@handle_service_errors(Exception)
|
|
137
146
|
def validate_log_file(ctx: Context, log_file_path: str) -> None:
|
|
138
|
-
"""
|
|
139
|
-
Validate console bus log file format and telegram checksums.
|
|
147
|
+
r"""Validate console bus log file format and telegram checksums.
|
|
140
148
|
|
|
141
|
-
|
|
149
|
+
Args:
|
|
150
|
+
ctx: Click context object.
|
|
151
|
+
log_file_path: Path to the log file to validate.
|
|
142
152
|
|
|
143
|
-
|
|
153
|
+
Examples:
|
|
154
|
+
\b
|
|
144
155
|
xp file validate conbus.log
|
|
145
156
|
"""
|
|
146
157
|
from xp.services.log_file_service import LogFileService
|
|
@@ -10,11 +10,7 @@ from xp.cli.utils.decorators import service_command
|
|
|
10
10
|
cls=HelpColorsGroup, help_headers_color="yellow", help_options_color="green"
|
|
11
11
|
)
|
|
12
12
|
def homekit() -> None:
|
|
13
|
-
"""
|
|
14
|
-
HomeKit management commands.
|
|
15
|
-
|
|
16
|
-
Manage the HomeKit server for XP Protocol operations.
|
|
17
|
-
"""
|
|
13
|
+
"""Manage the HomeKit server for XP Protocol operations."""
|
|
18
14
|
pass
|
|
19
15
|
|
|
20
16
|
|
|
@@ -22,7 +18,7 @@ def homekit() -> None:
|
|
|
22
18
|
cls=HelpColorsGroup, help_headers_color="yellow", help_options_color="green"
|
|
23
19
|
)
|
|
24
20
|
def config() -> None:
|
|
25
|
-
"""HomeKit configuration
|
|
21
|
+
"""Manage HomeKit configuration."""
|
|
26
22
|
pass
|
|
27
23
|
|
|
28
24
|
|
|
@@ -39,7 +35,12 @@ def config() -> None:
|
|
|
39
35
|
)
|
|
40
36
|
@service_command()
|
|
41
37
|
def validate(conson_config: str, homekit_config: str) -> None:
|
|
42
|
-
"""Validate homekit.yml and conson.yml coherence
|
|
38
|
+
"""Validate homekit.yml and conson.yml coherence.
|
|
39
|
+
|
|
40
|
+
Args:
|
|
41
|
+
conson_config: Path to conson.yml configuration file.
|
|
42
|
+
homekit_config: Path to homekit.yml configuration file.
|
|
43
|
+
"""
|
|
43
44
|
from xp.services.homekit.homekit_config_validator import ConfigValidationService
|
|
44
45
|
|
|
45
46
|
try:
|
|
@@ -97,7 +98,12 @@ def validate(conson_config: str, homekit_config: str) -> None:
|
|
|
97
98
|
)
|
|
98
99
|
@service_command()
|
|
99
100
|
def show_config(conson_config: str, homekit_config: str) -> None:
|
|
100
|
-
"""Display parsed configuration summary
|
|
101
|
+
"""Display parsed configuration summary.
|
|
102
|
+
|
|
103
|
+
Args:
|
|
104
|
+
conson_config: Path to conson.yml configuration file.
|
|
105
|
+
homekit_config: Path to homekit.yml configuration file.
|
|
106
|
+
"""
|
|
101
107
|
from xp.services.homekit.homekit_config_validator import ConfigValidationService
|
|
102
108
|
|
|
103
109
|
try:
|
|
@@ -12,18 +12,18 @@ from xp.services.homekit.homekit_service import HomeKitService
|
|
|
12
12
|
@homekit.command("start")
|
|
13
13
|
@click.pass_context
|
|
14
14
|
def homekit_start(ctx: Context) -> None:
|
|
15
|
-
"""
|
|
16
|
-
Start the HomeKit server.
|
|
15
|
+
r"""Start the HomeKit server.
|
|
17
16
|
|
|
18
17
|
This command starts the XP Protocol HomeKit server using HAP-python.
|
|
19
18
|
The server provides HomeKit endpoints for Conbus operations.
|
|
20
19
|
|
|
21
|
-
|
|
20
|
+
Args:
|
|
21
|
+
ctx: Click context object.
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
Examples:
|
|
24
|
+
\b
|
|
24
25
|
# Start server on default host and port
|
|
25
26
|
xp homekit start
|
|
26
|
-
|
|
27
27
|
"""
|
|
28
28
|
click.echo("Starting XP Protocol HomeKit server...")
|
|
29
29
|
|