Skill: photonixlaser-ux/synology-surveillance-skill (version 0.1.0)

--- name: synology-surveillance description: Steuere Synology Surveillance Station Kameras über die Web API. Nutze diesen Skill für Snapshots, Live-Streams, Aufnahmen, PTZ-Steuerung und Ereignis-Überwachung. Erfordert Synology NAS mit Surveillance Station. --- # Synology Surveillance Station Skill Steuere deine Überwachungskameras über die Synology Surveillance Station API. ## Voraussetzungen 1. **Synology NAS** mit installierter Surveillance Station 2. **Benutzer** mit Surveillance Station-Rechten 3. **2FA deaktiviert** für den API-Benutzer 4. **jq** installiert (`apt install jq`) ## Schnellstart ### 1. Konfiguration in TOOLS.md Füge die Verbindungsdaten zu `TOOLS.md` hinzu: ```markdown ### Synology Surveillance - **Host:** 192.168.1.100 (deine NAS IP) - **Port:** 5000 (HTTP) oder 5001 (HTTPS) - **User:** surveillance_user - **Pass:** dein_passwort - **HTTPS:** false (true falls HTTPS aktiviert) ``` ### 2. Login testen ```bash ./scripts/syno-surveillance.sh login ``` ### 3. Kameras anzeigen ```bash ./scripts/syno-surveillance.sh cameras ``` Output: ``` ID: 1, Name: Eingang, Status: 1 ID: 2, Name: Garten, Status: 1 ID: 3, Name: Garage, Status: 0 ``` ### 4. Snapshot erstellen ```bash ./scripts/syno-surveillance.sh snapshot 1 ``` Speichert: `syno_snapshot_1_1738972800.jpg` ### 5. Ereignisse anzeigen ```bash # Letzte 10 Ereignisse ./scripts/syno-surveillance.sh events # Letzte 50 Ereignisse ./scripts/syno-surveillance.sh events 50 ``` ## Verfügbare Befehle | Befehl | Beschreibung | |--------|--------------| | `login` | Session erstellen (wird automatisch bei anderen Befehlen ausgeführt) | | `logout` | Session beenden | | `cameras` | Alle Kameras mit ID und Status auflisten | | `snapshot <id>` | Snapshot einer Kamera erstellen | | `record <id> start\|stop` | Aufnahme starten/stoppen | | `events [limit]` | Ereignis-Log anzeigen | | `stream <id>` | Live-Stream URL generieren | | `ptz <id> <direction>` | PTZ-Kamera bewegen (left/right/up/down/zoomin/zoomout) | | `preset <id> <num>` | PTZ-Voreinstellung anfahren | ## Umgebungsvariablen | Variable | Standard | Beschreibung | |----------|----------|--------------| | `SYNOLOGY_HOST` | 192.168.1.100 | NAS IP/Hostname | | `SYNOLOGY_PORT` | 5000 | NAS Port | | `SYNOLOGY_USER` | admin | Username | | `SYNOLOGY_PASS` | (leer) | Passwort | | `SYNOLOGY_HTTPS` | false | HTTPS verwenden | ## Direkte API-Calls Falls das Script nicht passt, direkt mit curl: ```bash # Login curl -c cookies.txt "http://192.168.1.100:5000/webapi/auth.cgi?api=SYNO.API.Auth&method=login&version=3&account=USER&[REDACTED_SECRET]" # Snapshot curl -b cookies.txt "http://192.168.1.100:5000/webapi/entry.cgi?api=SYNO.SurveillanceStation.Camera&method=GetSnapshot&version=1&cameraId=1" -o snapshot.jpg ``` ## API Details Für komplexere Operationen: [references/api.md](references/api.md) ## Home Assistant Integration Für Home Assistant Nutzer: Der Skill kann auch für HA Automatisierungen genutzt werden: ```yaml shell_command: syno_snapshot: "/pfad/zu/syno-surveillance.sh snapshot {{ camera_id }}" ``` ## Troubleshooting - **Login failed**: Passwort prüfen, 2FA deaktivieren - **Permission denied**: Benutzer braucht Surveillance Station-Rechte - **Camera not found**: Kamera-ID prüfen mit `cameras` Befehl - **Empty snapshot**: Kamera offline oder keine Lizenz verfügbar ## Lizenz-Hinweis Surveillance Station benötigt pro Kamera eine Lizenz (2 kostenlose inklusive bei den meisten NAS-Modellen).

path: README.md
content: # synology-surveillance-skill
OpenClaw Skill für Synology Surveillance Station - Steuere Kameras über die Web API


path: references/api.md
content: # Synology Surveillance Station API Reference

Offizielle API-Dokumentation: https://global.download.synology.com/download/Document/Software/DeveloperGuide/Package/SurveillanceStation/All/enu/SurveillanceStation_Web_API.pdf

## Basis-URL

```
http://<NAS-IP>:<PORT>/webapi/
```

Standard-Ports:
- HTTP: 5000
- HTTPS: 5001

## Authentifizierung

### Login
```
GET /webapi/auth.cgi
  ?api=SYNO.API.Auth
  &method=login
  &version=3
  &account=<user>
  &[REDACTED_SECRET]
  &session=SurveillanceStation
  &format=cookie
```

Response:
```json
{
  "success": true,
  "data": {
    "sid": "SESSION_ID"
  }
}
```

### Logout
```
GET /webapi/auth.cgi
  ?api=SYNO.API.Auth
  &method=logout
  &version=1
  &session=SurveillanceStation
```

## Kamera-API

### Kamera-Liste abrufen
```
GET /webapi/entry.cgi
  ?api=SYNO.SurveillanceStation.Camera
  &method=List
  &version=1
  &_=<timestamp>
```

### Snapshot erstellen
```
GET /webapi/entry.cgi
  ?api=SYNO.SurveillanceStation.Camera
  &method=GetSnapshot
  &version=1
  &cameraId=<ID>
  &_=<timestamp>
```

### Live-Stream URL
```
GET /webapi/entry.cgi
  ?api=SYNO.SurveillanceStation.Streaming
  &method=LiveStream
  &version=1
  &cameraId=<ID>
  &format=mjpeg|hls|mxpeg
```

## Ereignis-API

### Ereignisse abrufen
```
GET /webapi/entry.cgi
  ?api=SYNO.SurveillanceStation.Event
  &method=List
  &version=1
  &timeStart=<unix_timestamp>
  &timeEnd=<unix_timestamp>
  &limit=<count>
```

### Letzte Ereignisse
```
GET /webapi/entry.cgi
  ?api=SYNO.SurveillanceStation.Event
  &method=List
  &version=1
  &limit=10
```

## Aufnahme-API

### Aufnahme starten
```
GET /webapi/entry.cgi
  ?api=SYNO.SurveillanceStation.Recording
  &method=Record
  &version=1
  &cameraId=<ID>
```

### Aufnahme stoppen
```
GET /webapi/entry.cgi
  ?api=SYNO.SurveillanceStation.Recording
  &method=Stop
  &version=1
  &cameraId=<ID>
```

## PTZ-API (für bewegliche Kameras)

### PTZ Steuerung
```
GET /webapi/entry.cgi
  ?api=SYNO.SurveillanceStation.PTZ
  &method=Move
  &version=1
  &cameraId=<ID>
  &direction=left|right|up|down|zoomin|zoomout
  &speed=<1-5>
```

### Voreinstellung anfahren
```
GET /webapi/entry.cgi
  ?api=SYNO.SurveillanceStation.PTZ
  &method=GoPreset
  &version=1
  &cameraId=<ID>
  &position=<1-100>
```

## Fehler-Codes

| Code | Beschreibung |
|------|--------------|
| 100 | Unknown error |
| 101 | Invalid parameters |
| 102 | API does not exist |
| 103 | Method does not exist |
| 104 | This API version is not supported |
| 105 | Insufficient user privilege |
| 106 | Connection time out |
| 107 | Multiple login detected |
| 400 | Invalid credential |
| 401 | Account disabled |
| 402 | Permission denied |
| 403 | 2-step verification needed |

