Skip to content

Instantly share code, notes, and snippets.

@DurandA
Created November 21, 2019 13:25
Show Gist options
  • Save DurandA/7f90edc3c640e6f53a2083b134a9bf7c to your computer and use it in GitHub Desktop.
Save DurandA/7f90edc3c640e6f53a2083b134a9bf7c to your computer and use it in GitHub Desktop.
Node-RED Thingy:52 subflow
[
{
"id": "aa418b47.80ad28",
"type": "subflow",
"name": "thingy subflow",
"info": "",
"category": "thingy",
"in": [
{
"x": 400,
"y": 540,
"wires": [
{
"id": "ff6f3b72.a1db08"
}
]
}
],
"out": [
{
"x": 960,
"y": 160,
"wires": [
{
"id": "ebabb3c2.d24a",
"port": 0
}
]
},
{
"x": 960,
"y": 220,
"wires": [
{
"id": "15bd5857.9db478",
"port": 0
}
]
},
{
"x": 960,
"y": 280,
"wires": [
{
"id": "6d3ee781.44db08",
"port": 0
}
]
},
{
"x": 960,
"y": 340,
"wires": [
{
"id": "9b99c736.3afb48",
"port": 0
}
]
},
{
"x": 960,
"y": 400,
"wires": [
{
"id": "7910be48.fec8c",
"port": 0
}
]
},
{
"x": 960,
"y": 460,
"wires": [
{
"id": "3b407da9.3a5342",
"port": 0
}
]
}
],
"env": [
{
"name": "device_uri",
"type": "str",
"value": "d3:5a:51:c0:de:9c"
}
],
"color": "#DDAA99",
"inputLabels": [
"led"
],
"outputLabels": [
"temperature",
"pressure",
"humidity",
"gas",
"color",
"button"
],
"icon": "node-red/bluetooth.png"
},
{
"id": "3423493.720fcb6",
"type": "mqtt in",
"z": "aa418b47.80ad28",
"name": "webbluetooth-gateway",
"topic": "d3:5a:51:c0:de:9c/+/+",
"qos": "2",
"datatype": "utf8",
"broker": "d4198199.11ac2",
"x": 160,
"y": 300,
"wires": [
[
"f142def9.4d5d2"
]
]
},
{
"id": "9b99c736.3afb48",
"type": "function",
"z": "aa418b47.80ad28",
"name": "gas",
"func": "let data = msg.payload;\nmsg.payload = {\n eco2: data.col1,\n tvoc: data.col2\n}\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 810,
"y": 340,
"wires": [
[]
]
},
{
"id": "a54bb81c.c2fea8",
"type": "switch",
"z": "aa418b47.80ad28",
"name": "",
"property": "topic",
"propertyType": "msg",
"rules": [
{
"t": "regex",
"v": ".+\\/Thingy Environment Service\\/Thingy Temperature Characteristic",
"vt": "str",
"case": false
},
{
"t": "regex",
"v": ".+\\/Thingy Environment Service\\/Thingy Pressure Characteristic",
"vt": "str",
"case": false
},
{
"t": "regex",
"v": ".+\\/Thingy Environment Service\\/Thingy Humidity Characteristic",
"vt": "str",
"case": false
},
{
"t": "regex",
"v": ".+\\/Thingy Environment Service\\/Thingy Air Quality Characteristic",
"vt": "str",
"case": false
},
{
"t": "regex",
"v": ".+\\/Thingy Environment Service\\/Thingy Light Intensity Characteristic",
"vt": "str",
"case": false
},
{
"t": "regex",
"v": ".+\\/Thingy User Interface Service\\/Thingy Button Characteristic",
"vt": "str",
"case": false
}
],
"checkall": "true",
"repair": false,
"outputs": 6,
"x": 570,
"y": 300,
"wires": [
[
"ebabb3c2.d24a"
],
[
"15bd5857.9db478"
],
[
"6d3ee781.44db08"
],
[
"9b99c736.3afb48"
],
[
"7910be48.fec8c"
],
[
"3b407da9.3a5342"
]
],
"outputLabels": [
"temperature",
"pressure",
"humidity",
"gas",
"color",
"button"
]
},
{
"id": "ebabb3c2.d24a",
"type": "function",
"z": "aa418b47.80ad28",
"name": "temperature",
"func": "let data = msg.payload;\nlet integer = data.col1;\nlet decimal = data.col2;\nmsg.payload = {\n temperature: integer + (decimal/100)\n}\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 830,
"y": 160,
"wires": [
[]
]
},
{
"id": "15bd5857.9db478",
"type": "function",
"z": "aa418b47.80ad28",
"name": "pressure",
"func": "let data = msg.payload;\nlet integer = data.col1;\nlet decimal = data.col2;\nmsg.payload = {\n pressure: integer + (decimal/100)\n}\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 820,
"y": 220,
"wires": [
[]
]
},
{
"id": "6d3ee781.44db08",
"type": "function",
"z": "aa418b47.80ad28",
"name": "humidity",
"func": "let data = msg.payload;\nmsg.payload = {\n humidity: data.col1\n}\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 820,
"y": 280,
"wires": [
[]
]
},
{
"id": "7910be48.fec8c",
"type": "function",
"z": "aa418b47.80ad28",
"name": "color",
"func": "let data = msg.payload;\nmsg.payload = {\n red: data.col1,\n green: data.col2,\n blue: data.col3,\n clear: data.col4\n}\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 810,
"y": 400,
"wires": [
[]
]
},
{
"id": "3b407da9.3a5342",
"type": "function",
"z": "aa418b47.80ad28",
"name": "button",
"func": "let pressed = false;\nif (msg.payload.col1===\"true\")\n pressed=true;\nmsg.payload = {\n pressed: pressed\n}\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 810,
"y": 460,
"wires": [
[]
]
},
{
"id": "ea0f9595.9deb38",
"type": "mqtt out",
"z": "aa418b47.80ad28",
"name": "webbluetooth-gateway",
"topic": "d3:5a:51:c0:de:9c/Thingy User Interface Service/Thingy LED Characteristic/Set",
"qos": "",
"retain": "",
"broker": "d4198199.11ac2",
"x": 860,
"y": 540,
"wires": []
},
{
"id": "f142def9.4d5d2",
"type": "csv",
"z": "aa418b47.80ad28",
"name": "",
"sep": ",",
"hdrin": "",
"hdrout": "",
"multi": "one",
"ret": "\\n",
"temp": "",
"skip": "0",
"strings": true,
"x": 390,
"y": 300,
"wires": [
[
"a54bb81c.c2fea8"
]
]
},
{
"id": "ff6f3b72.a1db08",
"type": "csv",
"z": "aa418b47.80ad28",
"name": "",
"sep": ",",
"hdrin": "",
"hdrout": "",
"multi": "one",
"ret": "\\n",
"temp": "",
"skip": "0",
"strings": true,
"x": 570,
"y": 540,
"wires": [
[
"ea0f9595.9deb38"
]
]
},
{
"id": "d4198199.11ac2",
"type": "mqtt-broker",
"z": "",
"broker": "mqtt.thing.zone",
"port": "1883",
"clientid": "",
"usetls": false,
"compatmode": false,
"keepalive": "60",
"cleansession": true,
"birthTopic": "",
"birthQos": "0",
"birthPayload": "",
"willTopic": "",
"willQos": "0",
"willPayload": ""
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment