Dokumentation für NocoDB-Setup und n8n-Workflows hinzugefügt

- NocoDB-Tabellenstruktur mit allen erforderlichen Spalten dokumentiert
- n8n-Workflow für automatische Datensammlung (alle 15 Min.) hinzugefügt
- n8n-Webhook für Datenbereitstellung an Visualisierung hinzugefügt
- CSV-Beispieldatei als Strukturvorlage hinzugefügt

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-14 08:17:28 +00:00
parent 01fc486db7
commit be1da0d7d5
4 changed files with 3442 additions and 0 deletions

3046
1763107744883.csv Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -83,6 +83,74 @@ Oder als Objekt mit Daten-Array:
- `Zeitstempel`
- `created_at`
## NocoDB-Setup
Für die automatische Datenerfassung und -speicherung muss eine NocoDB-Datenbank mit folgender Tabellenstruktur eingerichtet werden:
### Erforderliche Tabellenspalten
| Spaltenname | Typ | Beschreibung |
|-------------|-----|--------------|
| `Title` | Text | Optionaler Titel (kann leer bleiben) |
| `SDS_P1` | Number | Feinstaub PM10-Wert |
| `SDS_P2` | Number | Feinstaub PM2.5-Wert |
| `BME280_Temperature` | Number | Temperatur in °C |
| `BME280_Humidity` | Number | Luftfeuchtigkeit in % |
| `BME280_Pressure` | Number | Luftdruck (optional) |
| `Datum` | Date/Text | Datum im Format TT/MM/YYYY |
| `Uhrzeit` | Time/Text | Uhrzeit im Format HH:MM:SS |
**Hinweis**: Die genaue Struktur ist in der CSV-Datei `1763107744883.csv` zu finden, die als Vorlage dienen kann.
## n8n Workflows
Das Projekt enthält zwei n8n-Workflows für die Automatisierung:
### 1. Datensammlung (`feinstaub-daten.json`)
**Zweck**: Automatisches Sammeln von Sensordaten und Speichern in NocoDB
**Workflow-Schritte**:
1. **Schedule Trigger**: Läuft alle 15 Minuten automatisch
2. **HTTP Request**: Ruft Daten von `https://feinstaub.homeabc.de/data.json` ab
3. **NocoDB Create**: Schreibt die Sensordaten in die NocoDB-Tabelle
**Import in n8n**:
```bash
# Workflow in n8n importieren
# Settings → Import from File → feinstaub-daten.json auswählen
```
**Konfiguration**:
- NocoDB API-Token einrichten
- Project-ID und Table-ID anpassen
- Sensor-URL bei Bedarf ändern
### 2. Daten-Webhook (`feinstaub-webhook.json`)
**Zweck**: API-Endpunkt für die Visualisierung
**Workflow-Schritte**:
1. **Webhook**: Empfängt Anfragen auf `/sds-data`
2. **NocoDB GetAll**: Liest alle Daten aus der Tabelle (SDS_P1, SDS_P2, Uhrzeit)
3. **JavaScript Code**: Filtert die letzten 50 Einträge
4. **Response**: Gibt JSON-Daten zurück
**Verwendung**:
```javascript
// In feinstaub.html die API-URL anpassen:
const webhookUrl = 'https://your-n8n-instance.com/webhook/sds-data';
```
## CSV-Export
Die Datei `1763107744883.csv` enthält exportierte Sensordaten im CSV-Format und dient als:
- Beispieldatei für die erwartete Datenstruktur
- Vorlage für NocoDB-Tabellendefinition
- Backup der Sensordaten
**CSV-Struktur**: Siehe NocoDB-Setup oben
## Ausreißer-Filterung
Die Anwendung verwendet eine statistische Methode zur automatischen Erkennung von Ausreißern:

169
feinstaub-daten.json Normal file
View File

