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
|
@@ -23,23 +23,30 @@ from xp.services.telegram.telegram_blink_service import BlinkError
|
|
|
23
23
|
@connection_command()
|
|
24
24
|
@handle_service_errors(BlinkError)
|
|
25
25
|
def send_blink_on_telegram(ctx: Context, serial_number: str) -> None:
|
|
26
|
-
"""
|
|
27
|
-
Send blink command to start blinking module LED.
|
|
26
|
+
r"""Send blink command to start blinking module LED.
|
|
28
27
|
|
|
29
|
-
|
|
28
|
+
Args:
|
|
29
|
+
ctx: Click context object.
|
|
30
|
+
serial_number: 10-digit module serial number.
|
|
30
31
|
|
|
31
|
-
|
|
32
|
+
Examples:
|
|
33
|
+
\b
|
|
32
34
|
xp conbus blink on 0012345008
|
|
33
35
|
"""
|
|
34
36
|
|
|
35
|
-
def
|
|
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
|
+
"""
|
|
36
43
|
click.echo(json.dumps(service_response.to_dict(), indent=2))
|
|
37
44
|
|
|
38
45
|
service: ConbusBlinkService = (
|
|
39
46
|
ctx.obj.get("container").get_container().resolve(ConbusBlinkService)
|
|
40
47
|
)
|
|
41
48
|
with service:
|
|
42
|
-
service.send_blink_telegram(serial_number, "on",
|
|
49
|
+
service.send_blink_telegram(serial_number, "on", on_finish, 0.5)
|
|
43
50
|
|
|
44
51
|
|
|
45
52
|
@conbus_blink.command("off")
|
|
@@ -48,30 +55,35 @@ def send_blink_on_telegram(ctx: Context, serial_number: str) -> None:
|
|
|
48
55
|
@connection_command()
|
|
49
56
|
@handle_service_errors(BlinkError)
|
|
50
57
|
def send_blink_off_telegram(ctx: Context, serial_number: str) -> None:
|
|
51
|
-
"""
|
|
52
|
-
Send blink command to start blinking module LED.
|
|
58
|
+
r"""Send blink command to stop blinking module LED.
|
|
53
59
|
|
|
54
|
-
|
|
60
|
+
Args:
|
|
61
|
+
ctx: Click context object.
|
|
62
|
+
serial_number: 10-digit module serial number.
|
|
55
63
|
|
|
56
|
-
|
|
64
|
+
Examples:
|
|
65
|
+
\b
|
|
57
66
|
xp conbus blink off 0012345008
|
|
58
67
|
"""
|
|
59
68
|
|
|
60
|
-
def
|
|
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
|
+
"""
|
|
61
75
|
click.echo(json.dumps(service_response.to_dict(), indent=2))
|
|
62
76
|
|
|
63
77
|
service: ConbusBlinkService = (
|
|
64
78
|
ctx.obj.get("container").get_container().resolve(ConbusBlinkService)
|
|
65
79
|
)
|
|
66
80
|
with service:
|
|
67
|
-
service.send_blink_telegram(serial_number, "off",
|
|
81
|
+
service.send_blink_telegram(serial_number, "off", on_finish, 0.5)
|
|
68
82
|
|
|
69
83
|
|
|
70
84
|
@conbus_blink.group("all", short_help="Control blink state for all devices")
|
|
71
85
|
def conbus_blink_all() -> None:
|
|
72
|
-
"""
|
|
73
|
-
Control blink state for all discovered devices.
|
|
74
|
-
"""
|
|
86
|
+
"""Control blink state for all discovered devices."""
|
|
75
87
|
pass
|
|
76
88
|
|
|
77
89
|
|
|
@@ -80,27 +92,37 @@ def conbus_blink_all() -> None:
|
|
|
80
92
|
@connection_command()
|
|
81
93
|
@handle_service_errors(BlinkError)
|
|
82
94
|
def blink_all_off(ctx: Context) -> None:
|
|
83
|
-
"""
|
|
84
|
-
Turn off blinking for all discovered devices.
|
|
95
|
+
r"""Turn off blinking for all discovered devices.
|
|
85
96
|
|
|
86
|
-
|
|
97
|
+
Args:
|
|
98
|
+
ctx: Click context object.
|
|
87
99
|
|
|
88
|
-
|
|
100
|
+
Examples:
|
|
101
|
+
\b
|
|
89
102
|
xp conbus blink all off
|
|
90
103
|
"""
|
|
91
104
|
|
|
92
|
-
def
|
|
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
|
+
"""
|
|
93
111
|
click.echo(json.dumps(discovered_devices.to_dict(), indent=2))
|
|
94
112
|
|
|
95
113
|
def progress(message: str) -> None:
|
|
114
|
+
"""Handle progress updates during blink all off operation.
|
|
115
|
+
|
|
116
|
+
Args:
|
|
117
|
+
message: Progress message string.
|
|
118
|
+
"""
|
|
96
119
|
click.echo(message)
|
|
97
|
-
pass
|
|
98
120
|
|
|
99
121
|
service: ConbusBlinkAllService = (
|
|
100
122
|
ctx.obj.get("container").get_container().resolve(ConbusBlinkAllService)
|
|
101
123
|
)
|
|
102
124
|
with service:
|
|
103
|
-
service.send_blink_all_telegram("off", progress,
|
|
125
|
+
service.send_blink_all_telegram("off", progress, on_finish, 0.5)
|
|
104
126
|
|
|
105
127
|
|
|
106
128
|
@conbus_blink_all.command("on", short_help="Turn on blinking for all devices")
|
|
@@ -108,24 +130,34 @@ def blink_all_off(ctx: Context) -> None:
|
|
|
108
130
|
@connection_command()
|
|
109
131
|
@handle_service_errors(BlinkError)
|
|
110
132
|
def blink_all_on(ctx: Context) -> None:
|
|
111
|
-
"""
|
|
112
|
-
Turn on blinking for all discovered devices.
|
|
133
|
+
r"""Turn on blinking for all discovered devices.
|
|
113
134
|
|
|
114
|
-
|
|
135
|
+
Args:
|
|
136
|
+
ctx: Click context object.
|
|
115
137
|
|
|
116
|
-
|
|
138
|
+
Examples:
|
|
139
|
+
\b
|
|
117
140
|
xp conbus blink all on
|
|
118
141
|
"""
|
|
119
142
|
|
|
120
|
-
def
|
|
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
|
+
"""
|
|
121
149
|
click.echo(json.dumps(discovered_devices.to_dict(), indent=2))
|
|
122
150
|
|
|
123
151
|
def progress(message: str) -> None:
|
|
152
|
+
"""Handle progress updates during blink all on operation.
|
|
153
|
+
|
|
154
|
+
Args:
|
|
155
|
+
message: Progress message string.
|
|
156
|
+
"""
|
|
124
157
|
click.echo(message)
|
|
125
|
-
pass
|
|
126
158
|
|
|
127
159
|
service: ConbusBlinkAllService = (
|
|
128
160
|
ctx.obj.get("container").get_container().resolve(ConbusBlinkAllService)
|
|
129
161
|
)
|
|
130
162
|
with service:
|
|
131
|
-
service.send_blink_all_telegram("on", progress,
|
|
163
|
+
service.send_blink_all_telegram("on", progress, on_finish, 0.5)
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
"""Conbus configuration CLI commands."""
|
|
2
|
+
|
|
1
3
|
import json
|
|
2
4
|
|
|
3
5
|
import click
|
|
@@ -12,13 +14,16 @@ from xp.models import ConbusClientConfig
|
|
|
12
14
|
@click.pass_context
|
|
13
15
|
@handle_service_errors(Exception)
|
|
14
16
|
def show_config(ctx: Context) -> None:
|
|
15
|
-
"""
|
|
16
|
-
Display current Conbus client configuration.
|
|
17
|
+
r"""Display current Conbus client configuration.
|
|
17
18
|
|
|
18
|
-
|
|
19
|
+
Args:
|
|
20
|
+
ctx: Click context object.
|
|
19
21
|
|
|
20
|
-
|
|
22
|
+
Examples:
|
|
23
|
+
\b
|
|
21
24
|
xp conbus config
|
|
22
25
|
"""
|
|
23
|
-
config =
|
|
26
|
+
config: ConbusClientConfig = (
|
|
27
|
+
ctx.obj.get("container").get_container().resolve(ConbusClientConfig)
|
|
28
|
+
)
|
|
24
29
|
click.echo(json.dumps(config.conbus.model_dump(mode="json"), indent=2))
|
|
@@ -23,18 +23,29 @@ from xp.services.conbus.conbus_custom_service import ConbusCustomService
|
|
|
23
23
|
def send_custom_telegram(
|
|
24
24
|
ctx: Context, serial_number: str, function_code: str, datapoint_code: str
|
|
25
25
|
) -> None:
|
|
26
|
-
"""
|
|
27
|
-
Send custom telegram with specified function and data point codes.
|
|
26
|
+
r"""Send custom telegram with specified function and data point codes.
|
|
28
27
|
|
|
29
|
-
|
|
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.
|
|
30
33
|
|
|
31
|
-
|
|
34
|
+
Examples:
|
|
35
|
+
\b
|
|
32
36
|
xp conbus custom 0012345011 02 E2
|
|
33
37
|
xp conbus custom 0012345011 17 AA
|
|
34
38
|
"""
|
|
35
|
-
service =
|
|
39
|
+
service: ConbusCustomService = (
|
|
40
|
+
ctx.obj.get("container").get_container().resolve(ConbusCustomService)
|
|
41
|
+
)
|
|
36
42
|
|
|
37
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
|
+
"""
|
|
38
49
|
click.echo(json.dumps(service_response.to_dict(), indent=2))
|
|
39
50
|
|
|
40
51
|
with service:
|
|
@@ -30,21 +30,31 @@ from xp.services.conbus.conbus_datapoint_service import (
|
|
|
30
30
|
@click.pass_context
|
|
31
31
|
@connection_command()
|
|
32
32
|
def query_datapoint(ctx: Context, serial_number: str, datapoint: DataPointType) -> None:
|
|
33
|
-
"""
|
|
34
|
-
Query a specific datapoint from Conbus server.
|
|
33
|
+
r"""Query a specific datapoint from Conbus server.
|
|
35
34
|
|
|
36
|
-
|
|
35
|
+
Args:
|
|
36
|
+
ctx: Click context object.
|
|
37
|
+
serial_number: 10-digit module serial number.
|
|
38
|
+
datapoint: Datapoint type to query.
|
|
37
39
|
|
|
38
|
-
|
|
40
|
+
Examples:
|
|
41
|
+
\b
|
|
39
42
|
xp conbus datapoint query version 0012345011
|
|
40
43
|
xp conbus datapoint query voltage 0012345011
|
|
41
44
|
xp conbus datapoint query temperature 0012345011
|
|
42
45
|
xp conbus datapoint query current 0012345011
|
|
43
46
|
xp conbus datapoint query humidity 0012345011
|
|
44
47
|
"""
|
|
45
|
-
service =
|
|
48
|
+
service: ConbusDatapointService = (
|
|
49
|
+
ctx.obj.get("container").get_container().resolve(ConbusDatapointService)
|
|
50
|
+
)
|
|
46
51
|
|
|
47
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
|
+
"""
|
|
48
58
|
click.echo(json.dumps(service_response.to_dict(), indent=2))
|
|
49
59
|
|
|
50
60
|
# Send telegram
|
|
@@ -65,22 +75,34 @@ conbus_datapoint.add_command(query_datapoint)
|
|
|
65
75
|
@click.pass_context
|
|
66
76
|
@connection_command()
|
|
67
77
|
def query_all_datapoints(ctx: Context, serial_number: str) -> None:
|
|
68
|
-
"""
|
|
69
|
-
Query all datapoints from a specific module.
|
|
78
|
+
r"""Query all datapoints from a specific module.
|
|
70
79
|
|
|
71
|
-
|
|
80
|
+
Args:
|
|
81
|
+
ctx: Click context object.
|
|
82
|
+
serial_number: 10-digit module serial number.
|
|
72
83
|
|
|
73
|
-
|
|
84
|
+
Examples:
|
|
85
|
+
\b
|
|
74
86
|
xp conbus datapoint all 0123450001
|
|
75
87
|
"""
|
|
76
|
-
service = (
|
|
88
|
+
service: ConbusDatapointQueryAllService = (
|
|
77
89
|
ctx.obj.get("container").get_container().resolve(ConbusDatapointQueryAllService)
|
|
78
90
|
)
|
|
79
91
|
|
|
80
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
|
+
"""
|
|
81
98
|
click.echo(json.dumps(service_response.to_dict(), indent=2))
|
|
82
99
|
|
|
83
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
|
+
"""
|
|
84
106
|
click.echo(json.dumps(reply_telegram.to_dict(), indent=2))
|
|
85
107
|
|
|
86
108
|
with service:
|
|
@@ -18,22 +18,35 @@ from xp.services.conbus.conbus_discover_service import (
|
|
|
18
18
|
@click.pass_context
|
|
19
19
|
@connection_command()
|
|
20
20
|
def send_discover_telegram(ctx: click.Context) -> None:
|
|
21
|
-
"""
|
|
22
|
-
Send discover telegram to Conbus server.
|
|
21
|
+
r"""Send discover telegram to Conbus server.
|
|
23
22
|
|
|
24
|
-
|
|
23
|
+
Args:
|
|
24
|
+
ctx: Click context object.
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
Examples:
|
|
27
|
+
\b
|
|
27
28
|
xp conbus discover
|
|
28
29
|
"""
|
|
29
30
|
|
|
30
|
-
def
|
|
31
|
+
def on_finish(discovered_devices: ConbusDiscoverResponse) -> None:
|
|
32
|
+
"""Handle successful completion of device discovery.
|
|
33
|
+
|
|
34
|
+
Args:
|
|
35
|
+
discovered_devices: Discover response with all found devices.
|
|
36
|
+
"""
|
|
31
37
|
click.echo(json.dumps(discovered_devices.to_dict(), indent=2))
|
|
32
38
|
|
|
33
39
|
def progress(_serial_number: str) -> None:
|
|
40
|
+
"""Handle progress updates during device discovery.
|
|
41
|
+
|
|
42
|
+
Args:
|
|
43
|
+
_serial_number: Serial number of discovered device (unused).
|
|
44
|
+
"""
|
|
34
45
|
# click.echo(f"Discovered : {serial_number}")
|
|
35
46
|
pass
|
|
36
47
|
|
|
37
|
-
service =
|
|
48
|
+
service: ConbusDiscoverService = (
|
|
49
|
+
ctx.obj.get("container").get_container().resolve(ConbusDiscoverService)
|
|
50
|
+
)
|
|
38
51
|
with service:
|
|
39
|
-
service.start(progress,
|
|
52
|
+
service.start(progress, on_finish, 0.5)
|
|
@@ -7,14 +7,14 @@ import click
|
|
|
7
7
|
from xp.cli.commands.conbus.conbus import conbus_lightlevel
|
|
8
8
|
from xp.cli.utils.decorators import (
|
|
9
9
|
connection_command,
|
|
10
|
-
handle_service_errors,
|
|
11
10
|
)
|
|
12
11
|
from xp.cli.utils.serial_number_type import SERIAL
|
|
13
|
-
from xp.models
|
|
14
|
-
from xp.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
@conbus_lightlevel.command("set")
|
|
@@ -23,28 +23,45 @@ from xp.services.conbus.conbus_lightlevel_set_service import (
|
|
|
23
23
|
@click.argument("level", type=click.IntRange(0, 100))
|
|
24
24
|
@click.pass_context
|
|
25
25
|
@connection_command()
|
|
26
|
-
@handle_service_errors(ConbusLightlevelError)
|
|
27
26
|
def xp_lightlevel_set(
|
|
28
27
|
ctx: click.Context, serial_number: str, output_number: int, level: int
|
|
29
28
|
) -> None:
|
|
30
|
-
"""Set light level for output_number on XP module serial_number
|
|
29
|
+
r"""Set light level for output_number on XP module serial_number.
|
|
31
30
|
|
|
32
|
-
|
|
31
|
+
Args:
|
|
32
|
+
ctx: Click context object.
|
|
33
|
+
serial_number: 10-digit module serial number.
|
|
34
|
+
output_number: Output number (0-8).
|
|
35
|
+
level: Light level (0-100).
|
|
33
36
|
|
|
34
|
-
|
|
37
|
+
Examples:
|
|
38
|
+
\b
|
|
35
39
|
xp conbus lightlevel set 0123450001 2 50 # Set output 2 to 50%
|
|
36
40
|
xp conbus lightlevel set 0011223344 0 100 # Set output 0 to 100%
|
|
37
41
|
"""
|
|
38
42
|
|
|
39
|
-
def
|
|
43
|
+
def on_finish(response: "ConbusWriteConfigResponse") -> None:
|
|
44
|
+
"""Handle successful completion of light level on command.
|
|
45
|
+
|
|
46
|
+
Args:
|
|
47
|
+
response: Light level response object.
|
|
48
|
+
"""
|
|
40
49
|
click.echo(json.dumps(response.to_dict(), indent=2))
|
|
41
50
|
|
|
42
|
-
service = (
|
|
43
|
-
ctx.obj.get("container").get_container().resolve(
|
|
51
|
+
service: WriteConfigService = (
|
|
52
|
+
ctx.obj.get("container").get_container().resolve(WriteConfigService)
|
|
44
53
|
)
|
|
45
54
|
|
|
55
|
+
data_value = f"{output_number:02d}:{level:03d}"
|
|
56
|
+
|
|
46
57
|
with service:
|
|
47
|
-
service.
|
|
58
|
+
service.write_config(
|
|
59
|
+
serial_number=serial_number,
|
|
60
|
+
datapoint_type=DataPointType.MODULE_LIGHT_LEVEL,
|
|
61
|
+
data_value=data_value,
|
|
62
|
+
finish_callback=on_finish,
|
|
63
|
+
timeout_seconds=0.5,
|
|
64
|
+
)
|
|
48
65
|
|
|
49
66
|
|
|
50
67
|
@conbus_lightlevel.command("off")
|
|
@@ -52,28 +69,45 @@ def xp_lightlevel_set(
|
|
|
52
69
|
@click.argument("output_number", type=click.IntRange(0, 8))
|
|
53
70
|
@click.pass_context
|
|
54
71
|
@connection_command()
|
|
55
|
-
@handle_service_errors(ConbusLightlevelError)
|
|
56
72
|
def xp_lightlevel_off(
|
|
57
73
|
ctx: click.Context, serial_number: str, output_number: int
|
|
58
74
|
) -> None:
|
|
59
|
-
"""Turn off light for output_number on XP module serial_number (set level to 0)
|
|
75
|
+
r"""Turn off light for output_number on XP module serial_number (set level to 0).
|
|
60
76
|
|
|
61
|
-
|
|
77
|
+
Args:
|
|
78
|
+
ctx: Click context object.
|
|
79
|
+
serial_number: 10-digit module serial number.
|
|
80
|
+
output_number: Output number (0-8).
|
|
62
81
|
|
|
63
|
-
|
|
82
|
+
Examples:
|
|
83
|
+
\b
|
|
64
84
|
xp conbus lightlevel off 0123450001 2 # Turn off output 2
|
|
65
85
|
xp conbus lightlevel off 0011223344 0 # Turn off output 0
|
|
66
86
|
"""
|
|
67
87
|
|
|
68
|
-
def
|
|
88
|
+
def on_finish(response: "ConbusWriteConfigResponse") -> None:
|
|
89
|
+
"""Handle successful completion of light level on command.
|
|
90
|
+
|
|
91
|
+
Args:
|
|
92
|
+
response: Light level response object.
|
|
93
|
+
"""
|
|
69
94
|
click.echo(json.dumps(response.to_dict(), indent=2))
|
|
70
95
|
|
|
71
|
-
service = (
|
|
72
|
-
ctx.obj.get("container").get_container().resolve(
|
|
96
|
+
service: WriteConfigService = (
|
|
97
|
+
ctx.obj.get("container").get_container().resolve(WriteConfigService)
|
|
73
98
|
)
|
|
74
99
|
|
|
100
|
+
level = 0
|
|
101
|
+
data_value = f"{output_number:02d}:{level:03d}"
|
|
102
|
+
|
|
75
103
|
with service:
|
|
76
|
-
service.
|
|
104
|
+
service.write_config(
|
|
105
|
+
serial_number=serial_number,
|
|
106
|
+
datapoint_type=DataPointType.MODULE_LIGHT_LEVEL,
|
|
107
|
+
data_value=data_value,
|
|
108
|
+
finish_callback=on_finish,
|
|
109
|
+
timeout_seconds=0.5,
|
|
110
|
+
)
|
|
77
111
|
|
|
78
112
|
|
|
79
113
|
@conbus_lightlevel.command("on")
|
|
@@ -81,28 +115,45 @@ def xp_lightlevel_off(
|
|
|
81
115
|
@click.argument("output_number", type=click.IntRange(0, 8))
|
|
82
116
|
@click.pass_context
|
|
83
117
|
@connection_command()
|
|
84
|
-
@handle_service_errors(ConbusLightlevelError)
|
|
85
118
|
def xp_lightlevel_on(
|
|
86
119
|
ctx: click.Context, serial_number: str, output_number: int
|
|
87
120
|
) -> None:
|
|
88
|
-
"""Turn on light for output_number on XP module serial_number (set level to 80%)
|
|
121
|
+
r"""Turn on light for output_number on XP module serial_number (set level to 80%).
|
|
89
122
|
|
|
90
|
-
|
|
123
|
+
Args:
|
|
124
|
+
ctx: Click context object.
|
|
125
|
+
serial_number: 10-digit module serial number.
|
|
126
|
+
output_number: Output number (0-8).
|
|
91
127
|
|
|
92
|
-
|
|
128
|
+
Examples:
|
|
129
|
+
\b
|
|
93
130
|
xp conbus lightlevel on 0123450001 2 # Turn on output 2 (80%)
|
|
94
131
|
xp conbus lightlevel on 0011223344 0 # Turn on output 0 (80%)
|
|
95
132
|
"""
|
|
96
133
|
|
|
97
|
-
def
|
|
134
|
+
def on_finish(response: "ConbusWriteConfigResponse") -> None:
|
|
135
|
+
"""Handle successful completion of light level on command.
|
|
136
|
+
|
|
137
|
+
Args:
|
|
138
|
+
response: Light level response object.
|
|
139
|
+
"""
|
|
98
140
|
click.echo(json.dumps(response.to_dict(), indent=2))
|
|
99
141
|
|
|
100
|
-
service = (
|
|
101
|
-
ctx.obj.get("container").get_container().resolve(
|
|
142
|
+
service: WriteConfigService = (
|
|
143
|
+
ctx.obj.get("container").get_container().resolve(WriteConfigService)
|
|
102
144
|
)
|
|
103
145
|
|
|
146
|
+
level = 60
|
|
147
|
+
data_value = f"{output_number:02d}:{level:03d}"
|
|
148
|
+
|
|
104
149
|
with service:
|
|
105
|
-
service.
|
|
150
|
+
service.write_config(
|
|
151
|
+
serial_number=serial_number,
|
|
152
|
+
datapoint_type=DataPointType.MODULE_LIGHT_LEVEL,
|
|
153
|
+
data_value=data_value,
|
|
154
|
+
finish_callback=on_finish,
|
|
155
|
+
timeout_seconds=0.5,
|
|
156
|
+
)
|
|
106
157
|
|
|
107
158
|
|
|
108
159
|
@conbus_lightlevel.command("get")
|
|
@@ -110,23 +161,47 @@ def xp_lightlevel_on(
|
|
|
110
161
|
@click.argument("output_number", type=click.IntRange(0, 8))
|
|
111
162
|
@click.pass_context
|
|
112
163
|
@connection_command()
|
|
113
|
-
@handle_service_errors(ConbusLightlevelError)
|
|
114
164
|
def xp_lightlevel_get(
|
|
115
165
|
ctx: click.Context, serial_number: str, output_number: int
|
|
116
166
|
) -> None:
|
|
117
|
-
"""Get current light level for output_number on XP module serial_number
|
|
167
|
+
r"""Get current light level for output_number on XP module serial_number.
|
|
168
|
+
|
|
169
|
+
Args:
|
|
170
|
+
ctx: Click context object.
|
|
171
|
+
serial_number: 10-digit module serial number.
|
|
172
|
+
output_number: Output number (0-8).
|
|
173
|
+
|
|
118
174
|
Examples:
|
|
119
|
-
|
|
175
|
+
\b
|
|
120
176
|
xp conbus lightlevel get 0123450001 2 # Get light level for output 2
|
|
121
177
|
xp conbus lightlevel get 0011223344 0 # Get light level for output 0
|
|
122
178
|
"""
|
|
179
|
+
# Get service from container
|
|
180
|
+
service: ConbusDatapointService = (
|
|
181
|
+
ctx.obj.get("container").get_container().resolve(ConbusDatapointService)
|
|
182
|
+
)
|
|
183
|
+
telegram_service: TelegramDatapointService = (
|
|
184
|
+
ctx.obj.get("container").get_container().resolve(TelegramDatapointService)
|
|
185
|
+
)
|
|
123
186
|
|
|
124
|
-
def
|
|
125
|
-
|
|
187
|
+
def on_finish(service_response: "ConbusDatapointResponse") -> None:
|
|
188
|
+
"""Handle successful completion of light level get command.
|
|
126
189
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
190
|
+
Args:
|
|
191
|
+
service_response: Light level response object.
|
|
192
|
+
"""
|
|
193
|
+
lightlevel_level = telegram_service.get_lightlevel(
|
|
194
|
+
service_response.data_value, output_number
|
|
195
|
+
)
|
|
196
|
+
result = service_response.to_dict()
|
|
197
|
+
result["output_number"] = output_number
|
|
198
|
+
result["lightlevel_level"] = lightlevel_level
|
|
199
|
+
click.echo(json.dumps(result, indent=2))
|
|
130
200
|
|
|
131
201
|
with service:
|
|
132
|
-
service.
|
|
202
|
+
service.query_datapoint(
|
|
203
|
+
serial_number=serial_number,
|
|
204
|
+
datapoint_type=DataPointType.MODULE_LIGHT_LEVEL,
|
|
205
|
+
finish_callback=on_finish,
|
|
206
|
+
timeout_seconds=0.5,
|
|
207
|
+
)
|