Skip to content

Instantly share code, notes, and snippets.

@vongomben
Created July 20, 2022 15:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vongomben/d5c1c9be68cf7c526fed3793bd883563 to your computer and use it in GitHub Desktop.
Save vongomben/d5c1c9be68cf7c526fed3793bd883563 to your computer and use it in GitHub Desktop.
[
{
"id": "cc7a1b10.a7c038",
"type": "http in",
"z": "f59413a0a9e17cdd",
"name": "",
"url": "/daten.json",
"method": "get",
"upload": false,
"swaggerDoc": "",
"x": 320,
"y": 480,
"wires": [
[
"61e489ce.08eb68"
]
]
},
{
"id": "89f4552e.8cc4f8",
"type": "http response",
"z": "f59413a0a9e17cdd",
"name": "",
"statusCode": "",
"headers": {},
"x": 1040,
"y": 480,
"wires": []
},
{
"id": "ced95c01.75153",
"type": "change",
"z": "f59413a0a9e17cdd",
"name": "Set Headers",
"rules": [
{
"t": "set",
"p": "headers",
"pt": "msg",
"to": "{}",
"tot": "json"
},
{
"t": "set",
"p": "headers.content-type",
"pt": "msg",
"to": "application/json",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 880,
"y": 480,
"wires": [
[
"89f4552e.8cc4f8"
]
]
},
{
"id": "a5b108a6.e68c88",
"type": "template",
"z": "f59413a0a9e17cdd",
"name": "page",
"field": "payload",
"fieldType": "msg",
"format": "handlebars",
"syntax": "mustache",
"template": "{ \n \"Daten\": [\n {\n \"name\": \"RPi Temp\",\n \"value\": \"{{temp}}°C\",\n \"lastUpdate\": \"{{temp-timestamp}}\"\n },\n {\n \"name\": \"CPU Load\",\n \"value\": \"{{load}}%\",\n \"lastUpdate\": \"{{load-timestamp}}\"\n },\n {\n \"name\": \"Free Memory\",\n \"value\": \"{{free}}MB\",\n \"lastUpdate\": \"{{free-timestamp}}\"\n }\n ]\n}",
"output": "str",
"x": 720,
"y": 480,
"wires": [
[
"ced95c01.75153"
]
]
},
{
"id": "c088c2a8.b53bc",
"type": "comment",
"z": "f59413a0a9e17cdd",
"name": "Json Feed to feed the MagicMirror",
"info": "",
"x": 220,
"y": 100,
"wires": []
},
{
"id": "61e489ce.08eb68",
"type": "change",
"z": "f59413a0a9e17cdd",
"name": "Copy time",
"rules": [
{
"t": "set",
"p": "temp",
"pt": "msg",
"to": "temp",
"tot": "flow"
},
{
"t": "set",
"p": "temp-timestamp",
"pt": "msg",
"to": "temp-timestamp",
"tot": "flow"
},
{
"t": "set",
"p": "load",
"pt": "msg",
"to": "load",
"tot": "flow"
},
{
"t": "set",
"p": "load-timestamp",
"pt": "msg",
"to": "load-timestamp",
"tot": "flow"
},
{
"t": "set",
"p": "free",
"pt": "msg",
"to": "free",
"tot": "flow"
},
{
"t": "set",
"p": "free-timestamp",
"pt": "msg",
"to": "free-timestamp",
"tot": "flow"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 560,
"y": 480,
"wires": [
[
"a5b108a6.e68c88"
]
]
},
{
"id": "b64f17d1.b71778",
"type": "comment",
"z": "f59413a0a9e17cdd",
"name": "Incoming data is buffered here for later sending",
"info": "",
"x": 380,
"y": 160,
"wires": []
},
{
"id": "9eede084.b713a",
"type": "comment",
"z": "f59413a0a9e17cdd",
"name": "Here the stored data is delivered as Json",
"info": "",
"x": 360,
"y": 440,
"wires": []
},
{
"id": "877b026b.7bbd9",
"type": "exec",
"z": "f59413a0a9e17cdd",
"command": "vcgencmd measure_temp",
"addpay": false,
"append": "",
"useSpawn": "",
"timer": "",
"winHide": false,
"name": "RPi Temp.",
"x": 510,
"y": 240,
"wires": [
[
"c71030c9.e8723"
],
[],
[]
]
},
{
"id": "e2c23c0f.e6896",
"type": "inject",
"z": "f59413a0a9e17cdd",
"name": "",
"repeat": "10",
"crontab": "",
"once": false,
"onceDelay": "",
"topic": "",
"payload": "",
"payloadType": "date",
"x": 310,
"y": 240,
"wires": [
[
"877b026b.7bbd9",
"bd2a3aa8.b05be8",
"f6021bf6.b47108"
]
]
},
{
"id": "c71030c9.e8723",
"type": "function",
"z": "f59413a0a9e17cdd",
"name": "cutString",
"func": "str = msg.payload\nmsg.payload = str.substring(5,9);\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 700,
"y": 240,
"wires": [
[
"38abd283.af271e"
]
]
},
{
"id": "bd2a3aa8.b05be8",
"type": "exec",
"z": "f59413a0a9e17cdd",
"command": "top -d 1 -b -n2 | grep \"Cpu(s)\"|tail -n 1 | awk '{print $2 + $4}'",
"addpay": false,
"append": "",
"useSpawn": "",
"timer": "",
"oldrc": false,
"name": "CPU Load",
"x": 510,
"y": 300,
"wires": [
[
"966babc4.47d538"
],
[],
[]
]
},
{
"id": "f6021bf6.b47108",
"type": "exec",
"z": "f59413a0a9e17cdd",
"command": "free | grep Mem | awk '{print 100*($4+$6+$7)/$2}'",
"addpay": false,
"append": "",
"useSpawn": "",
"timer": "",
"name": "Free Memory",
"x": 510,
"y": 360,
"wires": [
[
"350be0e6.dc723"
],
[],
[]
]
},
{
"id": "ff73e7b0.560078",
"type": "change",
"z": "f59413a0a9e17cdd",
"name": "Store time",
"rules": [
{
"t": "set",
"p": "temp",
"pt": "flow",
"to": "payload",
"tot": "msg"
},
{
"t": "set",
"p": "temp-timestamp",
"pt": "flow",
"to": "timestamp",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1170,
"y": 240,
"wires": [
[]
]
},
{
"id": "ec6a82fb.238ff",
"type": "change",
"z": "f59413a0a9e17cdd",
"name": "Store time",
"rules": [
{
"t": "set",
"p": "load",
"pt": "flow",
"to": "payload",
"tot": "msg"
},
{
"t": "set",
"p": "load-timestamp",
"pt": "flow",
"to": "timestamp",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1170,
"y": 300,
"wires": [
[]
]
},
{
"id": "bd9b96f7.e4c268",
"type": "change",
"z": "f59413a0a9e17cdd",
"name": "Store time",
"rules": [
{
"t": "set",
"p": "free",
"pt": "flow",
"to": "payload",
"tot": "msg"
},
{
"t": "set",
"p": "free-timestamp",
"pt": "flow",
"to": "timestamp",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1170,
"y": 360,
"wires": [
[]
]
},
{
"id": "38abd283.af271e",
"type": "function",
"z": "f59413a0a9e17cdd",
"name": "addTimestamp",
"func": "msg.payload = msg.payload;\nvar now = new Date();\n\nvar Hours=now.getHours();\nvar Minutes=now.getMinutes();\nvar Seconds=now.getSeconds();\n\n if (Seconds<10)\n Seconds=\"0\"+Seconds;\n \n if (Minutes<10)\n Minutes=\"0\"+Minutes;\n \n if (Hours<10)\n Hours=\"0\"+Hours;\n \nmsg.timestamp=Hours+\":\"+Minutes+\":\"+Seconds;\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 960,
"y": 240,
"wires": [
[
"ff73e7b0.560078"
]
]
},
{
"id": "9a625c6e.b43da",
"type": "function",
"z": "f59413a0a9e17cdd",
"name": "addTimestamp",
"func": "msg.payload = msg.payload;\nvar now = new Date();\n\nvar Hours=now.getHours();\nvar Minutes=now.getMinutes();\nvar Seconds=now.getSeconds();\n\n if (Seconds<10)\n Seconds=\"0\"+Seconds;\n \n if (Minutes<10)\n Minutes=\"0\"+Minutes;\n \n if (Hours<10)\n Hours=\"0\"+Hours;\n \nmsg.timestamp=Hours+\":\"+Minutes+\":\"+Seconds;\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 960,
"y": 300,
"wires": [
[
"ec6a82fb.238ff"
]
]
},
{
"id": "a85eaa63.cad4a8",
"type": "function",
"z": "f59413a0a9e17cdd",
"name": "addTimestamp",
"func": "msg.payload = msg.payload;\nvar now = new Date();\n\nvar Hours=now.getHours();\nvar Minutes=now.getMinutes();\nvar Seconds=now.getSeconds();\n\n if (Seconds<10)\n Seconds=\"0\"+Seconds;\n \n if (Minutes<10)\n Minutes=\"0\"+Minutes;\n \n if (Hours<10)\n Hours=\"0\"+Hours;\n \nmsg.timestamp=Hours+\":\"+Minutes+\":\"+Seconds;\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 960,
"y": 360,
"wires": [
[
"bd9b96f7.e4c268"
]
]
},
{
"id": "350be0e6.dc723",
"type": "function",
"z": "f59413a0a9e17cdd",
"name": "deleteWhitespace",
"func": "str = msg.payload\nmsg.payload = str.trim();\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 730,
"y": 360,
"wires": [
[
"a85eaa63.cad4a8"
]
]
},
{
"id": "966babc4.47d538",
"type": "function",
"z": "f59413a0a9e17cdd",
"name": "deleteWhitespace",
"func": "str = msg.payload\nmsg.payload = str.trim();\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 730,
"y": 300,
"wires": [
[
"9a625c6e.b43da"
]
]
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment