This repository is an implementation of the code for IoTGPT (IoT Smart Home Automation Agent), an LLM-based task automation system designed for smart homes. IoTGPT dynamically translates natural language user instructions into executable automation rules or control commands, matching them with active smart devices and user preferences using a human-like memory bank.
IoTGPT is split into two major components:
- Python Server ([IoTGPT/Server]): Processes user intent, manages memory retrieval/storage, generates execution plans, and resolves device mapping.
- Android Client App ([IoTGPT/App]): Runs on the mobile device, and sends instructions.
To run the server, Python 3.12 (or compatible) is required.
- Navigate to the Server directory:
cd IoTGPT/Server - Activate your virtual environment (e.g.,
.venv):.venv\Scripts\activate
- Install the required libraries:
pip install -r requirements_iotgpt.txt
- Create the required memory cache folder it does not exist:
mkdir memory\cache
Create or update the [.env] file in the [Server/] directory with your API keys:
- Open the [App/] folder in Android Studio.
- Open [IoTGPTAccessibilityService.kt] and configure the host IP address and port to match your PC's IP and server port:
// For local testing on Emulator: private val ip = "10.0.2.2" private var port = 5001
- Build the project and install the app on your Android Emulator or physical device.
From the Server directory, run [main.py]:
python main.py <IP_ADDRESS> <PORT>
# Example:
python main.py 0.0.0.0 5001The server will boot up and print: Server is listening on 0.0.0.0:5001
- Unlock your emulator or phone.
- Launch the iot_llm application.
- Grant Accessibility Permissions when prompted. (Go to Android Settings -> Accessibility -> Installed apps -> enable
iot_llm/IoTGPT).
- Once the app launches and connects to the server, you will see
Connected to clienton the server terminal. - Input a natural language command (e.g.,
"When I sleep, make the room the best sleeping environment") in the text field. - Click the Send button.
- IoTGPT will automatically analyze the intent, retrieve matching memories, structure the commands, and perform the automation.
- [main.py]: The entry point that parses CLI arguments and boots the socket server.
- [server.py]: Manages network connections, monitors application logs, coordinates client feedback, and routes execution results.
- [iotGPT.py]: Handles intent analysis, device disambiguation, rule creation, and personalization using LLM models.
- [memory_manager.py]: Controls the semantic search, matching, and logging of rules inside the
memory/cache/database. - [IoTGPTAccessibilityService.kt]: Listens for system actions, extracts page properties, sends user strings to the server, and triggers interface clicks. =======