Skip to content

Instantly share code, notes, and snippets.

@beckenc
Created May 2, 2017 19:17
Show Gist options
  • Save beckenc/108d9656ee4375fc95cfc0e9cd1eab0b to your computer and use it in GitHub Desktop.
Save beckenc/108d9656ee4375fc95cfc0e9cd1eab0b to your computer and use it in GitHub Desktop.
homie-dht volkszaehler bridge
[
{
"id": "58fc4856.5ea308",
"type": "tab",
"label": "homie-dht vz bridge"
},
{
"id": "4c9e86d7.9209f8",
"type": "mqtt in",
"z": "58fc4856.5ea308",
"name": "",
"topic": "HomieDHT/+/temperature/absolute",
"qos": "2",
"broker": "cd968864.aa7c5",
"x": 160,
"y": 40,
"wires": [
[
"6b76a55c.181204"
]
]
},
{
"id": "bf1de348.2106a",
"type": "http request",
"z": "58fc4856.5ea308",
"name": "volkszaehler push",
"method": "POST",
"ret": "obj",
"url": "http://sandboxpi:5582",
"tls": "",
"x": 630,
"y": 220,
"wires": [
[
"90bf7fa1.fcfcd"
]
]
},
{
"id": "90bf7fa1.fcfcd",
"type": "debug",
"z": "58fc4856.5ea308",
"name": "push response",
"active": false,
"console": "false",
"complete": "true",
"x": 820,
"y": 220,
"wires": []
},
{
"id": "cd2f2129.344348",
"type": "change",
"z": "58fc4856.5ea308",
"name": "set timestamp and headers properties",
"rules": [
{
"t": "set",
"p": "timestamp",
"pt": "msg",
"to": "",
"tot": "date"
},
{
"t": "set",
"p": "headers",
"pt": "msg",
"to": "{\"Content-Type\":\"application/json\",\"Accept\":\"application/json\"}",
"tot": "json"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 550,
"y": 140,
"wires": [
[
"5ed21b04.ede574",
"b7c29e63.d6dfb8"
]
]
},
{
"id": "1ce4ce9f.e31b31",
"type": "mqtt in",
"z": "58fc4856.5ea308",
"name": "",
"topic": "HomieDHT/+/humidity/relative",
"qos": "2",
"broker": "cd968864.aa7c5",
"x": 180,
"y": 120,
"wires": [
[
"6b76a55c.181204"
]
]
},
{
"id": "212d0cae.ded2f4",
"type": "debug",
"z": "58fc4856.5ea308",
"name": "device",
"active": false,
"console": "false",
"complete": "true",
"x": 730,
"y": 80,
"wires": []
},
{
"id": "5ed21b04.ede574",
"type": "template",
"z": "58fc4856.5ea308",
"name": "push data payload",
"field": "payload",
"fieldType": "msg",
"format": "json",
"syntax": "mustache",
"template": "{\"data\":[{\"uuid\":\"{{uuid}}\",\"tuples\":[[{{timestamp}}, {{payload}}]]}]}",
"x": 150,
"y": 220,
"wires": [
[
"71ae6bb4.9ef894"
]
]
},
{
"id": "71ae6bb4.9ef894",
"type": "json",
"z": "58fc4856.5ea308",
"name": "",
"x": 470,
"y": 220,
"wires": [
[
"bf1de348.2106a"
]
]
},
{
"id": "6b76a55c.181204",
"type": "function",
"z": "58fc4856.5ea308",
"name": "set uuid property",
"func": "msg2 = {}\nvar b = new Buffer(msg.topic);\nvar rxDevice = new RegExp('[^/#+]+', 'g');\nvar match = b.toString().match(rxDevice);\nvar property = match[2];\nvar device = match[1];\nvar uuid_temperature = {}\nvar uuid_humidity = {}\n\nmsg2.payload = msg.payload;\n\nswitch(device) {\n case \"5ccf7fc08f0c\":\n uuid_temperature = \"a0cb0640-285d-11e7-b746-3bf5f04ea601\";\n uuid_humidity = \"176c1e00-2869-11e7-b234-a90cb6c58f3c\";\n break;\n case \"5ccf7f2f5ffc\":\n uuid_temperature = \"ac041a20-29e3-11e7-8253-83fd9e099811\";\n uuid_humidity = \"5cd847b0-29e3-11e7-be58-997ccf6ad1f5\";\n break;\n case \"a020a621aef4\":\n uuid_temperature = \"ad57b400-285c-11e7-af88-bdef81eec0b2\";\n uuid_humidity = \"32a34c90-2869-11e7-8451-f557a5e399dd\";\n break;\n case \"60019410012e\":\n uuid_temperature = \"670f5fe0-285d-11e7-8291-2bfed8eeb9e1\";\n uuid_humidity = \"4996f1d0-2869-11e7-bfc9-01dcae611e27\";\n break;\n case \"a020a621c43a\":\n uuid_temperature = \"507076c0-2b7e-11e7-834f-63af3d27ebb3\";\n uuid_humidity = \"37e32120-2b7e-11e7-95fb-715d5e4d332b\";\n break;\n case \"5ccf7f2d01d2\":\n uuid_temperature = \"0f7e50d0-2b83-11e7-b665-e95662e27ebf\";\n uuid_humidity = \"1ef60df0-2b83-11e7-ae7c-47f6f18ba096\";\n break;\n case \"5ccf7f29c06a\":\n uuid_temperature = \"69f82600-2b83-11e7-9c34-47b2eb1d8030\";\n uuid_humidity = \"7a34d5c0-2b83-11e7-9112-ad14cb52a771\";\n break;\n case \"a020a611b44d\":\n uuid_temperature = \"837cb680-2b8c-11e7-a09a-4ddbe5fd2426\";\n uuid_humidity = \"8f529ec0-2b8c-11e7-a1ba-afef89ba0375\";\n break; \n case \"a020a621d0aa\":\n uuid_temperature = \"9c7fea10-2b8e-11e7-8516-df23b935a1f6\";\n uuid_humidity = \"b8534780-2b8e-11e7-83c9-69272ad24db0\";\n break; \n case \"600194165c71\":\n uuid_temperature = \"28ef5d80-2b90-11e7-9228-495dc7793881\";\n uuid_humidity = \"0ffc9910-2b90-11e7-9b8b-7dae2ded4c4d\";\n break;\n default:\n return null;\n}\n\nmsg2.uuid = (property == \"temperature\") ? uuid_temperature :uuid_humidity;\n\nreturn msg2;",
"outputs": 1,
"noerr": 0,
"x": 490,
"y": 80,
"wires": [
[
"cd2f2129.344348",
"212d0cae.ded2f4"
]
]
},
{
"id": "5678dccf.3096ac",
"type": "http request",
"z": "58fc4856.5ea308",
"name": "volkszaehler post",
"method": "POST",
"ret": "obj",
"url": "",
"tls": "",
"x": 630,
"y": 320,
"wires": [
[
"baa5c3eb.4df12"
]
]
},
{
"id": "b7c29e63.d6dfb8",
"type": "template",
"z": "58fc4856.5ea308",
"name": "post data url",
"field": "url",
"fieldType": "msg",
"format": "handlebars",
"syntax": "mustache",
"template": "http://sandboxpi/volkszaehler/middleware.php/data/{{uuid}}.json?ts={{timestamp}}&value={{payload}}",
"x": 130,
"y": 320,
"wires": [
[
"7958db9b.1c06fc"
]
]
},
{
"id": "13859d36.56bc83",
"type": "json",
"z": "58fc4856.5ea308",
"name": "",
"x": 470,
"y": 320,
"wires": [
[
"5678dccf.3096ac"
]
]
},
{
"id": "baa5c3eb.4df12",
"type": "debug",
"z": "58fc4856.5ea308",
"name": "post response",
"active": false,
"console": "false",
"complete": "true",
"x": 820,
"y": 320,
"wires": []
},
{
"id": "7958db9b.1c06fc",
"type": "change",
"z": "58fc4856.5ea308",
"name": "",
"rules": [
{
"t": "delete",
"p": "payload",
"pt": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 310,
"y": 320,
"wires": [
[
"13859d36.56bc83"
]
]
},
{
"id": "cd968864.aa7c5",
"type": "mqtt-broker",
"z": "",
"broker": "localhost",
"port": "1883",
"clientid": "vzbridge",
"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