## Hinweise

- Session-Cookie `id` nach Login speichern
- Bei jeder Anfrage Session-Cookie mitgeben
- 2FA muss für den API-User deaktiviert sein
- HTTPS empfohlen für produktive Umgebungen


path: scripts/syno-surveillance.sh
content: #!/bin/bash
# Synology Surveillance Station CLI Helper
# Interagiert mit der Surveillance Station Web API

SYNO_HOST="${SYNOLOGY_HOST:-192.168.1.100}"
SYNO_PORT="${SYNOLOGY_PORT:-5000}"
SYNO_USER="${SYNOLOGY_USER:-admin}"
SYNO_PASS="${SYNOLOGY_PASS:-}"
SYNO_HTTPS="${SYNOLOGY_HTTPS:-false}"

COOKIE_FILE="/tmp/syno_session_$$.cookie"
BASE_URL="http${SYNO_HTTPS:+s}://${SYNO_HOST}:${SYNO_PORT}"

# Cleanup beim Beenden
trap 'rm -f "$COOKIE_FILE"' EXIT

# Hilfe anzeigen
show_help() {
    cat << EOF
Usage: $0 <command> [args...]

Commands:
  login                      - Login und Session erstellen
  logout                     - Session beenden
  cameras                    - Liste aller Kameras anzeigen
  snapshot <camera-id>       - Snapshot einer Kamera abrufen
  record <camera-id> [start|stop] - Aufnahme starten/stoppen
  events [limit]             - Letzte Ereignisse anzeigen (default: 10)
  stream <camera-id>         - Live-Stream URL anzeigen
  ptz <camera-id> <direction>  - PTZ Bewegung (left|right|up|down|zoomin|zoomout)
  preset <camera-id> <num>    - PTZ Voreinstellung anfahren

Environment Variables:
  SYNOLOGY_HOST   - NAS IP/Hostname (default: 192.168.1.100)
  SYNOLOGY_PORT   - NAS Port (default: 5000, HTTPS: 5001)
  SYNOLOGY_USER   - Username (default: admin)
  SYNOLOGY_PASS   - Passwort
  SYNOLOGY_HTTPS  - HTTPS verwenden (default: false)

Examples:
  $0 cameras
  $0 snapshot 1
  $0 record 1 start
  $0 events 20
  $0 ptz 1 left
EOF
}

# API Request mit Session-Handling
api_request() {
    local endpoint=$1
    local params=$2
    
    curl -s -b "$COOKIE_FILE" -c "$COOKIE_FILE" \
        "${BASE_URL}/webapi/${endpoint}?${params}"
}

# Einloggen
syno_login() {
    if [[ -z "$SYNO_PASS" ]]; then
        echo "Error: SYNOLOGY_PASS nicht gesetzt"
        exit 1
    fi
    
    local response=$(curl -s -c "$COOKIE_FILE" \
        "${BASE_URL}/webapi/auth.cgi?api=SYNO.API.Auth&method=login&version=3&account=${SYNO_USER}&[REDACTED_SECRET]")
    
    if echo "$response" | grep -q '"success":true'; then
        echo "Login erfolgreich"
        return 0
    else
        echo "Login fehlgeschlagen: $response"
        return 1
    fi
}

# Ausloggen
syno_logout() {
    api_request "auth.cgi" "api=SYNO.API.Auth&method=logout&version=1&session=SurveillanceStation"
    echo "Logout durchgeführt"
}

# Kameraliste abrufen
syno_cameras() {
    api_request "entry.cgi" "api=SYNO.SurveillanceStation.Camera&method=List&version=1&_=$(date +%s)" | jq -r '.data.cameras[] | "ID: \(.id), Name: \(.name), Status: \(.status)"' 2>/dev/null || echo "Fehler beim Abrufen der Kameras"
}

# Snapshot erstellen
syno_snapshot() {
    local camera_id=$1
    if [[ -z "$camera_id" ]]; then
        echo "Usage: $0 snapshot <camera-id>"
        exit 1
    fi
    
    local timestamp=$(date +%s)
    local output="syno_snapshot_${camera_id}_${timestamp}.jpg"
    
    curl -s -b "$COOKIE_FILE" \
        "${BASE_URL}/webapi/entry.cgi?api=SYNO.SurveillanceStation.Camera&method=GetSnapshot&version=1&cameraId=${camera_id}&_=${timestamp}" \
        -o "$output"
    
    if [[ -f "$output" && -s "$output" ]]; then
        echo "Snapshot gespeichert: $output"
    else
        rm -f "$output"
        echo "Fehler beim Erstellen des Snapshots"
    fi
}

# Aufnahme steuern
syno_record() {
    local camera_id=$1
    local action=$2
    
    if [[ -z "$camera_id" || -z "$action" ]]; then
        echo "Usage: $0 record <camera-id> [start|stop]"
        exit 1
    fi
    
    local method=""
    case "$action" in
        start) method="Record" ;;
        stop) method="Stop" ;;
        *) echo "Ungültige Aktion: $action (start|stop)"; exit 1 ;;
    esac
    
    api_request "entry.cgi" "api=SYNO.SurveillanceStation.Recording&method=${method}&version=1&cameraId=${camera_id}"
}

# Ereignisse abrufen
syno_events() {
    local limit=${1:-10}
    api_request "entry.cgi" "api=SYNO.SurveillanceStation.Event&method=List&version=1&limit=${limit}" | jq -r '.data.events[] | "\(.timestamp): \(.camera_name) - \(.reason)"' 2>/dev/null || echo "Keine Ereignisse gefunden"
}

# Stream URL anzeigen
syno_stream() {
    local camera_id=$1
    if [[ -z "$camera_id" ]]; then
        echo "Usage: $0 stream <camera-id>"
        exit 1
    fi
    
    echo "Live-Stream URL:"
    echo "${BASE_URL}/webapi/entry.cgi?api=SYNO.SurveillanceStation.Streaming&method=LiveStream&version=1&cameraId=${camera_id}&format=mjpeg"
}

# PTZ Steuerung
syno_ptz() {
    local camera_id=$1
    local direction=$2
    
    if [[ -z "$camera_id" || -z "$direction" ]]; then
        echo "Usage: $0 ptz <camera-id> <direction>"
        echo "Directions: left, right, up, down, zoomin, zoomout"
        exit 1
    fi
    
    api_request "entry.cgi" "api=SYNO.SurveillanceStation.PTZ&method=Move&version=1&cameraId=${camera_id}&direction=${direction}&speed=3"
}

# PTZ Preset
syno_preset() {
    local camera_id=$1
    local position=$2
    
    if [[ -z "$camera_id" || -z "$position" ]]; then
        echo "Usage: $0 preset <camera-id> <preset-number>"
        exit 1
    fi
    
    api_request "entry.cgi" "api=SYNO.SurveillanceStation.PTZ&method=GoPreset&version=1&cameraId=${camera_id}&position=${position}"
}

# Main
CMD=$1
shift

case "$CMD" in
    login)
        syno_login
        ;;
    logout)
        syno_logout
        ;;
    cameras)
        syno_cameras
        ;;
    snapshot)
        syno_snapshot "$1"
        ;;
    record)
        syno_record "$1" "$2"
        ;;
    events)
        syno_events "$1"
        ;;
    stream)
        syno_stream "$1"
        ;;
    ptz)
        syno_ptz "$1" "$2"
        ;;
    preset)
        syno_preset "$1" "$2"
        ;;
    *)
        show_help
        exit 1
        ;;
esac


Security scan verdicts — ClawScan: suspicious | static analysis: clean | VirusTotal: clean | SkillSpector: suspicious (HIGH)