Initial release v1.0 - Flask bridge tussen Node-RED en Hermes Agent
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
# Hermes Relay
|
||||
|
||||
Flask bridge tussen Node-RED en Hermes Agent.
|
||||
|
||||
## Architectuur
|
||||
|
||||
```
|
||||
Node-RED (192.168.1.125) ──POST /ask──▶ Hermes Relay (192.168.1.74:8650)
|
||||
│
|
||||
├──▶ hermes chat -q (subprocess)
|
||||
│ │
|
||||
│ ▼
|
||||
│ JSON response ──▶ Node-RED
|
||||
│
|
||||
└──▶ hermes send --to telegram
|
||||
│
|
||||
▼
|
||||
Telegram chat
|
||||
```
|
||||
|
||||
## Endpoints
|
||||
|
||||
### `POST /ask`
|
||||
Verwacht JSON body:
|
||||
```json
|
||||
{ "payload": "Wat is het weer in Best?" }
|
||||
```
|
||||
|
||||
Response:
|
||||
```json
|
||||
{
|
||||
"status": "ok",
|
||||
"answer": "Het is 22°C en zonnig in Best...",
|
||||
"elapsed_seconds": 8.3,
|
||||
"telegram_sent": true
|
||||
}
|
||||
```
|
||||
|
||||
### `GET /health`
|
||||
Health check voor monitoring.
|
||||
|
||||
## Setup
|
||||
|
||||
```bash
|
||||
cd /root/hermes-relay
|
||||
python3 -m venv venv
|
||||
source venv/bin/activate
|
||||
pip install -r requirements.txt
|
||||
|
||||
# Test
|
||||
python app.py
|
||||
|
||||
# Of als service
|
||||
sudo systemctl enable hermes-relay
|
||||
sudo systemctl start hermes-relay
|
||||
```
|
||||
|
||||
## Node-RED Nodes
|
||||
|
||||
### Versturen (HTTP Request node)
|
||||
- **Method:** POST
|
||||
- **URL:** `http://192.168.1.74:8650/ask`
|
||||
- **Return:** a parsed JSON object
|
||||
- **Timeout:** 120000 (ms) — Hermes kan even duren
|
||||
|
||||
### Ontvangen
|
||||
Het antwoord komt terug als `msg.payload`:
|
||||
- `msg.payload.answer` — het Hermes antwoord
|
||||
- `msg.payload.elapsed_seconds` — hoe lang het duurde
|
||||
- `msg.payload.telegram_sent` — of het ook naar Telegram is gestuurd
|
||||
- `msg.payload.status` — "ok" of "error"
|
||||
|
||||
### Health check (optioneel)
|
||||
- **Method:** GET
|
||||
- **URL:** `http://192.168.1.74:8650/health`
|
||||
Reference in New Issue
Block a user