-
-
Save alekslt/ac45e4b55401e341692849f303cdca91 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"id": "df626f78.5289a", | |
"type": "tab", | |
"label": "Flow 2", | |
"disabled": false, | |
"info": "" | |
}, | |
{ | |
"id": "5dc7c403.ddffcc", | |
"type": "mqtt in", | |
"z": "df626f78.5289a", | |
"name": "Obis Messages", | |
"topic": "kdg/sensors/powermeterhan/obis/#", | |
"qos": "2", | |
"broker": "8ca1b137.0297b", | |
"x": 120, | |
"y": 40, | |
"wires": [ | |
[ | |
"5d7c27fd.5067e8" | |
] | |
] | |
}, | |
{ | |
"id": "91903e4d.a9cd5", | |
"type": "debug", | |
"z": "df626f78.5289a", | |
"name": "", | |
"active": false, | |
"tosidebar": true, | |
"console": false, | |
"tostatus": false, | |
"complete": "true", | |
"x": 650, | |
"y": 80, | |
"wires": [] | |
}, | |
{ | |
"id": "5d7c27fd.5067e8", | |
"type": "function", | |
"z": "df626f78.5289a", | |
"name": "Combine Obis Objects and Convert datatypes", | |
"func": "var obisMap = {};\n\nobisMap[\"1.1.0.2.129.255\"] = { \"store_influx\": false, \"short_name\": \"listname\" }\nobisMap[\"0.0.96.1.0.255\"] = { \"store_influx\": false, \"short_name\": \"meter_id\" }\nobisMap[\"0.0.96.1.7.255\"] = { \"store_influx\": false, \"short_name\": \"meter_type\" }\nobisMap[\"1.0.1.7.0.255\"] = { \"store_influx\": true, \"short_name\": \"p_act_in\" }\nobisMap[\"1.0.2.7.0.255\"] = { \"store_influx\": true, \"short_name\": \"p_act_out\" }\nobisMap[\"1.0.3.7.0.255\"] = { \"store_influx\": true, \"short_name\": \"p_react_in\" }\nobisMap[\"1.0.4.7.0.255\"] = { \"store_influx\": true, \"short_name\": \"p_react_out\" }\nobisMap[\"1.0.31.7.0.255\"] = { \"store_influx\": true, \"short_name\": \"il1\" }\nobisMap[\"1.0.71.7.0.255\"] = { \"store_influx\": true, \"short_name\": \"il3\" }\nobisMap[\"1.0.32.7.0.255\"] = { \"store_influx\": true, \"short_name\": \"ul1\" }\nobisMap[\"1.0.52.7.0.255\"] = { \"store_influx\": true, \"short_name\": \"ul2\" }\nobisMap[\"1.0.72.7.0.255\"] = { \"store_influx\": true, \"short_name\": \"ul3\" }\nobisMap[\"0.0.1.0.0.255\"] = { \"store_influx\": false, \"short_name\": \"datetime\" }\nobisMap[\"1.0.1.8.0.255\"] = { \"store_influx\": true, \"short_name\": \"p_act_in_cum_h\" }\nobisMap[\"1.0.2.8.0.255\"] = { \"store_influx\": true, \"short_name\": \"p_act_out_cum_h\" }\nobisMap[\"1.0.3.8.0.255\"] = { \"store_influx\": true, \"short_name\": \"p_ract_in_cum_h\" }\nobisMap[\"1.0.4.8.0.255\"] = { \"store_influx\": true, \"short_name\": \"p_ract_out_cum_h\" }\n\nmsg.log = [];\n\nmsg.log.push(\"Entry storage\");\nvar obis_code = msg.topic.split(\"/\")[4];\nvar obis_data = flow.get(\"obis_data\");\nmsg.log.push(\"obis_data: \" + obis_data);\nif (obis_data === undefined) {\n obis_data = {};\n flow.set(\"obis_data\", obis_data);\n}\n\nvar obis = obis_data[obis_code];\nif (obis === undefined) {\n if (obisMap[obis_code] !== undefined) {\n obis = Object.assign({}, obisMap[obis_code])\n } else {\n obis = { \"store_influx\": false, \"short_name\": obis_code }\n }\n}\n\nvar part = msg.topic.split(\"/\")[5];\nmsg.log.push(\"part: \" + part);\nif (part === \"value\") {\n msg.log.push(\"unit: \" + obis.unit);\n if (obis.unit !== \"TYPE_STRING\" &&\n obis.unit !== \"TYPE_DATETIME\") {\n msg.log.push(\"not string or datetime\");\n obis[part] = Number(msg.payload);\n } else {\n obis[part] = msg.payload;\n }\n} else if (part === \"unit\") {\n obis[part] = msg.payload;\n} else if (part === \"updated\") {\n obis[part] = Number(msg.payload);\n} else {\n obis[part] = msg.payload;\n}\n\n\nobis_data[obis_code] = obis;\nflow.set(\"obis_data\", obis_data);\n\nmsg.log.push(\"Obis Code: \" + obis_code);\nmsg.obis_code = obis_code;\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 240, | |
"y": 120, | |
"wires": [ | |
[ | |
"91903e4d.a9cd5", | |
"36bb1cee.2e1dc4" | |
] | |
] | |
}, | |
{ | |
"id": "48b4bb73.4d1284", | |
"type": "function", | |
"z": "df626f78.5289a", | |
"name": "Assemble influxdb update payload", | |
"func": "\nvar current_timestamp = Number(msg.payload);\n\nvar values = {};\nvar obis_data = flow.get(\"obis_data\");\n\nObject.keys(obis_data).forEach(function (item) {\n if (obis_data[item].store_influx === true &&\n obis_data[item].updated === current_timestamp) {\n values[obis_data[item].short_name] = obis_data[item].value;\n }\n});\n\nvalues.time = new Date(current_timestamp).getTime();\nvar ret_msg = {};\nret_msg.topic = \"influx_update\";\nret_msg.payload = [\n values,\n {\n building: \"kdg6\"\n }\n ];\n\nreturn ret_msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 200, | |
"y": 300, | |
"wires": [ | |
[ | |
"8c8adffa.4945a", | |
"970d5a84.10d3e8" | |
] | |
] | |
}, | |
{ | |
"id": "36bb1cee.2e1dc4", | |
"type": "switch", | |
"z": "df626f78.5289a", | |
"name": "Check for a complete list update", | |
"property": "topic", | |
"propertyType": "msg", | |
"rules": [ | |
{ | |
"t": "eq", | |
"v": "kdg/sensors/powermeterhan/obis/list_updated", | |
"vt": "str" | |
} | |
], | |
"checkall": "true", | |
"repair": false, | |
"outputs": 1, | |
"x": 190, | |
"y": 200, | |
"wires": [ | |
[ | |
"48b4bb73.4d1284" | |
] | |
] | |
}, | |
{ | |
"id": "8c8adffa.4945a", | |
"type": "debug", | |
"z": "df626f78.5289a", | |
"name": "", | |
"active": true, | |
"tosidebar": true, | |
"console": false, | |
"tostatus": false, | |
"complete": "false", | |
"x": 550, | |
"y": 320, | |
"wires": [] | |
}, | |
{ | |
"id": "970d5a84.10d3e8", | |
"type": "influxdb out", | |
"z": "df626f78.5289a", | |
"influxdb": "e8469a01.5a1ae8", | |
"name": "InfluxDB PowermeterHAN", | |
"measurement": "powermeterhan", | |
"precision": "s", | |
"retentionPolicy": "", | |
"x": 270, | |
"y": 440, | |
"wires": [] | |
}, | |
{ | |
"id": "e18b10a4.cfd4e", | |
"type": "debug", | |
"z": "df626f78.5289a", | |
"name": "", | |
"active": true, | |
"tosidebar": true, | |
"console": false, | |
"tostatus": false, | |
"complete": "false", | |
"x": 520, | |
"y": 500, | |
"wires": [] | |
}, | |
{ | |
"id": "f1061f9a.4b716", | |
"type": "mqtt in", | |
"z": "df626f78.5289a", | |
"name": "Debug Messages", | |
"topic": "kdg/sensors/powermeterhan/debug", | |
"qos": "2", | |
"broker": "8ca1b137.0297b", | |
"x": 980, | |
"y": 60, | |
"wires": [ | |
[ | |
"3e274818.c12cb8" | |
] | |
] | |
}, | |
{ | |
"id": "3e274818.c12cb8", | |
"type": "switch", | |
"z": "df626f78.5289a", | |
"name": "Mistmatched checksum", | |
"property": "payload", | |
"propertyType": "msg", | |
"rules": [ | |
{ | |
"t": "cont", | |
"v": "checksum.", | |
"vt": "str" | |
} | |
], | |
"checkall": "true", | |
"repair": false, | |
"outputs": 1, | |
"x": 970, | |
"y": 200, | |
"wires": [ | |
[ | |
"92eac79e.79a3f8" | |
] | |
] | |
}, | |
{ | |
"id": "92eac79e.79a3f8", | |
"type": "function", | |
"z": "df626f78.5289a", | |
"name": "Assemble influxdb update payload", | |
"func": "var ret_msg = {};\nret_msg.topic = \"influx_update\";\nret_msg.payload = [\n {\n checksum_error: 1\n },\n {\n building: \"kdg6\"\n }\n ];\n\nreturn ret_msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 980, | |
"y": 300, | |
"wires": [ | |
[ | |
"90bfb276.009b9" | |
] | |
] | |
}, | |
{ | |
"id": "90bfb276.009b9", | |
"type": "influxdb out", | |
"z": "df626f78.5289a", | |
"influxdb": "e8469a01.5a1ae8", | |
"name": "InfluxDB PowermeterHAN", | |
"measurement": "powermeterhan", | |
"precision": "s", | |
"retentionPolicy": "", | |
"x": 990, | |
"y": 420, | |
"wires": [] | |
}, | |
{ | |
"id": "8ca1b137.0297b", | |
"type": "mqtt-broker", | |
"z": "", | |
"name": "", | |
"broker": "mqtt.local", | |
"port": "1883", | |
"clientid": "", | |
"usetls": false, | |
"compatmode": true, | |
"keepalive": "60", | |
"cleansession": true, | |
"birthTopic": "", | |
"birthQos": "0", | |
"birthPayload": "", | |
"closeTopic": "", | |
"closeQos": "0", | |
"closePayload": "", | |
"willTopic": "", | |
"willQos": "0", | |
"willPayload": "" | |
}, | |
{ | |
"id": "e8469a01.5a1ae8", | |
"type": "influxdb", | |
"z": "", | |
"hostname": "influx.local", | |
"port": "8086", | |
"protocol": "http", | |
"database": "sensors", | |
"name": "InfluxDB KDG", | |
"usetls": false, | |
"tls": "" | |
} | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment