Hi,
I have installed Node Red with Docker on a Raspberry Pi 4.
I have a chart in which I display temperatures as a graph.
Since this chart was often empty at the beginning, I was looking for a way to save the data. I have also found one.
But recently the content of the files has been deleted and I have not found a clue in any log as to why this is happening. So I don't know how I can prevent this or why it happens at all. But it is very annoying.
My installation:
Raspberry Pi OS (Bullseye)
Docker:
Client: Docker Engine - Community
Version: 25.0.0-beta.2
API version: 1.44
Go version: go1.21.5
Git commit: 7b3a60f
Built: Tue Dec 12 16:28:46 2023
OS/Arch: linux/arm64
Context: defaultServer: Docker Engine - Community
Engine:
Version: 25.0.0-beta.2
API version: 1.44 (minimum version 1.24)
Go version: go1.21.5
Git commit: 92884c2
Built: Tue Dec 12 16:28:46 2023
OS/Arch: linux/arm64
Experimental: false
containerd:
Version: 1.6.26
GitCommit: 3dd1e886e55dd695541fdcd67420c2888645a495
runc:
Version: 1.1.10
GitCommit: v1.1.10-0-g18a0cb0
docker-init:
Version: 0.19.0
GitCommit: de40ad0Docker Compose version v2.23.3
Directory:
/opt/nodered/
docker-compose.yml:
version: "3.7"
services:
node-red:
image: nodered/node-red:latest
container_name: node-red
Environment:
- TZ=Europe/Amsterdam
ports:
- "1880:1880"
volumes:
- node-red-data:/data
- ./temp-data:/home
Restart: if not stopped
networks:
- node-red-netVolumes:
node-red-data:networks:
node-red-net:
external: true
Name: node-red-net
The directory in which the data is located:
/opt/nodered/temp-data
Authorizations of the file:
-rw-rw-rw- 1 root root
Flows/Nodes:
[
{
"id": "67b87ba115798d5d",
"type": "mqtt in",
"z": "f6f2187d.f17ca8",
"g": "b1758e321249d0e8",
"name": "KĂźche",
"topic": "temp/outside",
"qos": "0",
"datatype": "auto-detect",
"broker": "17eb78de4afb253f",
"nl": false,
"rap": true,
"rh": 0,
"inputs": 0,
"x": 90,
"y": 140,
"wires": [
[
"a7bca3f79db9a314",
"454b28ab60627ba5",
"b073864d775c966c",
"b7aa17a737acda56",
"29bd06c1b4c1fda7"
]
]
},
{
"id": "a7bca3f79db9a314",
"type": "ui_chart",
"z": "f6f2187d.f17ca8",
"g": "b1758e321249d0e8",
"name": "",
"group": "5b086e8c2eee96c1",
"order": 3,
"width": 6,
"height": 6,
"label": "Temperatur drauĂen letzten 8 Wochen",
"chartType": "line",
"legend": "true",
"xformat": "dd HH:mm",
"interpolate": "bezier",
"nodata": "",
"dot": false,
"ymin": "-20",
"ymax": "40",
"removeOlder": "8",
"removeOlderPoints": "",
"removeOlderUnit": "604800",
"cutout": 0,
"useOneColor": false,
"useUTC": false,
"colors": [
"#d62728",
"#aec7e8",
"#ff7f0e",
"#2ca02c",
"#98df8a",
"#1f77b4",
"#ff9896",
"#9467bd",
"#c5b0d5"
],
"outputs": 1,
"useDifferentColor": false,
"className": "",
"x": 470,
"y": 180,
"wires": [
[
"0ecf46a5cde31204"
]
]
},
{
"id": "454b28ab60627ba5",
"type": "debug",
"z": "f6f2187d.f17ca8",
"g": "b1758e321249d0e8",
"name": "debug 1",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 300,
"y": 60,
"wires": []
},
{
"id": "b073864d775c966c",
"type": "ui_chart",
"z": "f6f2187d.f17ca8",
"g": "b1758e321249d0e8",
"name": "",
"group": "5b086e8c2eee96c1",
"order": 2,
"width": 6,
"height": 6,
"label": "Temperatur drauĂen letzten 12 Stunden",
"chartType": "line",
"legend": "true",
"xformat": "HH:mm",
"interpolate": "bezier",
"nodata": "",
"dot": false,
"ymin": "-10",
"ymax": "10",
"removeOlder": "12",
"removeOlderPoints": "",
"removeOlderUnit": "3600",
"cutout": 0,
"useOneColor": false,
"useUTC": false,
"colors": [
"#2ca02c",
"#aec7e8",
"#ff7f0e",
"#d62728",
"#98df8a",
"#1f77b4",
"#ff9896",
"#9467bd",
"#c5b0d5"
],
"outputs": 1,
"useDifferentColor": false,
"className": "",
"x": 480,
"y": 120,
"wires": [
[]
]
},
{
"id": "9673589d7815b17d",
"type": "ui_button",
"z": "f6f2187d.f17ca8",
"g": "b1758e321249d0e8",
"name": "",
"group": "5b086e8c2eee96c1",
"order": 5,
"width": 2,
"height": 1,
"passthru": false,
"label": "restore",
"tooltip": "",
"color": "",
"bgcolor": "",
"className": "",
"icon": "",
"payload": "",
"payloadType": "str",
"topic": "",
"topicType": "str",
"x": 90,
"y": 360,
"wires": [
[
"365dafb703db805b"
]
]
},
{
"id": "56ca315f23e1ceb1",
"type": "file",
"z": "f6f2187d.f17ca8",
"g": "b1758e321249d0e8",
"name": "",
"filename": "/home/chart.log",
"filenameType": "str",
"appendNewline": true,
"createDir": true,
"overwriteFile": "true",
"x": 660,
"y": 300,
"wires": [
[]
]
},
{
"id": "365dafb703db805b",
"type": "file in",
"z": "f6f2187d.f17ca8",
"g": "b1758e321249d0e8",
"name": "",
"filename": "/home/chart.log",
"filenameType": "str",
"format": "utf8",
"allProps": false,
"x": 300,
"y": 360,
"wires": [
[
"253884caecfa64bf"
]
]
},
{
"id": "0ecf46a5cde31204",
"type": "json",
"z": "f6f2187d.f17ca8",
"g": "b1758e321249d0e8",
"name": "",
"property": "payload",
"action": "",
"pretty": false,
"x": 710,
"y": 180,
"wires": [
[
"6b10ac5dab4db1e3"
]
]
},
{
"id": "253884caecfa64bf",
"type": "json",
"z": "f6f2187d.f17ca8",
"g": "b1758e321249d0e8",
"name": "",
"property": "payload",
"action": "",
"pretty": false,
"x": 490,
"y": 360,
"wires": [
[
"a7bca3f79db9a314"
]
]
},
{
"id": "6b10ac5dab4db1e3",
"type": "function",
"z": "f6f2187d.f17ca8",
"g": "b1758e321249d0e8",
"name": "",
"func": "if (msg.topic === \"save\") {\n msg.payload = context.last;\n return msg;\n}\nelse {\n context.last = msg.payload;\n}\nreturn null;",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 340,
"y": 300,
"wires": [
[
"56ca315f23e1ceb1"
]
]
},
{
"id": "b7aa17a737acda56",
"type": "ui_button",
"z": "f6f2187d.f17ca8",
"g": "b1758e321249d0e8",
"name": "",
"group": "5b086e8c2eee96c1",
"order": 4,
"width": 1,
"height": 1,
"passthru": true,
"label": "save",
"tooltip": "",
"color": "",
"bgcolor": "",
"className": "",
"icon": "",
"payload": "",
"payloadType": "str",
"topic": "save",
"topicType": "str",
"x": 130,
"y": 300,
"wires": [
[
"6b10ac5dab4db1e3"
]
]
},
{
"id": "29bd06c1b4c1fda7",
"type": "ui_text",
"z": "f6f2187d.f17ca8",
"g": "b1758e321249d0e8",
"group": "5b086e8c2eee96c1",
"order": 1,
"width": "6",
"height": "1",
"name": "",
"label": "Aktuelle Temperatur",
"format": "{{msg.payload}}",
"layout": "col-center",
"className": "",
"style": false,
"font": "",
"fontSize": 16,
"color": "#000000",
"x": 600,
"y": 60,
"wires": []
},
{
"id": "17eb78de4afb253f",
"type": "mqtt-broker",
"name": "Broker",
"broker": "mosquitto",
"port": "1883",
"clientid": "",
"autoConnect": true,
"usetls": false,
"protocolVersion": "4",
"keepalive": "60",
"cleansession": true,
"autoUnsubscribe": true,
"birthTopic": "",
"birthQos": "0",
"birthRetain": "false",
"birthPayload": "",
"birthMsg": {},
"closeTopic": "",
"closeQos": "0",
"closeRetain": "false",
"closePayload": "",
"closeMsg": {},
"willTopic": "",
"willQos": "0",
"willRetain": "false",
"willPayload": "",
"willMsg": {},
"userProps": "",
"sessionExpiry": ""
},
{
"id": "5b086e8c2eee96c1",
"type": "ui_group",
"name": "Temperatur DrauĂen",
"tab": "be7464e7b0f7fc9e",
"order": 1,
"disp": true,
"width": "6",
"collapse": false,
"className": ""
},
{
"id": "be7464e7b0f7fc9e",
"type": "ui_tab",
"name": "Pi Zero",
"icon": "dashboard",
"order": 1,
"disabled": false,
"hidden": false
}
]
Can someone help me so that the contents of the files are no longer deleted?