conson-xp 1.37.0__py3-none-any.whl → 1.38.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.
Files changed (43) hide show
  1. {conson_xp-1.37.0.dist-info → conson_xp-1.38.0.dist-info}/METADATA +6 -1
  2. {conson_xp-1.37.0.dist-info → conson_xp-1.38.0.dist-info}/RECORD +43 -38
  3. xp/__init__.py +1 -1
  4. xp/cli/commands/__init__.py +2 -0
  5. xp/cli/commands/conbus/__init__.py +2 -0
  6. xp/cli/commands/conbus/conbus.py +26 -0
  7. xp/cli/commands/conbus/conbus_actiontable_commands.py +17 -8
  8. xp/cli/commands/conbus/conbus_event_commands.py +1 -7
  9. xp/cli/commands/conbus/conbus_export_commands.py +7 -6
  10. xp/cli/commands/conbus/conbus_msactiontable_commands.py +92 -9
  11. xp/models/actiontable/msactiontable.py +9 -0
  12. xp/models/actiontable/msactiontable_xp20.py +14 -14
  13. xp/models/actiontable/msactiontable_xp24.py +228 -11
  14. xp/models/actiontable/msactiontable_xp33.py +42 -14
  15. xp/models/conbus/conbus_export.py +6 -2
  16. xp/models/config/__init__.py +1 -0
  17. xp/models/{homekit/homekit_conson_config.py → config/conson_module_config.py} +3 -1
  18. xp/models/protocol/conbus_protocol.py +1 -1
  19. xp/services/actiontable/msactiontable_xp20_serializer.py +12 -0
  20. xp/services/actiontable/msactiontable_xp24_serializer.py +13 -1
  21. xp/services/actiontable/msactiontable_xp33_serializer.py +12 -0
  22. xp/services/conbus/actiontable/actiontable_download_service.py +8 -5
  23. xp/services/conbus/actiontable/actiontable_list_service.py +2 -1
  24. xp/services/conbus/actiontable/actiontable_show_service.py +2 -2
  25. xp/services/conbus/actiontable/actiontable_upload_service.py +1 -1
  26. xp/services/conbus/conbus_event_list_service.py +1 -1
  27. xp/services/conbus/conbus_export_service.py +1 -1
  28. xp/services/conbus/msactiontable/__init__.py +1 -0
  29. xp/services/conbus/{actiontable/msactiontable_service.py → msactiontable/msactiontable_download_service.py} +9 -5
  30. xp/services/conbus/msactiontable/msactiontable_list_service.py +92 -0
  31. xp/services/conbus/msactiontable/msactiontable_show_service.py +89 -0
  32. xp/services/homekit/homekit_config_validator.py +1 -1
  33. xp/services/homekit/homekit_conson_validator.py +1 -1
  34. xp/services/homekit/homekit_dimminglight.py +1 -1
  35. xp/services/homekit/homekit_lightbulb.py +1 -1
  36. xp/services/homekit/homekit_module_service.py +1 -1
  37. xp/services/homekit/homekit_outlet.py +1 -1
  38. xp/services/server/server_service.py +1 -1
  39. xp/services/term/state_monitor_service.py +1 -1
  40. xp/utils/dependencies.py +36 -14
  41. {conson_xp-1.37.0.dist-info → conson_xp-1.38.0.dist-info}/WHEEL +0 -0
  42. {conson_xp-1.37.0.dist-info → conson_xp-1.38.0.dist-info}/entry_points.txt +0 -0
  43. {conson_xp-1.37.0.dist-info → conson_xp-1.38.0.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,92 @@
1
+ """Service for listing modules with action table configurations from conson.yml."""
2
+
3
+ import logging
4
+ from pathlib import Path
5
+ from typing import Any, Optional
6
+
7
+ from psygnal import Signal
8
+
9
+
10
+ class MsActionTableListService:
11
+ """Service for listing modules with action table configurations.
12
+
13
+ Reads conson.yml and returns a list of all modules that have action table
14
+ configurations defined.
15
+
16
+ Attributes:
17
+ on_finish: Signal emitted with dict[str, Any] when listing completes.
18
+ on_error: Signal emitted with error message string when an error occurs.
19
+ """
20
+
21
+ on_finish: Signal = Signal(object) # dict[str, Any]
22
+ on_error: Signal = Signal(str)
23
+
24
+ def __init__(self) -> None:
25
+ """Initialize the action table list service."""
26
+ self.logger = logging.getLogger(__name__)
27
+
28
+ def __enter__(self) -> "MsActionTableListService":
29
+ """Context manager entry.
30
+
31
+ Returns:
32
+ Self for context manager use.
33
+ """
34
+ return self
35
+
36
+ def __exit__(self, _exc_type: Any, _exc_val: Any, _exc_tb: Any) -> None:
37
+ """Context manager exit."""
38
+ # Disconnect service signals
39
+ self.on_finish.disconnect()
40
+ self.on_error.disconnect()
41
+
42
+ def start(
43
+ self,
44
+ config_path: Optional[Path] = None,
45
+ ) -> None:
46
+ """List all modules with action table configurations.
47
+
48
+ Args:
49
+ config_path: Optional path to conson.yml. Defaults to current directory.
50
+ """
51
+ # Default to current directory if not specified
52
+ if config_path is None:
53
+ config_path = Path.cwd() / "conson.yml"
54
+
55
+ # Check if config file exists
56
+ if not config_path.exists():
57
+ self._handle_error("Error: conson.yml not found in current directory")
58
+ return
59
+
60
+ # Load configuration
61
+ try:
62
+ from xp.models.config.conson_module_config import ConsonModuleListConfig
63
+
64
+ config = ConsonModuleListConfig.from_yaml(str(config_path))
65
+ except Exception as e:
66
+ self.logger.error(f"Failed to load conson.yml: {e}")
67
+ self._handle_error(f"Error: Failed to load conson.yml: {e}")
68
+ return
69
+
70
+ # Filter modules that have ms_action_table configured
71
+ modules_with_msactiontable = [
72
+ {
73
+ "serial_number": module.serial_number,
74
+ "module_type": module.module_type,
75
+ "msaction_table": 1 if module.msaction_table else 0,
76
+ }
77
+ for module in config.root
78
+ ]
79
+
80
+ # Prepare result
81
+ result = {"modules": modules_with_msactiontable}
82
+
83
+ # Emit finish signal
84
+ self.on_finish.emit(result)
85
+
86
+ def _handle_error(self, message: str) -> None:
87
+ """Handle error and emit error signal.
88
+
89
+ Args:
90
+ message: Error message.
91
+ """
92
+ self.on_error.emit(message)
@@ -0,0 +1,89 @@
1
+ """Service for showing ms action table configuration for a specific module."""
2
+
3
+ import logging
4
+ from pathlib import Path
5
+ from typing import Any, Callable, Optional
6
+
7
+ from xp.models.config.conson_module_config import ConsonModuleConfig
8
+
9
+
10
+ class MsActionTableShowService:
11
+ """Service for showing action table configuration for a specific module.
12
+
13
+ Reads conson.yml and returns the action table configuration for the specified
14
+ module serial number.
15
+ """
16
+
17
+ def __init__(self) -> None:
18
+ """Initialize the action table show service."""
19
+ self.logger = logging.getLogger(__name__)
20
+ self.finish_callback: Optional[Callable[[ConsonModuleConfig], None]] = None
21
+ self.error_callback: Optional[Callable[[str], None]] = None
22
+
23
+ def __enter__(self) -> "MsActionTableShowService":
24
+ """Context manager entry.
25
+
26
+ Returns:
27
+ Self for context manager use.
28
+ """
29
+ return self
30
+
31
+ def __exit__(self, _exc_type: Any, _exc_val: Any, _exc_tb: Any) -> None:
32
+ """Context manager exit."""
33
+ pass
34
+
35
+ def start(
36
+ self,
37
+ serial_number: str,
38
+ finish_callback: Callable[[ConsonModuleConfig], None],
39
+ error_callback: Callable[[str], None],
40
+ config_path: Optional[Path] = None,
41
+ ) -> None:
42
+ """Show ms action table configuration for a specific module.
43
+
44
+ Args:
45
+ serial_number: Module serial number.
46
+ finish_callback: Callback to invoke with the module configuration.
47
+ error_callback: Callback to invoke on error.
48
+ config_path: Optional path to conson.yml. Defaults to current directory.
49
+ """
50
+ self.finish_callback = finish_callback
51
+ self.error_callback = error_callback
52
+
53
+ # Default to current directory if not specified
54
+ if config_path is None:
55
+ config_path = Path.cwd() / "conson.yml"
56
+
57
+ # Check if config file exists
58
+ if not config_path.exists():
59
+ self._handle_error("Error: conson.yml not found in current directory")
60
+ return
61
+
62
+ # Load configuration
63
+ try:
64
+ from xp.models.config.conson_module_config import ConsonModuleListConfig
65
+
66
+ config = ConsonModuleListConfig.from_yaml(str(config_path))
67
+ except Exception as e:
68
+ self.logger.error(f"Failed to load conson.yml: {e}")
69
+ self._handle_error(f"Error: Failed to load conson.yml: {e}")
70
+ return
71
+
72
+ # Find module
73
+ module = config.find_module(serial_number)
74
+ if not module:
75
+ self._handle_error(f"Error: Module {serial_number} not found in conson.yml")
76
+ return
77
+
78
+ # Invoke callback
79
+ if self.finish_callback is not None:
80
+ self.finish_callback(module)
81
+
82
+ def _handle_error(self, message: str) -> None:
83
+ """Handle error and invoke error callback.
84
+
85
+ Args:
86
+ message: Error message.
87
+ """
88
+ if self.error_callback is not None:
89
+ self.error_callback(message)
@@ -253,8 +253,8 @@ class ConfigValidationService:
253
253
  conson_config_path: Path to conson.yml configuration file.
254
254
  homekit_config_path: Path to homekit.yml configuration file.
255
255
  """
256
+ from xp.models.config.conson_module_config import ConsonModuleListConfig
256
257
  from xp.models.homekit.homekit_config import HomekitConfig
257
- from xp.models.homekit.homekit_conson_config import ConsonModuleListConfig
258
258
 
259
259
  self.conson_config = ConsonModuleListConfig.from_yaml(conson_config_path)
260
260
  self.homekit_config = HomekitConfig.from_yaml(homekit_config_path)
@@ -5,7 +5,7 @@ This module validates conson.yml configuration files for HomeKit integration.
5
5
 
6
6
  from typing import List, Set
7
7
 
8
- from xp.models.homekit.homekit_conson_config import (
8
+ from xp.models.config.conson_module_config import (
9
9
  ConsonModuleConfig,
10
10
  ConsonModuleListConfig,
11
11
  )
@@ -10,8 +10,8 @@ from pyhap.accessory import Accessory
10
10
  from pyhap.accessory_driver import AccessoryDriver
11
11
  from pyhap.const import CATEGORY_LIGHTBULB
12
12
 
13
+ from xp.models.config.conson_module_config import ConsonModuleConfig
13
14
  from xp.models.homekit.homekit_config import HomekitAccessoryConfig
14
- from xp.models.homekit.homekit_conson_config import ConsonModuleConfig
15
15
  from xp.models.protocol.conbus_protocol import (
16
16
  DimmingLightGetBrightnessEvent,
17
17
  DimmingLightGetOnEvent,
@@ -10,8 +10,8 @@ from pyhap.accessory import Accessory
10
10
  from pyhap.accessory_driver import AccessoryDriver
11
11
  from pyhap.const import CATEGORY_LIGHTBULB
12
12
 
13
+ from xp.models.config.conson_module_config import ConsonModuleConfig
13
14
  from xp.models.homekit.homekit_config import HomekitAccessoryConfig
14
- from xp.models.homekit.homekit_conson_config import ConsonModuleConfig
15
15
  from xp.models.protocol.conbus_protocol import (
16
16
  LightBulbGetOnEvent,
17
17
  LightBulbSetOnEvent,
@@ -6,7 +6,7 @@ This module provides service implementation for HomeKit module management.
6
6
  import logging
7
7
  from typing import Optional
8
8
 
9
- from xp.models.homekit.homekit_conson_config import (
9
+ from xp.models.config.conson_module_config import (
10
10
  ConsonModuleConfig,
11
11
  ConsonModuleListConfig,
12
12
  )
@@ -10,8 +10,8 @@ from pyhap.accessory import Accessory
10
10
  from pyhap.accessory_driver import AccessoryDriver
11
11
  from pyhap.const import CATEGORY_OUTLET
12
12
 
13
+ from xp.models.config.conson_module_config import ConsonModuleConfig
13
14
  from xp.models.homekit.homekit_config import HomekitAccessoryConfig
14
- from xp.models.homekit.homekit_conson_config import ConsonModuleConfig
15
15
  from xp.models.protocol.conbus_protocol import (
16
16
  OutletGetInUseEvent,
17
17
  OutletGetOnEvent,
@@ -11,7 +11,7 @@ import threading
11
11
  from pathlib import Path
12
12
  from typing import Dict, List, Optional
13
13
 
14
- from xp.models.homekit.homekit_conson_config import (
14
+ from xp.models.config.conson_module_config import (
15
15
  ConsonModuleConfig,
16
16
  ConsonModuleListConfig,
17
17
  )
@@ -6,7 +6,7 @@ from typing import Dict, List, Optional
6
6
 
7
7
  from psygnal import Signal
8
8
 
9
- from xp.models.homekit.homekit_conson_config import ConsonModuleListConfig
9
+ from xp.models.config.conson_module_config import ConsonModuleListConfig
10
10
  from xp.models.protocol.conbus_protocol import TelegramReceivedEvent
11
11
  from xp.models.telegram.datapoint_type import DataPointType
12
12
  from xp.models.telegram.module_type_code import ModuleTypeCode
xp/utils/dependencies.py CHANGED
@@ -8,8 +8,8 @@ from twisted.internet.posixbase import PosixReactorBase
8
8
 
9
9
  from xp.models import ConbusClientConfig
10
10
  from xp.models.conbus.conbus_logger_config import ConbusLoggerConfig
11
+ from xp.models.config.conson_module_config import ConsonModuleListConfig
11
12
  from xp.models.homekit.homekit_config import HomekitConfig
12
- from xp.models.homekit.homekit_conson_config import ConsonModuleListConfig
13
13
  from xp.models.term.protocol_keys_config import ProtocolKeysConfig
14
14
  from xp.services.actiontable.actiontable_serializer import ActionTableSerializer
15
15
  from xp.services.actiontable.msactiontable_serializer import MsActionTableSerializer
@@ -23,7 +23,7 @@ from xp.services.actiontable.msactiontable_xp33_serializer import (
23
23
  Xp33MsActionTableSerializer,
24
24
  )
25
25
  from xp.services.conbus.actiontable.actiontable_download_service import (
26
- ActionTableService,
26
+ ActionTableDownloadService,
27
27
  )
28
28
  from xp.services.conbus.actiontable.actiontable_list_service import (
29
29
  ActionTableListService,
@@ -34,7 +34,6 @@ from xp.services.conbus.actiontable.actiontable_show_service import (
34
34
  from xp.services.conbus.actiontable.actiontable_upload_service import (
35
35
  ActionTableUploadService,
36
36
  )
37
- from xp.services.conbus.actiontable.msactiontable_service import MsActionTableService
38
37
  from xp.services.conbus.conbus_blink_all_service import ConbusBlinkAllService
39
38
  from xp.services.conbus.conbus_blink_service import ConbusBlinkService
40
39
  from xp.services.conbus.conbus_custom_service import ConbusCustomService
@@ -52,6 +51,15 @@ from xp.services.conbus.conbus_output_service import ConbusOutputService
52
51
  from xp.services.conbus.conbus_raw_service import ConbusRawService
53
52
  from xp.services.conbus.conbus_receive_service import ConbusReceiveService
54
53
  from xp.services.conbus.conbus_scan_service import ConbusScanService
54
+ from xp.services.conbus.msactiontable.msactiontable_download_service import (
55
+ MsActionTableDownloadService,
56
+ )
57
+ from xp.services.conbus.msactiontable.msactiontable_list_service import (
58
+ MsActionTableListService,
59
+ )
60
+ from xp.services.conbus.msactiontable.msactiontable_show_service import (
61
+ MsActionTableShowService,
62
+ )
55
63
  from xp.services.conbus.write_config_service import WriteConfigService
56
64
  from xp.services.homekit.homekit_cache_service import HomeKitCacheService
57
65
  from xp.services.homekit.homekit_conbus_service import HomeKitConbusService
@@ -99,6 +107,7 @@ class ServiceContainer:
99
107
  logger_config_path: str = "logger.yml",
100
108
  homekit_config_path: str = "homekit.yml",
101
109
  conson_config_path: str = "conson.yml",
110
+ export_config_path: str = "export.yml",
102
111
  server_port: int = 10001,
103
112
  protocol_keys_config_path: str = "protocol.yml",
104
113
  reverse_proxy_port: int = 10001,
@@ -111,6 +120,7 @@ class ServiceContainer:
111
120
  logger_config_path: Path to the Conbus Loggerr configuration file
112
121
  homekit_config_path: Path to the HomeKit configuration file
113
122
  conson_config_path: Path to the Conson configuration file
123
+ export_config_path: Path to the Conson export file
114
124
  protocol_keys_config_path: Path to the protocol keys configuration file
115
125
  server_port: Port for the server service
116
126
  reverse_proxy_port: Port for the reverse proxy service
@@ -120,6 +130,7 @@ class ServiceContainer:
120
130
  self._logger_config_path = logger_config_path
121
131
  self._homekit_config_path = homekit_config_path
122
132
  self._conson_config_path = conson_config_path
133
+ self._export_config_path = export_config_path
123
134
  self._protocol_keys_config_path = protocol_keys_config_path
124
135
  self._server_port = server_port
125
136
  self._reverse_proxy_port = reverse_proxy_port
@@ -141,6 +152,12 @@ class ServiceContainer:
141
152
  scope=punq.Scope.singleton,
142
153
  )
143
154
 
155
+ self.container.register(
156
+ ConsonModuleListConfig,
157
+ factory=lambda: ConsonModuleListConfig.from_yaml(self._conson_config_path),
158
+ scope=punq.Scope.singleton,
159
+ )
160
+
144
161
  # Telegram services layer
145
162
  self.container.register(TelegramService, scope=punq.Scope.singleton)
146
163
  self.container.register(
@@ -302,8 +319,8 @@ class ServiceContainer:
302
319
  )
303
320
 
304
321
  self.container.register(
305
- ActionTableService,
306
- factory=lambda: ActionTableService(
322
+ ActionTableDownloadService,
323
+ factory=lambda: ActionTableDownloadService(
307
324
  conbus_protocol=self.container.resolve(ConbusEventProtocol),
308
325
  actiontable_serializer=self.container.resolve(ActionTableSerializer),
309
326
  telegram_service=self.container.resolve(TelegramService),
@@ -353,8 +370,8 @@ class ServiceContainer:
353
370
  )
354
371
 
355
372
  self.container.register(
356
- MsActionTableService,
357
- factory=lambda: MsActionTableService(
373
+ MsActionTableDownloadService,
374
+ factory=lambda: MsActionTableDownloadService(
358
375
  conbus_protocol=self.container.resolve(ConbusEventProtocol),
359
376
  xp20ms_serializer=self.container.resolve(Xp20MsActionTableSerializer),
360
377
  xp24ms_serializer=self.container.resolve(Xp24MsActionTableSerializer),
@@ -389,13 +406,6 @@ class ServiceContainer:
389
406
  scope=punq.Scope.singleton,
390
407
  )
391
408
 
392
- # HomeKit conson config
393
- self.container.register(
394
- ConsonModuleListConfig,
395
- factory=lambda: ConsonModuleListConfig.from_yaml(self._conson_config_path),
396
- scope=punq.Scope.singleton,
397
- )
398
-
399
409
  # HomeKit services layer
400
410
  self.container.register(
401
411
  HomekitModuleService,
@@ -468,6 +478,18 @@ class ServiceContainer:
468
478
  scope=punq.Scope.singleton,
469
479
  )
470
480
 
481
+ self.container.register(
482
+ MsActionTableListService,
483
+ factory=MsActionTableListService,
484
+ scope=punq.Scope.singleton,
485
+ )
486
+
487
+ self.container.register(
488
+ MsActionTableShowService,
489
+ factory=MsActionTableShowService,
490
+ scope=punq.Scope.singleton,
491
+ )
492
+
471
493
  # Server services layer
472
494
  self.container.register(
473
495
  ServerService,