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.
- {conson_xp-1.1.0.dist-info → conson_xp-1.3.0.dist-info}/METADATA +1 -5
- conson_xp-1.3.0.dist-info/RECORD +164 -0
- xp/__init__.py +4 -3
- xp/cli/__init__.py +1 -1
- xp/cli/commands/__init__.py +1 -2
- xp/cli/commands/conbus/conbus.py +9 -37
- xp/cli/commands/conbus/conbus_actiontable_commands.py +26 -4
- xp/cli/commands/conbus/conbus_autoreport_commands.py +58 -30
- xp/cli/commands/conbus/conbus_blink_commands.py +61 -29
- xp/cli/commands/conbus/conbus_config_commands.py +10 -5
- xp/cli/commands/conbus/conbus_custom_commands.py +16 -5
- xp/cli/commands/conbus/conbus_datapoint_commands.py +32 -10
- xp/cli/commands/conbus/conbus_discover_commands.py +20 -7
- xp/cli/commands/conbus/conbus_lightlevel_commands.py +114 -39
- xp/cli/commands/conbus/conbus_linknumber_commands.py +50 -25
- xp/cli/commands/conbus/conbus_msactiontable_commands.py +36 -5
- xp/cli/commands/conbus/conbus_output_commands.py +52 -14
- xp/cli/commands/conbus/conbus_raw_commands.py +17 -6
- xp/cli/commands/conbus/conbus_receive_commands.py +20 -10
- xp/cli/commands/conbus/conbus_scan_commands.py +17 -4
- xp/cli/commands/file_commands.py +35 -18
- xp/cli/commands/homekit/homekit.py +14 -8
- xp/cli/commands/homekit/homekit_start_commands.py +8 -6
- xp/cli/commands/module_commands.py +38 -23
- xp/cli/commands/reverse_proxy_commands.py +27 -19
- 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 -3
- 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 +25 -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/conbus/conbus_writeconfig.py +60 -0
- 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_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 +42 -18
- xp/services/conbus/conbus_discover_service.py +43 -7
- 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 +44 -18
- xp/services/conbus/write_config_service.py +193 -0
- 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 +110 -16
- 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_datapoint_service.py +70 -0
- 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 +4 -47
- xp/utils/serialization.py +6 -0
- xp/utils/time_utils.py +6 -11
- conson_xp-1.1.0.dist-info/RECORD +0 -181
- xp/api/__init__.py +0 -1
- xp/api/main.py +0 -110
- xp/api/models/__init__.py +0 -1
- xp/api/models/api.py +0 -20
- xp/api/models/discover.py +0 -21
- xp/api/routers/__init__.py +0 -17
- xp/api/routers/conbus.py +0 -5
- xp/api/routers/conbus_blink.py +0 -105
- xp/api/routers/conbus_custom.py +0 -63
- xp/api/routers/conbus_datapoint.py +0 -67
- xp/api/routers/conbus_output.py +0 -147
- xp/api/routers/errors.py +0 -37
- xp/cli/commands/api.py +0 -16
- xp/cli/commands/api_start_commands.py +0 -126
- xp/services/conbus/conbus_autoreport_get_service.py +0 -85
- xp/services/conbus/conbus_autoreport_set_service.py +0 -128
- xp/services/conbus/conbus_lightlevel_get_service.py +0 -101
- xp/services/conbus/conbus_lightlevel_set_service.py +0 -205
- xp/services/conbus/conbus_linknumber_get_service.py +0 -86
- xp/services/conbus/conbus_linknumber_set_service.py +0 -155
- {conson_xp-1.1.0.dist-info → conson_xp-1.3.0.dist-info}/WHEEL +0 -0
- {conson_xp-1.1.0.dist-info → conson_xp-1.3.0.dist-info}/entry_points.txt +0 -0
- {conson_xp-1.1.0.dist-info → conson_xp-1.3.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -9,9 +9,12 @@ from xp.cli.utils.decorators import (
|
|
|
9
9
|
connection_command,
|
|
10
10
|
)
|
|
11
11
|
from xp.cli.utils.serial_number_type import SERIAL
|
|
12
|
-
from xp.models
|
|
13
|
-
from xp.
|
|
14
|
-
from xp.
|
|
12
|
+
from xp.models import ConbusDatapointResponse
|
|
13
|
+
from xp.models.conbus.conbus_writeconfig import ConbusWriteConfigResponse
|
|
14
|
+
from xp.models.telegram.datapoint_type import DataPointType
|
|
15
|
+
from xp.services.conbus.conbus_datapoint_service import ConbusDatapointService
|
|
16
|
+
from xp.services.conbus.write_config_service import WriteConfigService
|
|
17
|
+
from xp.services.telegram.telegram_datapoint_service import TelegramDatapointService
|
|
15
18
|
|
|
16
19
|
|
|
17
20
|
@conbus_linknumber.command("set", short_help="Set link number for a module")
|
|
@@ -22,29 +25,38 @@ from xp.services.conbus.conbus_linknumber_set_service import ConbusLinknumberSet
|
|
|
22
25
|
def set_linknumber_command(
|
|
23
26
|
ctx: click.Context, serial_number: str, link_number: int
|
|
24
27
|
) -> None:
|
|
25
|
-
"""
|
|
26
|
-
Set the link number for a specific module.
|
|
28
|
+
r"""Set the link number for a specific module.
|
|
27
29
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
Args:
|
|
31
|
+
ctx: Click context object.
|
|
32
|
+
serial_number: 10-digit module serial number.
|
|
33
|
+
link_number: Link number to set (0-99).
|
|
30
34
|
|
|
31
35
|
Examples:
|
|
32
|
-
|
|
33
|
-
\b
|
|
36
|
+
\b
|
|
34
37
|
xp conbus linknumber set 0123450001 25
|
|
35
38
|
"""
|
|
36
|
-
service = (
|
|
37
|
-
ctx.obj.get("container").get_container().resolve(ConbusLinknumberSetService)
|
|
38
|
-
)
|
|
39
39
|
|
|
40
|
-
def on_finish(response:
|
|
40
|
+
def on_finish(response: "ConbusWriteConfigResponse") -> None:
|
|
41
|
+
"""Handle successful completion of light level on command.
|
|
42
|
+
|
|
43
|
+
Args:
|
|
44
|
+
response: Light level response object.
|
|
45
|
+
"""
|
|
41
46
|
click.echo(json.dumps(response.to_dict(), indent=2))
|
|
42
47
|
|
|
48
|
+
service: WriteConfigService = (
|
|
49
|
+
ctx.obj.get("container").get_container().resolve(WriteConfigService)
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
data_value = f"{link_number: 02d}"
|
|
43
53
|
with service:
|
|
44
|
-
service.
|
|
54
|
+
service.write_config(
|
|
45
55
|
serial_number=serial_number,
|
|
46
|
-
|
|
56
|
+
datapoint_type=DataPointType.LINK_NUMBER,
|
|
57
|
+
data_value=data_value,
|
|
47
58
|
finish_callback=on_finish,
|
|
59
|
+
timeout_seconds=0.5,
|
|
48
60
|
)
|
|
49
61
|
|
|
50
62
|
|
|
@@ -53,25 +65,38 @@ def set_linknumber_command(
|
|
|
53
65
|
@click.pass_context
|
|
54
66
|
@connection_command()
|
|
55
67
|
def get_linknumber_command(ctx: click.Context, serial_number: str) -> None:
|
|
56
|
-
"""
|
|
57
|
-
Get the current link number for a specific module.
|
|
68
|
+
r"""Get the current link number for a specific module.
|
|
58
69
|
|
|
59
|
-
|
|
70
|
+
Args:
|
|
71
|
+
ctx: Click context object.
|
|
72
|
+
serial_number: 10-digit module serial number.
|
|
60
73
|
|
|
61
74
|
Examples:
|
|
62
|
-
|
|
63
|
-
\b
|
|
75
|
+
\b
|
|
64
76
|
xp conbus linknumber get 0123450001
|
|
65
77
|
"""
|
|
66
|
-
service = (
|
|
67
|
-
ctx.obj.get("container").get_container().resolve(
|
|
78
|
+
service: ConbusDatapointService = (
|
|
79
|
+
ctx.obj.get("container").get_container().resolve(ConbusDatapointService)
|
|
80
|
+
)
|
|
81
|
+
telegram_service: TelegramDatapointService = (
|
|
82
|
+
ctx.obj.get("container").get_container().resolve(TelegramDatapointService)
|
|
68
83
|
)
|
|
69
84
|
|
|
70
|
-
def on_finish(
|
|
71
|
-
|
|
85
|
+
def on_finish(service_response: ConbusDatapointResponse) -> None:
|
|
86
|
+
"""Handle successful completion of link number get command.
|
|
87
|
+
|
|
88
|
+
Args:
|
|
89
|
+
service_response: Link number response object.
|
|
90
|
+
"""
|
|
91
|
+
linknumber_value = telegram_service.get_linknumber(service_response.data_value)
|
|
92
|
+
result = service_response.to_dict()
|
|
93
|
+
result["linknumber_value"] = linknumber_value
|
|
94
|
+
click.echo(json.dumps(result, indent=2))
|
|
72
95
|
|
|
73
96
|
with service:
|
|
74
|
-
service.
|
|
97
|
+
service.query_datapoint(
|
|
75
98
|
serial_number=serial_number,
|
|
99
|
+
datapoint_type=DataPointType.LINK_NUMBER,
|
|
76
100
|
finish_callback=on_finish,
|
|
101
|
+
timeout_seconds=0.5,
|
|
77
102
|
)
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import json
|
|
4
4
|
from dataclasses import asdict
|
|
5
|
+
from typing import Union
|
|
5
6
|
|
|
6
7
|
import click
|
|
7
8
|
from click import Context
|
|
@@ -12,7 +13,9 @@ from xp.cli.utils.decorators import (
|
|
|
12
13
|
)
|
|
13
14
|
from xp.cli.utils.serial_number_type import SERIAL
|
|
14
15
|
from xp.cli.utils.xp_module_type import XP_MODULE_TYPE
|
|
15
|
-
from xp.models.actiontable.
|
|
16
|
+
from xp.models.actiontable.msactiontable_xp20 import Xp20MsActionTable
|
|
17
|
+
from xp.models.actiontable.msactiontable_xp24 import Xp24MsActionTable
|
|
18
|
+
from xp.models.actiontable.msactiontable_xp33 import Xp33MsActionTable
|
|
16
19
|
from xp.services.conbus.actiontable.msactiontable_service import (
|
|
17
20
|
MsActionTableService,
|
|
18
21
|
)
|
|
@@ -26,13 +29,33 @@ from xp.services.conbus.actiontable.msactiontable_service import (
|
|
|
26
29
|
def conbus_download_msactiontable(
|
|
27
30
|
ctx: Context, serial_number: str, xpmoduletype: str
|
|
28
31
|
) -> None:
|
|
29
|
-
"""Download MS action table from XP24 module
|
|
30
|
-
|
|
32
|
+
"""Download MS action table from XP24 module.
|
|
33
|
+
|
|
34
|
+
Args:
|
|
35
|
+
ctx: Click context object.
|
|
36
|
+
serial_number: 10-digit module serial number.
|
|
37
|
+
xpmoduletype: XP module type.
|
|
38
|
+
"""
|
|
39
|
+
service: MsActionTableService = (
|
|
40
|
+
ctx.obj.get("container").get_container().resolve(MsActionTableService)
|
|
41
|
+
)
|
|
31
42
|
|
|
32
43
|
def progress_callback(progress: str) -> None:
|
|
44
|
+
"""Handle progress updates during MS action table download.
|
|
45
|
+
|
|
46
|
+
Args:
|
|
47
|
+
progress: Progress message string.
|
|
48
|
+
"""
|
|
33
49
|
click.echo(progress, nl=False)
|
|
34
50
|
|
|
35
|
-
def
|
|
51
|
+
def on_finish(
|
|
52
|
+
action_table: Union[Xp20MsActionTable | Xp24MsActionTable | Xp33MsActionTable],
|
|
53
|
+
) -> None:
|
|
54
|
+
"""Handle successful completion of MS action table download.
|
|
55
|
+
|
|
56
|
+
Args:
|
|
57
|
+
action_table: Downloaded MS action table object.
|
|
58
|
+
"""
|
|
36
59
|
output = {
|
|
37
60
|
"serial_number": serial_number,
|
|
38
61
|
"xpmoduletype": xpmoduletype,
|
|
@@ -41,6 +64,14 @@ def conbus_download_msactiontable(
|
|
|
41
64
|
click.echo(json.dumps(output, indent=2, default=str))
|
|
42
65
|
|
|
43
66
|
def error_callback(error: str) -> None:
|
|
67
|
+
"""Handle errors during MS action table download.
|
|
68
|
+
|
|
69
|
+
Args:
|
|
70
|
+
error: Error message string.
|
|
71
|
+
|
|
72
|
+
Raises:
|
|
73
|
+
Abort: Always raised to abort the command on error.
|
|
74
|
+
"""
|
|
44
75
|
click.echo(f"Error: {error}")
|
|
45
76
|
raise click.Abort()
|
|
46
77
|
|
|
@@ -49,6 +80,6 @@ def conbus_download_msactiontable(
|
|
|
49
80
|
serial_number=serial_number,
|
|
50
81
|
xpmoduletype=xpmoduletype,
|
|
51
82
|
progress_callback=progress_callback,
|
|
52
|
-
finish_callback=
|
|
83
|
+
finish_callback=on_finish,
|
|
53
84
|
error_callback=error_callback,
|
|
54
85
|
)
|
|
@@ -23,16 +23,27 @@ 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
|
-
service =
|
|
37
|
+
service: ConbusOutputService = (
|
|
38
|
+
ctx.obj.get("container").get_container().resolve(ConbusOutputService)
|
|
39
|
+
)
|
|
34
40
|
|
|
35
41
|
def on_finish(response: ConbusOutputResponse) -> None:
|
|
42
|
+
"""Handle successful completion of output on command.
|
|
43
|
+
|
|
44
|
+
Args:
|
|
45
|
+
response: Output response object.
|
|
46
|
+
"""
|
|
36
47
|
click.echo(json.dumps(response.to_dict(), indent=2))
|
|
37
48
|
|
|
38
49
|
with service:
|
|
@@ -50,16 +61,27 @@ def xp_output_on(ctx: click.Context, serial_number: str, output_number: int) ->
|
|
|
50
61
|
@click.pass_context
|
|
51
62
|
@connection_command()
|
|
52
63
|
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
|
|
64
|
+
r"""Send OFF command for output_number XP module serial_number.
|
|
54
65
|
|
|
55
|
-
|
|
66
|
+
Args:
|
|
67
|
+
ctx: Click context object.
|
|
68
|
+
serial_number: 10-digit module serial number.
|
|
69
|
+
output_number: Output number.
|
|
56
70
|
|
|
57
|
-
|
|
71
|
+
Examples:
|
|
72
|
+
\b
|
|
58
73
|
xp conbus output off 0011223344 1 # Turn off output 1
|
|
59
74
|
"""
|
|
60
|
-
service =
|
|
75
|
+
service: ConbusOutputService = (
|
|
76
|
+
ctx.obj.get("container").get_container().resolve(ConbusOutputService)
|
|
77
|
+
)
|
|
61
78
|
|
|
62
79
|
def on_finish(response: ConbusOutputResponse) -> None:
|
|
80
|
+
"""Handle successful completion of output off command.
|
|
81
|
+
|
|
82
|
+
Args:
|
|
83
|
+
response: Output response object.
|
|
84
|
+
"""
|
|
63
85
|
click.echo(json.dumps(response.to_dict(), indent=2))
|
|
64
86
|
|
|
65
87
|
with service:
|
|
@@ -76,11 +98,14 @@ def xp_output_off(ctx: click.Context, serial_number: str, output_number: int) ->
|
|
|
76
98
|
@click.pass_context
|
|
77
99
|
@connection_command()
|
|
78
100
|
def xp_output_status(ctx: click.Context, serial_number: str) -> None:
|
|
79
|
-
"""Query output state command to XP module serial_number.
|
|
101
|
+
r"""Query output state command to XP module serial_number.
|
|
80
102
|
|
|
81
|
-
|
|
103
|
+
Args:
|
|
104
|
+
ctx: Click context object.
|
|
105
|
+
serial_number: 10-digit module serial number.
|
|
82
106
|
|
|
83
|
-
|
|
107
|
+
Examples:
|
|
108
|
+
\b
|
|
84
109
|
xp conbus output status 0011223344 # Query output status
|
|
85
110
|
"""
|
|
86
111
|
service: ConbusDatapointService = (
|
|
@@ -88,6 +113,11 @@ def xp_output_status(ctx: click.Context, serial_number: str) -> None:
|
|
|
88
113
|
)
|
|
89
114
|
|
|
90
115
|
def on_finish(response: ConbusDatapointResponse) -> None:
|
|
116
|
+
"""Handle successful completion of output status query.
|
|
117
|
+
|
|
118
|
+
Args:
|
|
119
|
+
response: Datapoint response object.
|
|
120
|
+
"""
|
|
91
121
|
click.echo(json.dumps(response.to_dict(), indent=2))
|
|
92
122
|
|
|
93
123
|
with service:
|
|
@@ -103,11 +133,14 @@ def xp_output_status(ctx: click.Context, serial_number: str) -> None:
|
|
|
103
133
|
@click.pass_context
|
|
104
134
|
@connection_command()
|
|
105
135
|
def xp_module_state(ctx: click.Context, serial_number: str) -> None:
|
|
106
|
-
"""Query module state of the XP module serial_number
|
|
136
|
+
r"""Query module state of the XP module serial_number.
|
|
107
137
|
|
|
108
|
-
|
|
138
|
+
Args:
|
|
139
|
+
ctx: Click context object.
|
|
140
|
+
serial_number: 10-digit module serial number.
|
|
109
141
|
|
|
110
|
-
|
|
142
|
+
Examples:
|
|
143
|
+
\b
|
|
111
144
|
xp conbus output state 0011223344 # Query module state
|
|
112
145
|
"""
|
|
113
146
|
service: ConbusDatapointService = (
|
|
@@ -115,6 +148,11 @@ def xp_module_state(ctx: click.Context, serial_number: str) -> None:
|
|
|
115
148
|
)
|
|
116
149
|
|
|
117
150
|
def on_finish(response: ConbusDatapointResponse) -> None:
|
|
151
|
+
"""Handle successful completion of module state query.
|
|
152
|
+
|
|
153
|
+
Args:
|
|
154
|
+
response: Datapoint response object.
|
|
155
|
+
"""
|
|
118
156
|
click.echo(json.dumps(response.to_dict(), indent=2))
|
|
119
157
|
|
|
120
158
|
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,30 +20,40 @@ 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
|
-
def
|
|
39
|
+
def on_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
|
-
service =
|
|
55
|
+
service: ConbusReceiveService = (
|
|
56
|
+
ctx.obj.get("container").get_container().resolve(ConbusReceiveService)
|
|
57
|
+
)
|
|
48
58
|
with service:
|
|
49
|
-
service.start(progress,
|
|
59
|
+
service.start(progress, on_finish, timeout)
|
|
@@ -18,12 +18,15 @@ from xp.services.conbus.conbus_scan_service import ConbusScanService
|
|
|
18
18
|
@click.pass_context
|
|
19
19
|
@connection_command()
|
|
20
20
|
def scan_module(ctx: Context, serial_number: str, function_code: str) -> None:
|
|
21
|
-
"""
|
|
22
|
-
Scan all datapoints of a function_code for a module.
|
|
21
|
+
r"""Scan all datapoints of a function_code for a module.
|
|
23
22
|
|
|
24
|
-
|
|
23
|
+
Args:
|
|
24
|
+
ctx: Click context object.
|
|
25
|
+
serial_number: 10-digit module serial number.
|
|
26
|
+
function_code: Function code.
|
|
25
27
|
|
|
26
|
-
|
|
28
|
+
Examples:
|
|
29
|
+
\b
|
|
27
30
|
xp conbus scan 0012345011 02 # Scan all datapoints of function Read data points (02)
|
|
28
31
|
"""
|
|
29
32
|
service: ConbusScanService = (
|
|
@@ -31,9 +34,19 @@ def scan_module(ctx: Context, serial_number: str, function_code: str) -> None:
|
|
|
31
34
|
)
|
|
32
35
|
|
|
33
36
|
def on_progress(progress: str) -> None:
|
|
37
|
+
"""Handle progress updates during module scan.
|
|
38
|
+
|
|
39
|
+
Args:
|
|
40
|
+
progress: Progress message string.
|
|
41
|
+
"""
|
|
34
42
|
click.echo(progress)
|
|
35
43
|
|
|
36
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
|
+
"""
|
|
37
50
|
click.echo(json.dumps(service_response.to_dict(), indent=2))
|
|
38
51
|
|
|
39
52
|
with service:
|
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,18 +36,29 @@ 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
|
|
51
58
|
|
|
52
|
-
service =
|
|
59
|
+
service: LogFileService = (
|
|
60
|
+
ctx.obj.get("container").get_container().resolve(LogFileService)
|
|
61
|
+
)
|
|
53
62
|
StatisticsFormatter(True)
|
|
54
63
|
|
|
55
64
|
try:
|
|
@@ -105,17 +114,21 @@ def decode_log_file(
|
|
|
105
114
|
@click.pass_context
|
|
106
115
|
@handle_service_errors(Exception)
|
|
107
116
|
def analyze_log_file(ctx: Context, log_file_path: str) -> None:
|
|
108
|
-
"""
|
|
109
|
-
Analyze console bus log file for patterns and statistics.
|
|
117
|
+
r"""Analyze console bus log file for patterns and statistics.
|
|
110
118
|
|
|
111
|
-
|
|
119
|
+
Args:
|
|
120
|
+
ctx: Click context object.
|
|
121
|
+
log_file_path: Path to the log file to analyze.
|
|
112
122
|
|
|
113
|
-
|
|
123
|
+
Examples:
|
|
124
|
+
\b
|
|
114
125
|
xp file analyze conbus.log
|
|
115
126
|
"""
|
|
116
127
|
from xp.services.log_file_service import LogFileService
|
|
117
128
|
|
|
118
|
-
service =
|
|
129
|
+
service: LogFileService = (
|
|
130
|
+
ctx.obj.get("container").get_container().resolve(LogFileService)
|
|
131
|
+
)
|
|
119
132
|
StatisticsFormatter(True)
|
|
120
133
|
|
|
121
134
|
try:
|
|
@@ -135,17 +148,21 @@ def analyze_log_file(ctx: Context, log_file_path: str) -> None:
|
|
|
135
148
|
@click.pass_context
|
|
136
149
|
@handle_service_errors(Exception)
|
|
137
150
|
def validate_log_file(ctx: Context, log_file_path: str) -> None:
|
|
138
|
-
"""
|
|
139
|
-
Validate console bus log file format and telegram checksums.
|
|
151
|
+
r"""Validate console bus log file format and telegram checksums.
|
|
140
152
|
|
|
141
|
-
|
|
153
|
+
Args:
|
|
154
|
+
ctx: Click context object.
|
|
155
|
+
log_file_path: Path to the log file to validate.
|
|
142
156
|
|
|
143
|
-
|
|
157
|
+
Examples:
|
|
158
|
+
\b
|
|
144
159
|
xp file validate conbus.log
|
|
145
160
|
"""
|
|
146
161
|
from xp.services.log_file_service import LogFileService
|
|
147
162
|
|
|
148
|
-
service =
|
|
163
|
+
service: LogFileService = (
|
|
164
|
+
ctx.obj.get("container").get_container().resolve(LogFileService)
|
|
165
|
+
)
|
|
149
166
|
OutputFormatter(True)
|
|
150
167
|
|
|
151
168
|
try:
|
|
@@ -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,23 +12,25 @@ 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
|
|
|
30
30
|
try:
|
|
31
|
-
service =
|
|
31
|
+
service: HomeKitService = (
|
|
32
|
+
ctx.obj.get("container").get_container().resolve(HomeKitService)
|
|
33
|
+
)
|
|
32
34
|
service.start() # Blocking call - reactor.run() never returns
|
|
33
35
|
|
|
34
36
|
except KeyboardInterrupt:
|