Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [
- {
- "id": "124e80d5.d5d04f",
- "type": "function",
- "z": "bfb890c.05fc67",
- "name": "Check status",
- "func": "\nvar soc1=global.get('shuntsoc1') || 0;\nvar soc2=global.get('shuntsoc2') || 0;\nvar soc = (soc1*20 + soc2*80)/100;\n\nvar house=global.get('power3sum') || 0;\nvar garage=global.get('power4sum') || 0;\nvar total = house - garage; // Due to error in my meter... I have to retract\n\nvar s1=global.get('shuntwatt1') || 0;\nvar s2=global.get('shuntwatt2') || 0;\nvar sw = s1 + s2;\n\n\n\nmsg.soc = soc;\nmsg.house = house;\nmsg.garage = garage;\nmsg.total = total;\nmsg.battery = sw;\n\nif (soc > 96 && total > -1000 )\n{\n msg.payload = 1;\n} else if (soc < 94 || total < -2000 )\n{\n msg.payload = 0;\n} else return null;\n\nreturn msg;\n",
- "outputs": 1,
- "noerr": 0,
- "x": 390,
- "y": 280,
- "wires": [
- [
- "281e2e12.35e392",
- "9fa1a542.1ccc38"
- ]
- ]
- },
- {
- "id": "9fa1a542.1ccc38",
- "type": "mqtt out",
- "z": "bfb890c.05fc67",
- "name": "Power",
- "topic": "cmnd/heater1/POWER",
- "qos": "0",
- "retain": "false",
- "broker": "8605b863.295d48",
- "x": 610,
- "y": 280,
- "wires": []
- },
- {
- "id": "a3c307bf.9a5ca8",
- "type": "inject",
- "z": "bfb890c.05fc67",
- "name": "Every 5 seconds do",
- "topic": "",
- "payload": "",
- "payloadType": "date",
- "repeat": "5",
- "crontab": "",
- "once": true,
- "onceDelay": 0.1,
- "x": 140,
- "y": 280,
- "wires": [
- [
- "124e80d5.d5d04f"
- ]
- ]
- },
- {
- "id": "281e2e12.35e392",
- "type": "debug",
- "z": "bfb890c.05fc67",
- "name": "",
- "active": false,
- "tosidebar": true,
- "console": false,
- "tostatus": false,
- "complete": "true",
- "x": 610,
- "y": 220,
- "wires": []
- },
- {
- "id": "698fa5f2.a08e2c",
- "type": "mqtt in",
- "z": "bfb890c.05fc67",
- "name": "",
- "topic": "tele/+/SENSOR",
- "qos": "0",
- "broker": "8605b863.295d48",
- "x": 100,
- "y": 440,
- "wires": [
- [
- "18ae8321.070ccd"
- ]
- ]
- },
- {
- "id": "18ae8321.070ccd",
- "type": "json",
- "z": "bfb890c.05fc67",
- "name": "",
- "property": "payload",
- "action": "",
- "pretty": false,
- "x": 330,
- "y": 440,
- "wires": [
- [
- "fce35a91.1b9cb8"
- ]
- ]
- },
- {
- "id": "46ec5bc0.f2d304",
- "type": "influxdb out",
- "z": "bfb890c.05fc67",
- "influxdb": "e809e7f6.256c48",
- "name": "",
- "measurement": "sensors",
- "precision": "s",
- "retentionPolicy": "",
- "x": 910,
- "y": 500,
- "wires": []
- },
- {
- "id": "fce35a91.1b9cb8",
- "type": "function",
- "z": "bfb890c.05fc67",
- "name": "MQTT to InfluxDB",
- "func": "var tokens = msg.topic.split(\"/\");\nvar dest = tokens[1];\n\n\nif ('ENERGY' in msg.payload)\n{ \n value = parseFloat(msg.payload.ENERGY.Power)\n type = \"watt\";\n \n} else if ('DS18B20' in msg.payload)\n{\n value = parseFloat(msg.payload.DS18B20.Temperature)\n type = \"celcius\";\n} else\n{ return null;\n}\n\nmsg.payload = [{\n value:value\n},{ \n \n device: dest ,\n type: type\n}];\n\n\n\nreturn msg;",
- "outputs": 1,
- "noerr": 0,
- "x": 570,
- "y": 440,
- "wires": [
- [
- "a9d31a67.d03278",
- "46ec5bc0.f2d304"
- ]
- ]
- },
- {
- "id": "cd8a72ef.3cd29",
- "type": "function",
- "z": "bfb890c.05fc67",
- "name": "MQTT to InfluxDB",
- "func": "var tokens = msg.topic.split(\"/\");\nvar dest = tokens[1];\n\nif (msg.payload.POWER == \"ON\")\n{ val = 1;\n\n} else \n{ val = 0; }\n\n\nmsg.payload = [{\n value:parseFloat(val)\n \n},{ \n \n device: dest,\n type: \"bool\"\n}];\n\n\n\nreturn msg;",
- "outputs": 1,
- "noerr": 0,
- "x": 570,
- "y": 500,
- "wires": [
- [
- "46ec5bc0.f2d304"
- ]
- ]
- },
- {
- "id": "18e12e53.f75c22",
- "type": "mqtt in",
- "z": "bfb890c.05fc67",
- "name": "",
- "topic": "tele/+/STATE",
- "qos": "0",
- "broker": "8605b863.295d48",
- "x": 90,
- "y": 500,
- "wires": [
- [
- "d681e007.ff2a3"
- ]
- ]
- },
- {
- "id": "d681e007.ff2a3",
- "type": "json",
- "z": "bfb890c.05fc67",
- "name": "",
- "property": "payload",
- "action": "",
- "pretty": false,
- "x": 330,
- "y": 500,
- "wires": [
- [
- "cd8a72ef.3cd29"
- ]
- ]
- },
- {
- "id": "a9d31a67.d03278",
- "type": "debug",
- "z": "bfb890c.05fc67",
- "name": "",
- "active": false,
- "tosidebar": true,
- "console": false,
- "tostatus": false,
- "complete": "true",
- "x": 850,
- "y": 440,
- "wires": []
- },
- {
- "id": "8605b863.295d48",
- "type": "mqtt-broker",
- "z": "",
- "name": "localhost",
- "broker": "localhost",
- "port": "1883",
- "clientid": "",
- "usetls": false,
- "compatmode": true,
- "keepalive": "60",
- "cleansession": true,
- "birthTopic": "",
- "birthQos": "0",
- "birthPayload": "",
- "closeTopic": "",
- "closeQos": "0",
- "closePayload": "",
- "willTopic": "",
- "willQos": "0",
- "willPayload": ""
- },
- {
- "id": "e809e7f6.256c48",
- "type": "influxdb",
- "z": "",
- "hostname": "127.0.0.1",
- "port": "8086",
- "protocol": "http",
- "database": "temps",
- "name": "",
- "usetls": false,
- "tls": ""
- }
- ]
Advertisement
Add Comment
Please, Sign In to add comment