conson-xp 1.18.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.18.0.dist-info/METADATA +412 -0
- conson_xp-1.18.0.dist-info/RECORD +176 -0
- conson_xp-1.18.0.dist-info/WHEEL +4 -0
- conson_xp-1.18.0.dist-info/entry_points.txt +5 -0
- conson_xp-1.18.0.dist-info/licenses/LICENSE +29 -0
- xp/__init__.py +9 -0
- xp/cli/__init__.py +5 -0
- xp/cli/__main__.py +6 -0
- xp/cli/commands/__init__.py +153 -0
- xp/cli/commands/conbus/__init__.py +25 -0
- xp/cli/commands/conbus/conbus.py +128 -0
- xp/cli/commands/conbus/conbus_actiontable_commands.py +233 -0
- xp/cli/commands/conbus/conbus_autoreport_commands.py +108 -0
- xp/cli/commands/conbus/conbus_blink_commands.py +163 -0
- xp/cli/commands/conbus/conbus_config_commands.py +29 -0
- xp/cli/commands/conbus/conbus_custom_commands.py +57 -0
- xp/cli/commands/conbus/conbus_datapoint_commands.py +113 -0
- xp/cli/commands/conbus/conbus_discover_commands.py +61 -0
- xp/cli/commands/conbus/conbus_event_commands.py +81 -0
- xp/cli/commands/conbus/conbus_lightlevel_commands.py +207 -0
- xp/cli/commands/conbus/conbus_linknumber_commands.py +102 -0
- xp/cli/commands/conbus/conbus_modulenumber_commands.py +104 -0
- xp/cli/commands/conbus/conbus_msactiontable_commands.py +94 -0
- xp/cli/commands/conbus/conbus_output_commands.py +163 -0
- xp/cli/commands/conbus/conbus_raw_commands.py +62 -0
- xp/cli/commands/conbus/conbus_receive_commands.py +59 -0
- xp/cli/commands/conbus/conbus_scan_commands.py +58 -0
- xp/cli/commands/file_commands.py +186 -0
- xp/cli/commands/homekit/__init__.py +3 -0
- xp/cli/commands/homekit/homekit.py +118 -0
- xp/cli/commands/homekit/homekit_start_commands.py +43 -0
- xp/cli/commands/module_commands.py +187 -0
- xp/cli/commands/reverse_proxy_commands.py +178 -0
- xp/cli/commands/server/__init__.py +3 -0
- xp/cli/commands/server/server_commands.py +135 -0
- xp/cli/commands/telegram/__init__.py +5 -0
- xp/cli/commands/telegram/telegram.py +41 -0
- xp/cli/commands/telegram/telegram_blink_commands.py +79 -0
- xp/cli/commands/telegram/telegram_checksum_commands.py +112 -0
- xp/cli/commands/telegram/telegram_discover_commands.py +41 -0
- xp/cli/commands/telegram/telegram_linknumber_commands.py +86 -0
- xp/cli/commands/telegram/telegram_parse_commands.py +75 -0
- xp/cli/commands/telegram/telegram_version_commands.py +52 -0
- xp/cli/main.py +87 -0
- xp/cli/utils/__init__.py +1 -0
- xp/cli/utils/click_tree.py +57 -0
- xp/cli/utils/datapoint_type_choice.py +57 -0
- xp/cli/utils/decorators.py +351 -0
- xp/cli/utils/error_handlers.py +201 -0
- xp/cli/utils/formatters.py +312 -0
- xp/cli/utils/module_type_choice.py +56 -0
- xp/cli/utils/serial_number_type.py +52 -0
- xp/cli/utils/system_function_choice.py +57 -0
- xp/cli/utils/xp_module_type.py +53 -0
- xp/connection/__init__.py +13 -0
- xp/connection/exceptions.py +22 -0
- xp/models/__init__.py +36 -0
- xp/models/actiontable/__init__.py +1 -0
- xp/models/actiontable/actiontable.py +43 -0
- xp/models/actiontable/msactiontable_xp20.py +53 -0
- xp/models/actiontable/msactiontable_xp24.py +58 -0
- xp/models/actiontable/msactiontable_xp33.py +65 -0
- xp/models/conbus/__init__.py +1 -0
- xp/models/conbus/conbus.py +87 -0
- xp/models/conbus/conbus_autoreport.py +67 -0
- xp/models/conbus/conbus_blink.py +80 -0
- xp/models/conbus/conbus_client_config.py +55 -0
- xp/models/conbus/conbus_connection_status.py +40 -0
- xp/models/conbus/conbus_custom.py +58 -0
- xp/models/conbus/conbus_datapoint.py +89 -0
- xp/models/conbus/conbus_discover.py +64 -0
- xp/models/conbus/conbus_event_raw.py +47 -0
- xp/models/conbus/conbus_lightlevel.py +52 -0
- xp/models/conbus/conbus_linknumber.py +54 -0
- xp/models/conbus/conbus_output.py +57 -0
- xp/models/conbus/conbus_raw.py +45 -0
- xp/models/conbus/conbus_receive.py +42 -0
- xp/models/conbus/conbus_writeconfig.py +60 -0
- xp/models/homekit/__init__.py +1 -0
- xp/models/homekit/homekit_accessory.py +35 -0
- xp/models/homekit/homekit_config.py +106 -0
- xp/models/homekit/homekit_conson_config.py +86 -0
- xp/models/log_entry.py +130 -0
- xp/models/protocol/__init__.py +1 -0
- xp/models/protocol/conbus_protocol.py +312 -0
- xp/models/response.py +42 -0
- xp/models/telegram/__init__.py +1 -0
- xp/models/telegram/action_type.py +31 -0
- xp/models/telegram/datapoint_type.py +82 -0
- xp/models/telegram/event_telegram.py +140 -0
- xp/models/telegram/event_type.py +15 -0
- xp/models/telegram/input_action_type.py +69 -0
- xp/models/telegram/input_type.py +17 -0
- xp/models/telegram/module_type.py +188 -0
- xp/models/telegram/module_type_code.py +205 -0
- xp/models/telegram/output_telegram.py +103 -0
- xp/models/telegram/reply_telegram.py +297 -0
- xp/models/telegram/system_function.py +116 -0
- xp/models/telegram/system_telegram.py +94 -0
- xp/models/telegram/telegram.py +28 -0
- xp/models/telegram/telegram_type.py +19 -0
- xp/models/telegram/timeparam_type.py +51 -0
- xp/models/write_config_type.py +33 -0
- xp/services/__init__.py +26 -0
- xp/services/actiontable/__init__.py +1 -0
- xp/services/actiontable/actiontable_serializer.py +273 -0
- xp/services/actiontable/msactiontable_serializer.py +7 -0
- xp/services/actiontable/msactiontable_xp20_serializer.py +169 -0
- xp/services/actiontable/msactiontable_xp24_serializer.py +120 -0
- xp/services/actiontable/msactiontable_xp33_serializer.py +239 -0
- xp/services/conbus/__init__.py +1 -0
- xp/services/conbus/actiontable/__init__.py +1 -0
- xp/services/conbus/actiontable/actiontable_download_service.py +158 -0
- xp/services/conbus/actiontable/actiontable_list_service.py +91 -0
- xp/services/conbus/actiontable/actiontable_show_service.py +89 -0
- xp/services/conbus/actiontable/actiontable_upload_service.py +211 -0
- xp/services/conbus/actiontable/msactiontable_service.py +232 -0
- xp/services/conbus/conbus_blink_all_service.py +181 -0
- xp/services/conbus/conbus_blink_service.py +158 -0
- xp/services/conbus/conbus_custom_service.py +156 -0
- xp/services/conbus/conbus_datapoint_queryall_service.py +182 -0
- xp/services/conbus/conbus_datapoint_service.py +170 -0
- xp/services/conbus/conbus_discover_service.py +312 -0
- xp/services/conbus/conbus_event_raw_service.py +181 -0
- xp/services/conbus/conbus_output_service.py +194 -0
- xp/services/conbus/conbus_raw_service.py +122 -0
- xp/services/conbus/conbus_receive_service.py +115 -0
- xp/services/conbus/conbus_scan_service.py +150 -0
- xp/services/conbus/write_config_service.py +194 -0
- xp/services/homekit/__init__.py +1 -0
- xp/services/homekit/homekit_cache_service.py +307 -0
- xp/services/homekit/homekit_conbus_service.py +93 -0
- xp/services/homekit/homekit_config_validator.py +310 -0
- xp/services/homekit/homekit_conson_validator.py +121 -0
- xp/services/homekit/homekit_dimminglight.py +182 -0
- xp/services/homekit/homekit_dimminglight_service.py +148 -0
- xp/services/homekit/homekit_hap_service.py +342 -0
- xp/services/homekit/homekit_lightbulb.py +120 -0
- xp/services/homekit/homekit_lightbulb_service.py +86 -0
- xp/services/homekit/homekit_module_service.py +56 -0
- xp/services/homekit/homekit_outlet.py +168 -0
- xp/services/homekit/homekit_outlet_service.py +121 -0
- xp/services/homekit/homekit_service.py +359 -0
- xp/services/log_file_service.py +309 -0
- xp/services/module_type_service.py +257 -0
- xp/services/protocol/__init__.py +21 -0
- xp/services/protocol/conbus_event_protocol.py +360 -0
- xp/services/protocol/conbus_protocol.py +318 -0
- xp/services/protocol/protocol_factory.py +78 -0
- xp/services/protocol/telegram_protocol.py +264 -0
- xp/services/reverse_proxy_service.py +435 -0
- xp/services/server/__init__.py +1 -0
- xp/services/server/base_server_service.py +366 -0
- xp/services/server/cp20_server_service.py +65 -0
- xp/services/server/device_service_factory.py +94 -0
- xp/services/server/server_service.py +428 -0
- xp/services/server/xp130_server_service.py +67 -0
- xp/services/server/xp20_server_service.py +92 -0
- xp/services/server/xp230_server_service.py +58 -0
- xp/services/server/xp24_server_service.py +245 -0
- xp/services/server/xp33_server_service.py +535 -0
- xp/services/telegram/__init__.py +1 -0
- xp/services/telegram/telegram_blink_service.py +138 -0
- xp/services/telegram/telegram_checksum_service.py +149 -0
- xp/services/telegram/telegram_datapoint_service.py +82 -0
- xp/services/telegram/telegram_discover_service.py +277 -0
- xp/services/telegram/telegram_link_number_service.py +216 -0
- xp/services/telegram/telegram_output_service.py +322 -0
- xp/services/telegram/telegram_service.py +380 -0
- xp/services/telegram/telegram_version_service.py +288 -0
- xp/utils/__init__.py +12 -0
- xp/utils/checksum.py +61 -0
- xp/utils/dependencies.py +531 -0
- xp/utils/event_helper.py +31 -0
- xp/utils/serialization.py +205 -0
- xp/utils/time_utils.py +134 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
"""Conbus client operations CLI commands."""
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
|
|
5
|
+
import click
|
|
6
|
+
from click import Context
|
|
7
|
+
|
|
8
|
+
from xp.cli.commands.conbus.conbus import conbus_blink
|
|
9
|
+
from xp.cli.utils.decorators import (
|
|
10
|
+
connection_command,
|
|
11
|
+
handle_service_errors,
|
|
12
|
+
)
|
|
13
|
+
from xp.cli.utils.serial_number_type import SERIAL
|
|
14
|
+
from xp.models.conbus.conbus_blink import ConbusBlinkResponse
|
|
15
|
+
from xp.services.conbus.conbus_blink_all_service import ConbusBlinkAllService
|
|
16
|
+
from xp.services.conbus.conbus_blink_service import ConbusBlinkService
|
|
17
|
+
from xp.services.telegram.telegram_blink_service import BlinkError
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@conbus_blink.command("on", short_help="Blink on remote service")
|
|
21
|
+
@click.argument("serial_number", type=SERIAL)
|
|
22
|
+
@click.pass_context
|
|
23
|
+
@connection_command()
|
|
24
|
+
@handle_service_errors(BlinkError)
|
|
25
|
+
def send_blink_on_telegram(ctx: Context, serial_number: str) -> None:
|
|
26
|
+
r"""Send blink command to start blinking module LED.
|
|
27
|
+
|
|
28
|
+
Args:
|
|
29
|
+
ctx: Click context object.
|
|
30
|
+
serial_number: 10-digit module serial number.
|
|
31
|
+
|
|
32
|
+
Examples:
|
|
33
|
+
\b
|
|
34
|
+
xp conbus blink on 0012345008
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
def on_finish(service_response: ConbusBlinkResponse) -> None:
|
|
38
|
+
"""Handle successful completion of blink on command.
|
|
39
|
+
|
|
40
|
+
Args:
|
|
41
|
+
service_response: Blink response object.
|
|
42
|
+
"""
|
|
43
|
+
click.echo(json.dumps(service_response.to_dict(), indent=2))
|
|
44
|
+
|
|
45
|
+
service: ConbusBlinkService = (
|
|
46
|
+
ctx.obj.get("container").get_container().resolve(ConbusBlinkService)
|
|
47
|
+
)
|
|
48
|
+
with service:
|
|
49
|
+
service.send_blink_telegram(serial_number, "on", on_finish, 0.5)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
@conbus_blink.command("off")
|
|
53
|
+
@click.argument("serial_number", type=SERIAL)
|
|
54
|
+
@click.pass_context
|
|
55
|
+
@connection_command()
|
|
56
|
+
@handle_service_errors(BlinkError)
|
|
57
|
+
def send_blink_off_telegram(ctx: Context, serial_number: str) -> None:
|
|
58
|
+
r"""Send blink command to stop blinking module LED.
|
|
59
|
+
|
|
60
|
+
Args:
|
|
61
|
+
ctx: Click context object.
|
|
62
|
+
serial_number: 10-digit module serial number.
|
|
63
|
+
|
|
64
|
+
Examples:
|
|
65
|
+
\b
|
|
66
|
+
xp conbus blink off 0012345008
|
|
67
|
+
"""
|
|
68
|
+
|
|
69
|
+
def on_finish(service_response: ConbusBlinkResponse) -> None:
|
|
70
|
+
"""Handle successful completion of blink off command.
|
|
71
|
+
|
|
72
|
+
Args:
|
|
73
|
+
service_response: Blink response object.
|
|
74
|
+
"""
|
|
75
|
+
click.echo(json.dumps(service_response.to_dict(), indent=2))
|
|
76
|
+
|
|
77
|
+
service: ConbusBlinkService = (
|
|
78
|
+
ctx.obj.get("container").get_container().resolve(ConbusBlinkService)
|
|
79
|
+
)
|
|
80
|
+
with service:
|
|
81
|
+
service.send_blink_telegram(serial_number, "off", on_finish, 0.5)
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
@conbus_blink.group("all", short_help="Control blink state for all devices")
|
|
85
|
+
def conbus_blink_all() -> None:
|
|
86
|
+
"""Control blink state for all discovered devices."""
|
|
87
|
+
pass
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
@conbus_blink_all.command("off", short_help="Turn off blinking for all devices")
|
|
91
|
+
@click.pass_context
|
|
92
|
+
@connection_command()
|
|
93
|
+
@handle_service_errors(BlinkError)
|
|
94
|
+
def blink_all_off(ctx: Context) -> None:
|
|
95
|
+
r"""Turn off blinking for all discovered devices.
|
|
96
|
+
|
|
97
|
+
Args:
|
|
98
|
+
ctx: Click context object.
|
|
99
|
+
|
|
100
|
+
Examples:
|
|
101
|
+
\b
|
|
102
|
+
xp conbus blink all off
|
|
103
|
+
"""
|
|
104
|
+
|
|
105
|
+
def on_finish(discovered_devices: ConbusBlinkResponse) -> None:
|
|
106
|
+
"""Handle successful completion of blink all off command.
|
|
107
|
+
|
|
108
|
+
Args:
|
|
109
|
+
discovered_devices: Blink response with all devices.
|
|
110
|
+
"""
|
|
111
|
+
click.echo(json.dumps(discovered_devices.to_dict(), indent=2))
|
|
112
|
+
|
|
113
|
+
def progress(message: str) -> None:
|
|
114
|
+
"""Handle progress updates during blink all off operation.
|
|
115
|
+
|
|
116
|
+
Args:
|
|
117
|
+
message: Progress message string.
|
|
118
|
+
"""
|
|
119
|
+
click.echo(message)
|
|
120
|
+
|
|
121
|
+
service: ConbusBlinkAllService = (
|
|
122
|
+
ctx.obj.get("container").get_container().resolve(ConbusBlinkAllService)
|
|
123
|
+
)
|
|
124
|
+
with service:
|
|
125
|
+
service.send_blink_all_telegram("off", progress, on_finish, 0.5)
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
@conbus_blink_all.command("on", short_help="Turn on blinking for all devices")
|
|
129
|
+
@click.pass_context
|
|
130
|
+
@connection_command()
|
|
131
|
+
@handle_service_errors(BlinkError)
|
|
132
|
+
def blink_all_on(ctx: Context) -> None:
|
|
133
|
+
r"""Turn on blinking for all discovered devices.
|
|
134
|
+
|
|
135
|
+
Args:
|
|
136
|
+
ctx: Click context object.
|
|
137
|
+
|
|
138
|
+
Examples:
|
|
139
|
+
\b
|
|
140
|
+
xp conbus blink all on
|
|
141
|
+
"""
|
|
142
|
+
|
|
143
|
+
def on_finish(discovered_devices: ConbusBlinkResponse) -> None:
|
|
144
|
+
"""Handle successful completion of blink all on command.
|
|
145
|
+
|
|
146
|
+
Args:
|
|
147
|
+
discovered_devices: Blink response with all devices.
|
|
148
|
+
"""
|
|
149
|
+
click.echo(json.dumps(discovered_devices.to_dict(), indent=2))
|
|
150
|
+
|
|
151
|
+
def progress(message: str) -> None:
|
|
152
|
+
"""Handle progress updates during blink all on operation.
|
|
153
|
+
|
|
154
|
+
Args:
|
|
155
|
+
message: Progress message string.
|
|
156
|
+
"""
|
|
157
|
+
click.echo(message)
|
|
158
|
+
|
|
159
|
+
service: ConbusBlinkAllService = (
|
|
160
|
+
ctx.obj.get("container").get_container().resolve(ConbusBlinkAllService)
|
|
161
|
+
)
|
|
162
|
+
with service:
|
|
163
|
+
service.send_blink_all_telegram("on", progress, on_finish, 0.5)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"""Conbus configuration CLI commands."""
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
|
|
5
|
+
import click
|
|
6
|
+
from click import Context
|
|
7
|
+
|
|
8
|
+
from xp.cli.commands.conbus.conbus import conbus
|
|
9
|
+
from xp.cli.utils.decorators import handle_service_errors
|
|
10
|
+
from xp.models import ConbusClientConfig
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@conbus.command("config")
|
|
14
|
+
@click.pass_context
|
|
15
|
+
@handle_service_errors(Exception)
|
|
16
|
+
def show_config(ctx: Context) -> None:
|
|
17
|
+
r"""Display current Conbus client configuration.
|
|
18
|
+
|
|
19
|
+
Args:
|
|
20
|
+
ctx: Click context object.
|
|
21
|
+
|
|
22
|
+
Examples:
|
|
23
|
+
\b
|
|
24
|
+
xp conbus config
|
|
25
|
+
"""
|
|
26
|
+
config: ConbusClientConfig = (
|
|
27
|
+
ctx.obj.get("container").get_container().resolve(ConbusClientConfig)
|
|
28
|
+
)
|
|
29
|
+
click.echo(json.dumps(config.conbus.model_dump(mode="json"), indent=2))
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"""Conbus client operations CLI commands."""
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
|
|
5
|
+
import click
|
|
6
|
+
from click import Context
|
|
7
|
+
|
|
8
|
+
from xp.cli.commands.conbus.conbus import conbus
|
|
9
|
+
from xp.cli.utils.decorators import (
|
|
10
|
+
connection_command,
|
|
11
|
+
)
|
|
12
|
+
from xp.cli.utils.serial_number_type import SERIAL
|
|
13
|
+
from xp.models.conbus.conbus_custom import ConbusCustomResponse
|
|
14
|
+
from xp.services.conbus.conbus_custom_service import ConbusCustomService
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@conbus.command("custom")
|
|
18
|
+
@click.argument("serial_number", type=SERIAL)
|
|
19
|
+
@click.argument("function_code")
|
|
20
|
+
@click.argument("datapoint_code")
|
|
21
|
+
@click.pass_context
|
|
22
|
+
@connection_command()
|
|
23
|
+
def send_custom_telegram(
|
|
24
|
+
ctx: Context, serial_number: str, function_code: str, datapoint_code: str
|
|
25
|
+
) -> None:
|
|
26
|
+
r"""Send custom telegram with specified function and data point codes.
|
|
27
|
+
|
|
28
|
+
Args:
|
|
29
|
+
ctx: Click context object.
|
|
30
|
+
serial_number: 10-digit module serial number.
|
|
31
|
+
function_code: Function code.
|
|
32
|
+
datapoint_code: Data point code.
|
|
33
|
+
|
|
34
|
+
Examples:
|
|
35
|
+
\b
|
|
36
|
+
xp conbus custom 0012345011 02 E2
|
|
37
|
+
xp conbus custom 0012345011 17 AA
|
|
38
|
+
"""
|
|
39
|
+
service: ConbusCustomService = (
|
|
40
|
+
ctx.obj.get("container").get_container().resolve(ConbusCustomService)
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
def on_finish(service_response: "ConbusCustomResponse") -> None:
|
|
44
|
+
"""Handle successful completion of custom telegram.
|
|
45
|
+
|
|
46
|
+
Args:
|
|
47
|
+
service_response: Custom response object.
|
|
48
|
+
"""
|
|
49
|
+
click.echo(json.dumps(service_response.to_dict(), indent=2))
|
|
50
|
+
|
|
51
|
+
with service:
|
|
52
|
+
service.send_custom_telegram(
|
|
53
|
+
serial_number=serial_number,
|
|
54
|
+
function_code=function_code,
|
|
55
|
+
data=datapoint_code,
|
|
56
|
+
finish_callback=on_finish,
|
|
57
|
+
)
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"""Conbus client operations CLI commands."""
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
|
|
5
|
+
import click
|
|
6
|
+
from click import Context
|
|
7
|
+
|
|
8
|
+
from xp.cli.commands.conbus.conbus import conbus_datapoint
|
|
9
|
+
|
|
10
|
+
# Import will be handled by conbus.py registration
|
|
11
|
+
from xp.cli.utils.datapoint_type_choice import DATAPOINT
|
|
12
|
+
from xp.cli.utils.decorators import (
|
|
13
|
+
connection_command,
|
|
14
|
+
)
|
|
15
|
+
from xp.cli.utils.serial_number_type import SERIAL
|
|
16
|
+
from xp.models.conbus.conbus_datapoint import ConbusDatapointResponse
|
|
17
|
+
from xp.models.telegram.datapoint_type import DataPointType
|
|
18
|
+
from xp.models.telegram.reply_telegram import ReplyTelegram
|
|
19
|
+
from xp.services.conbus.conbus_datapoint_queryall_service import (
|
|
20
|
+
ConbusDatapointQueryAllService,
|
|
21
|
+
)
|
|
22
|
+
from xp.services.conbus.conbus_datapoint_service import (
|
|
23
|
+
ConbusDatapointService,
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@click.command("query")
|
|
28
|
+
@click.argument("datapoint", type=DATAPOINT)
|
|
29
|
+
@click.argument("serial_number", type=SERIAL)
|
|
30
|
+
@click.pass_context
|
|
31
|
+
@connection_command()
|
|
32
|
+
def query_datapoint(ctx: Context, serial_number: str, datapoint: DataPointType) -> None:
|
|
33
|
+
r"""Query a specific datapoint from Conbus server.
|
|
34
|
+
|
|
35
|
+
Args:
|
|
36
|
+
ctx: Click context object.
|
|
37
|
+
serial_number: 10-digit module serial number.
|
|
38
|
+
datapoint: Datapoint type to query.
|
|
39
|
+
|
|
40
|
+
Examples:
|
|
41
|
+
\b
|
|
42
|
+
xp conbus datapoint query version 0012345011
|
|
43
|
+
xp conbus datapoint query voltage 0012345011
|
|
44
|
+
xp conbus datapoint query temperature 0012345011
|
|
45
|
+
xp conbus datapoint query current 0012345011
|
|
46
|
+
xp conbus datapoint query humidity 0012345011
|
|
47
|
+
"""
|
|
48
|
+
service: ConbusDatapointService = (
|
|
49
|
+
ctx.obj.get("container").get_container().resolve(ConbusDatapointService)
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
def on_finish(service_response: ConbusDatapointResponse) -> None:
|
|
53
|
+
"""Handle successful completion of datapoint query.
|
|
54
|
+
|
|
55
|
+
Args:
|
|
56
|
+
service_response: Datapoint response object.
|
|
57
|
+
"""
|
|
58
|
+
click.echo(json.dumps(service_response.to_dict(), indent=2))
|
|
59
|
+
|
|
60
|
+
# Send telegram
|
|
61
|
+
with service:
|
|
62
|
+
service.query_datapoint(
|
|
63
|
+
serial_number=serial_number,
|
|
64
|
+
datapoint_type=datapoint,
|
|
65
|
+
finish_callback=on_finish,
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
# Add the single datapoint query command to the group
|
|
70
|
+
conbus_datapoint.add_command(query_datapoint)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
@conbus_datapoint.command("all", short_help="Query all datapoints from a module")
|
|
74
|
+
@click.argument("serial_number", type=SERIAL)
|
|
75
|
+
@click.pass_context
|
|
76
|
+
@connection_command()
|
|
77
|
+
def query_all_datapoints(ctx: Context, serial_number: str) -> None:
|
|
78
|
+
r"""Query all datapoints from a specific module.
|
|
79
|
+
|
|
80
|
+
Args:
|
|
81
|
+
ctx: Click context object.
|
|
82
|
+
serial_number: 10-digit module serial number.
|
|
83
|
+
|
|
84
|
+
Examples:
|
|
85
|
+
\b
|
|
86
|
+
xp conbus datapoint all 0123450001
|
|
87
|
+
"""
|
|
88
|
+
service: ConbusDatapointQueryAllService = (
|
|
89
|
+
ctx.obj.get("container").get_container().resolve(ConbusDatapointQueryAllService)
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
def on_finish(service_response: ConbusDatapointResponse) -> None:
|
|
93
|
+
"""Handle successful completion of all datapoints query.
|
|
94
|
+
|
|
95
|
+
Args:
|
|
96
|
+
service_response: Datapoint response object with all datapoints.
|
|
97
|
+
"""
|
|
98
|
+
click.echo(json.dumps(service_response.to_dict(), indent=2))
|
|
99
|
+
|
|
100
|
+
def on_progress(reply_telegram: ReplyTelegram) -> None:
|
|
101
|
+
"""Handle progress updates during all datapoints query.
|
|
102
|
+
|
|
103
|
+
Args:
|
|
104
|
+
reply_telegram: Reply telegram object with progress data.
|
|
105
|
+
"""
|
|
106
|
+
click.echo(json.dumps(reply_telegram.to_dict(), indent=2))
|
|
107
|
+
|
|
108
|
+
with service:
|
|
109
|
+
service.query_all_datapoints(
|
|
110
|
+
serial_number=serial_number,
|
|
111
|
+
finish_callback=on_finish,
|
|
112
|
+
progress_callback=on_progress,
|
|
113
|
+
)
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"""Conbus client operations CLI commands."""
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
|
|
5
|
+
import click
|
|
6
|
+
|
|
7
|
+
from xp.cli.commands.conbus.conbus import conbus
|
|
8
|
+
from xp.cli.utils.decorators import (
|
|
9
|
+
connection_command,
|
|
10
|
+
)
|
|
11
|
+
from xp.models import ConbusDiscoverResponse
|
|
12
|
+
from xp.models.conbus.conbus_discover import DiscoveredDevice
|
|
13
|
+
from xp.services.conbus.conbus_discover_service import (
|
|
14
|
+
ConbusDiscoverService,
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@conbus.command("discover")
|
|
19
|
+
@click.pass_context
|
|
20
|
+
@connection_command()
|
|
21
|
+
def send_discover_telegram(ctx: click.Context) -> None:
|
|
22
|
+
r"""Send discover telegram to Conbus server.
|
|
23
|
+
|
|
24
|
+
Args:
|
|
25
|
+
ctx: Click context object.
|
|
26
|
+
|
|
27
|
+
Examples:
|
|
28
|
+
\b
|
|
29
|
+
xp conbus discover
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
def on_finish(discovered_devices: ConbusDiscoverResponse) -> None:
|
|
33
|
+
"""Handle successful completion of device discovery.
|
|
34
|
+
|
|
35
|
+
Args:
|
|
36
|
+
discovered_devices: Discover response with all found devices.
|
|
37
|
+
"""
|
|
38
|
+
click.echo(json.dumps(discovered_devices.to_dict(), indent=2))
|
|
39
|
+
|
|
40
|
+
def on_device_discovered(discovered_device: DiscoveredDevice) -> None:
|
|
41
|
+
"""Handle discovery of sa single module.
|
|
42
|
+
|
|
43
|
+
Args:
|
|
44
|
+
discovered_device: Discover device.
|
|
45
|
+
"""
|
|
46
|
+
click.echo(json.dumps(discovered_device, indent=2))
|
|
47
|
+
|
|
48
|
+
def progress(_serial_number: str) -> None:
|
|
49
|
+
"""Handle progress updates during device discovery.
|
|
50
|
+
|
|
51
|
+
Args:
|
|
52
|
+
_serial_number: Serial number of discovered device (unused).
|
|
53
|
+
"""
|
|
54
|
+
# click.echo(f"Discovered : {serial_number}")
|
|
55
|
+
pass
|
|
56
|
+
|
|
57
|
+
service: ConbusDiscoverService = (
|
|
58
|
+
ctx.obj.get("container").get_container().resolve(ConbusDiscoverService)
|
|
59
|
+
)
|
|
60
|
+
service.run(progress, on_device_discovered, on_finish, 5)
|
|
61
|
+
service.start_reactor()
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"""Conbus event operations CLI commands."""
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
|
|
5
|
+
import click
|
|
6
|
+
|
|
7
|
+
from xp.cli.commands.conbus.conbus import conbus
|
|
8
|
+
from xp.cli.utils.decorators import connection_command
|
|
9
|
+
from xp.cli.utils.module_type_choice import MODULE_TYPE
|
|
10
|
+
from xp.models import ConbusEventRawResponse
|
|
11
|
+
from xp.services.conbus.conbus_event_raw_service import ConbusEventRawService
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@click.group(name="event")
|
|
15
|
+
def conbus_event() -> None:
|
|
16
|
+
"""Send event telegrams to Conbus modules."""
|
|
17
|
+
pass
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@conbus_event.command("raw")
|
|
21
|
+
@click.argument("module_type", type=MODULE_TYPE)
|
|
22
|
+
@click.argument("link_number", type=click.IntRange(0, 99))
|
|
23
|
+
@click.argument("input_number", type=click.IntRange(0, 9))
|
|
24
|
+
@click.argument("time_ms", type=click.IntRange(min=1), default=1000)
|
|
25
|
+
@click.pass_context
|
|
26
|
+
@connection_command()
|
|
27
|
+
def send_event_raw(
|
|
28
|
+
ctx: click.Context,
|
|
29
|
+
module_type: int,
|
|
30
|
+
link_number: int,
|
|
31
|
+
input_number: int,
|
|
32
|
+
time_ms: int,
|
|
33
|
+
) -> None:
|
|
34
|
+
r"""Send raw event telegrams to simulate button presses.
|
|
35
|
+
|
|
36
|
+
Args:
|
|
37
|
+
ctx: Click context object.
|
|
38
|
+
module_type: Module type code (e.g., CP20, XP33).
|
|
39
|
+
link_number: Link number (0-99).
|
|
40
|
+
input_number: Input number (0-9).
|
|
41
|
+
time_ms: Delay between MAKE/BREAK events in milliseconds (default: 1000).
|
|
42
|
+
|
|
43
|
+
Examples:
|
|
44
|
+
\b
|
|
45
|
+
xp conbus event raw CP20 00 00
|
|
46
|
+
xp conbus event raw XP33 00 00 500
|
|
47
|
+
"""
|
|
48
|
+
|
|
49
|
+
def on_finish(response: ConbusEventRawResponse) -> None:
|
|
50
|
+
"""Handle successful completion of event raw operation.
|
|
51
|
+
|
|
52
|
+
Args:
|
|
53
|
+
response: Event raw response with sent and received telegrams.
|
|
54
|
+
"""
|
|
55
|
+
click.echo(json.dumps(response.to_dict(), indent=2))
|
|
56
|
+
|
|
57
|
+
def on_progress(telegram: str) -> None:
|
|
58
|
+
"""Handle progress updates during event operation.
|
|
59
|
+
|
|
60
|
+
Args:
|
|
61
|
+
telegram: Received telegram.
|
|
62
|
+
"""
|
|
63
|
+
click.echo(json.dumps({"telegram": telegram}))
|
|
64
|
+
|
|
65
|
+
service: ConbusEventRawService = (
|
|
66
|
+
ctx.obj.get("container").get_container().resolve(ConbusEventRawService)
|
|
67
|
+
)
|
|
68
|
+
service.run(
|
|
69
|
+
module_type_code=module_type,
|
|
70
|
+
link_number=link_number,
|
|
71
|
+
input_number=input_number,
|
|
72
|
+
time_ms=time_ms,
|
|
73
|
+
progress_callback=on_progress,
|
|
74
|
+
finish_callback=on_finish,
|
|
75
|
+
timeout_seconds=5,
|
|
76
|
+
)
|
|
77
|
+
service.start_reactor()
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
# Register the event command group with conbus
|
|
81
|
+
conbus.add_command(conbus_event)
|