# Leveraging Retrieval-Augmented Generation for Automated Smart Home Orchestration
## 3 System Overview
### Architectural Design and Components
#### 3.3.1 Device Registration Layer  
This layer oversees the onboarding of new devices from the moment they announce their presence via MQTT to the point where their service bundles become operational in OSGi. Key stages include:  
1. MQTT Message Publishing: for uniform integration, device manufacturers must adhere to a predefined format for the device's announcement message. Upon first connecting or being installed, a smart device publishes a JSON-formatted message to a designated MQTT topic, such as _discovery/#_, where the wildcard # ensures the orchestrator captures all discovery messages. This registration message contains the key variables detailed in Table 1[22].
2. Message Consumption: The orchestrator's MQTT client (running as a Python component) is continuously subscribed to the discovery topic to listen for new device messages. When a registration message is received, the MQTT client parses the JSON payload to extract the device information. The successful reception and parsing of the message mark the device as discovered by the system.
3. Data Segregation and Storage: Once the device data are parsed, the system stores it in two separate databases for different purposes. First, the device's descriptive  
Figure 3: Service bundle generation process from natural language user input to automatic code generation, compilation, deployment, and activation within the OSGi framework.  
attributes (ID, name, type, capabilities, location) are vectorised into an embedding using Sentence Transformer techniques and sent to the vector database [23; 24]. Storing this information in the vector database enables semantic queries--for example, finding devices that match a capability or location described in a user's request (even if the request wording is not an exact literal match to the stored data). Each device's embedding is stored with an ID and metadata. Second, the orchestrator stores configuration-specific details in a relational database. This includes the device's configuration URL (for the bundle), the OSGi interface package and class that the device implements, method signatures offered by the device, and an entry in a device usage or similar table to track the device's availability. Using a structured database for this information allows the orchestrator to perform fast lookups.
4. Service Registration via OSGi: After storing the device data, the orchestrator moves to integrate the device's service bundle into the runtime. The Python MQTT handler invokes the Java controller by issuing a REST call (HTTP POST) with the device's bundle URL. The controller, which leverages the OSGi framework, handles the bundle deployment. It uses an OSGi API call to fetch the JAR from the given URL, install it into the Apache Felix OSGi container, and start the bundle. This process is robust: the controller first verifies the bundle file can be retrieved and is not already installed, then performs the installation. Once the bundle is started, the device's code (which implements certain service interfaces) is activated within the OSGi environment. During startup, the bundle typically registers its services with the OSGi Service Registry. This registration is often automated through Declarative Services: the bundle's manifest file contains a pointer to an OSGI-INF component descriptor that declares the provided service interface and implementation. The OSGi Service Component Runtime then reads this and registers the new service. As a result, other components in the system can discover the device's service via the registry. The process of bundle installation, activation, and service registration happens almost instantly and with minimal overhead. To summarise, the new device's functionality becomes available to the orchestrator as a modular service without stopping or reconfiguring the running system.  
Upon completion, the Device Registration Layer hands off a fully integrated device service to the rest of the system, enabling context-aware automation.