Skip to content

Commit e589099

Browse files
committed
Docs: Add Integrations section (AI Reporter)
1 parent 014e80b commit e589099

4 files changed

Lines changed: 118 additions & 3 deletions

File tree

docs/smart-home/index.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ This section contains all architectural documentation for the Home Assistant set
2121
- **[Package Catalog](packages/index.md)**:
2222
Index of all feature-based configuration packages (Automations, Scripts, etc.).
2323

24+
- **[Integrations Catalog](integrations/index.md)**:
25+
Index of external systems running outside Home Assistant.
26+
2427
## Contents
2528
- **[Automations](automations.md)**: Detailed breakdown of UI-managed automations (`automations.yaml`).
2629
- **[Dashboards](dashboards/index.md)**: Overview of Lovelace dashboards.
30+
- **[Integrations](integrations/index.md)**: External systems (Docker, Scripts).
2731
- **[Packages](packages/index.md)**: Modular configuration bundles.
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
---
2+
tags:
3+
- integration
4+
- manual
5+
- ai
6+
- docker
7+
---
8+
9+
# Integration: AI Log Reporter
10+
11+
**Type:** Remote Docker Container
12+
**Host:** `10.0.0.23`
13+
**Language:** Python 3.11
14+
15+
## Overview
16+
The **AI Log Reporter** is an external system designed to offload heavy log analysis from the Home Assistant host. It runs in a Docker container on a separate server, allowing it to process large datasets without impacting HA performance.
17+
18+
## Architecture
19+
20+
The system works via a "Pull & Push" mechanism:
21+
1. **Trigger:** Home Assistant opens a secure SSH tunnel to the host.
22+
2. **Execution:** HA executes the python script inside the running container.
23+
3. **Callback:** The script analyzes the data and pushes the result back to Home Assistant via the API.
24+
25+
```mermaid
26+
sequenceDiagram
27+
participant HA as 🏠 Home Assistant
28+
participant SSH as 🔐 SSH Tunnel
29+
participant Docker as 🐳 Docker (ai-log-reporter)
30+
participant API as 📡 HA API
31+
32+
HA->>SSH: Connect (Identity File)
33+
SSH->>Docker: exec python /app/reporter.py
34+
activate Docker
35+
Docker->>Docker: Analyze Logs & Generate Summary
36+
Docker->>API: POST /api/events/update_ai_summary
37+
deactivate Docker
38+
```
39+
40+
## Deployment
41+
42+
### Docker Compose
43+
The system is deployed using a standard `docker-compose.yml` file on the remote host.
44+
45+
```yaml
46+
version: '3.8'
47+
services:
48+
reporter:
49+
container_name: ai-log-reporter
50+
image: python:3.11-slim
51+
restart: unless-stopped
52+
volumes:
53+
- ./app:/app
54+
- ./logs:/logs:ro
55+
environment:
56+
- HA_URL=http://10.0.0.5:8123
57+
- HA_TOKEN=klsjdflkjsdf...
58+
command: tail -f /dev/null # Keep alive for exec
59+
```
60+
61+
### The Reporter Script
62+
The core logic resides in `reporter.py`. It uses the Gemini API to summarize text.
63+
64+
```python
65+
# /app/reporter.py (Simplified)
66+
import requests
67+
import os
68+
69+
def analyze_logs():
70+
# ... logic to read files ...
71+
summary = "System is stable. No critical errors found."
72+
73+
# Send Event to HA
74+
url = f"{os.getenv('HA_URL')}/api/events/update_ai_summary"
75+
headers = {"Authorization": f"Bearer {os.getenv('HA_TOKEN')}"}
76+
requests.post(url, json={"summary": summary}, headers=headers)
77+
78+
if __name__ == "__main__":
79+
analyze_logs()
80+
```
81+
82+
## Related Components
83+
* **[Ai Summary Package](../packages/ai_summary.md)**: The Home Assistant configuration that triggers this integration.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
tags:
3+
- index
4+
- integrations
5+
---
6+
7+
# External Integrations
8+
9+
This section documents external systems and custom integrations that run outside of Home Assistant but are critical to the smart home ecosystem.
10+
11+
## 🔗 Integrations Catalog
12+
13+
- **[AI Log Reporter](ai_reporter.md)**
14+
<br> :material-arrow-right-bottom: *Remote Python system running on Docker to analyze logs and report back to Home Assistant.*

docs/smart-home/packages/ai_summary.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ version: Unknown
1616

1717
## Executive Summary
1818
<!-- START_SUMMARY -->
19-
*No executive summary generated yet.*
19+
This package acts as the **Frontend** and **Controller** for the external **[AI Log Reporter Integration](../integrations/ai_reporter.md)**.
20+
1. It provides the **Template Sensor** to display the summary.
21+
2. It handles the **Scheduling** (7:00 AM) and **SSH Connection** logic to trigger the remote analysis.
2022
<!-- END_SUMMARY -->
2123

2224
## Process Description (Non-Technical)
@@ -31,11 +33,23 @@ version: Unknown
3133

3234
## Architecture Diagram
3335
<!-- START_MERMAID_DESC -->
34-
*No architecture explanation generated yet.*
36+
The diagram below illustrates the hand-off between this Home Assistant package and the external Docker container. For full implementation details of the remote system, see the **[AI Reporter Integration](../integrations/ai_reporter.md)** documentation.
3537
<!-- END_MERMAID_DESC -->
3638

3739
<!-- START_MERMAID -->
38-
*No architecture diagram generated yet.*
40+
```mermaid
41+
sequenceDiagram
42+
participant Sched as ⏰ Schedule
43+
participant Script as 📜 Script
44+
participant SSH as 🔐 SSH Tunnel
45+
participant Remote as 📦 Remote Integration
46+
47+
Sched->>Script: Trigger 7:00 AM
48+
Script->>SSH: Connect root@10.0.0.23
49+
SSH->>Remote: Trigger Docker Analysis
50+
Note over Remote: Processing...
51+
Remote-->>Script: (Async Event Return)
52+
```
3953
<!-- END_MERMAID -->
4054

4155
## Configuration (Source Code)

0 commit comments

Comments
 (0)