diff options
Diffstat (limited to 'core/profile.py')
| -rw-r--r-- | core/profile.py | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/core/profile.py b/core/profile.py index 2a70370..ef8c55b 100644 --- a/core/profile.py +++ b/core/profile.py @@ -231,6 +231,16 @@ class ProfileManager: except Exception: pass + # Clear all existing devices — profile defines the complete device set + for dev in list(registry.all_instances()): + try: + dev.disconnect() + except Exception: + pass + registry.remove_instance(dev.info.device_id) + if engine is not None: + engine.remove_device(dev.info.device_id) + for dev_cfg in profile.devices: dev_type = dev_cfg.get("device_type") dev_id = dev_cfg.get("device_id") @@ -241,17 +251,6 @@ class ProfileManager: print(f"[Profile] Unknown device type: {dev_type}") continue try: - # Replace existing device so saved config takes effect - existing = registry.get_instance(dev_id) - if existing is not None: - try: - existing.disconnect() - except Exception: - pass - registry.remove_instance(dev_id) - if engine is not None: - engine.remove_device(dev_id) - kwargs = {k: v for k, v in dev_cfg.items() if k != "device_type"} dev = factory(**kwargs) registry.add_instance(dev) |
