Skip to content

Instantly share code, notes, and snippets.

@ktinkerer
Last active December 10, 2020 03:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ktinkerer/7e1d66da3b9e5e96857a9e413cb6120d to your computer and use it in GitHub Desktop.
Save ktinkerer/7e1d66da3b9e5e96857a9e413cb6120d to your computer and use it in GitHub Desktop.
[
{
"id":"64325772.978db8",
"type":"serial in",
"z":"18eb1548.cf005b",
"name":"",
"serial":"cd679ecd.7f72f",
"x":160,
"y":140,
"wires":[
[
"40fed6bb.631528"
]
]
},
{
"id":"40fed6bb.631528",
"type":"function",
"z":"18eb1548.cf005b",
"name":"",
"func":"var readings = {};\nvar values = msg.payload.split(\",\");\nfor (var i = 0; i < values.length; i++) {\n var items = values[i].split(\":\");\n //msg.payload = items[0];\n readings[items[0].trim()] = parseFloat(items[1]);\n}\nmsg.readings = readings;\n\nreturn msg;",
"outputs":1,
"noerr":0,
"x":163,
"y":286,
"wires":[
[
"e30c9765.7acdd8",
"e3d1a3ca.55791",
"d1643fd8.c77b1"
]
]
},
{
"id":"e30c9765.7acdd8",
"type":"mqtt out",
"z":"18eb1548.cf005b",
"name":"",
"topic":"kitchen/readings",
"qos":"",
"retain":"",
"broker":"e21e1f11.efd04",
"x":400,
"y":215,
"wires":[
]
},
{
"id":"a4c2dad.e108128",
"type":"mqtt out",
"z":"18eb1548.cf005b",
"name":"",
"topic":"kitchen/temperature",
"qos":"",
"retain":"true",
"broker":"e21e1f11.efd04",
"x":413,
"y":346,
"wires":[
]
},
{
"id":"4077afc7.5988a",
"type":"mqtt out",
"z":"18eb1548.cf005b",
"name":"",
"topic":"kitchen/humidity",
"qos":"",
"retain":"true",
"broker":"e21e1f11.efd04",
"x":386,
"y":441,
"wires":[
]
},
{
"id":"e3d1a3ca.55791",
"type":"function",
"z":"18eb1548.cf005b",
"name":"Temperature",
"func":"msg.payload = msg.readings.Temperature;\nreturn msg;",
"outputs":1,
"noerr":0,
"x":170,
"y":369,
"wires":[
[
"a4c2dad.e108128"
]
]
},
{
"id":"d1643fd8.c77b1",
"type":"function",
"z":"18eb1548.cf005b",
"name":"Humidity",
"func":"msg.payload = msg.readings.Humidity;\nreturn msg;",
"outputs":1,
"noerr":0,
"x":160,
"y":420,
"wires":[
[
"4077afc7.5988a"
]
]
},
{
"id":"cd679ecd.7f72f",
"type":"serial-port",
"z":"",
"serialport":"/dev/ttyUSB0",
"serialbaud":"9600",
"databits":"8",
"parity":"none",
"stopbits":"1",
"newline":"\\n",
"bin":"false",
"out":"char",
"addchar":false
},
{
"id":"e21e1f11.efd04",
"type":"mqtt-broker",
"z":"",
"broker":"mqttipaddress",
"port":"1883",
"clientid":"",
"usetls":false,
"compatmode":true,
"keepalive":"60",
"cleansession":true,
"willTopic":"",
"willQos":"0",
"willPayload":"",
"birthTopic":"",
"birthQos":"0",
"birthPayload":""
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment