Skip to content

Instantly share code, notes, and snippets.

@Raidok
Last active November 6, 2016 01:29
Show Gist options
  • Save Raidok/2d85473e89f3272af268a16b588c2e0f to your computer and use it in GitHub Desktop.
Save Raidok/2d85473e89f3272af268a16b588c2e0f to your computer and use it in GitHub Desktop.
node-red sensorTag and Wii-Scale flow
[
{
"id": "48444261.4abf7c",
"type": "tab",
"label": "sensorTag"
},
{
"id": "8ad329cd.911818",
"type": "sensorTag",
"z": "48444261.4abf7c",
"name": "",
"topic": "sensorTag",
"uuid": "b59349a1f37042bbbd43ff389a8791e9",
"temperature": true,
"humidity": true,
"pressure": true,
"magnetometer": true,
"accelerometer": true,
"gyroscope": true,
"keys": true,
"luxometer": false,
"x": 53,
"y": 187,
"wires": [
[
"91b0d9a7.708268",
"c063b170.e0a82"
]
]
},
{
"id": "91b0d9a7.708268",
"type": "debug",
"z": "48444261.4abf7c",
"name": "",
"active": false,
"console": "false",
"complete": "false",
"x": 296,
"y": 124,
"wires": []
},
{
"id": "e533efb7.b1db7",
"type": "debug",
"z": "48444261.4abf7c",
"name": "",
"active": false,
"console": "false",
"complete": "false",
"x": 490,
"y": 160,
"wires": []
},
{
"id": "62492d1d.e130e4",
"type": "debug",
"z": "48444261.4abf7c",
"name": "",
"active": false,
"console": "false",
"complete": "false",
"x": 490,
"y": 200,
"wires": []
},
{
"id": "c063b170.e0a82",
"type": "function",
"z": "48444261.4abf7c",
"name": "",
"func": "\nvar payload = msg.payload\n temperature = undefined,\n humidity = undefined,\n x = undefined,\n y = undefined,\n z = undefined,\n pressure = undefined,\n other = undefined;\n\nif (msg.topic == 'sensorTag/humidity') {\n temperature = { payload: payload.temperature, topic: 'red/temperature' };\n humidity = { payload: payload.humidity, topic: 'red/humidity' };\n} else if (msg.topic == 'sensorTag/magnetometer') {\n x = { payload: payload.x, topic: 'red/x' };\n y = { payload: payload.y, topic: 'red/y' };\n z = { payload: payload.z, topic: 'red/z' };\n} else if (msg.topic == 'sensorTag/pressure') {\n msg.payload = payload.pressure;\n msg.topic = 'red/pressure'\n pressure = msg;\n} else {\n other = msg\n}\n\n\nreturn [\n temperature,\n humidity,\n pressure,\n x,\n y,\n z,\n other\n ];",
"outputs": "7",
"noerr": 0,
"x": 249,
"y": 256,
"wires": [
[
"e533efb7.b1db7",
"e5c49b73.fe8978"
],
[
"62492d1d.e130e4",
"75b9c67d.3ba418"
],
[
"41900438.ac89cc",
"d6804dce.712b3"
],
[
"54c40a5e.39b1c4",
"b2554e22.87bd1"
],
[
"7506c1ca.130c9",
"a1a0f966.cf9e98"
],
[
"6ebc0979.c93448",
"fbb5d65c.13dc88"
],
[]
]
},
{
"id": "41900438.ac89cc",
"type": "debug",
"z": "48444261.4abf7c",
"name": "",
"active": false,
"console": "false",
"complete": "payload",
"x": 490,
"y": 240,
"wires": []
},
{
"id": "54c40a5e.39b1c4",
"type": "debug",
"z": "48444261.4abf7c",
"name": "",
"active": false,
"console": "false",
"complete": "payload",
"x": 490,
"y": 280,
"wires": []
},
{
"id": "7506c1ca.130c9",
"type": "debug",
"z": "48444261.4abf7c",
"name": "",
"active": false,
"console": "false",
"complete": "payload",
"x": 490,
"y": 320,
"wires": []
},
{
"id": "6ebc0979.c93448",
"type": "debug",
"z": "48444261.4abf7c",
"name": "",
"active": false,
"console": "false",
"complete": "payload",
"x": 490,
"y": 360,
"wires": []
},
{
"id": "e893961d.ba6078",
"type": "ui_gauge",
"z": "48444261.4abf7c",
"name": "x",
"group": "72e38159.21d28",
"order": 0,
"width": "4",
"height": "2",
"gtype": "gage",
"title": "x",
"label": "",
"format": "{{value}}",
"min": "-180",
"max": "180",
"colors": [
"#00b500",
"#e6e600",
"#ca3838"
],
"x": 870,
"y": 280,
"wires": []
},
{
"id": "c2dda291.be38",
"type": "ui_gauge",
"z": "48444261.4abf7c",
"name": "y",
"group": "72e38159.21d28",
"order": 0,
"width": "4",
"height": "2",
"gtype": "gage",
"title": "y",
"label": "",
"format": "{{value}}",
"min": "-180",
"max": "180",
"colors": [
"#00b500",
"#e6e600",
"#ca3838"
],
"x": 870,
"y": 320,
"wires": []
},
{
"id": "d64c3b35.3c6748",
"type": "ui_gauge",
"z": "48444261.4abf7c",
"name": "z",
"group": "72e38159.21d28",
"order": 0,
"width": "4",
"height": "2",
"gtype": "gage",
"title": "z",
"label": "",
"format": "{{value}}",
"min": "-180",
"max": "180",
"colors": [
"#00b500",
"#e6e600",
"#ca3838"
],
"x": 870,
"y": 360,
"wires": []
},
{
"id": "3de38e5e.a98a32",
"type": "ui_text",
"z": "48444261.4abf7c",
"group": "15e478ae.ddf6c7",
"order": 0,
"width": "4",
"height": "3",
"name": "",
"label": "uks on",
"format": "{{msg.payload}}",
"layout": "col-center",
"x": 1339,
"y": 366,
"wires": []
},
{
"id": "368f3ba.ab727c4",
"type": "switch",
"z": "48444261.4abf7c",
"name": "",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "lt",
"v": "141",
"vt": "num"
},
{
"t": "else"
}
],
"checkall": "true",
"outputs": 2,
"x": 1059,
"y": 366,
"wires": [
[
"29be18b6.0237d8"
],
[
"2d84768e.8a124a"
]
]
},
{
"id": "29be18b6.0237d8",
"type": "change",
"z": "48444261.4abf7c",
"name": "lahti",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "lahti",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1199,
"y": 346,
"wires": [
[
"3de38e5e.a98a32"
]
]
},
{
"id": "2d84768e.8a124a",
"type": "change",
"z": "48444261.4abf7c",
"name": "kinni",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "kinni",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1199,
"y": 386,
"wires": [
[
"3de38e5e.a98a32"
]
]
},
{
"id": "b599f96a.1f6168",
"type": "ui_gauge",
"z": "48444261.4abf7c",
"name": "rõhk",
"group": "5360a6e2.4cafb8",
"order": 0,
"width": "4",
"height": "2",
"gtype": "gage",
"title": "rõhk",
"label": "hPa",
"format": "{{value}}",
"min": "950",
"max": "1050",
"colors": [
"#e1e700",
"#34d951",
"#ca3838"
],
"x": 870,
"y": 240,
"wires": []
},
{
"id": "b6a82078.1c94a",
"type": "ui_gauge",
"z": "48444261.4abf7c",
"name": "niiskus",
"group": "5360a6e2.4cafb8",
"order": 0,
"width": "4",
"height": "2",
"gtype": "gage",
"title": "niiskus",
"label": "%",
"format": "{{value}}",
"min": "0",
"max": "100",
"colors": [
"#00b500",
"#e6e600",
"#ca3838"
],
"x": 870,
"y": 200,
"wires": []
},
{
"id": "ada8eb6.166ac18",
"type": "ui_gauge",
"z": "48444261.4abf7c",
"name": "temperatuur",
"group": "5360a6e2.4cafb8",
"order": 0,
"width": "4",
"height": "2",
"gtype": "gage",
"title": "temperatuur",
"label": "°C",
"format": "{{value}}",
"min": "0",
"max": "100",
"colors": [
"#00b500",
"#e6e600",
"#ca3838"
],
"x": 890,
"y": 160,
"wires": []
},
{
"id": "35993dc0.98d632",
"type": "debug",
"z": "48444261.4abf7c",
"name": "",
"active": false,
"console": "false",
"complete": "false",
"x": 890,
"y": 400,
"wires": []
},
{
"id": "fbb5d65c.13dc88",
"type": "smooth",
"z": "48444261.4abf7c",
"name": "",
"action": "mean",
"count": "3",
"round": "1",
"x": 660,
"y": 360,
"wires": [
[
"368f3ba.ab727c4",
"35993dc0.98d632",
"d64c3b35.3c6748"
]
]
},
{
"id": "b2554e22.87bd1",
"type": "smooth",
"z": "48444261.4abf7c",
"name": "",
"action": "mean",
"count": "3",
"round": "1",
"x": 660,
"y": 280,
"wires": [
[
"e893961d.ba6078"
]
]
},
{
"id": "a1a0f966.cf9e98",
"type": "smooth",
"z": "48444261.4abf7c",
"name": "",
"action": "mean",
"count": "3",
"round": "1",
"x": 660,
"y": 320,
"wires": [
[
"c2dda291.be38"
]
]
},
{
"id": "d6804dce.712b3",
"type": "smooth",
"z": "48444261.4abf7c",
"name": "",
"action": "mean",
"count": "3",
"round": "1",
"x": 660,
"y": 240,
"wires": [
[
"b599f96a.1f6168"
]
]
},
{
"id": "75b9c67d.3ba418",
"type": "smooth",
"z": "48444261.4abf7c",
"name": "",
"action": "mean",
"count": "3",
"round": "1",
"x": 660,
"y": 200,
"wires": [
[
"b6a82078.1c94a",
"108984f3.b2063b"
]
]
},
{
"id": "e5c49b73.fe8978",
"type": "smooth",
"z": "48444261.4abf7c",
"name": "",
"action": "mean",
"count": "3",
"round": "1",
"x": 660,
"y": 160,
"wires": [
[
"ada8eb6.166ac18",
"af749f7d.8395e",
"df33356d.1bdb98",
"f2899df.50ad96"
]
]
},
{
"id": "af749f7d.8395e",
"type": "switch",
"z": "48444261.4abf7c",
"name": "",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "lte",
"v": "60",
"vt": "num"
},
{
"t": "btwn",
"v": "60",
"vt": "num",
"v2": "80",
"v2t": "num"
},
{
"t": "else"
}
],
"checkall": "true",
"outputs": 3,
"x": 1110,
"y": 160,
"wires": [
[
"3dd53d57.f280c2"
],
[
"f5b88d32.1ae34"
],
[
"3b96c914.5df466"
]
]
},
{
"id": "3dd53d57.f280c2",
"type": "change",
"z": "48444261.4abf7c",
"name": "külm",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "külm",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1230,
"y": 120,
"wires": [
[
"a2411f38.c1018"
]
]
},
{
"id": "f5b88d32.1ae34",
"type": "change",
"z": "48444261.4abf7c",
"name": "soe",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "soe",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1230,
"y": 160,
"wires": [
[
"a2411f38.c1018"
]
]
},
{
"id": "3b96c914.5df466",
"type": "change",
"z": "48444261.4abf7c",
"name": "kuum",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "kuum",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1230,
"y": 200,
"wires": [
[
"a2411f38.c1018"
]
]
},
{
"id": "a2411f38.c1018",
"type": "ui_text",
"z": "48444261.4abf7c",
"group": "15e478ae.ddf6c7",
"order": 0,
"width": "4",
"height": "3",
"name": "",
"label": "saun on",
"format": "{{msg.payload}}",
"layout": "col-center",
"x": 1360,
"y": 160,
"wires": []
},
{
"id": "df33356d.1bdb98",
"type": "delay",
"z": "48444261.4abf7c",
"name": "",
"pauseType": "rate",
"timeout": "5",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "minute",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": true,
"x": 1257,
"y": 237,
"wires": [
[
"7a134386.66406c"
]
]
},
{
"id": "7a134386.66406c",
"type": "ui_chart",
"z": "48444261.4abf7c",
"name": "",
"group": "5360a6e2.4cafb8",
"order": 0,
"width": 0,
"height": 0,
"label": "",
"chartType": "line",
"legend": "false",
"xformat": "%H:%M:%S",
"interpolate": "linear",
"nodata": "",
"ymin": "0",
"ymax": "100",
"removeOlder": 1,
"removeOlderUnit": "3600",
"x": 1470,
"y": 260,
"wires": [
[],
[]
]
},
{
"id": "108984f3.b2063b",
"type": "delay",
"z": "48444261.4abf7c",
"name": "",
"pauseType": "rate",
"timeout": "5",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "minute",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": true,
"x": 1260,
"y": 280,
"wires": [
[
"7a134386.66406c"
]
]
},
{
"id": "36d9a740.872368",
"type": "rbe",
"z": "48444261.4abf7c",
"name": "",
"func": "deadband",
"gap": "3",
"start": "",
"inout": "in",
"x": 1250,
"y": 40,
"wires": [
[
"7e0974c7.45f3fc"
]
]
},
{
"id": "f2899df.50ad96",
"type": "delay",
"z": "48444261.4abf7c",
"name": "",
"pauseType": "rate",
"timeout": "10",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "10",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": true,
"x": 962,
"y": 68,
"wires": [
[
"36d9a740.872368"
]
]
},
{
"id": "7e0974c7.45f3fc",
"type": "switch",
"z": "48444261.4abf7c",
"name": "",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "lt",
"v": "",
"vt": "prev"
},
{
"t": "else"
}
],
"checkall": "true",
"outputs": 2,
"x": 1410,
"y": 40,
"wires": [
[
"167e5959.2fa6b7"
],
[
"20132d1a.1df7a2"
]
]
},
{
"id": "167e5959.2fa6b7",
"type": "change",
"z": "48444261.4abf7c",
"name": "langeb",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "langeb",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1550,
"y": 20,
"wires": [
[
"bdbdb829.7523c8"
]
]
},
{
"id": "20132d1a.1df7a2",
"type": "change",
"z": "48444261.4abf7c",
"name": "tõuseb",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "tõuseb",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1550,
"y": 60,
"wires": [
[
"bdbdb829.7523c8"
]
]
},
{
"id": "bdbdb829.7523c8",
"type": "ui_text",
"z": "48444261.4abf7c",
"group": "15e478ae.ddf6c7",
"order": 0,
"width": "4",
"height": "3",
"name": "",
"label": "temperatuur",
"format": "{{msg.payload}}",
"layout": "col-center",
"x": 1710,
"y": 40,
"wires": []
},
{
"id": "bc9909c8.a90248",
"type": "wii-scale",
"z": "48444261.4abf7c",
"name": "",
"client": "387d0be.bde2ef4",
"allChannels": false,
"channel": "",
"x": 546,
"y": 609,
"wires": [
[
"7ac787e6.c899b8",
"42c887d9.77e6a8"
]
]
},
{
"id": "7ac787e6.c899b8",
"type": "smooth",
"z": "48444261.4abf7c",
"name": "",
"action": "mean",
"count": "3",
"round": "1",
"x": 739,
"y": 608,
"wires": [
[
"7375f529.672e1c"
]
]
},
{
"id": "7375f529.672e1c",
"type": "ui_gauge",
"z": "48444261.4abf7c",
"name": "",
"group": "72e38159.21d28",
"order": 0,
"width": "4",
"height": "2",
"gtype": "gage",
"title": "Kaal",
"label": "kg",
"format": "{{value}}",
"min": 0,
"max": "100",
"colors": [
"#00b500",
"#e6e600",
"#ca3838"
],
"x": 934,
"y": 604,
"wires": []
},
{
"id": "72d7bb1b.8cdaa4",
"type": "ui_slider",
"z": "48444261.4abf7c",
"name": "min",
"label": "min kaal",
"group": "caa118e5.1ab9c8",
"order": 0,
"width": "10",
"height": "1",
"passthru": true,
"topic": "min",
"min": 0,
"max": "100",
"step": "0.1",
"x": 710,
"y": 720,
"wires": [
[
"88916334.25283",
"8e7a80b4.68b9c"
]
]
},
{
"id": "88916334.25283",
"type": "function",
"z": "48444261.4abf7c",
"name": "save slider value",
"func": "\nvar sliders = (flow.get('sliders') || {}); \nsliders[msg.topic] = msg.payload;\nflow.set('sliders', sliders);\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 900,
"y": 680,
"wires": [
[
"3c422f18.ae8fb"
]
]
},
{
"id": "3c422f18.ae8fb",
"type": "debug",
"z": "48444261.4abf7c",
"name": "",
"active": true,
"console": "false",
"complete": "true",
"x": 1134,
"y": 680,
"wires": []
},
{
"id": "8e7a80b4.68b9c",
"type": "ui_text",
"z": "48444261.4abf7c",
"group": "caa118e5.1ab9c8",
"order": 0,
"width": "2",
"height": "1",
"name": "",
"label": "",
"format": "{{msg.payload}}",
"layout": "row-left",
"x": 870,
"y": 720,
"wires": []
},
{
"id": "2aaaa547.71e82a",
"type": "ui_slider",
"z": "48444261.4abf7c",
"name": "max",
"label": "max kaal",
"group": "caa118e5.1ab9c8",
"order": 0,
"width": "10",
"height": "1",
"passthru": true,
"topic": "max",
"min": 0,
"max": "100",
"step": "0.1",
"x": 710,
"y": 760,
"wires": [
[
"88916334.25283",
"68e95d68.53b3e4"
]
]
},
{
"id": "68e95d68.53b3e4",
"type": "ui_text",
"z": "48444261.4abf7c",
"group": "caa118e5.1ab9c8",
"order": 0,
"width": "2",
"height": "1",
"name": "",
"label": "",
"format": "{{msg.payload}}",
"layout": "row-left",
"x": 870,
"y": 760,
"wires": []
},
{
"id": "5f1d0542.c0b13c",
"type": "ui_slider",
"z": "48444261.4abf7c",
"name": "count",
"label": "count",
"group": "caa118e5.1ab9c8",
"order": 0,
"width": "10",
"height": "1",
"passthru": true,
"topic": "count",
"min": 0,
"max": "100",
"step": 1,
"x": 710,
"y": 800,
"wires": [
[
"88916334.25283",
"2178fb29.04c6c4"
]
]
},
{
"id": "2178fb29.04c6c4",
"type": "ui_text",
"z": "48444261.4abf7c",
"group": "caa118e5.1ab9c8",
"order": 0,
"width": "2",
"height": "1",
"name": "",
"label": "",
"format": "{{msg.payload}}",
"layout": "row-left",
"x": 870,
"y": 800,
"wires": []
},
{
"id": "c25af7f8.53a1c8",
"type": "ui_text",
"z": "48444261.4abf7c",
"group": "72e38159.21d28",
"order": 0,
"width": "4",
"height": "2",
"name": "",
"label": "jääk",
"format": "{{msg.payload}}",
"layout": "row-center",
"x": 1252,
"y": 514,
"wires": []
},
{
"id": "42c887d9.77e6a8",
"type": "delay",
"z": "48444261.4abf7c",
"name": "",
"pauseType": "rate",
"timeout": "5",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "2",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": true,
"x": 768,
"y": 515,
"wires": [
[
"23d7bebd.1bf262"
]
]
},
{
"id": "23d7bebd.1bf262",
"type": "function",
"z": "48444261.4abf7c",
"name": "",
"func": "var sliders = (flow.get('sliders') || {min:10,max:20,count:10});\nflow.set('sliders', sliders);\nmsg.payload = Math.min(Math.max(0, (msg.payload - sliders.min) / (sliders.max - sliders.min)) * sliders.count, sliders.count);\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 942,
"y": 515,
"wires": [
[
"a14ef384.a6062",
"a15b563e.4a2708"
]
]
},
{
"id": "a14ef384.a6062",
"type": "debug",
"z": "48444261.4abf7c",
"name": "",
"active": true,
"console": "false",
"complete": "false",
"x": 1136,
"y": 577,
"wires": []
},
{
"id": "a15b563e.4a2708",
"type": "smooth",
"z": "48444261.4abf7c",
"name": "",
"action": "mean",
"count": "3",
"round": "0",
"x": 1108,
"y": 517,
"wires": [
[
"c25af7f8.53a1c8",
"597632d0.4c2b5c"
]
]
},
{
"id": "597632d0.4c2b5c",
"type": "ui_gauge",
"z": "48444261.4abf7c",
"name": "õlu",
"group": "15e478ae.ddf6c7",
"order": 0,
"width": "12",
"height": "3",
"gtype": "wave",
"title": "õlu",
"label": "tk",
"format": "{{value}}",
"min": 0,
"max": "48",
"colors": [
"#00b500",
"#e6e600",
"#ca3838"
],
"x": 1256,
"y": 465,
"wires": []
},
{
"id": "72e38159.21d28",
"type": "ui_group",
"z": "",
"name": "Default",
"tab": "c85b393d.55df08",
"disp": true,
"width": "12"
},
{
"id": "15e478ae.ddf6c7",
"type": "ui_group",
"z": "",
"name": "Kokkuvõte",
"tab": "be45ba9a.a29d78",
"disp": false,
"width": "12"
},
{
"id": "5360a6e2.4cafb8",
"type": "ui_group",
"z": "",
"name": "Näidud",
"tab": "be45ba9a.a29d78",
"disp": false,
"width": "12"
},
{
"id": "387d0be.bde2ef4",
"type": "socketio-client",
"z": "",
"host": "http://localhost",
"path": "/socket.io",
"wholemsg": "false"
},
{
"id": "caa118e5.1ab9c8",
"type": "ui_group",
"z": "",
"name": "Konf",
"tab": "c85b393d.55df08",
"disp": true,
"width": "12"
},
{
"id": "c85b393d.55df08",
"type": "ui_tab",
"z": "",
"name": "Toores data",
"icon": "dashboard"
},
{
"id": "be45ba9a.a29d78",
"type": "ui_tab",
"z": "",
"name": "Saun",
"icon": "dashboard"
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment