Files
Openhab-AI-Bridge/docs/SETUP.md
T

79 lines
2.0 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.
# Setup – Simple Bridge
## 1. Raspberry Pi
```bash
cd ~
# Projekt kopieren (oder aus dem ZIP)
cp -r openhab-ai-bridge-simple ~/
cd ~/openhab-ai-bridge-simple
cp .env.example .env
openssl rand -hex 32
nano .env # API_TOKEN eintragen, MQTT_HOST prüfen
```
Audio-Gruppe:
```bash
getent group audio | cut -d: -f3
# Wert in AUDIO_GID in .env
```
Start:
```bash
docker compose build && docker compose up -d
docker compose logs -f
curl http://127.0.0.1:8090/health
```
TTS-Test:
```bash
curl -X POST http://127.0.0.1:8090/api/v1/audio/speak \
-H "Authorization: Bearer DEIN_TOKEN" \
-H "Content-Type: application/json" \
-d '{"text":"Hallo, das ist ein Test vom Raspberry Pi."}'
```
## 2. openHAB
### Thing
Datei `openhab/ai_bridge.things` nach `$OPENHAB_CONF/things/` kopieren
oder im Main UI manuell anlegen (Broker-UID: `mqtt:broker:72a3b87ef9`).
### Items
Datei `openhab/ai_bridge.items` nach `$OPENHAB_CONF/items/` kopieren
oder Items über die API/MCP anlegen und manuell mit den Channels verlinken.
### JS-Regel (Dialog → Bridge)
- Add-on **JavaScript Scripting** installieren
- Inhalt von `openhab/ai_bridge.rules.js` als Script anlegen
- `BRIDGE_URL` und `BRIDGE_TOKEN` anpassen
### Push-Regel
Wenn Item `AI_Bridge_Notify` sich ändert → openHAB Cloud Notification
mit Text z. B. `KI_DIALOG <session_id>` an dein iPhone senden.
Die Notification muss die Automation auf dem iPhone auslösen.
## 3. iOS Shortcut
1. Automation: „Wenn Benachrichtigung von openHAB empfangen“ und Text enthält `KI_DIALOG`
2. HTTP GET `http://PI-IP:8090/api/v1/active`
Header: `Authorization: Bearer TOKEN`
3. Session-ID aus der Antwort nehmen
4. HTTP GET `.../api/v1/sessions/{id}/context`
5. Messages zu einem Prompt zusammensetzen
6. Aktion **Ask Claude**
7. HTTP POST `.../api/v1/sessions/{id}/answer`
Body: `{"content":"<Claude-Antwort>"}`
8. HTTP POST `.../api/v1/audio/speak`
Body: `{"text":"<Claude-Antwort>"}`
Optional: Button „Gespräch beenden“ → POST `.../sessions/{id}/end`