util/mysensors_flow.json

603 lines
15 KiB
JSON

[
{
"id": "fbd1cc91.a9a0e",
"type": "tab",
"label": "Flow 1",
"disabled": false,
"info": ""
},
{
"id": "c99f1ed8.90d96",
"type": "debug",
"z": "fbd1cc91.a9a0e",
"name": "",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"x": 1070,
"y": 740,
"wires": []
},
{
"id": "3e3aa83b.2ecb78",
"type": "mysdecode",
"z": "fbd1cc91.a9a0e",
"database": "15bf6546.29bb5b",
"name": "",
"mqtt": true,
"enrich": true,
"x": 560,
"y": 680,
"wires": [
[
"2ef90b94.f5f394"
]
]
},
{
"id": "bcc8e40b.37a9e8",
"type": "mqtt in",
"z": "fbd1cc91.a9a0e",
"name": "",
"topic": "mys-in_ares/+/+/1/#",
"qos": "2",
"broker": "85db82eb.8126e",
"x": 180,
"y": 680,
"wires": [
[
"3e3aa83b.2ecb78"
]
]
},
{
"id": "2ef90b94.f5f394",
"type": "function",
"z": "fbd1cc91.a9a0e",
"name": "Rewrite mysensors to Influx",
"func": "if (!isNaN(msg.payload)) {\n \n st = msg.subType;\n switch (st) {\n case 0 : type = \"temperature\";break;\n case 1 : type = \"humidity\"; break;\n case 2 : type = \"status\"; break;\n case 4 : type = \"barometer\"; break;\n case 13 : type = \"distance\"; break;\n case 17: type = \"electricity\"; break;\n }\n msg.measurement = type;\n \n msg.payload = [{\n value: parseFloat(msg.payload),\n },\n {\n type:msg.subTypeStr,\n nodeId: msg.nodeId,\n childId: msg.childSensorId,\n }];\n if (msg.sensorDescStr != '' ){\n sensorDescStr = msg.sensorDescStr;\n sensorDescStr = sensorDescStr.split(' ').join('_');\n msg.payload[1]['name'] = sensorDescStr;\n }\n return msg\n}",
"outputs": 1,
"noerr": 0,
"x": 820,
"y": 680,
"wires": [
[
"c99f1ed8.90d96",
"d8a7109.fd35af"
]
]
},
{
"id": "d8a7109.fd35af",
"type": "influxdb out",
"z": "fbd1cc91.a9a0e",
"influxdb": "271994ef.c6303c",
"name": "",
"measurement": "",
"precision": "",
"retentionPolicy": "",
"x": 1250,
"y": 680,
"wires": []
},
{
"id": "fb38d962.0e9318",
"type": "serial in",
"z": "fbd1cc91.a9a0e",
"name": "Mysensors NRF",
"serial": "61c6f4ab.a7171c",
"x": 140,
"y": 340,
"wires": [
[
"de2dee71.08aa3",
"c527b7f0.281aa8"
]
]
},
{
"id": "68feaf1b.6696a",
"type": "serial out",
"z": "fbd1cc91.a9a0e",
"name": "Mysensors NRF",
"serial": "61c6f4ab.a7171c",
"x": 1040,
"y": 140,
"wires": []
},
{
"id": "81951c2f.5a4a",
"type": "debug",
"z": "fbd1cc91.a9a0e",
"name": "msg_nrf",
"active": false,
"tosidebar": true,
"console": false,
"complete": "payload",
"x": 880,
"y": 80,
"wires": []
},
{
"id": "de2dee71.08aa3",
"type": "debug",
"z": "fbd1cc91.a9a0e",
"name": "NRF input",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"x": 360,
"y": 300,
"wires": []
},
{
"id": "b8a0d8cc.8a2078",
"type": "mqtt out",
"z": "fbd1cc91.a9a0e",
"name": "",
"topic": "",
"qos": "2",
"retain": "false",
"broker": "85db82eb.8126e",
"x": 870,
"y": 340,
"wires": []
},
{
"id": "e1956a11.f50968",
"type": "mqtt in",
"z": "fbd1cc91.a9a0e",
"name": "",
"topic": "mys-out_ares/#",
"qos": "2",
"broker": "85db82eb.8126e",
"x": 140,
"y": 140,
"wires": [
[
"e2b15548.e15198",
"e6a13dc4.9893b"
]
]
},
{
"id": "df9cac92.f846c",
"type": "debug",
"z": "fbd1cc91.a9a0e",
"name": "MQTT out",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"x": 880,
"y": 300,
"wires": []
},
{
"id": "c527b7f0.281aa8",
"type": "mysdecode",
"z": "fbd1cc91.a9a0e",
"database": "6333159d.e25c4c",
"name": "",
"mqtt": false,
"enrich": false,
"x": 390,
"y": 340,
"wires": [
[
"470093f.7e5ff6c"
]
]
},
{
"id": "470093f.7e5ff6c",
"type": "mysencode",
"z": "fbd1cc91.a9a0e",
"name": "",
"mqtt": true,
"mqtttopic": "mys-in_ares",
"x": 660,
"y": 340,
"wires": [
[
"df9cac92.f846c",
"b8a0d8cc.8a2078"
]
]
},
{
"id": "e2b15548.e15198",
"type": "mysdecode",
"z": "fbd1cc91.a9a0e",
"name": "",
"mqtt": true,
"x": 380,
"y": 140,
"wires": [
[
"2d00cb25.06a444"
]
]
},
{
"id": "2d00cb25.06a444",
"type": "mysencode",
"z": "fbd1cc91.a9a0e",
"name": "",
"mqtt": false,
"x": 630,
"y": 140,
"wires": [
[
"81951c2f.5a4a",
"8997768e.d3d838"
]
]
},
{
"id": "e6a13dc4.9893b",
"type": "debug",
"z": "fbd1cc91.a9a0e",
"name": "MQTT out",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"x": 360,
"y": 100,
"wires": []
},
{
"id": "29110b1d.1fa064",
"type": "comment",
"z": "fbd1cc91.a9a0e",
"name": "Mysensors Serial <-> MQTT transformation",
"info": "",
"x": 220,
"y": 60,
"wires": []
},
{
"id": "8997768e.d3d838",
"type": "function",
"z": "fbd1cc91.a9a0e",
"name": "add \\n\\r",
"func": "msg.payload = msg.payload + \"\\n\\r\";\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 880,
"y": 140,
"wires": [
[
"68feaf1b.6696a"
]
]
},
{
"id": "c77f2965.02b0b8",
"type": "mqtt in",
"z": "fbd1cc91.a9a0e",
"name": "",
"topic": "mys-in_ares/#",
"qos": "2",
"broker": "85db82eb.8126e",
"x": 130,
"y": 200,
"wires": [
[
"4dd32aae.242314"
]
]
},
{
"id": "6fe20174.d5d23",
"type": "mqtt out",
"z": "fbd1cc91.a9a0e",
"name": "",
"topic": "",
"qos": "",
"retain": "",
"broker": "85db82eb.8126e",
"x": 590,
"y": 200,
"wires": []
},
{
"id": "4dd32aae.242314",
"type": "myscontroller",
"z": "fbd1cc91.a9a0e",
"database": "15bf6546.29bb5b",
"name": "controller",
"handleid": true,
"timeresponse": true,
"timezone": "Europe/Copenhagen",
"measurementsystem": "M",
"mqttroot": "mys-out_ares",
"x": 360,
"y": 200,
"wires": [
[
"6fe20174.d5d23",
"1e5fb97e.06be77"
]
]
},
{
"id": "1e5fb97e.06be77",
"type": "debug",
"z": "fbd1cc91.a9a0e",
"name": "",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"x": 590,
"y": 260,
"wires": []
},
{
"id": "6a23bcdf.bfed64",
"type": "debug",
"z": "fbd1cc91.a9a0e",
"name": "gw debug",
"active": false,
"tosidebar": true,
"console": false,
"complete": "true",
"x": 860,
"y": 1020,
"wires": []
},
{
"id": "fea87d75.a835c",
"type": "mqtt in",
"z": "fbd1cc91.a9a0e",
"name": "",
"topic": "mys-in_ares/#",
"qos": "2",
"broker": "85db82eb.8126e",
"x": 170,
"y": 880,
"wires": [
[
"86765597.5093b8"
]
]
},
{
"id": "86765597.5093b8",
"type": "mysdecode",
"z": "fbd1cc91.a9a0e",
"database": "6333159d.e25c4c",
"name": "",
"mqtt": true,
"enrich": false,
"x": 420,
"y": 880,
"wires": [
[
"8b473ff9.acb37"
]
]
},
{
"id": "41bb127b.c7446c",
"type": "comment",
"z": "fbd1cc91.a9a0e",
"name": "Logging and data collection from nodes",
"info": "",
"x": 230,
"y": 600,
"wires": []
},
{
"id": "b3f92fff.6bef4",
"type": "file",
"z": "fbd1cc91.a9a0e",
"name": "Battery log",
"filename": "/var/tmp/battlog.txt",
"appendNewline": false,
"createDir": false,
"overwriteFile": "false",
"x": 1310,
"y": 820,
"wires": [
[]
]
},
{
"id": "8681ea7a.deefe8",
"type": "function",
"z": "fbd1cc91.a9a0e",
"name": "inject date",
"func": "var date = new Date();\nvar str = date.getFullYear() + \"-\" + (date.getMonth() + 1) + \"-\" + date.getDate() + \" \" + date.getHours() + \":\" + date.getMinutes() + \":\" + date.getSeconds();\nmsg.payload = str + \" - \" + msg.payload + '\\r\\n';\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 1090,
"y": 820,
"wires": [
[
"b3f92fff.6bef4"
]
]
},
{
"id": "f97d8b56.f93b28",
"type": "function",
"z": "fbd1cc91.a9a0e",
"name": "Check batt level",
"func": "var date = new Date();\nvar str = date.getFullYear() + \"-\" + (date.getMonth() + 1) + \"-\" + date.getDate() + \" \" + date.getHours() + \":\" + date.getMinutes() + \":\" + date.getSeconds();\nmsg.date = str;\nif (parseInt(msg.payload)<5)\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 880,
"y": 860,
"wires": [
[
"54cf4848.075828"
]
]
},
{
"id": "54cf4848.075828",
"type": "template",
"z": "fbd1cc91.a9a0e",
"name": "BatLow message",
"field": "payload",
"fieldType": "msg",
"format": "handlebars",
"syntax": "mustache",
"template": "{{date}} - Battery level is low on node {{nodeId}} : {{payload}} !",
"x": 1110,
"y": 860,
"wires": [
[]
]
},
{
"id": "667ec42e.1a7c8c",
"type": "file",
"z": "fbd1cc91.a9a0e",
"name": "Presentation log",
"filename": "/var/tmp/presentation.txt",
"appendNewline": true,
"createDir": false,
"overwriteFile": "false",
"x": 1100,
"y": 920,
"wires": [
[]
]
},
{
"id": "2ea95d34.b71d12",
"type": "mysencode",
"z": "fbd1cc91.a9a0e",
"name": "",
"mqtt": false,
"x": 890,
"y": 820,
"wires": [
[
"8681ea7a.deefe8"
]
]
},
{
"id": "8f69337f.4e5e3",
"type": "mysencode",
"z": "fbd1cc91.a9a0e",
"name": "",
"mqtt": false,
"x": 890,
"y": 920,
"wires": [
[
"667ec42e.1a7c8c"
]
]
},
{
"id": "8b473ff9.acb37",
"type": "function",
"z": "fbd1cc91.a9a0e",
"name": "Filter battery msg",
"func": "var battMsg = null;\nvar debugMsg = null;\nvar sketchMsg = null;\nif (msg.messageType==3) {\n if (msg.subType===0)\n battMsg = msg;\n if (msg.subType==9)\n debugMsg = msg;\n if (msg.subType==11 || msg.subType==12)\n sketchMsg = msg;\n}\n\nreturn [battMsg, sketchMsg, debugMsg];",
"outputs": "3",
"noerr": 0,
"x": 650,
"y": 880,
"wires": [
[
"f97d8b56.f93b28",
"2ea95d34.b71d12"
],
[
"8f69337f.4e5e3"
],
[
"6a23bcdf.bfed64"
]
]
},
{
"id": "4134bb4f.ba2f54",
"type": "comment",
"z": "fbd1cc91.a9a0e",
"name": "Log serial traffic and put data to domoticz",
"info": "",
"x": 180,
"y": 460,
"wires": []
},
{
"id": "15bf6546.29bb5b",
"type": "mysensorsdb",
"z": "",
"name": "",
"file": "/home/simon/sqlitemysensors.sqlite"
},
{
"id": "85db82eb.8126e",
"type": "mqtt-broker",
"z": "",
"name": "",
"broker": "10.0.0.3",
"port": "1883",
"clientid": "nodered",
"usetls": false,
"compatmode": true,
"keepalive": "15",
"cleansession": false,
"birthTopic": "",
"birthQos": "0",
"birthPayload": "",
"closeTopic": "",
"closeQos": "0",
"closePayload": "",
"willTopic": "",
"willQos": "0",
"willPayload": ""
},
{
"id": "271994ef.c6303c",
"type": "influxdb",
"z": "",
"hostname": "10.0.0.3",
"port": "8086",
"protocol": "http",
"database": "mysensors",
"name": "",
"usetls": false,
"tls": ""
},
{
"id": "61c6f4ab.a7171c",
"type": "serial-port",
"z": "",
"serialport": "/dev/ttyUSB0",
"serialbaud": "115200",
"databits": "8",
"parity": "none",
"stopbits": "1",
"newline": "\\n",
"bin": "false",
"out": "char",
"addchar": false,
"responsetimeout": "10000"
},
{
"id": "6333159d.e25c4c",
"type": "mysensorsdb",
"z": "",
"name": "",
"file": "/data/mysensors.db"
}
]