Files
Openhab-AI-Bridge/README.md
T
2026-09-22 13:52:48 +00:00

63 lines
1.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# openHAB AI Bridge – Simple (Text + Claude + Edge TTS)
Kostenlose KI-Anbindung über **Ask Claude** (iOS Shortcut), ohne API-Key.
## Ablauf
```
openHAB Textfeld
→ Bridge (Session + Kontext in SQLite)
→ MQTT notify
→ openHAB Cloud Push ans iPhone
→ Shortcut: Ask Claude
→ Antwort zurück an Bridge
→ Edge TTS → Lautsprecher am Pi
```
Rückfragen nutzen denselben Session-Kontext (Standard: 2 Stunden).
## Schnellstart (Raspberry Pi)
```bash
cd ~/openhab-ai-bridge-simple
cp .env.example .env
openssl rand -hex 32 # → in .env als API_TOKEN eintragen
getent group audio | cut -d: -f3 # → AUDIO_GID setzen
docker compose build
docker compose up -d
curl http://127.0.0.1:8090/health
```
## openHAB
1. Thing + Items aus `openhab/` übernehmen (Broker-UID anpassen).
2. JS-Regel aus `openhab/ai_bridge.rules.js` (Token + IP eintragen).
3. Regel „AI Bridge Notify → Push“ sendet die Cloud-Notification.
## iOS Shortcut
1. Trigger: openHAB-Notification mit Text `KI_DIALOG`
2. GET `http://PI:8090/api/v1/active` (Header: `Authorization: Bearer TOKEN`)
3. GET `/api/v1/sessions/{session_id}/context`
4. Prompt aus Messages bauen → **Ask Claude**
5. POST `/api/v1/sessions/{session_id}/answer` `{"content":"..."}`
6. POST `/api/v1/audio/speak` `{"text":"..."}` (Pi spricht)
## API (alle außer /health brauchen Bearer-Token)
| Methode | Pfad | Zweck |
|---------|------|--------|
| POST | /api/v1/dialog | Frage aus openHAB |
| GET | /api/v1/active | Aktive Session |
| GET | /api/v1/sessions/{id}/context | Gesprächsverlauf |
| POST | /api/v1/sessions/{id}/answer | Claude-Antwort speichern |
| POST | /api/v1/audio/speak | Edge TTS abspielen |
| POST | /api/v1/sessions/{id}/end | Session beenden |
## Sicherheit
- Nur LAN, Port 8090 nicht nach außen freigeben
- Langer zufälliger API_TOKEN
- Docker: non-root, read-only root, dropped capabilities