conson-xp 1.52.0__py3-none-any.whl → 2.0.1__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.52.0.dist-info → conson_xp-2.0.1.dist-info}/METADATA +1 -11
- {conson_xp-1.52.0.dist-info → conson_xp-2.0.1.dist-info}/RECORD +20 -39
- xp/__init__.py +1 -1
- xp/cli/commands/__init__.py +0 -4
- xp/cli/commands/term/term_commands.py +1 -1
- xp/cli/main.py +23 -7
- xp/models/conbus/conbus_client_config.py +2 -0
- xp/models/protocol/conbus_protocol.py +30 -25
- xp/models/term/accessory_state.py +1 -1
- xp/services/protocol/__init__.py +2 -3
- xp/services/protocol/conbus_event_protocol.py +6 -6
- xp/services/term/homekit_accessory_driver.py +5 -2
- xp/services/term/homekit_service.py +118 -11
- xp/term/homekit.py +140 -8
- xp/term/homekit.tcss +4 -4
- xp/term/widgets/room_list.py +61 -3
- xp/utils/dependencies.py +24 -154
- xp/cli/commands/homekit/__init__.py +0 -3
- xp/cli/commands/homekit/homekit.py +0 -120
- xp/cli/commands/homekit/homekit_start_commands.py +0 -44
- xp/services/homekit/__init__.py +0 -1
- xp/services/homekit/homekit_cache_service.py +0 -313
- xp/services/homekit/homekit_conbus_service.py +0 -99
- xp/services/homekit/homekit_config_validator.py +0 -327
- xp/services/homekit/homekit_conson_validator.py +0 -130
- xp/services/homekit/homekit_dimminglight.py +0 -189
- xp/services/homekit/homekit_dimminglight_service.py +0 -155
- xp/services/homekit/homekit_hap_service.py +0 -351
- xp/services/homekit/homekit_lightbulb.py +0 -125
- xp/services/homekit/homekit_lightbulb_service.py +0 -91
- xp/services/homekit/homekit_module_service.py +0 -60
- xp/services/homekit/homekit_outlet.py +0 -175
- xp/services/homekit/homekit_outlet_service.py +0 -127
- xp/services/homekit/homekit_service.py +0 -371
- xp/services/protocol/protocol_factory.py +0 -84
- xp/services/protocol/telegram_protocol.py +0 -270
- {conson_xp-1.52.0.dist-info → conson_xp-2.0.1.dist-info}/WHEEL +0 -0
- {conson_xp-1.52.0.dist-info → conson_xp-2.0.1.dist-info}/entry_points.txt +0 -0
- {conson_xp-1.52.0.dist-info → conson_xp-2.0.1.dist-info}/licenses/LICENSE +0 -0
xp/utils/dependencies.py
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"""Dependency injection container for XP services."""
|
|
2
2
|
|
|
3
3
|
import punq
|
|
4
|
-
from bubus import EventBus
|
|
5
4
|
from twisted.internet import asyncioreactor
|
|
6
|
-
from twisted.internet.interfaces import IConnector
|
|
7
5
|
from twisted.internet.posixbase import PosixReactorBase
|
|
8
6
|
|
|
9
7
|
from xp.models import ConbusClientConfig
|
|
@@ -55,19 +53,9 @@ from xp.services.conbus.conbus_raw_service import ConbusRawService
|
|
|
55
53
|
from xp.services.conbus.conbus_receive_service import ConbusReceiveService
|
|
56
54
|
from xp.services.conbus.conbus_scan_service import ConbusScanService
|
|
57
55
|
from xp.services.conbus.write_config_service import WriteConfigService
|
|
58
|
-
from xp.services.homekit.homekit_cache_service import HomeKitCacheService
|
|
59
|
-
from xp.services.homekit.homekit_conbus_service import HomeKitConbusService
|
|
60
|
-
from xp.services.homekit.homekit_dimminglight_service import HomeKitDimmingLightService
|
|
61
|
-
from xp.services.homekit.homekit_hap_service import HomekitHapService
|
|
62
|
-
from xp.services.homekit.homekit_lightbulb_service import HomeKitLightbulbService
|
|
63
|
-
from xp.services.homekit.homekit_module_service import HomekitModuleService
|
|
64
|
-
from xp.services.homekit.homekit_outlet_service import HomeKitOutletService
|
|
65
|
-
from xp.services.homekit.homekit_service import HomeKitService
|
|
66
56
|
from xp.services.log_file_service import LogFileService
|
|
67
57
|
from xp.services.module_type_service import ModuleTypeService
|
|
68
58
|
from xp.services.protocol import ConbusEventProtocol
|
|
69
|
-
from xp.services.protocol.protocol_factory import TelegramFactory
|
|
70
|
-
from xp.services.protocol.telegram_protocol import TelegramProtocol
|
|
71
59
|
from xp.services.reverse_proxy_service import ReverseProxyService
|
|
72
60
|
from xp.services.server.device_service_factory import DeviceServiceFactory
|
|
73
61
|
from xp.services.server.server_service import ServerService
|
|
@@ -169,7 +157,24 @@ class ServiceContainer:
|
|
|
169
157
|
self.container.register(TelegramDatapointService, scope=punq.Scope.singleton)
|
|
170
158
|
self.container.register(LinkNumberService, scope=punq.Scope.singleton)
|
|
171
159
|
|
|
160
|
+
# Reactor
|
|
161
|
+
self.container.register(
|
|
162
|
+
PosixReactorBase,
|
|
163
|
+
factory=lambda: reactor,
|
|
164
|
+
scope=punq.Scope.singleton,
|
|
165
|
+
)
|
|
166
|
+
|
|
172
167
|
# Conbus services layer
|
|
168
|
+
self.container.register(
|
|
169
|
+
ConbusEventProtocol,
|
|
170
|
+
factory=lambda: ConbusEventProtocol(
|
|
171
|
+
cli_config=self.container.resolve(ConbusClientConfig),
|
|
172
|
+
reactor=self.container.resolve(PosixReactorBase),
|
|
173
|
+
telegram_service=self.container.resolve(TelegramService),
|
|
174
|
+
),
|
|
175
|
+
scope=punq.Scope.singleton,
|
|
176
|
+
)
|
|
177
|
+
|
|
173
178
|
self.container.register(
|
|
174
179
|
ConbusDatapointService,
|
|
175
180
|
factory=lambda: ConbusDatapointService(
|
|
@@ -196,16 +201,6 @@ class ServiceContainer:
|
|
|
196
201
|
scope=punq.Scope.singleton,
|
|
197
202
|
)
|
|
198
203
|
|
|
199
|
-
self.container.register(
|
|
200
|
-
ConbusEventProtocol,
|
|
201
|
-
factory=lambda: ConbusEventProtocol(
|
|
202
|
-
cli_config=self.container.resolve(ConbusClientConfig),
|
|
203
|
-
reactor=self.container.resolve(PosixReactorBase),
|
|
204
|
-
telegram_service=self.container.resolve(TelegramService),
|
|
205
|
-
),
|
|
206
|
-
scope=punq.Scope.singleton,
|
|
207
|
-
)
|
|
208
|
-
|
|
209
204
|
self.container.register(
|
|
210
205
|
ConbusDiscoverService,
|
|
211
206
|
factory=lambda: ConbusDiscoverService(
|
|
@@ -268,6 +263,13 @@ class ServiceContainer:
|
|
|
268
263
|
scope=punq.Scope.singleton,
|
|
269
264
|
)
|
|
270
265
|
|
|
266
|
+
# HomeKit config
|
|
267
|
+
self.container.register(
|
|
268
|
+
HomekitConfig,
|
|
269
|
+
factory=lambda: HomekitConfig.from_yaml(self._homekit_config_path),
|
|
270
|
+
scope=punq.Scope.singleton,
|
|
271
|
+
)
|
|
272
|
+
|
|
271
273
|
self.container.register(
|
|
272
274
|
HomekitAccessoryDriver,
|
|
273
275
|
factory=lambda: HomekitAccessoryDriver(
|
|
@@ -441,39 +443,6 @@ class ServiceContainer:
|
|
|
441
443
|
scope=punq.Scope.singleton,
|
|
442
444
|
)
|
|
443
445
|
|
|
444
|
-
# HomeKit services layer
|
|
445
|
-
self.container.register(
|
|
446
|
-
HomekitModuleService,
|
|
447
|
-
factory=lambda: HomekitModuleService(
|
|
448
|
-
conson_modules_config=self.container.resolve(ConsonModuleListConfig),
|
|
449
|
-
),
|
|
450
|
-
scope=punq.Scope.singleton,
|
|
451
|
-
)
|
|
452
|
-
|
|
453
|
-
# Create event bus
|
|
454
|
-
self.container.register(
|
|
455
|
-
EventBus,
|
|
456
|
-
factory=lambda: EventBus(max_history_size=500),
|
|
457
|
-
scope=punq.Scope.singleton,
|
|
458
|
-
)
|
|
459
|
-
|
|
460
|
-
# HomeKit conson config
|
|
461
|
-
self.container.register(
|
|
462
|
-
HomekitConfig,
|
|
463
|
-
factory=lambda: HomekitConfig.from_yaml(self._homekit_config_path),
|
|
464
|
-
scope=punq.Scope.singleton,
|
|
465
|
-
)
|
|
466
|
-
|
|
467
|
-
self.container.register(
|
|
468
|
-
HomekitHapService,
|
|
469
|
-
factory=lambda: HomekitHapService(
|
|
470
|
-
homekit_config=self.container.resolve(HomekitConfig),
|
|
471
|
-
module_service=self.container.resolve(HomekitModuleService),
|
|
472
|
-
event_bus=self.container.resolve(EventBus),
|
|
473
|
-
),
|
|
474
|
-
scope=punq.Scope.singleton,
|
|
475
|
-
)
|
|
476
|
-
|
|
477
446
|
# Log file services layer
|
|
478
447
|
self.container.register(
|
|
479
448
|
LogFileService,
|
|
@@ -536,105 +505,6 @@ class ServiceContainer:
|
|
|
536
505
|
scope=punq.Scope.singleton,
|
|
537
506
|
)
|
|
538
507
|
|
|
539
|
-
# Create protocol with built-in debouncing
|
|
540
|
-
self.container.register(
|
|
541
|
-
TelegramProtocol,
|
|
542
|
-
factory=lambda: TelegramProtocol(
|
|
543
|
-
event_bus=self.container.resolve(EventBus),
|
|
544
|
-
debounce_ms=50,
|
|
545
|
-
),
|
|
546
|
-
scope=punq.Scope.singleton,
|
|
547
|
-
)
|
|
548
|
-
|
|
549
|
-
self.container.register(
|
|
550
|
-
IConnector,
|
|
551
|
-
factory=lambda: reactor,
|
|
552
|
-
scope=punq.Scope.singleton,
|
|
553
|
-
)
|
|
554
|
-
|
|
555
|
-
self.container.register(
|
|
556
|
-
TelegramFactory,
|
|
557
|
-
factory=lambda: TelegramFactory(
|
|
558
|
-
event_bus=self.container.resolve(EventBus),
|
|
559
|
-
telegram_protocol=self.container.resolve(TelegramProtocol),
|
|
560
|
-
connector=self.container.resolve(IConnector),
|
|
561
|
-
),
|
|
562
|
-
scope=punq.Scope.singleton,
|
|
563
|
-
)
|
|
564
|
-
|
|
565
|
-
self.container.register(
|
|
566
|
-
PosixReactorBase,
|
|
567
|
-
factory=lambda: reactor,
|
|
568
|
-
scope=punq.Scope.singleton,
|
|
569
|
-
)
|
|
570
|
-
|
|
571
|
-
self.container.register(
|
|
572
|
-
HomeKitLightbulbService,
|
|
573
|
-
factory=lambda: HomeKitLightbulbService(
|
|
574
|
-
event_bus=self.container.resolve(EventBus),
|
|
575
|
-
),
|
|
576
|
-
scope=punq.Scope.singleton,
|
|
577
|
-
)
|
|
578
|
-
|
|
579
|
-
self.container.register(
|
|
580
|
-
HomeKitOutletService,
|
|
581
|
-
factory=lambda: HomeKitOutletService(
|
|
582
|
-
event_bus=self.container.resolve(EventBus),
|
|
583
|
-
),
|
|
584
|
-
scope=punq.Scope.singleton,
|
|
585
|
-
)
|
|
586
|
-
|
|
587
|
-
self.container.register(
|
|
588
|
-
HomeKitDimmingLightService,
|
|
589
|
-
factory=lambda: HomeKitDimmingLightService(
|
|
590
|
-
event_bus=self.container.resolve(EventBus),
|
|
591
|
-
),
|
|
592
|
-
scope=punq.Scope.singleton,
|
|
593
|
-
)
|
|
594
|
-
|
|
595
|
-
# Cache service must be registered BEFORE HomeKitConbusService
|
|
596
|
-
# so it intercepts ReadDatapointEvent first
|
|
597
|
-
self.container.register(
|
|
598
|
-
HomeKitCacheService,
|
|
599
|
-
factory=lambda: HomeKitCacheService(
|
|
600
|
-
event_bus=self.container.resolve(EventBus),
|
|
601
|
-
),
|
|
602
|
-
scope=punq.Scope.singleton,
|
|
603
|
-
)
|
|
604
|
-
|
|
605
|
-
self.container.register(
|
|
606
|
-
HomeKitConbusService,
|
|
607
|
-
factory=lambda: HomeKitConbusService(
|
|
608
|
-
event_bus=self.container.resolve(EventBus),
|
|
609
|
-
telegram_protocol=self.container.resolve(TelegramProtocol),
|
|
610
|
-
),
|
|
611
|
-
scope=punq.Scope.singleton,
|
|
612
|
-
)
|
|
613
|
-
|
|
614
|
-
self.container.register(
|
|
615
|
-
TelegramService,
|
|
616
|
-
factory=TelegramService,
|
|
617
|
-
scope=punq.Scope.singleton,
|
|
618
|
-
)
|
|
619
|
-
|
|
620
|
-
self.container.register(
|
|
621
|
-
HomeKitService,
|
|
622
|
-
factory=lambda: HomeKitService(
|
|
623
|
-
cli_config=self.container.resolve(ConbusClientConfig),
|
|
624
|
-
event_bus=self.container.resolve(EventBus),
|
|
625
|
-
telegram_factory=self.container.resolve(TelegramFactory),
|
|
626
|
-
reactor=self.container.resolve(PosixReactorBase),
|
|
627
|
-
lightbulb_service=self.container.resolve(HomeKitLightbulbService),
|
|
628
|
-
outlet_service=self.container.resolve(HomeKitOutletService),
|
|
629
|
-
dimminglight_service=self.container.resolve(HomeKitDimmingLightService),
|
|
630
|
-
cache_service=self.container.resolve(HomeKitCacheService),
|
|
631
|
-
conbus_service=self.container.resolve(HomeKitConbusService),
|
|
632
|
-
module_factory=self.container.resolve(HomekitHapService),
|
|
633
|
-
telegram_service=self.container.resolve(TelegramService),
|
|
634
|
-
),
|
|
635
|
-
scope=punq.Scope.singleton,
|
|
636
|
-
)
|
|
637
|
-
|
|
638
508
|
def _load_protocol_keys(self) -> "ProtocolKeysConfig":
|
|
639
509
|
"""
|
|
640
510
|
Load protocol keys from YAML config file.
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
"""HomeKit management CLI commands."""
|
|
2
|
-
|
|
3
|
-
import click
|
|
4
|
-
from click_help_colors import HelpColorsGroup
|
|
5
|
-
|
|
6
|
-
from xp.cli.utils.decorators import service_command
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
@click.group(
|
|
10
|
-
cls=HelpColorsGroup, help_headers_color="yellow", help_options_color="green"
|
|
11
|
-
)
|
|
12
|
-
def homekit() -> None:
|
|
13
|
-
"""Manage the HomeKit server for XP Protocol operations."""
|
|
14
|
-
pass
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
@homekit.group(
|
|
18
|
-
cls=HelpColorsGroup, help_headers_color="yellow", help_options_color="green"
|
|
19
|
-
)
|
|
20
|
-
def config() -> None:
|
|
21
|
-
"""Manage HomeKit configuration."""
|
|
22
|
-
pass
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
@config.command()
|
|
26
|
-
@click.option(
|
|
27
|
-
"--conson-config",
|
|
28
|
-
default="conson.yml",
|
|
29
|
-
help="Path to conson.yml configuration file",
|
|
30
|
-
)
|
|
31
|
-
@click.option(
|
|
32
|
-
"--homekit-config",
|
|
33
|
-
default="homekit.yml",
|
|
34
|
-
help="Path to homekit.yml configuration file",
|
|
35
|
-
)
|
|
36
|
-
@service_command()
|
|
37
|
-
def validate(conson_config: str, homekit_config: str) -> None:
|
|
38
|
-
"""
|
|
39
|
-
Validate homekit.yml and conson.yml coherence.
|
|
40
|
-
|
|
41
|
-
Args:
|
|
42
|
-
conson_config: Path to conson.yml configuration file.
|
|
43
|
-
homekit_config: Path to homekit.yml configuration file.
|
|
44
|
-
"""
|
|
45
|
-
from xp.services.homekit.homekit_config_validator import ConfigValidationService
|
|
46
|
-
|
|
47
|
-
try:
|
|
48
|
-
validator = ConfigValidationService(conson_config, homekit_config)
|
|
49
|
-
results = validator.validate_all()
|
|
50
|
-
|
|
51
|
-
if results["is_valid"]:
|
|
52
|
-
click.echo(click.style("✓ Configuration validation passed", fg="green"))
|
|
53
|
-
else:
|
|
54
|
-
click.echo(
|
|
55
|
-
click.style(
|
|
56
|
-
f"✗ Configuration validation failed with {results['total_errors']} errors",
|
|
57
|
-
fg="red",
|
|
58
|
-
)
|
|
59
|
-
)
|
|
60
|
-
|
|
61
|
-
if results["conson_errors"]:
|
|
62
|
-
click.echo(
|
|
63
|
-
click.style("\nConson Configuration Errors:", fg="red", bold=True)
|
|
64
|
-
)
|
|
65
|
-
for error in results["conson_errors"]:
|
|
66
|
-
click.echo(f" - {error}")
|
|
67
|
-
|
|
68
|
-
if results["homekit_errors"]:
|
|
69
|
-
click.echo(
|
|
70
|
-
click.style("\nHomeKit Configuration Errors:", fg="red", bold=True)
|
|
71
|
-
)
|
|
72
|
-
for error in results["homekit_errors"]:
|
|
73
|
-
click.echo(f" - {error}")
|
|
74
|
-
|
|
75
|
-
if results["cross_reference_errors"]:
|
|
76
|
-
click.echo(
|
|
77
|
-
click.style("\nCross-Reference Errors:", fg="red", bold=True)
|
|
78
|
-
)
|
|
79
|
-
for error in results["cross_reference_errors"]:
|
|
80
|
-
click.echo(f" - {error}")
|
|
81
|
-
|
|
82
|
-
exit(1)
|
|
83
|
-
|
|
84
|
-
except Exception as e:
|
|
85
|
-
click.echo(click.style(f"✗ Validation failed: {e}", fg="red"))
|
|
86
|
-
exit(1)
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
@config.command("show")
|
|
90
|
-
@click.option(
|
|
91
|
-
"--conson-config",
|
|
92
|
-
default="conson.yml",
|
|
93
|
-
help="Path to conson.yml configuration file",
|
|
94
|
-
)
|
|
95
|
-
@click.option(
|
|
96
|
-
"--homekit-config",
|
|
97
|
-
default="homekit.yml",
|
|
98
|
-
help="Path to homekit.yml configuration file",
|
|
99
|
-
)
|
|
100
|
-
@service_command()
|
|
101
|
-
def show_config(conson_config: str, homekit_config: str) -> None:
|
|
102
|
-
"""
|
|
103
|
-
Display parsed configuration summary.
|
|
104
|
-
|
|
105
|
-
Args:
|
|
106
|
-
conson_config: Path to conson.yml configuration file.
|
|
107
|
-
homekit_config: Path to homekit.yml configuration file.
|
|
108
|
-
"""
|
|
109
|
-
from xp.services.homekit.homekit_config_validator import ConfigValidationService
|
|
110
|
-
|
|
111
|
-
try:
|
|
112
|
-
validator = ConfigValidationService(conson_config, homekit_config)
|
|
113
|
-
summary = validator.print_config_summary()
|
|
114
|
-
|
|
115
|
-
click.echo(click.style("Configuration Summary:", fg="blue", bold=True))
|
|
116
|
-
click.echo(summary)
|
|
117
|
-
|
|
118
|
-
except Exception as e:
|
|
119
|
-
click.echo(click.style(f"✗ Failed to load configuration: {e}", fg="red"))
|
|
120
|
-
exit(1)
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"""API server start command."""
|
|
2
|
-
|
|
3
|
-
import sys
|
|
4
|
-
|
|
5
|
-
import click
|
|
6
|
-
from click import Context
|
|
7
|
-
|
|
8
|
-
from xp.cli.commands.homekit.homekit import homekit
|
|
9
|
-
from xp.services.homekit.homekit_service import HomeKitService
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
@homekit.command("start")
|
|
13
|
-
@click.pass_context
|
|
14
|
-
def homekit_start(ctx: Context) -> None:
|
|
15
|
-
r"""
|
|
16
|
-
Start the HomeKit server.
|
|
17
|
-
|
|
18
|
-
This command starts the XP Protocol HomeKit server using HAP-python.
|
|
19
|
-
The server provides HomeKit endpoints for Conbus operations.
|
|
20
|
-
|
|
21
|
-
Args:
|
|
22
|
-
ctx: Click context object.
|
|
23
|
-
|
|
24
|
-
Examples:
|
|
25
|
-
\b
|
|
26
|
-
# Start server on default host and port
|
|
27
|
-
xp homekit start
|
|
28
|
-
"""
|
|
29
|
-
click.echo("Starting XP Protocol HomeKit server...")
|
|
30
|
-
|
|
31
|
-
try:
|
|
32
|
-
service: HomeKitService = (
|
|
33
|
-
ctx.obj.get("container").get_container().resolve(HomeKitService)
|
|
34
|
-
)
|
|
35
|
-
service.start() # Blocking call - reactor.run() never returns
|
|
36
|
-
|
|
37
|
-
except KeyboardInterrupt:
|
|
38
|
-
click.echo("\nShutting down server...")
|
|
39
|
-
except Exception as e:
|
|
40
|
-
click.echo(
|
|
41
|
-
click.style(f"Error starting server: {e}", fg="red"),
|
|
42
|
-
err=True,
|
|
43
|
-
)
|
|
44
|
-
sys.exit(1)
|
xp/services/homekit/__init__.py
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"""HomeKit integration services."""
|