added calculation for phase combination, only count + and/or - like EM24 to correct VRM display

This commit is contained in:
Carsten Schmiemann 2022-08-30 03:00:34 +02:00
parent 6e9085066b
commit 6ad117b2b8

View file

@ -28,8 +28,8 @@
"topic": "", "topic": "",
"payload": "", "payload": "",
"payloadType": "date", "payloadType": "date",
"x": 120, "x": 200,
"y": 300, "y": 400,
"wires": [ "wires": [
[ [
"5c5702e7ebd71a77", "5c5702e7ebd71a77",
@ -59,8 +59,8 @@
"method": "get", "method": "get",
"upload": false, "upload": false,
"swaggerDoc": "", "swaggerDoc": "",
"x": 100, "x": 120,
"y": 760, "y": 880,
"wires": [ "wires": [
[ [
"c61fcb67b3a33b47" "c61fcb67b3a33b47"
@ -71,7 +71,7 @@
"id": "fbe8cca3419d8161", "id": "fbe8cca3419d8161",
"type": "change", "type": "change",
"z": "f96eea4d4a3a345d", "z": "f96eea4d4a3a345d",
"name": "Set Headers", "name": "set http header",
"rules": [ "rules": [
{ {
"t": "set", "t": "set",
@ -93,8 +93,8 @@
"from": "", "from": "",
"to": "", "to": "",
"reg": false, "reg": false,
"x": 840, "x": 1150,
"y": 760, "y": 880,
"wires": [ "wires": [
[ [
"83f39f5649b78b86" "83f39f5649b78b86"
@ -105,26 +105,26 @@
"id": "83f39f5649b78b86", "id": "83f39f5649b78b86",
"type": "http response", "type": "http response",
"z": "f96eea4d4a3a345d", "z": "f96eea4d4a3a345d",
"name": "", "name": "serve as http api",
"statusCode": "", "statusCode": "",
"headers": {}, "headers": {},
"x": 1080, "x": 1420,
"y": 760, "y": 880,
"wires": [] "wires": []
}, },
{ {
"id": "c61fcb67b3a33b47", "id": "c61fcb67b3a33b47",
"type": "function", "type": "function",
"z": "f96eea4d4a3a345d", "z": "f96eea4d4a3a345d",
"name": "Build Object", "name": "Create java objects",
"func": "var einspeisung_total_power = parseFloat(global.get(\"einspeisung_total_power\"))\n\nvar einspeisung_l1_voltage = parseFloat(global.get(\"einspeisung_l1_voltage\"))\nvar einspeisung_l2_voltage = parseFloat(global.get(\"einspeisung_l2_voltage\"))\nvar einspeisung_l3_voltage = parseFloat(global.get(\"einspeisung_l3_voltage\"))\n\nvar einspeisung_l1_current = parseFloat(global.get(\"einspeisung_l1_current\"))\nvar einspeisung_l2_current = parseFloat(global.get(\"einspeisung_l2_current\"))\nvar einspeisung_l3_current = parseFloat(global.get(\"einspeisung_l3_current\"))\nvar einspeisung_total_current = einspeisung_l1_current + einspeisung_l2_current + einspeisung_l3_current\n\nvar einspeisung_l1_power = parseFloat(global.get(\"einspeisung_l1_power\"))\nvar einspeisung_l2_power = parseFloat(global.get(\"einspeisung_l2_power\"))\nvar einspeisung_l3_power = parseFloat(global.get(\"einspeisung_l3_power\"))\n\nvar einspeisung_l1_import = parseFloat(global.get(\"einspeisung_l1_import\") - global.get(\"einspeisung_l1_export\"));\nvar einspeisung_l2_import = parseFloat(global.get(\"einspeisung_l2_import\") - global.get(\"einspeisung_l2_export\"));\nvar einspeisung_l3_import = parseFloat(global.get(\"einspeisung_l3_import\") - global.get(\"einspeisung_l3_export\"));\n\nvar einspeisung_total_kWh = einspeisung_l1_import + einspeisung_l2_import + einspeisung_l3_import;\n\nmsg.payload.einspeisung = {total_kwh: einspeisung_total_kWh, total_power:einspeisung_total_power, total_current:einspeisung_total_current, l1_voltage:einspeisung_l1_voltage, l2_voltage:einspeisung_l2_voltage, l3_voltage:einspeisung_l3_voltage, l1_current:einspeisung_l1_current, l2_current:einspeisung_l2_current, l3_current:einspeisung_l3_current, l1_power:einspeisung_l1_power, l2_power:einspeisung_l2_power, l3_power:einspeisung_l3_power, l1_import:einspeisung_l1_import, l2_import:einspeisung_l2_import, l3_import:einspeisung_l3_import};\n\nreturn msg;\n", "func": "var einspeisung_total_power = parseFloat(global.get(\"einspeisung_total_power\"))\n\nvar einspeisung_l1_voltage = parseFloat(global.get(\"einspeisung_l1_voltage\"))\nvar einspeisung_l2_voltage = parseFloat(global.get(\"einspeisung_l2_voltage\"))\nvar einspeisung_l3_voltage = parseFloat(global.get(\"einspeisung_l3_voltage\"))\n\nvar einspeisung_l1_current = parseFloat(global.get(\"einspeisung_l1_current\"))\nvar einspeisung_l2_current = parseFloat(global.get(\"einspeisung_l2_current\"))\nvar einspeisung_l3_current = parseFloat(global.get(\"einspeisung_l3_current\"))\n\nvar einspeisung_l1_power = parseFloat(global.get(\"einspeisung_l1_power\"))\nvar einspeisung_l2_power = parseFloat(global.get(\"einspeisung_l2_power\"))\nvar einspeisung_l3_power = parseFloat(global.get(\"einspeisung_l3_power\"))\n\nvar einspeisung_l1_import = parseFloat(global.get(\"einspeisung_l1_import\"))\nvar einspeisung_l2_import = parseFloat(global.get(\"einspeisung_l2_import\"))\nvar einspeisung_l3_import = parseFloat(global.get(\"einspeisung_l3_import\"))\n\nvar einspeisung_l1_export = parseFloat(global.get(\"einspeisung_l1_export\"))\nvar einspeisung_l2_export = parseFloat(global.get(\"einspeisung_l2_export\"))\nvar einspeisung_l3_export = parseFloat(global.get(\"einspeisung_l3_export\"))\n\n//Totals\nvar einspeisung_total_current = einspeisung_l1_current + einspeisung_l2_current + einspeisung_l3_current\nvar einspeisung_total_import = parseFloat(global.get(\"einspeisung_total_import\"))\nvar einspeisung_total_export = parseFloat(global.get(\"einspeisung_total_export\"))\n\nmsg.payload.einspeisung = {total_power:einspeisung_total_power, total_current:einspeisung_total_current, total_import:einspeisung_total_import, total_export:einspeisung_total_export, l1_voltage:einspeisung_l1_voltage, l2_voltage:einspeisung_l2_voltage, l3_voltage:einspeisung_l3_voltage, l1_current:einspeisung_l1_current, l2_current:einspeisung_l2_current, l3_current:einspeisung_l3_current, l1_power:einspeisung_l1_power, l2_power:einspeisung_l2_power, l3_power:einspeisung_l3_power, l1_import:einspeisung_l1_import, l2_import:einspeisung_l2_import, l3_import:einspeisung_l3_import, l1_export:einspeisung_l1_export, l2_export:einspeisung_l2_export, l3_export:einspeisung_l3_export};\n\nreturn msg;",
"outputs": 1, "outputs": 1,
"noerr": 0, "noerr": 0,
"initialize": "", "initialize": "",
"finalize": "", "finalize": "",
"libs": [], "libs": [],
"x": 460, "x": 510,
"y": 760, "y": 880,
"wires": [ "wires": [
[ [
"307db2619dcf6228" "307db2619dcf6228"
@ -135,12 +135,12 @@
"id": "307db2619dcf6228", "id": "307db2619dcf6228",
"type": "json", "type": "json",
"z": "f96eea4d4a3a345d", "z": "f96eea4d4a3a345d",
"name": "", "name": "build json object",
"property": "payload", "property": "payload",
"action": "", "action": "",
"pretty": false, "pretty": false,
"x": 660, "x": 910,
"y": 760, "y": 880,
"wires": [ "wires": [
[ [
"fbe8cca3419d8161" "fbe8cca3419d8161"
@ -161,8 +161,8 @@
"proxy": "", "proxy": "",
"authType": "", "authType": "",
"senderr": false, "senderr": false,
"x": 320, "x": 560,
"y": 100, "y": 140,
"wires": [ "wires": [
[ [
"f5853a536891d509" "f5853a536891d509"
@ -180,8 +180,8 @@
"initialize": "", "initialize": "",
"finalize": "", "finalize": "",
"libs": [], "libs": [],
"x": 700, "x": 940,
"y": 100, "y": 140,
"wires": [ "wires": [
[] []
] ]
@ -200,8 +200,8 @@
"proxy": "", "proxy": "",
"authType": "", "authType": "",
"senderr": false, "senderr": false,
"x": 320, "x": 560,
"y": 140, "y": 180,
"wires": [ "wires": [
[ [
"a3b33ef1225b85e7" "a3b33ef1225b85e7"
@ -219,8 +219,8 @@
"initialize": "", "initialize": "",
"finalize": "", "finalize": "",
"libs": [], "libs": [],
"x": 700, "x": 940,
"y": 140, "y": 180,
"wires": [ "wires": [
[] []
] ]
@ -239,8 +239,8 @@
"proxy": "", "proxy": "",
"authType": "", "authType": "",
"senderr": false, "senderr": false,
"x": 320, "x": 560,
"y": 180, "y": 220,
"wires": [ "wires": [
[ [
"b284d02cb539994f" "b284d02cb539994f"
@ -258,8 +258,8 @@
"initialize": "", "initialize": "",
"finalize": "", "finalize": "",
"libs": [], "libs": [],
"x": 700, "x": 940,
"y": 180, "y": 220,
"wires": [ "wires": [
[] []
] ]
@ -278,8 +278,8 @@
"proxy": "", "proxy": "",
"authType": "", "authType": "",
"senderr": false, "senderr": false,
"x": 320, "x": 560,
"y": 220, "y": 260,
"wires": [ "wires": [
[ [
"1da7740caa290264" "1da7740caa290264"
@ -297,8 +297,8 @@
"initialize": "", "initialize": "",
"finalize": "", "finalize": "",
"libs": [], "libs": [],
"x": 700, "x": 940,
"y": 220, "y": 260,
"wires": [ "wires": [
[] []
] ]
@ -317,8 +317,8 @@
"proxy": "", "proxy": "",
"authType": "", "authType": "",
"senderr": false, "senderr": false,
"x": 320, "x": 560,
"y": 260, "y": 300,
"wires": [ "wires": [
[ [
"6c9ebd253a3c3b0d" "6c9ebd253a3c3b0d"
@ -336,8 +336,8 @@
"initialize": "", "initialize": "",
"finalize": "", "finalize": "",
"libs": [], "libs": [],
"x": 700, "x": 940,
"y": 260, "y": 300,
"wires": [ "wires": [
[] []
] ]
@ -356,8 +356,8 @@
"proxy": "", "proxy": "",
"authType": "", "authType": "",
"senderr": false, "senderr": false,
"x": 320, "x": 560,
"y": 300, "y": 340,
"wires": [ "wires": [
[ [
"d848102461062b3f" "d848102461062b3f"
@ -375,8 +375,8 @@
"initialize": "", "initialize": "",
"finalize": "", "finalize": "",
"libs": [], "libs": [],
"x": 700, "x": 940,
"y": 300, "y": 340,
"wires": [ "wires": [
[] []
] ]
@ -395,8 +395,8 @@
"proxy": "", "proxy": "",
"authType": "", "authType": "",
"senderr": false, "senderr": false,
"x": 310, "x": 550,
"y": 340, "y": 380,
"wires": [ "wires": [
[ [
"3e88cef8b8b508ac" "3e88cef8b8b508ac"
@ -414,8 +414,8 @@
"initialize": "", "initialize": "",
"finalize": "", "finalize": "",
"libs": [], "libs": [],
"x": 700, "x": 940,
"y": 340, "y": 380,
"wires": [ "wires": [
[] []
] ]
@ -434,8 +434,8 @@
"proxy": "", "proxy": "",
"authType": "", "authType": "",
"senderr": false, "senderr": false,
"x": 310, "x": 550,
"y": 380, "y": 420,
"wires": [ "wires": [
[ [
"466e66a05eddb62f" "466e66a05eddb62f"
@ -453,8 +453,8 @@
"initialize": "", "initialize": "",
"finalize": "", "finalize": "",
"libs": [], "libs": [],
"x": 700, "x": 940,
"y": 380, "y": 420,
"wires": [ "wires": [
[] []
] ]
@ -473,8 +473,8 @@
"proxy": "", "proxy": "",
"authType": "", "authType": "",
"senderr": false, "senderr": false,
"x": 310, "x": 550,
"y": 420, "y": 460,
"wires": [ "wires": [
[ [
"a0e6a154bfb85c09" "a0e6a154bfb85c09"
@ -492,8 +492,8 @@
"initialize": "", "initialize": "",
"finalize": "", "finalize": "",
"libs": [], "libs": [],
"x": 700, "x": 940,
"y": 420, "y": 460,
"wires": [ "wires": [
[] []
] ]
@ -512,7 +512,7 @@
"proxy": "", "proxy": "",
"authType": "", "authType": "",
"senderr": false, "senderr": false,
"x": 330, "x": 560,
"y": 40, "y": 40,
"wires": [ "wires": [
[ [
@ -531,7 +531,7 @@
"initialize": "", "initialize": "",
"finalize": "", "finalize": "",
"libs": [], "libs": [],
"x": 710, "x": 940,
"y": 40, "y": 40,
"wires": [ "wires": [
[] []
@ -551,8 +551,8 @@
"proxy": "", "proxy": "",
"authType": "", "authType": "",
"senderr": false, "senderr": false,
"x": 310, "x": 550,
"y": 460, "y": 500,
"wires": [ "wires": [
[ [
"22bdca2522a4b3c9" "22bdca2522a4b3c9"
@ -570,8 +570,8 @@
"initialize": "", "initialize": "",
"finalize": "", "finalize": "",
"libs": [], "libs": [],
"x": 700, "x": 940,
"y": 460, "y": 500,
"wires": [ "wires": [
[] []
] ]
@ -590,8 +590,8 @@
"proxy": "", "proxy": "",
"authType": "", "authType": "",
"senderr": false, "senderr": false,
"x": 310, "x": 550,
"y": 500, "y": 540,
"wires": [ "wires": [
[ [
"51dc86ef4b4e31fd" "51dc86ef4b4e31fd"
@ -609,8 +609,8 @@
"initialize": "", "initialize": "",
"finalize": "", "finalize": "",
"libs": [], "libs": [],
"x": 700, "x": 940,
"y": 500, "y": 540,
"wires": [ "wires": [
[] []
] ]
@ -629,8 +629,8 @@
"proxy": "", "proxy": "",
"authType": "", "authType": "",
"senderr": false, "senderr": false,
"x": 310, "x": 550,
"y": 540, "y": 580,
"wires": [ "wires": [
[ [
"804899fa9686be16" "804899fa9686be16"
@ -648,8 +648,125 @@
"initialize": "", "initialize": "",
"finalize": "", "finalize": "",
"libs": [], "libs": [],
"x": 700, "x": 940,
"y": 540, "y": 580,
"wires": [
[]
]
},
{
"id": "a5f8ee01c537330b",
"type": "http request",
"z": "f96eea4d4a3a345d",
"name": "Export L1",
"method": "GET",
"ret": "txt",
"paytoqs": "ignore",
"url": "http://10.1.0.5/cgi-bin/readVal.exe?PDP,%20R150,d",
"tls": "",
"persist": false,
"proxy": "",
"authType": "",
"senderr": false,
"x": 550,
"y": 620,
"wires": [
[
"ba0021b15f94fc41"
]
]
},
{
"id": "ba0021b15f94fc41",
"type": "function",
"z": "f96eea4d4a3a345d",
"name": "format and save to global var",
"func": "temp = parseFloat(msg.payload * 0.001).toFixed(2);\nglobal.set(\"einspeisung_l1_export\", temp)\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 940,
"y": 620,
"wires": [
[]
]
},
{
"id": "1e1823db7c7b4edd",
"type": "http request",
"z": "f96eea4d4a3a345d",
"name": "Export L2",
"method": "GET",
"ret": "txt",
"paytoqs": "ignore",
"url": "http://10.1.0.5/cgi-bin/readVal.exe?PDP,%20R151,d",
"tls": "",
"persist": false,
"proxy": "",
"authType": "",
"senderr": false,
"x": 550,
"y": 660,
"wires": [
[
"68157d83b4f176f5"
]
]
},
{
"id": "68157d83b4f176f5",
"type": "function",
"z": "f96eea4d4a3a345d",
"name": "format and save to global var",
"func": "temp = parseFloat(msg.payload * 0.001).toFixed(2);\nglobal.set(\"einspeisung_l2_export\", temp)\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 940,
"y": 660,
"wires": [
[]
]
},
{
"id": "7857cce5b19d21ea",
"type": "http request",
"z": "f96eea4d4a3a345d",
"name": "Export L3",
"method": "GET",
"ret": "txt",
"paytoqs": "ignore",
"url": "http://10.1.0.5/cgi-bin/readVal.exe?PDP,%20R152,d",
"tls": "",
"persist": false,
"proxy": "",
"authType": "",
"senderr": false,
"x": 550,
"y": 700,
"wires": [
[
"4d12b6c71b023fc8"
]
]
},
{
"id": "4d12b6c71b023fc8",
"type": "function",
"z": "f96eea4d4a3a345d",
"name": "format and save to global var",
"func": "temp = parseFloat(msg.payload * 0.001).toFixed(2);\nglobal.set(\"einspeisung_l3_export\", temp)\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 940,
"y": 700,
"wires": [ "wires": [
[] []
] ]
@ -675,7 +792,7 @@
"topic": "", "topic": "",
"payload": "", "payload": "",
"payloadType": "date", "payloadType": "date",
"x": 120, "x": 190,
"y": 40, "y": 40,
"wires": [ "wires": [
[ [
@ -684,120 +801,67 @@
] ]
}, },
{ {
"id": "a5f8ee01c537330b", "id": "18e719ada7da042a",
"type": "http request", "type": "inject",
"z": "f96eea4d4a3a345d", "z": "f96eea4d4a3a345d",
"name": "Export L1", "name": "Calc every minute",
"method": "GET", "props": [
"ret": "txt", {
"paytoqs": "ignore", "p": "payload"
"url": "http://10.1.0.5/cgi-bin/readVal.exe?PDP,%20R150,d", },
"tls": "", {
"persist": false, "p": "topic",
"proxy": "", "vt": "str"
"authType": "", }
"senderr": false, ],
"x": 310, "repeat": "60",
"y": 580, "crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 190,
"y": 760,
"wires": [ "wires": [
[ [
"ba0021b15f94fc41" "983943d318a0ef33"
] ]
] ]
}, },
{ {
"id": "ba0021b15f94fc41", "id": "983943d318a0ef33",
"type": "function", "type": "function",
"z": "f96eea4d4a3a345d", "z": "f96eea4d4a3a345d",
"name": "format and save to global var", "name": "Phase sum of import and export like EM24",
"func": "temp = parseFloat(msg.payload * 0.001).toFixed(1);\nglobal.set(\"einspeisung_l1_export\", temp)\nreturn msg;", "func": "//init counters if not defined\nif (global.get(\"einspeisung_total_import\") === undefined) {\n global.set(\"einspeisung_total_import\", 0);\n}\nif (global.get(\"einspeisung_total_export\") === undefined) {\n global.set(\"einspeisung_total_export\", 0);\n}\n//get counters from global variable\nvar total_import = parseFloat(global.get(\"einspeisung_total_import\"));\nvar total_export = parseFloat(global.get(\"einspeisung_total_export\"));\nvar phase_combined_last = parseFloat(global.get(\"einspeisung_total_phase_combined_last\"));\nvar check = \"Nothing\";\n\n//get measurements\nvar einspeisung_l1_import = parseFloat(global.get(\"einspeisung_l1_import\"));\nvar einspeisung_l2_import = parseFloat(global.get(\"einspeisung_l2_import\"));\nvar einspeisung_l3_import = parseFloat(global.get(\"einspeisung_l3_import\"));\n\nvar einspeisung_l1_export = parseFloat(global.get(\"einspeisung_l1_export\"));\nvar einspeisung_l2_export = parseFloat(global.get(\"einspeisung_l2_export\"));\nvar einspeisung_l3_export = parseFloat(global.get(\"einspeisung_l3_export\"));\n\n//get measurement of import and export\nvar phase_combined = (einspeisung_l1_import - einspeisung_l1_export) + (einspeisung_l2_import - einspeisung_l2_export) + (einspeisung_l3_import - einspeisung_l3_export);\n\nif (phase_combined < phase_combined_last) {\n total_export += Math.abs(phase_combined - phase_combined_last);\n check = \"Export: \" + Math.abs(phase_combined - phase_combined_last) + \" kWh\";\n}\nif (phase_combined > phase_combined_last) {\n total_import += Math.abs(phase_combined - phase_combined_last);\n check = \"Import: \" + Math.abs(phase_combined - phase_combined_last) + \" kWh\";\n}\n\nglobal.set(\"einspeisung_total_phase_combined_last\", phase_combined);\nglobal.set(\"einspeisung_total_import\", parseFloat(total_import).toFixed(2));\nglobal.set(\"einspeisung_total_export\", parseFloat(total_export).toFixed(2));\nmsg.payload = {total_import: total_import, total_export: total_export, phase_combined: phase_combined, phase_combined_last: phase_combined_last, check: check}\nreturn msg;",
"outputs": 1, "outputs": 1,
"noerr": 0, "noerr": 0,
"initialize": "", "initialize": "",
"finalize": "", "finalize": "",
"libs": [], "libs": [],
"x": 700, "x": 960,
"y": 580, "y": 760,
"wires": [
[]
]
},
{
"id": "1e1823db7c7b4edd",
"type": "http request",
"z": "f96eea4d4a3a345d",
"name": "Export L2",
"method": "GET",
"ret": "txt",
"paytoqs": "ignore",
"url": "http://10.1.0.5/cgi-bin/readVal.exe?PDP,%20R151,d",
"tls": "",
"persist": false,
"proxy": "",
"authType": "",
"senderr": false,
"x": 310,
"y": 620,
"wires": [ "wires": [
[ [
"68157d83b4f176f5" "9b291dc80aff0a1a"
] ]
] ]
}, },
{ {
"id": "68157d83b4f176f5", "id": "9b291dc80aff0a1a",
"type": "function", "type": "debug",
"z": "f96eea4d4a3a345d", "z": "f96eea4d4a3a345d",
"name": "format and save to global var", "name": "",
"func": "temp = parseFloat(msg.payload * 0.001).toFixed(1);\nglobal.set(\"einspeisung_l2_export\", temp)\nreturn msg;", "active": true,
"outputs": 1, "tosidebar": true,
"noerr": 0, "console": false,
"initialize": "", "tostatus": false,
"finalize": "", "complete": "false",
"libs": [], "statusVal": "",
"x": 700, "statusType": "auto",
"y": 620, "x": 1460,
"wires": [ "y": 760,
[] "wires": []
]
},
{
"id": "7857cce5b19d21ea",
"type": "http request",
"z": "f96eea4d4a3a345d",
"name": "Export L3",
"method": "GET",
"ret": "txt",
"paytoqs": "ignore",
"url": "http://10.1.0.5/cgi-bin/readVal.exe?PDP,%20R152,d",
"tls": "",
"persist": false,
"proxy": "",
"authType": "",
"senderr": false,
"x": 310,
"y": 660,
"wires": [
[
"4d12b6c71b023fc8"
]
]
},
{
"id": "4d12b6c71b023fc8",
"type": "function",
"z": "f96eea4d4a3a345d",
"name": "format and save to global var",
"func": "temp = parseFloat(msg.payload * 0.001).toFixed(1);\nglobal.set(\"einspeisung_l3_export\", temp)\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 700,
"y": 660,
"wires": [
[]
]
} }
] ]