Skip to content

Instantly share code, notes, and snippets.

@simonszu
Created September 4, 2017 13:13
Show Gist options
  • Save simonszu/c6f5884557ef8ee87bd97ca3eae4da38 to your computer and use it in GitHub Desktop.
Save simonszu/c6f5884557ef8ee87bd97ca3eae4da38 to your computer and use it in GitHub Desktop.
Feinstaubsensor -> MQTT bridge in node-red
[
{
"id": "54ce3785.15e3a8",
"type": "tab",
"label": "Feinstaubsensor -> MQTT",
"disabled": false,
"info": "Feinstaubsensor postet auf eine HTTP API, die wiederum \nauf den MQTT Broker pusht"
},
{
"id": "f2e33c93.125fc",
"type": "http in",
"z": "54ce3785.15e3a8",
"name": "API Endpoint",
"url": "/feinstaub",
"method": "post",
"upload": false,
"swaggerDoc": "",
"x": 90,
"y": 40,
"wires": [
[
"1eb04616.1999aa",
"24f21ce1.263f84"
]
]
},
{
"id": "ef5425.e58c2bd8",
"type": "http response",
"z": "54ce3785.15e3a8",
"name": "Respond HTTP 200",
"statusCode": "200",
"headers": {},
"x": 610,
"y": 40,
"wires": []
},
{
"id": "1eb04616.1999aa",
"type": "template",
"z": "54ce3785.15e3a8",
"name": "Content for Response",
"field": "payload",
"fieldType": "msg",
"format": "handlebars",
"syntax": "mustache",
"template": "OK",
"output": "str",
"x": 340,
"y": 40,
"wires": [
[
"ef5425.e58c2bd8"
]
]
},
{
"id": "24f21ce1.263f84",
"type": "jsonpath",
"z": "54ce3785.15e3a8",
"expression": "$.sensordatavalues.*",
"split": false,
"name": "Extract sensordatavalues",
"x": 350,
"y": 100,
"wires": [
[
"d0a267a1.157588"
]
]
},
{
"id": "e416a8b5.7b3828",
"type": "function",
"z": "54ce3785.15e3a8",
"name": "Merge value_type and value",
"func": "payload = msg.payload;\ntype = payload.value_type;\nvalue = payload.value;\nreturn {topic: type, payload: value}\n",
"outputs": 1,
"noerr": 0,
"x": 940,
"y": 100,
"wires": [
[
"a8474572.c39458"
]
]
},
{
"id": "d0a267a1.157588",
"type": "splitter",
"z": "54ce3785.15e3a8",
"name": "Iterate over measurements",
"property": "payload",
"x": 640,
"y": 100,
"wires": [
[
"e416a8b5.7b3828"
]
]
},
{
"id": "a8474572.c39458",
"type": "template",
"z": "54ce3785.15e3a8",
"name": "Modify topic",
"field": "topic",
"fieldType": "msg",
"format": "handlebars",
"syntax": "mustache",
"template": "feinstaub/{{topic}}",
"output": "str",
"x": 1190,
"y": 100,
"wires": [
[
"df6fbd1d.bc7f2"
]
]
},
{
"id": "df6fbd1d.bc7f2",
"type": "mqtt out",
"z": "54ce3785.15e3a8",
"name": "Send to MQTT",
"topic": "",
"qos": "1",
"retain": "true",
"broker": "b6376b41.3b0508",
"x": 1400,
"y": 100,
"wires": []
},
{
"id": "b6376b41.3b0508",
"type": "mqtt-broker",
"z": "",
"broker": "localhost",
"port": "1883",
"clientid": "",
"usetls": false,
"compatmode": true,
"keepalive": "60",
"cleansession": true,
"willTopic": "node-red/status",
"willQos": "1",
"willRetain": "true",
"willPayload": "offline",
"birthTopic": "node-red/status",
"birthQos": "1",
"birthRetain": "true",
"birthPayload": "online"
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment