Node-RED node to track and store historical values with automatic time-based aggregation (hour, day, month, year)
npm install @schey-dev/node-red-contrib-history-trackeryaml
npm_packages:
- github:GreenHearted/node-red-contrib-history-tracker
`
Speichern und Addon neu starten.
$3
`bash
cd ~/.node-red
npm install github:GreenHearted/node-red-contrib-history-tracker
`
$3
`bash
cd ~/.node-red
npm install node-red-contrib-history-tracker
`
Verwendung
$3
1. Füge den "history tracker" Node zu deinem Flow hinzu
2. Konfiguriere:
- Dateiname: Name der History-Datei (z.B. wasserverbrauch.txt)
- Pfad: Optional - vollständiger Pfad zur Datei
- Wertfeld: Feld mit dem Wert (Standard: payload)
- Output: Welche Daten sollen ausgegeben werden
3. Verbinde einen Input-Node, der numerische Werte sendet
$3
`json
[
{
"id": "inject1",
"type": "inject",
"payload": "15.5",
"payloadType": "num"
},
{
"id": "history1",
"type": "history-tracker",
"filename": "wasserverbrauch.txt",
"outputMode": "current"
},
{
"id": "debug1",
"type": "debug"
}
]
`
$3
⚠️ Hinweis: Die standalone Version (history_file.js) ist nicht im Package enthalten.
Verwendung über Node-RED Node wird empfohlen.
Output-Modi
$3
Node gibt keine Nachricht aus (nur Speicherung)
$3
`javascript
msg.payload = {
wert: 15.5,
zeitstempel: "12.01.2025, 14:30:00"
}
`
$3
`javascript
msg.payload = {
letzterWert: {...},
aktuelleStunde: {...},
aktuellerTag: {...},
aktuellerMonat: {...},
aktuellesJahr: {...}
}
`
$3
Gibt die komplette Datenstruktur inkl. History zurück
Dateiformat
Die History-Datei ist eine lesbare Textdatei:
`
============================================================
LETZTER WERT
============================================================
Wert: 15.50 Liter
Zeitstempel: 12.01.2025, 14:30:00
============================================================
AKTUELLE STUNDE
============================================================
Periode: 2025-01-12_14
Wert: 47.20 Liter
Zeitstempel: 12.01.2025, 14:45:00
...
``