@@ -0,0 +1,169 @@
{
"name": "Feinstaub Sensor",
"nodes": [
{
"parameters": {},
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [
0,
0
],
"id": "97a097ea-86dd-4cc1-9fe8-0b93c165fdb4",
"name": "When clicking Execute workflow"
},
{
"parameters": {
"url": "https://feinstaub.homeabc.de/data.json",
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
192,
96
],
"id": "3661b690-3859-4d85-84c9-5fb1d80fede2",
"name": "HTTP Request"
},
{
"parameters": {
"authentication": "nocoDbApiToken",
"operation": "create",
"projectId": "pdxl4cx4dbu9nxi",
"table": "mq93uflujstkrdh",
"fieldsUi": {
"fieldValues": [
{
"fieldName": "=SDS_P1",
"fieldValue": "={{ $json.sensordatavalues[0].value }}"
},
{
"fieldName": "SDS_P2",
"fieldValue": "={{ $json.sensordatavalues[1].value }}"
},
{
"fieldName": "BME280_Temperature",
"fieldValue": "={{ $json.sensordatavalues[2].value }}"
},
{
"fieldName": "BME280_Humidity",
"fieldValue": "={{ $json.sensordatavalues[4].value }}"
},
{
"fieldName": "Datum",
"fieldValue": "={{ $now.toLocaleString('de-DE', { timeZone: 'Europe/Berlin' }) }}"
},
{
"fieldName": "Uhrzeit",
"fieldValue": "={{ $now.toFormat('HH:mm:ss') }}"
}
]
}
},
"type": "n8n-nodes-base.nocoDb",
"typeVersion": 3,
"position": [
384,
96
],
"id": "1bfeba86-aca1-4b75-b2cb-5712645e0981",
"name": "Create a row",
"credentials": {
"nocoDbApiToken": {
"id": "T9XuGr6CJD2W2BPO",
"name": "NocoDB Token account"
}
}
},
{
"parameters": {
"rule": {
"interval": [
{
"field": "minutes",
"minutesInterval": 15
}
]
}
},
"type": "n8n-nodes-base.scheduleTrigger",
"typeVersion": 1.2,
"position": [
0,
192
],
"id": "b9749aa9-4472-4b8c-b7ce-2ad59d979d6c",
"name": "Schedule Trigger"
}
],
"pinData": {},
"connections": {
"When clicking Execute workflow": {
"main": [
[
{
"node": "HTTP Request",
"type": "main",
"index": 0
}
]
]
},
"HTTP Request": {
"main": [
[
{
"node": "Create a row",
"type": "main",
"index": 0
}
]
]
},
"Schedule Trigger": {
"main": [
[
{
"node": "HTTP Request",
"type": "main",
"index": 0
}
]
]
}
},
"active": true,
"settings": {
"executionOrder": "v1",
"callerPolicy": "workflowsFromSameOwner",
"availableInMCP": false,
"errorWorkflow": "0bBZzSE6SUzVsif5"
},
"versionId": "fd1b3549-6bad-48eb-9b7c-e7554966ad01",
"meta": {
"templateCredsSetupCompleted": true,
"instanceId": "2f7fd37175cefa82de44e06b8af9ab9c01e7956018045d6efc4f7bf1588a41eb"
},
"id": "1P67HarmPSvmjDxc",
"tags": [
{
"updatedAt": "2025-11-01T14:23:20.263Z",
"createdAt": "2025-11-01T14:23:20.263Z",
"id": "N0uCqYBwuniqV9Up",
"name": "feinstaub"
},
{
"updatedAt": "2025-11-01T14:23:20.250Z",
"createdAt": "2025-11-01T14:23:20.250Z",
"id": "WqB4PpiYqVO3BD4U",
"name": "smarthome"
},
{
"updatedAt": "2025-11-01T14:23:20.273Z",
"createdAt": "2025-11-01T14:23:20.273Z",
"id": "k6O9Q9n2ZJ8bPx17",
"name": "sensor"
}
]
}

159
feinstaub-webhook.json Normal file
View File

@@ -0,0 +1,159 @@
{
"name": "NocoDB Webhook für Grafiken",
"nodes": [
{
"parameters": {},
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [
16,
224
],
"id": "cde82cdb-6c25-49bc-a09f-a74fec973575",
"name": "When clicking Execute workflow"
},
{
"parameters": {
"authentication": "nocoDbApiToken",
"operation": "getAll",
"projectId": "pdxl4cx4dbu9nxi",
"table": "mq93uflujstkrdh",
"returnAll": true,
"options": {
"fields": [
"SDS_P1",
"SDS_P2",
"Uhrzeit"
]
}
},
"type": "n8n-nodes-base.nocoDb",
"typeVersion": 3,
"position": [
208,
112
],
"id": "4e1510cc-1843-43d4-bdda-3ff32ccc4aea",
"name": "Get many rows",
"credentials": {
"nocoDbApiToken": {
"id": "T9XuGr6CJD2W2BPO",
"name": "NocoDB Token account"
}
}
},
{
"parameters": {
"path": "sds-data",
"responseMode": "lastNode",
"responseData": "allEntries",
"options": {}
},
"type": "n8n-nodes-base.webhook",
"typeVersion": 2.1,
"position": [
0,
0
],
"id": "2c42cea9-afaa-4d93-8a3b-9ea8d11dda88",
"name": "Webhook",
"webhookId": "7f744ddd-79a1-4bb0-987a-3a7beef09f13"
},
{
"parameters": {
"jsCode": "// nur die letzten 50 behalten\nreturn items.slice(-50);\n"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
400,
112
],
"id": "238b6d39-7ade-4146-9fd9-64521cd32b4f",
"name": "Code in JavaScript"
},
{
"parameters": {
"height": 480,
"width": 784
},
"type": "n8n-nodes-base.stickyNote",
"position": [
-144,
-80
],
"typeVersion": 1,
"id": "7490e26e-5661-4e77-a6d4-4084f77d1921",
"name": "Sticky Note"
}
],
"pinData": {},
"connections": {
"When clicking Execute workflow": {
"main": [
[
{
"node": "Get many rows",
"type": "main",
"index": 0
}
]
]
},
"Webhook": {
"main": [
[
{
"node": "Get many rows",
"type": "main",
"index": 0
}
]
]
},
"Get many rows": {
"main": [
[
{
"node": "Code in JavaScript",
"type": "main",
"index": 0
}
]
]
}
},
"active": true,
"settings": {
"executionOrder": "v1",
"callerPolicy": "workflowsFromSameOwner",
"availableInMCP": false,
"errorWorkflow": "0bBZzSE6SUzVsif5"
},
"versionId": "9ece3377-504a-4df7-900d-ef23c1bd5905",
"meta": {
"templateCredsSetupCompleted": true,
"instanceId": "2f7fd37175cefa82de44e06b8af9ab9c01e7956018045d6efc4f7bf1588a41eb"
},
"id": "71Oy271yDtaElXuQ",
"tags": [
{
"updatedAt": "2025-11-01T14:27:07.596Z",
"createdAt": "2025-11-01T14:27:07.596Z",
"id": "8ktLneL4GgVFyanL",
"name": "webhook"
},
{
"updatedAt": "2025-11-01T14:23:20.263Z",
"createdAt": "2025-11-01T14:23:20.263Z",
"id": "N0uCqYBwuniqV9Up",
"name": "feinstaub"
},
{
"updatedAt": "2025-11-01T14:27:03.941Z",
"createdAt": "2025-11-01T14:27:03.941Z",
"id": "ZXuz8AjF5AIBPY4Z",
"name": "nocodb"
}
]
}