Remove obsolete documentation files and n8n references
- Delete GEMINI.md (obsolete notes) - Delete MQTT_TOPIC_FIX.md (obsolete notes) - Delete OWNTRACKS_SETUP.md (obsolete setup guide) - Remove n8n reference from README.md 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
108
GEMINI.md
108
GEMINI.md
@@ -1,108 +0,0 @@
|
||||
# Gemini Code Assistant Context
|
||||
|
||||
This document provides a comprehensive overview of the **Location Tracker** project, designed to give the Gemini code assistant the necessary context to understand the codebase, its architecture, and its conventions.
|
||||
|
||||
## 1. Project Overview
|
||||
|
||||
This is a full-stack web application for real-time location tracking, built with Next.js 14. Its primary purpose is to receive location data from [OwnTracks](https://owntracks.org/) mobile clients via an MQTT broker and display the tracks on an interactive map.
|
||||
|
||||
### Key Technologies
|
||||
|
||||
- **Framework**: Next.js 14 (App Router)
|
||||
- **Language**: TypeScript
|
||||
- **Database**: Dual SQLite databases using `better-sqlite3`.
|
||||
- `data/database.sqlite`: For core application data like users, devices, and settings.
|
||||
- `data/locations.sqlite`: For high-volume, time-series location data.
|
||||
- **Data Ingestion**: An MQTT subscriber (`lib/mqtt-subscriber.ts`) connects to a Mosquitto broker to receive location updates from OwnTracks clients. An HTTP endpoint (`/api/locations/ingest`) is also available for manual data pushes.
|
||||
- **Authentication**: `next-auth` (v5) with a credentials (username/password) provider. It supports `ADMIN` and `VIEWER` roles.
|
||||
- **Frontend**: React, [React Leaflet](https://react-leaflet.js.org/) for mapping, and Tailwind CSS for styling.
|
||||
- **Deployment**: The project includes a `Dockerfile` and `docker-compose.yml` for containerized deployment alongside a Mosquitto MQTT broker.
|
||||
|
||||
### Core Features
|
||||
|
||||
- Interactive map displaying real-time location data.
|
||||
- Filtering by device and time range.
|
||||
- Admin dashboard for user and device management.
|
||||
- Secure authentication with role-based access control.
|
||||
- Database maintenance tasks (cleanup, optimization) via API or scripts.
|
||||
|
||||
## 2. Building and Running the Project
|
||||
|
||||
### Prerequisites
|
||||
|
||||
- Node.js 18+
|
||||
- npm
|
||||
|
||||
### Development Mode
|
||||
|
||||
1. **Install dependencies:**
|
||||
```bash
|
||||
npm install
|
||||
```
|
||||
|
||||
2. **Initialize the databases:**
|
||||
This command creates the two SQLite databases in the `data/` directory and seeds them with a default admin user (`admin` / `admin123`).
|
||||
```bash
|
||||
npm run db:init
|
||||
```
|
||||
|
||||
3. **Run the development server:**
|
||||
This starts the Next.js application on `http://localhost:3000`. It also starts the MQTT subscriber service.
|
||||
```bash
|
||||
npm run dev
|
||||
```
|
||||
|
||||
### Production Mode
|
||||
|
||||
- **Build the application:**
|
||||
```bash
|
||||
npm run build
|
||||
```
|
||||
- **Start the application:**
|
||||
```bash
|
||||
npm run start
|
||||
```
|
||||
|
||||
### Docker Compose
|
||||
|
||||
The most straightforward way to run the application and its dependent MQTT broker is using Docker Compose.
|
||||
|
||||
1. **Create an environment file:**
|
||||
Copy `.env.example` to `.env` and fill in the required secrets, especially `AUTH_SECRET`.
|
||||
|
||||
2. **Start the services:**
|
||||
```bash
|
||||
docker-compose up --build
|
||||
```
|
||||
This will build the Next.js app image and start both the application container and the Mosquitto container. The `data` directory is mounted as a volume to persist the SQLite databases.
|
||||
|
||||
## 3. Architecture and Data Flow
|
||||
|
||||
The application follows a clean, decoupled architecture.
|
||||
|
||||
**Data Ingestion Flow:**
|
||||
1. An OwnTracks client publishes a location update to a specific MQTT topic (e.g., `owntracks/device_12_4397af93/12` where `device_12_4397af93` is the MQTT username).
|
||||
2. The Mosquitto broker receives the message.
|
||||
3. The Next.js application's MQTT Subscriber (`lib/mqtt-subscriber.ts`), which is started on server boot via `instrumentation.ts`, is subscribed to the `owntracks/+/+` topic with admin credentials.
|
||||
4. Upon receiving a message, the subscriber parses the payload, transforms it into the application's `Location` format, and saves it to `data/locations.sqlite` using the functions in `lib/db.ts`.
|
||||
|
||||
**Data Retrieval Flow:**
|
||||
1. The user's browser, viewing the map page, periodically fetches data from the `/api/locations` endpoint.
|
||||
2. This API route queries the `data/locations.sqlite` database, applying any user-specified filters for device or time.
|
||||
3. The API returns the location data as a JSON response.
|
||||
4. The frontend `MapView.tsx` component renders the received data as markers and polylines on the Leaflet map.
|
||||
|
||||
**Authentication & Authorization:**
|
||||
- Users log in via the `/login` page, which uses the NextAuth.js `Credentials` provider.
|
||||
- The `lib/auth.ts` file contains the NextAuth configuration, validating credentials against the `User` table in `data/database.sqlite`.
|
||||
- The `middleware.ts` file protects the `/admin` and `/map` routes, checking for a valid session and enforcing role-based access (`ADMIN` vs. `VIEWER`).
|
||||
|
||||
## 4. Development Conventions
|
||||
|
||||
- **Database Access**: All direct database operations are encapsulated within the `lib/db.ts` file. This provides a single, consistent interface (`userDb`, `deviceDb`, `locationDb`) for interacting with the data layer.
|
||||
- **Authentication**: All authentication and session logic is centralized in `lib/auth.ts`. The `auth()` object exported from this file is the primary entry point for accessing session data on the server.
|
||||
- **Background Services**: Long-running background services, like the MQTT subscriber, should be initialized in `lib/startup.ts` and triggered from the `instrumentation.ts` file. This is the standard Next.js way to run code on server startup.
|
||||
- **Configuration**: Environment variables are used for configuration (see `.env.example`).
|
||||
- **Scripts**: The `scripts/` directory contains Node.js scripts for various administrative tasks, such as database initialization (`init-database.js`), cleanup (`cleanup-old-locations.js`), and testing. They should be run using `node scripts/<script_name>.js`.
|
||||
- **Styling**: Utility-first CSS using Tailwind CSS.
|
||||
- **Types**: TypeScript types are used throughout. Core application types are defined in files like `lib/db.ts` and `types/location.ts`.
|
||||
@@ -1,228 +0,0 @@
|
||||
# MQTT Topic Pattern Fix - Implementation Summary
|
||||
|
||||
## Problem Description
|
||||
|
||||
The OwnTracks smartphone app publishes location data to MQTT topics in the format:
|
||||
```
|
||||
owntracks/<username>/<device_id>
|
||||
```
|
||||
|
||||
Example: `owntracks/device_15_2b73f9bb/15`
|
||||
|
||||
However, the application was configured with the incorrect pattern:
|
||||
```
|
||||
owntracks/owntrack/<device_id>
|
||||
```
|
||||
|
||||
This was a **critical privacy and data protection issue** because:
|
||||
- Users could not receive their location data (wrong subscription pattern)
|
||||
- ACL rules would not properly isolate users
|
||||
- GDPR compliance was at risk
|
||||
|
||||
## Solution Overview
|
||||
|
||||
All MQTT topic patterns have been corrected to use the proper OwnTracks format:
|
||||
```
|
||||
owntracks/<username>/#
|
||||
```
|
||||
|
||||
Where `<username>` is the MQTT username (e.g., `device_12_4397af93`).
|
||||
|
||||
## Privacy & Security Architecture
|
||||
|
||||
### Multi-Layer Security (Defense in Depth)
|
||||
|
||||
1. **MQTT Broker Level (Mosquitto ACL)**
|
||||
- Each user has strict ACL rules limiting access to their own topics only
|
||||
- Example ACL for user `device_12_4397af93`:
|
||||
```
|
||||
user device_12_4397af93
|
||||
topic readwrite owntracks/device_12_4397af93/#
|
||||
```
|
||||
- Admin user has full access for backend operations
|
||||
|
||||
2. **Backend Level**
|
||||
- Subscribes to `owntracks/+/+` using admin credentials
|
||||
- Collects all location data but filters by `parent_user_id` in database queries
|
||||
- Acts as centralized data processor
|
||||
|
||||
3. **Application Level**
|
||||
- Web UI/API filters data by user ownership
|
||||
- Users only see their own devices and locations
|
||||
|
||||
## Files Modified
|
||||
|
||||
### Core Logic Changes
|
||||
|
||||
1. **`lib/mqtt-db.ts`** (Line 209-214)
|
||||
- Updated `createDefaultRule()` function signature to accept `username` parameter
|
||||
- Changed topic pattern from `owntracks/owntrack/${deviceId}/#` to `owntracks/${username}/#`
|
||||
|
||||
2. **`app/api/mqtt/credentials/route.ts`** (Line 111)
|
||||
- Updated call to `createDefaultRule()` to pass both `device_id` and `username`
|
||||
|
||||
3. **`lib/mqtt-subscriber.ts`** (Line 202-203)
|
||||
- Backend now uses `MQTT_ADMIN_USERNAME` and `MQTT_ADMIN_PASSWORD` from environment
|
||||
- Ensures backend has admin privileges to subscribe to all topics
|
||||
|
||||
### UI Changes
|
||||
|
||||
4. **`app/admin/mqtt/page.tsx`**
|
||||
- Line 67: Added `mqtt_username` field to `aclFormData` state
|
||||
- Line 413: Pass `mqtt_username` when opening ACL modal
|
||||
- Line 246: Include `mqtt_username` when resetting form
|
||||
- Line 603: Fixed placeholder to show `owntracks/<username>/#`
|
||||
- Line 607: Fixed help text example to show correct pattern
|
||||
|
||||
### Email Template
|
||||
|
||||
5. **`emails/mqtt-credentials.tsx`** (Line 52)
|
||||
- Changed topic pattern from `owntracks/owntrack/{deviceId}` to `owntracks/{mqttUsername}/#`
|
||||
|
||||
### Documentation
|
||||
|
||||
6. **`README.md`** (Line 283-284)
|
||||
- Updated OwnTracks configuration example with correct topic format
|
||||
|
||||
7. **`GEMINI.md`** (Line 84, 86)
|
||||
- Updated architecture documentation with correct topic patterns
|
||||
- Added note about backend using admin credentials
|
||||
|
||||
### Migration Tools
|
||||
|
||||
8. **`scripts/fix-acl-topic-patterns.js`** (New file)
|
||||
- Migration script to update existing ACL rules in database
|
||||
- Not needed for fresh installations
|
||||
|
||||
## Environment Variables Required
|
||||
|
||||
Ensure the following variables are set in `.env`:
|
||||
|
||||
```bash
|
||||
# MQTT Admin Credentials (used by backend subscriber and sync)
|
||||
MQTT_ADMIN_USERNAME=admin
|
||||
MQTT_ADMIN_PASSWORD=admin
|
||||
|
||||
# MQTT Broker URL
|
||||
MQTT_BROKER_URL=mqtt://mosquitto:1883
|
||||
|
||||
# Mosquitto Configuration Paths
|
||||
MOSQUITTO_PASSWORD_FILE=/mosquitto/config/password.txt
|
||||
MOSQUITTO_ACL_FILE=/mosquitto/config/acl.txt
|
||||
MOSQUITTO_CONTAINER_NAME=mosquitto
|
||||
```
|
||||
|
||||
## How It Works Now
|
||||
|
||||
### User Provisioning Flow
|
||||
|
||||
1. **Admin creates MQTT credentials for device:**
|
||||
- Username: `device_12_4397af93` (auto-generated)
|
||||
- Password: (auto-generated secure password)
|
||||
|
||||
2. **ACL rule is automatically created:**
|
||||
```
|
||||
user device_12_4397af93
|
||||
topic readwrite owntracks/device_12_4397af93/#
|
||||
```
|
||||
|
||||
3. **User configures OwnTracks app:**
|
||||
- MQTT Broker: `mqtt://your-broker:1883`
|
||||
- Username: `device_12_4397af93`
|
||||
- Password: (from credentials)
|
||||
- Device ID: `12`
|
||||
|
||||
4. **OwnTracks publishes to:**
|
||||
```
|
||||
owntracks/device_12_4397af93/12
|
||||
```
|
||||
|
||||
5. **Mosquitto ACL enforces:**
|
||||
- User `device_12_4397af93` can ONLY access topics matching `owntracks/device_12_4397af93/*`
|
||||
- Other users CANNOT read or write to this topic
|
||||
|
||||
6. **Backend receives data:**
|
||||
- Subscribes to `owntracks/+/+` with admin credentials
|
||||
- Stores location in database with device relationship
|
||||
- Web UI filters by `parent_user_id` to show only user's data
|
||||
|
||||
## Deployment Steps
|
||||
|
||||
### For Fresh Installations
|
||||
|
||||
1. Pull the updated code
|
||||
2. Ensure `.env` has correct `MQTT_ADMIN_USERNAME` and `MQTT_ADMIN_PASSWORD`
|
||||
3. Build and start services:
|
||||
```bash
|
||||
docker-compose up --build -d
|
||||
```
|
||||
|
||||
### For Existing Installations
|
||||
|
||||
1. Pull the updated code
|
||||
2. Verify `.env` has admin credentials set
|
||||
3. Run migration script if database has existing ACL rules:
|
||||
```bash
|
||||
node scripts/fix-acl-topic-patterns.js
|
||||
```
|
||||
4. Rebuild and restart services:
|
||||
```bash
|
||||
docker-compose up --build -d
|
||||
```
|
||||
5. In admin UI, click "MQTT Sync" to regenerate ACL file
|
||||
6. Restart Mosquitto to apply ACL changes:
|
||||
```bash
|
||||
docker-compose restart mosquitto
|
||||
```
|
||||
|
||||
## Testing the Fix
|
||||
|
||||
1. **Provision a test device** via admin UI
|
||||
2. **Check generated credentials:**
|
||||
- Note the MQTT username (e.g., `device_12_abc123`)
|
||||
3. **Verify ACL rule** was created with correct pattern:
|
||||
- Go to admin MQTT page
|
||||
- Check ACL rules show `owntracks/device_12_abc123/#`
|
||||
4. **Configure OwnTracks app** with credentials
|
||||
5. **Verify data flow:**
|
||||
- OwnTracks should publish successfully
|
||||
- Location data should appear on map
|
||||
- Other users should NOT see this device
|
||||
|
||||
## GDPR Compliance
|
||||
|
||||
✅ **Privacy by Design:** Users are isolated at the MQTT broker level
|
||||
✅ **Data Minimization:** Each user only has access to their own data
|
||||
✅ **Security:** Multi-layer defense prevents unauthorized access
|
||||
✅ **Transparency:** Clear ACL rules define access permissions
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Issue: OwnTracks not connecting to MQTT
|
||||
- Verify credentials are correct
|
||||
- Check Mosquitto logs: `docker-compose logs mosquitto`
|
||||
- Ensure ACL file was generated: `docker exec mosquitto cat /mosquitto/config/acl.txt`
|
||||
|
||||
### Issue: Location data not appearing
|
||||
- Check backend logs: `docker-compose logs app`
|
||||
- Verify MQTT subscriber is connected
|
||||
- Confirm topic pattern matches: `owntracks/<username>/<device_id>`
|
||||
|
||||
### Issue: User can see another user's data
|
||||
- This should NOT be possible after the fix
|
||||
- Verify ACL file has correct rules per user
|
||||
- Restart Mosquitto after ACL changes
|
||||
- Check user relationships in database (`parent_user_id`)
|
||||
|
||||
## Support
|
||||
|
||||
For questions or issues, please check:
|
||||
- [OwnTracks Documentation](https://owntracks.org/booklet/)
|
||||
- Project README.md
|
||||
- GitHub Issues
|
||||
|
||||
---
|
||||
|
||||
**Last Updated:** 2025-11-29
|
||||
**Author:** Claude Code
|
||||
**Version:** 1.0
|
||||
@@ -1,338 +0,0 @@
|
||||
# OwnTracks App Setup Anleitung
|
||||
|
||||
## Übersicht
|
||||
|
||||
Diese Anleitung erklärt Schritt-für-Schritt, wie Sie die OwnTracks App auf Ihrem Smartphone installieren und mit dem Location Tracker System verbinden.
|
||||
|
||||
---
|
||||
|
||||
## 1. Installation
|
||||
|
||||
### iOS (iPhone/iPad)
|
||||
1. Öffnen Sie den **App Store**
|
||||
2. Suchen Sie nach **"OwnTracks"**
|
||||
3. Laden Sie die App herunter und installieren Sie sie
|
||||
4. App-Link: https://apps.apple.com/app/owntracks/id692424691
|
||||
|
||||
### Android
|
||||
1. Öffnen Sie den **Google Play Store**
|
||||
2. Suchen Sie nach **"OwnTracks"**
|
||||
3. Laden Sie die App herunter und installieren Sie sie
|
||||
4. App-Link: https://play.google.com/store/apps/details?id=org.owntracks.android
|
||||
|
||||
---
|
||||
|
||||
## 2. MQTT Credentials erhalten
|
||||
|
||||
Bevor Sie die App konfigurieren können, benötigen Sie Ihre MQTT-Zugangsdaten:
|
||||
|
||||
1. Melden Sie sich im **Location Tracker** an: `http://192.168.10.118:3000/login`
|
||||
2. Navigieren Sie zu: **Admin → MQTT Provisioning** (`/admin/mqtt`)
|
||||
3. Klicken Sie auf **"Device Provisionieren"**
|
||||
4. Wählen Sie Ihr Device aus der Liste
|
||||
5. Aktivieren Sie **"Automatisch Username & Passwort generieren"**
|
||||
6. Klicken Sie auf **"Erstellen"**
|
||||
7. **WICHTIG:** Kopieren Sie sofort die angezeigten Credentials:
|
||||
```
|
||||
Username: device_10_abc123
|
||||
Password: xxxxxxxxxxxxxxxx
|
||||
```
|
||||
8. Speichern Sie diese Daten sicher - das Passwort wird nur einmal angezeigt!
|
||||
|
||||
---
|
||||
|
||||
## 3. OwnTracks App Konfiguration
|
||||
|
||||
### Schritt 1: App öffnen
|
||||
Starten Sie die OwnTracks App auf Ihrem Smartphone.
|
||||
|
||||
### Schritt 2: Zu Einstellungen navigieren
|
||||
- **iOS:** Tippen Sie auf das ⚙️ Symbol (oben rechts)
|
||||
- **Android:** Tippen Sie auf ☰ (Hamburger-Menü) → Einstellungen
|
||||
|
||||
### Schritt 3: Verbindung konfigurieren
|
||||
|
||||
#### 3.1 Modus auswählen
|
||||
1. Gehen Sie zu **"Verbindung"** oder **"Connection"**
|
||||
2. Wählen Sie **"Modus"** → **"MQTT"**
|
||||
- ✅ **MQTT** (Private Server)
|
||||
- ❌ Nicht: HTTP oder andere Modi
|
||||
|
||||
#### 3.2 MQTT Server-Einstellungen
|
||||
|
||||
Tragen Sie folgende Werte ein:
|
||||
|
||||
| Einstellung | Wert | Beschreibung |
|
||||
|------------|------|--------------|
|
||||
| **Hostname** | `192.168.10.118` | IP-Adresse Ihres Servers |
|
||||
| **Port** | `1883` | Standard MQTT Port (ohne Websocket) |
|
||||
| **Websockets nutzen** | ❌ **DEAKTIVIERT** | Websockets nur bei Port 9001 aktivieren |
|
||||
| **TLS** | ❌ **DEAKTIVIERT** | TLS/SSL nicht aktivieren (lokales Netzwerk) |
|
||||
| **Client ID** | Automatisch generiert | Kann leer gelassen werden |
|
||||
|
||||
#### 3.3 Authentifizierung
|
||||
|
||||
| Einstellung | Wert | Beispiel |
|
||||
|------------|------|----------|
|
||||
| **Benutzername** | Ihr MQTT Username | `device_10_f06e935e` |
|
||||
| **Passwort** | Ihr MQTT Passwort | `n5DkMF+xEi9p56DFa7ewUg==` |
|
||||
|
||||
#### 3.4 Device Identifikation
|
||||
|
||||
| Einstellung | Wert | Beschreibung |
|
||||
|------------|------|--------------|
|
||||
| **Geräte ID** / **Device ID** | `10` | Muss mit Ihrer Device-ID im System übereinstimmen |
|
||||
| **Tracker ID** | `10` | Identisch mit Device ID |
|
||||
|
||||
**WICHTIG:** Die Device ID und Tracker ID müssen mit der Device-ID übereinstimmen, die Sie im Location Tracker System konfiguriert haben (z.B. `10`, `11`, `12`, `15`).
|
||||
|
||||
---
|
||||
|
||||
## 4. Erweiterte Einstellungen (Optional)
|
||||
|
||||
### 4.1 Standort-Tracking Einstellungen
|
||||
|
||||
**Empfohlene Werte für präzises Tracking:**
|
||||
|
||||
| Einstellung | Empfohlener Wert | Beschreibung |
|
||||
|------------|------------------|--------------|
|
||||
| **Monitoring Modus** | Significant Changes | Spart Akku, trackt bei größeren Bewegungen |
|
||||
| **Move Intervall** | 60 Sekunden | Sendet alle 60 Sekunden bei Bewegung |
|
||||
| **Standby Intervall** | 300 Sekunden | Sendet alle 5 Minuten im Ruhezustand |
|
||||
|
||||
### 4.2 Benachrichtigungen
|
||||
|
||||
- **iOS:** Erlauben Sie Standortzugriff "Immer" für Hintergrund-Tracking
|
||||
- **Android:** Aktivieren Sie "Standortzugriff im Hintergrund"
|
||||
|
||||
### 4.3 Akkuoptimierung (Android)
|
||||
|
||||
**WICHTIG für zuverlässiges Tracking:**
|
||||
1. Gehen Sie zu **Systemeinstellungen → Apps → OwnTracks**
|
||||
2. Wählen Sie **"Akku"** oder **"Akkuoptimierung"**
|
||||
3. Wählen Sie **"Nicht optimieren"** oder deaktivieren Sie Akkuoptimierung
|
||||
4. Dies verhindert, dass Android die App im Hintergrund beendet
|
||||
|
||||
---
|
||||
|
||||
## 5. Verbindung testen
|
||||
|
||||
### Schritt 1: Verbindung prüfen
|
||||
1. Kehren Sie zum OwnTracks Hauptbildschirm zurück
|
||||
2. Sie sollten ein **grünes Symbol** oder "Connected" sehen
|
||||
3. Bei Problemen: Rotes Symbol oder "Disconnected"
|
||||
|
||||
### Schritt 2: Testpunkt senden
|
||||
1. Tippen Sie auf den **Location-Button** (Fadenkreuz-Symbol)
|
||||
2. Dies sendet sofort Ihre aktuelle Position
|
||||
|
||||
### Schritt 3: Im Location Tracker prüfen
|
||||
1. Öffnen Sie den Location Tracker im Browser: `http://192.168.10.118:3000/map`
|
||||
2. Ihre Position sollte jetzt auf der Karte erscheinen
|
||||
3. Bei erfolgreicher Verbindung sehen Sie:
|
||||
- Marker mit Ihrer Device-Farbe
|
||||
- Aktuelle Koordinaten
|
||||
- Zeitstempel der letzten Position
|
||||
|
||||
---
|
||||
|
||||
## 6. Port 1883 vs. Port 9001 - Was ist der Unterschied?
|
||||
|
||||
### Port 1883 (Standard MQTT)
|
||||
- **Protokoll:** Standard MQTT (TCP)
|
||||
- **Verwendung:** Normale MQTT-Clients (OwnTracks, IoT-Geräte)
|
||||
- **Websockets:** ❌ Nein
|
||||
- **Empfohlen für:** Mobile Apps, eingebettete Geräte
|
||||
|
||||
**Konfiguration:**
|
||||
```
|
||||
Port: 1883
|
||||
Websockets: DEAKTIVIERT
|
||||
```
|
||||
|
||||
### Port 9001 (MQTT over WebSockets)
|
||||
- **Protokoll:** MQTT über WebSocket
|
||||
- **Verwendung:** Browser-basierte Clients, Web-Anwendungen
|
||||
- **Websockets:** ✅ Ja
|
||||
- **Empfohlen für:** Web-Apps, JavaScript-Clients
|
||||
|
||||
**Konfiguration:**
|
||||
```
|
||||
Port: 9001
|
||||
Websockets: AKTIVIERT
|
||||
```
|
||||
|
||||
### Welchen Port sollten Sie verwenden?
|
||||
|
||||
| Client-Typ | Empfohlener Port | Websockets |
|
||||
|-----------|------------------|------------|
|
||||
| **OwnTracks App (iOS/Android)** | **1883** | ❌ Nein |
|
||||
| **Browser/Web-App** | **9001** | ✅ Ja |
|
||||
| **IoT-Geräte** | **1883** | ❌ Nein |
|
||||
| **Node.js/Python Scripts** | **1883** | ❌ Nein |
|
||||
|
||||
**Für die OwnTracks Mobile App verwenden Sie immer Port 1883 ohne Websockets!**
|
||||
|
||||
---
|
||||
|
||||
## 7. Troubleshooting - Häufige Probleme
|
||||
|
||||
### Problem: "Verbindung fehlgeschlagen"
|
||||
|
||||
**Mögliche Ursachen und Lösungen:**
|
||||
|
||||
#### 1. Falsche IP-Adresse oder Port
|
||||
- ✅ **Lösung:** Überprüfen Sie Hostname: `192.168.10.118` und Port: `1883`
|
||||
- Stellen Sie sicher, dass Ihr Smartphone im selben Netzwerk ist
|
||||
|
||||
#### 2. TLS aktiviert (sollte deaktiviert sein)
|
||||
- ✅ **Lösung:** Deaktivieren Sie TLS/SSL in den Verbindungseinstellungen
|
||||
- Lokale Verbindungen benötigen kein TLS
|
||||
|
||||
#### 3. Websockets fälschlicherweise aktiviert
|
||||
- ✅ **Lösung:** Deaktivieren Sie "Websockets nutzen" bei Port 1883
|
||||
- Websockets nur bei Port 9001 verwenden
|
||||
|
||||
#### 4. Falsche Credentials
|
||||
- ✅ **Lösung:** Überprüfen Sie Username und Passwort
|
||||
- Regenerieren Sie ggf. das Passwort über `/admin/mqtt`
|
||||
|
||||
#### 5. Firewall blockiert Port 1883
|
||||
- ✅ **Lösung:** Prüfen Sie Firewall-Einstellungen auf dem Server
|
||||
- Port 1883 muss für eingehende Verbindungen geöffnet sein
|
||||
|
||||
### Problem: "Verbunden, aber keine Daten auf der Karte"
|
||||
|
||||
**Mögliche Ursachen:**
|
||||
|
||||
#### 1. Falsche Device ID / Tracker ID
|
||||
- ✅ **Lösung:** Device ID und Tracker ID müssen mit dem konfigurierten Device im System übereinstimmen
|
||||
- Beispiel: Wenn Sie "Device 10" provisioniert haben, muss Tracker ID `10` sein
|
||||
|
||||
#### 2. Standortberechtigungen nicht erteilt
|
||||
- ✅ **Lösung (iOS):** Einstellungen → Datenschutz → Ortungsdienste → OwnTracks → "Immer"
|
||||
- ✅ **Lösung (Android):** App-Einstellungen → Berechtigungen → Standort → "Immer zulassen"
|
||||
|
||||
#### 3. Akkuoptimierung beendet App (Android)
|
||||
- ✅ **Lösung:** Akkuoptimierung für OwnTracks deaktivieren (siehe Abschnitt 4.3)
|
||||
|
||||
### Problem: "Tracking stoppt im Hintergrund"
|
||||
|
||||
**Lösungen:**
|
||||
|
||||
#### iOS
|
||||
1. Einstellungen → Allgemein → Hintergrundaktualisierung → OwnTracks aktivieren
|
||||
2. Standortzugriff: "Immer" (nicht "Beim Verwenden der App")
|
||||
|
||||
#### Android
|
||||
1. Akkuoptimierung deaktivieren
|
||||
2. Einstellungen → Apps → OwnTracks → Berechtigungen → Standort → "Immer zulassen"
|
||||
3. Bei manchen Herstellern: "Autostart" erlauben
|
||||
|
||||
---
|
||||
|
||||
## 8. Sicherheitshinweise
|
||||
|
||||
### WICHTIG - Nur im lokalen Netzwerk verwenden!
|
||||
|
||||
**Aktuelle Konfiguration ist NICHT für öffentliches Internet geeignet:**
|
||||
|
||||
- ❌ **TLS ist deaktiviert** - Daten werden unverschlüsselt übertragen
|
||||
- ❌ **Keine VPN-Verbindung** - Direkter Zugriff erforderlich
|
||||
- ⚠️ **Nur im sicheren WLAN** verwenden
|
||||
|
||||
### Für Zugriff von außerhalb:
|
||||
|
||||
Wenn Sie von außerhalb Ihres Heimnetzwerks zugreifen möchten, sollten Sie:
|
||||
|
||||
1. **VPN einrichten** (z.B. WireGuard, OpenVPN)
|
||||
2. **TLS/SSL aktivieren** für verschlüsselte Verbindung
|
||||
3. **Starke Passwörter verwenden** (automatisch generiert durch System)
|
||||
4. **Firewall korrekt konfigurieren** (nur VPN-Zugriff)
|
||||
|
||||
---
|
||||
|
||||
## 9. Konfigurationsübersicht
|
||||
|
||||
### ✅ Korrekte Konfiguration für OwnTracks Mobile App
|
||||
|
||||
```
|
||||
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
Verbindungseinstellungen
|
||||
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
|
||||
Modus: MQTT
|
||||
Hostname: 192.168.10.118
|
||||
Port: 1883
|
||||
Websockets nutzen: ❌ NEIN
|
||||
TLS: ❌ NEIN
|
||||
Client ID: (automatisch)
|
||||
|
||||
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
Authentifizierung
|
||||
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
|
||||
Benutzername: device_XX_xxxxxxxx
|
||||
Passwort: ******************
|
||||
|
||||
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
Device Identifikation
|
||||
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
|
||||
Geräte ID: 10 (Beispiel)
|
||||
Tracker ID: 10 (identisch)
|
||||
|
||||
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 10. Schnellstart-Checkliste
|
||||
|
||||
- [ ] OwnTracks App aus App Store / Play Store installiert
|
||||
- [ ] MQTT Credentials über `/admin/mqtt` generiert
|
||||
- [ ] Credentials sicher gespeichert
|
||||
- [ ] **Modus auf MQTT** gesetzt
|
||||
- [ ] **Hostname:** `192.168.10.118` eingetragen
|
||||
- [ ] **Port:** `1883` eingetragen
|
||||
- [ ] **Websockets:** ❌ Deaktiviert
|
||||
- [ ] **TLS:** ❌ Deaktiviert
|
||||
- [ ] **Benutzername** und **Passwort** eingetragen
|
||||
- [ ] **Device ID** und **Tracker ID** korrekt gesetzt
|
||||
- [ ] Standortberechtigungen "Immer" erteilt
|
||||
- [ ] Akkuoptimierung deaktiviert (Android)
|
||||
- [ ] Verbindung erfolgreich (grünes Symbol)
|
||||
- [ ] Testpunkt gesendet
|
||||
- [ ] Position auf Karte sichtbar unter `/map`
|
||||
|
||||
---
|
||||
|
||||
## 11. Weiterführende Informationen
|
||||
|
||||
### Offizielle OwnTracks Dokumentation
|
||||
- Website: https://owntracks.org
|
||||
- Dokumentation: https://owntracks.org/booklet/
|
||||
- GitHub: https://github.com/owntracks
|
||||
|
||||
### Location Tracker System
|
||||
- Dashboard: `http://192.168.10.118:3000/admin`
|
||||
- Live-Karte: `http://192.168.10.118:3000/map`
|
||||
- MQTT Provisioning: `http://192.168.10.118:3000/admin/mqtt`
|
||||
|
||||
---
|
||||
|
||||
## Support
|
||||
|
||||
Bei Problemen oder Fragen:
|
||||
1. Überprüfen Sie zuerst die Troubleshooting-Sektion (Abschnitt 7)
|
||||
2. Prüfen Sie die Verbindung im Location Tracker Dashboard
|
||||
3. Kontrollieren Sie die Server-Logs auf Fehler
|
||||
|
||||
**Wichtige Logs prüfen:**
|
||||
```bash
|
||||
# Next.js Server Logs
|
||||
npm run dev
|
||||
|
||||
# Mosquitto MQTT Broker Logs
|
||||
docker logs mosquitto
|
||||
```
|
||||
@@ -478,7 +478,7 @@ Die App verwendet einen **Echtzeit-Ansatz**:
|
||||
- Echtzeitdaten ohne Verzögerung
|
||||
- Schnelle Antwortzeiten (direkter SQLite Zugriff)
|
||||
- Längere Zeiträume abrufbar (24h+)
|
||||
- Keine externen Dependencies (kein n8n nötig)
|
||||
- Keine externen Dependencies
|
||||
- Duplikate werden automatisch verhindert (UNIQUE Index)
|
||||
|
||||
### Datenvalidierung & Normalisierung
|
||||
|
||||
Reference in New Issue
Block a user