Hi all,
I have a bit of a noob question; couldn't find the answer yet:
I'm running Node-Red on a Linux NUC pc, and I want to be able to write some logging info to a USB stick. So I began with nodes to determine whether a USB stick is present, and find out its address:
[
{
"id": "e9ee1b34.cfb5f8",
"type": "exec",
"z": "ca11a0459a7c29b7",
"command": "",
"addpay": true,
"append": "",
"useSpawn": "false",
"timer": "",
"oldrc": false,
"name": "",
"x": 330,
"y": 700,
"wires": [
[
"9ab2c2f4af80e0fe",
"2ca80c4b9170e354"
],
[
"bbdbf46cec725a29"
],
[
"3c6554e354978de1"
]
]
},
{
"id": "bbdbf46cec725a29",
"type": "debug",
"z": "ca11a0459a7c29b7",
"name": "debug 9",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 540,
"y": 780,
"wires": []
},
{
"id": "3c6554e354978de1",
"type": "debug",
"z": "ca11a0459a7c29b7",
"name": "debug 10",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 540,
"y": 840,
"wires": []
},
{
"id": "9ab2c2f4af80e0fe",
"type": "function",
"z": "ca11a0459a7c29b7",
"name": "Address of USB stick",
"func": "var response = [null, null, null];\nvar usbStickFound = Boolean(msg.payload != \"\");\n\nvar newMsg = { payload: usbStickFound };\n\nflow.set(\"usbStickFound\", usbStickFound);\n\nresponse[0] = newMsg;\nif (usbStickFound)\n{\n var usbStickName = msg.payload.trim();\n flow.set(\"usb_stick\", usbStickName);\n newMsg = { payload: \"/media/jw/\" + msg.payload };\n response[2] = newMsg;\n}\nelse\n{\n newMsg = { payload: \"Geen USB stick gedetecteerd.\" };\n response[1] = newMsg;\n}\nreturn response;\n\n\n",
"outputs": 3,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 580,
"y": 720,
"wires": [
[
"689f2a274e302539"
],
[
"b014d243d5220a1b"
],
[]
]
},
{
"id": "b014d243d5220a1b",
"type": "ui_toast",
"z": "ca11a0459a7c29b7",
"position": "dialog",
"displayTime": "0",
"highlight": "",
"sendall": true,
"outputs": 1,
"ok": "OK",
"cancel": "",
"raw": false,
"className": "",
"topic": "Let op!",
"name": "Foutmelding",
"x": 1010,
"y": 720,
"wires": [
[]
]
},
{
"id": "ba9bcba6d5c99313",
"type": "function",
"z": "ca11a0459a7c29b7",
"name": "Try to find usb stick",
"func": "msg.payload = \"ls /media/jw\";\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 190,
"y": 800,
"wires": [
[
"e9ee1b34.cfb5f8"
]
]
},
{
"id": "2ca80c4b9170e354",
"type": "debug",
"z": "ca11a0459a7c29b7",
"name": "debug 16",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 540,
"y": 660,
"wires": []
},
{
"id": "124fc669055f8694",
"type": "inject",
"z": "ca11a0459a7c29b7",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 120,
"y": 720,
"wires": [
[
"ba9bcba6d5c99313"
]
]
},
{
"id": "689f2a274e302539",
"type": "debug",
"z": "ca11a0459a7c29b7",
"name": "debug 17",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 760,
"y": 660,
"wires": []
}
]
.. which works nicely, but only as long as I'm logged in on the pc. I would like to be able to always write to a USB stick from the NR dashboard. Is that possible?