Node-RED
Zo stránky SensorWiki
Moje hratky s Node-RED
Pripojit sem aj poznamky z desktopu
Node-RED
- START http://localhost:1880/
- START Dashboard http://localhost:1880/ui
- http://noderedguide.com/node-red-lecture-3-basic-nodes-and-flows/
- Cookbook: https://cookbook.nodered.org/basic/map-between-different-number-ranges
- https://discourse.nodered.org/t/multiple-lines-on-a-graph-from-one-message/9315/4
- http://noderedguide.com/tutorial-node-red-dashboards-multiple-lines-on-a-chart/
- https://flows.nodered.org/node/node-red-contrib-ui-level - Pekny indikator
A sem dame jeden priklad na Dashboard s viacerymi prvkami
[
{
"id": "667ca37f.39af9c",
"type": "tab",
"label": "Flow 1",
"disabled": false,
"info": ""
},
{
"id": "716b65e3.f5fd44",
"type": "ui_tab",
"z": "",
"name": "FEI STU Bratislava : N48 11 06 E 017 12 023 : meteo",
"icon": "dashboard",
"disabled": false,
"hidden": false
},
{
"id": "3fbaf987.a5a6f6",
"type": "ui_group",
"z": "",
"name": "Aktuálne počasie",
"tab": "716b65e3.f5fd44",
"disp": true,
"width": "19",
"collapse": false
},
{
"id": "53a055fc.9dee3c",
"type": "ui_base",
"theme": {
"name": "theme-dark",
"lightTheme": {
"default": "#0094CE",
"baseColor": "#0094CE",
"baseFont": "-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif",
"edited": true,
"reset": false
},
"darkTheme": {
"default": "#097479",
"baseColor": "#0b3f7d",
"baseFont": "Copperplate,Copperplate Gothic Light,fantasy",
"edited": true,
"reset": false
},
"customTheme": {
"name": "Untitled Theme 1",
"default": "#4B7930",
"baseColor": "#4B7930",
"baseFont": "-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif"
},
"themeState": {
"base-color": {
"default": "#097479",
"value": "#0b3f7d",
"edited": true
},
"page-titlebar-backgroundColor": {
"value": "#0b3f7d",
"edited": false
},
"page-backgroundColor": {
"value": "#111111",
"edited": false
},
"page-sidebar-backgroundColor": {
"value": "#000000",
"edited": false
},
"group-textColor": {
"value": "#1162c3",
"edited": false
},
"group-borderColor": {
"value": "#555555",
"edited": false
},
"group-backgroundColor": {
"value": "#333333",
"edited": false
},
"widget-textColor": {
"value": "#eeeeee",
"edited": false
},
"widget-backgroundColor": {
"value": "#0b3f7d",
"edited": false
},
"widget-borderColor": {
"value": "#333333",
"edited": false
},
"base-font": {
"value": "Copperplate,Copperplate Gothic Light,fantasy"
}
},
"angularTheme": {
"primary": "indigo",
"accents": "blue",
"warn": "red",
"background": "grey"
}
},
"site": {
"name": "Node-RED Dashboard",
"hideToolbar": "false",
"allowSwipe": "false",
"lockMenu": "false",
"allowTempTheme": "true",
"dateFormat": "DD/MM/YYYY",
"sizes": {
"sx": 48,
"sy": 48,
"gx": 6,
"gy": 6,
"cx": 6,
"cy": 6,
"px": 0,
"py": 0
}
}
},
{
"id": "73736cc1.367c2c",
"type": "ui_spacer",
"name": "spacer",
"group": "3fbaf987.a5a6f6",
"order": 2,
"width": 12,
"height": 1
},
{
"id": "eff3ead5.cab97",
"type": "inject",
"z": "667ca37f.39af9c",
"name": "",
"topic": "",
"payload": "",
"payloadType": "str",
"repeat": "300",
"crontab": "",
"once": false,
"onceDelay": "",
"x": 190,
"y": 300,
"wires": [
[
"8cd83d4d.d778a"
]
]
},
{
"id": "8cd83d4d.d778a",
"type": "http request",
"z": "667ca37f.39af9c",
"name": "Recent Quakes",
"method": "GET",
"paytoqs": false,
"url": "https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/significant_week.csv",
"tls": "",
"persist": false,
"proxy": "",
"authType": "",
"x": 360,
"y": 300,
"wires": [
[
"f313061e.b57498"
]
]
},
{
"id": "f313061e.b57498",
"type": "csv",
"z": "667ca37f.39af9c",
"name": "",
"sep": ",",
"hdrin": true,
"hdrout": "",
"multi": "one",
"ret": "\\n",
"temp": "",
"skip": 0,
"strings": true,
"x": 530,
"y": 300,
"wires": [
[
"cd545c9b.47f688",
"29043f0a.fc5768"
]
]
},
{
"id": "cd545c9b.47f688",
"type": "debug",
"z": "667ca37f.39af9c",
"name": "",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"x": 690,
"y": 300,
"wires": []
},
{
"id": "29043f0a.fc5768",
"type": "switch",
"z": "667ca37f.39af9c",
"name": "",
"property": "payload.mag",
"propertyType": "msg",
"rules": [
{
"t": "gte",
"v": "6",
"vt": "num"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 570,
"y": 360,
"wires": [
[
"cb876b20.7e69e8"
]
]
},
{
"id": "cb876b20.7e69e8",
"type": "change",
"z": "667ca37f.39af9c",
"name": "",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "PANIC!",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 710,
"y": 420,
"wires": [
[
"2acc7858.b3f5"
]
]
},
{
"id": "2acc7858.b3f5",
"type": "debug",
"z": "667ca37f.39af9c",
"name": "",
"active": false,
"complete": false,
"x": 810,
"y": 360,
"wires": []
},
{
"id": "686552cf.1e648c",
"type": "comment",
"z": "667ca37f.39af9c",
"name": "Poznamka",
"info": "# Poznamocka\n\nTento komentar ma dve casti\n\n## Prva\n\nTu je dolezita **informacia**\n\n## Druha\n\nA tu je tiez nejaka informacia aj s odkazom na\nwebstranku [robotika.sk](http://robotika.sk)",
"x": 180,
"y": 160,
"wires": [],
"icon": "node-red/alert.svg"
},
{
"id": "6edc0476.ff6ae4",
"type": "inject",
"z": "667ca37f.39af9c",
"name": "temperature",
"topic": "temperature",
"payload": "10",
"payloadType": "num",
"repeat": "1",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 140,
"y": 440,
"wires": [
[
"655ff53d.c446a4",
"3c2afec9.d14f4a"
]
]
},
{
"id": "46876adc.ff037c",
"type": "join",
"z": "667ca37f.39af9c",
"name": "",
"mode": "custom",
"build": "object",
"property": "",
"propertyType": "full",
"key": "topic",
"joiner": "\\n",
"joinerType": "str",
"accumulate": false,
"timeout": "",
"count": "3",
"reduceRight": false,
"reduceExp": "",
"reduceInit": "",
"reduceInitType": "",
"reduceFixup": "",
"x": 570,
"y": 460,
"wires": [
[
"e707a31.e2eb56"
]
]
},
{
"id": "e707a31.e2eb56",
"type": "debug",
"z": "667ca37f.39af9c",
"name": "",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"x": 870,
"y": 500,
"wires": []
},
{
"id": "397cee7c.3b22e2",
"type": "inject",
"z": "667ca37f.39af9c",
"name": "humidity",
"topic": "humidity",
"payload": "",
"payloadType": "num",
"repeat": "1",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 120,
"y": 500,
"wires": [
[
"ad5871c6.a407c"
]
]
},
{
"id": "248e3e7b.d21dc2",
"type": "inject",
"z": "667ca37f.39af9c",
"name": "pressure",
"topic": "pressure",
"payload": "999",
"payloadType": "num",
"repeat": "1",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 120,
"y": 560,
"wires": [
[
"2be11026.fe49b8"
]
]
},
{
"id": "655ff53d.c446a4",
"type": "function",
"z": "667ca37f.39af9c",
"name": "nahodne cislo",
"func": "msg.payload = Math.round(Math.random()*100);\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 340,
"y": 440,
"wires": [
[
"46876adc.ff037c",
"1d61e023.7b57e8",
"e4e3aa12.79ac8"
]
]
},
{
"id": "ad5871c6.a407c",
"type": "function",
"z": "667ca37f.39af9c",
"name": "nahodne cislo",
"func": "msg.payload = Math.round(Math.random()*100);\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 340,
"y": 500,
"wires": [
[
"46876adc.ff037c",
"1d61e023.7b57e8",
"775a9045.e6d6c"
]
]
},
{
"id": "2be11026.fe49b8",
"type": "function",
"z": "667ca37f.39af9c",
"name": "nahodne cislo",
"func": "msg.payload = Math.round(Math.random()*100);\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 340,
"y": 560,
"wires": [
[
"46876adc.ff037c",
"1d61e023.7b57e8",
"e925c588.27715"
]
]
},
{
"id": "1d61e023.7b57e8",
"type": "ui_chart",
"z": "667ca37f.39af9c",
"name": "",
"group": "3fbaf987.a5a6f6",
"order": 6,
"width": 19,
"height": 5,
"label": "Tri veličiny:",
"chartType": "line",
"legend": "true",
"xformat": "HH:mm:ss",
"interpolate": "linear",
"nodata": "",
"dot": false,
"ymin": "",
"ymax": "",
"removeOlder": 1,
"removeOlderPoints": "100",
"removeOlderUnit": "60",
"cutout": 0,
"useOneColor": false,
"colors": [
"#1f77b4",
"#aec7e8",
"#ff7f0e",
"#2ca02c",
"#98df8a",
"#d62728",
"#ff9896",
"#9467bd",
"#c5b0d5"
],
"useOldStyle": false,
"outputs": 1,
"x": 630,
"y": 640,
"wires": [
[]
]
},
{
"id": "3c2afec9.d14f4a",
"type": "debug",
"z": "667ca37f.39af9c",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"x": 320,
"y": 380,
"wires": []
},
{
"id": "e4e3aa12.79ac8",
"type": "ui_gauge",
"z": "667ca37f.39af9c",
"name": "",
"group": "3fbaf987.a5a6f6",
"order": 3,
"width": 7,
"height": 4,
"gtype": "gage",
"title": "Teplota",
"label": "° C",
"format": "Šablóna:Value ",
"min": 0,
"max": "100",
"colors": [
"#49c4fe",
"#c927e0",
"#ca3838"
],
"seg1": "",
"seg2": "",
"x": 620,
"y": 500,
"wires": []
},
{
"id": "775a9045.e6d6c",
"type": "ui_chart",
"z": "667ca37f.39af9c",
"name": "",
"group": "3fbaf987.a5a6f6",
"order": 4,
"width": 4,
"height": 4,
"label": "Vlhkost",
"chartType": "bar",
"legend": "false",
"xformat": "HH:mm:ss",
"interpolate": "linear",
"nodata": "",
"dot": false,
"ymin": "0",
"ymax": "100",
"removeOlder": 1,
"removeOlderPoints": "",
"removeOlderUnit": "3600",
"cutout": 0,
"useOneColor": false,
"colors": [
"#1f77b4",
"#aec7e8",
"#ff7f0e",
"#2ca02c",
"#98df8a",
"#d62728",
"#ff9896",
"#9467bd",
"#c5b0d5"
],
"useOldStyle": false,
"outputs": 1,
"x": 620,
"y": 540,
"wires": [
[]
]
},
{
"id": "e925c588.27715",
"type": "ui_gauge",
"z": "667ca37f.39af9c",
"name": "",
"group": "3fbaf987.a5a6f6",
"order": 5,
"width": 8,
"height": 4,
"gtype": "donut",
"title": "Tlak",
"label": "kPa",
"format": "Šablóna:Value",
"min": 0,
"max": "100",
"colors": [
"#00b500",
"#e6e600",
"#ca3838"
],
"seg1": "",
"seg2": "",
"x": 610,
"y": 580,
"wires": []
},
{
"id": "2ed48bea.985704",
"type": "inject",
"z": "667ca37f.39af9c",
"name": "",
"topic": "",
"payload": "",
"payloadType": "date",
"repeat": "1",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 130,
"y": 640,
"wires": [
[
"2567a87a.c4cdb"
]
]
},
{
"id": "5541894f.182c98",
"type": "ui_text",
"z": "667ca37f.39af9c",
"group": "3fbaf987.a5a6f6",
"order": 1,
"width": 7,
"height": 1,
"name": "",
"label": "Dátum",
"format": "Šablóna:Msg.payload",
"layout": "row-right",
"x": 620,
"y": 720,
"wires": []
},
{
"id": "2567a87a.c4cdb",
"type": "function",
"z": "667ca37f.39af9c",
"name": "Datum",
"func": "// Create a Date object from the payload\nvar date = new Date(msg.payload);\n// Change the payload to be a formatted Date string\nmsg.payload = date.toString();\n// Return the message so it can be sent on\nreturn msg;\n",
"outputs": 1,
"noerr": 0,
"x": 340,
"y": 660,
"wires": [
[
"5541894f.182c98"
]
]
}
]