Hi @all out there!
I am nearly new on red-node. Or it seems to me as if...
I am using node-red : file to write data in a file. Fine and it works.
But (There will allways be a but..).
The file seems not to be updated in my file system (RP4). After waiting, maybe after the flows has ended or started again, the file updates. I also tried to send the filename via msg.filename, same effect.
Question: Can I force close file? Or where is my fault? Only a slow raspberry?
(See the flow for testing below...)
Thanks f reading and any hint!
Dirk
[
{
"id": "3b49d206.22100e",
"type": "tab",
"label": "Flow 2",
"disabled": false,
"info": ""
},
{
"id": "63d0071f.d1f498",
"type": "inject",
"z": "3b49d206.22100e",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 140,
"y": 80,
"wires": [
[
"e3b88583.644ca8"
]
]
},
{
"id": "cecce8d5.6464d8",
"type": "file",
"z": "3b49d206.22100e",
"name": "",
"filename": "//etc/openhab2/html/nr_message_001.html",
"appendNewline": false,
"createDir": false,
"overwriteFile": "true",
"encoding": "none",
"x": 570,
"y": 220,
"wires": [
[
"e76365a3.a55b28",
"783926c.f311ed8"
]
]
},
{
"id": "3ee8c328.aa0bdc",
"type": "function",
"z": "3b49d206.22100e",
"name": "set Text in iFrame",
"func": "let textValue = \"\"\ntextValue=\"<!doctype html>\"\ntextValue+=\"<html>\"\ntextValue+=\"<head>\"\ntextValue+=\"<meta charset='utf-8'>\"\ntextValue+=\"<meta name='viewport# content='width=device-width, initial-scale=1.0'>\"\ntextValue+=\"<title>Beschreibung der Seite (erscheint in der Titelzeile des Browsers)</title>\"\ntextValue+=\"</head>\"\ntextValue+=\"<body>\"\ntextValue+=\"<p>\"\n\nif (global.get('timerTime') >= 0)\n{\n textValue+=\"Timer: \" + global.get('timerTime');\n global.set('timerTime', global.get('timerTime')-1);\n}\nelse\n textValue+=\"Timer ist abgelaufen!\" + global.get('timerTime');\n\ntextValue+=\"</p>\"\ntextValue+=\"</body>\"\ntextValue+=\"</html>\";\nlet msg1 = {payload: textValue};\n//msg1 = {filename: \"//etc/openhab2/html/nr_message_001.html\"};\nlet msg2 = {payload: null};\nif (global.get('timerTime') > 0)\n msg2 = {payload: global.get('timerTime')};\nreturn [msg1,msg2];",
"outputs": 2,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 210,
"y": 220,
"wires": [
[
"cecce8d5.6464d8",
"103ccd57.3e4593"
],
[
"32205b50.ad7bc4",
"d51da409.3506b8"
]
]
},
{
"id": "85f312ec.288ef",
"type": "delay",
"z": "3b49d206.22100e",
"name": "",
"pauseType": "delay",
"timeout": "6",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "minute",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"x": 600,
"y": 140,
"wires": [
[
"3ee8c328.aa0bdc"
]
]
},
{
"id": "103ccd57.3e4593",
"type": "debug",
"z": "3b49d206.22100e",
"name": "m_01",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 310,
"y": 300,
"wires": []
},
{
"id": "32205b50.ad7bc4",
"type": "function",
"z": "3b49d206.22100e",
"name": "Trigger delay if needed again",
"func": "if (msg.payload != null)\n return msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 240,
"y": 140,
"wires": [
[
"85f312ec.288ef"
]
]
},
{
"id": "e3b88583.644ca8",
"type": "function",
"z": "3b49d206.22100e",
"name": "set delay for test to 15 ",
"func": "global.set('timerTime', 15);\nmsg.payload = 15;\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 360,
"y": 80,
"wires": [
[
"85f312ec.288ef"
]
]
},
{
"id": "d51da409.3506b8",
"type": "debug",
"z": "3b49d206.22100e",
"name": "m_02",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 310,
"y": 340,
"wires": []
},
{
"id": "e76365a3.a55b28",
"type": "debug",
"z": "3b49d206.22100e",
"name": "m_03",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 770,
"y": 300,
"wires": []
},
{
"id": "783926c.f311ed8",
"type": "function",
"z": "3b49d206.22100e",
"name": "",
"func": "\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 540,
"y": 320,
"wires": [
[]
]
}
]