Create all meters from power, and reset to zero, because VRM gets confused

This commit is contained in:
Carsten Schmiemann 2022-08-30 12:00:53 +02:00
parent 6ad117b2b8
commit a39ed57c7e
1 changed files with 160 additions and 176 deletions

View File

@ -28,7 +28,7 @@
"topic": "",
"payload": "",
"payloadType": "date",
"x": 200,
"x": 180,
"y": 400,
"wires": [
[
@ -40,13 +40,7 @@
"972360a051abdf88",
"21e06b0168fdee41",
"e107fc40d203f46a",
"7586c0c0ec778dad",
"ef783dcc259e1398",
"f748fa2266fa4302",
"ece76e52d325bd6e",
"a5f8ee01c537330b",
"1e1823db7c7b4edd",
"7857cce5b19d21ea"
"7586c0c0ec778dad"
]
]
},
@ -408,7 +402,7 @@
"type": "function",
"z": "f96eea4d4a3a345d",
"name": "format and save to global var",
"func": "temp = parseFloat(msg.payload * 0.1).toFixed(1);\nglobal.set(\"einspeisung_l1_power\", temp)\nreturn msg;",
"func": "temp = parseFloat(msg.payload * 0.1).toFixed(1);\nglobal.set(\"einspeisung_l1_power\", temp);\nmsg.payload = parseFloat(temp);\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
@ -417,7 +411,9 @@
"x": 940,
"y": 380,
"wires": [
[]
[
"1cdb84780936c696"
]
]
},
{
@ -447,7 +443,7 @@
"type": "function",
"z": "f96eea4d4a3a345d",
"name": "format and save to global var",
"func": "temp = parseFloat(msg.payload * 0.1).toFixed(1);\nglobal.set(\"einspeisung_l2_power\", temp)\nreturn msg;",
"func": "temp = parseFloat(msg.payload * 0.1).toFixed(1);\nglobal.set(\"einspeisung_l2_power\", temp);\nmsg.payload = parseFloat(temp);\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
@ -456,7 +452,9 @@
"x": 940,
"y": 420,
"wires": [
[]
[
"074a7fdb9ba59d27"
]
]
},
{
@ -486,7 +484,7 @@
"type": "function",
"z": "f96eea4d4a3a345d",
"name": "format and save to global var",
"func": "temp = parseFloat(msg.payload * 0.1).toFixed(1);\nglobal.set(\"einspeisung_l3_power\", temp)\nreturn msg;",
"func": "temp = parseFloat(msg.payload * 0.1).toFixed(1);\nglobal.set(\"einspeisung_l3_power\", temp);\nmsg.payload = parseFloat(temp);\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
@ -495,7 +493,9 @@
"x": 940,
"y": 460,
"wires": [
[]
[
"6ff639af913d0a4d"
]
]
},
{
@ -525,7 +525,7 @@
"type": "function",
"z": "f96eea4d4a3a345d",
"name": "format and save to global var",
"func": "temp = parseFloat(msg.payload * 0.1).toFixed(1);\nglobal.set(\"einspeisung_total_power\", temp)\nreturn msg;",
"func": "temp = parseFloat(msg.payload * 0.1).toFixed(1);\nglobal.set(\"einspeisung_total_power\", temp);\nmsg.payload = parseFloat(temp);\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
@ -533,29 +533,9 @@
"libs": [],
"x": 940,
"y": 40,
"wires": [
[]
]
},
{
"id": "ef783dcc259e1398",
"type": "http request",
"z": "f96eea4d4a3a345d",
"name": "Import L1",
"method": "GET",
"ret": "txt",
"paytoqs": "ignore",
"url": "http://10.1.0.5/cgi-bin/readVal.exe?PDP,%20R117,d",
"tls": "",
"persist": false,
"proxy": "",
"authType": "",
"senderr": false,
"x": 550,
"y": 500,
"wires": [
[
"22bdca2522a4b3c9"
"1504cb346fc652fd"
]
]
},
@ -576,28 +556,6 @@
[]
]
},
{
"id": "f748fa2266fa4302",
"type": "http request",
"z": "f96eea4d4a3a345d",
"name": "Import L2",
"method": "GET",
"ret": "txt",
"paytoqs": "ignore",
"url": "http://10.1.0.5/cgi-bin/readVal.exe?PDP,%20R118,d",
"tls": "",
"persist": false,
"proxy": "",
"authType": "",
"senderr": false,
"x": 550,
"y": 540,
"wires": [
[
"51dc86ef4b4e31fd"
]
]
},
{
"id": "51dc86ef4b4e31fd",
"type": "function",
@ -615,28 +573,6 @@
[]
]
},
{
"id": "ece76e52d325bd6e",
"type": "http request",
"z": "f96eea4d4a3a345d",
"name": "Import L3",
"method": "GET",
"ret": "txt",
"paytoqs": "ignore",
"url": "http://10.1.0.5/cgi-bin/readVal.exe?PDP,%20R119,d",
"tls": "",
"persist": false,
"proxy": "",
"authType": "",
"senderr": false,
"x": 550,
"y": 580,
"wires": [
[
"804899fa9686be16"
]
]
},
{
"id": "804899fa9686be16",
"type": "function",
@ -654,28 +590,6 @@
[]
]
},
{
"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",
@ -693,28 +607,6 @@
[]
]
},
{
"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",
@ -732,28 +624,6 @@
[]
]
},
{
"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",
@ -775,7 +645,7 @@
"id": "58942376d9fbdd07",
"type": "inject",
"z": "f96eea4d4a3a345d",
"name": "Poll every sec",
"name": "Poll every two sec",
"props": [
{
"p": "payload"
@ -785,14 +655,14 @@
"vt": "str"
}
],
"repeat": "1",
"repeat": "2",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 190,
"x": 200,
"y": 40,
"wires": [
[
@ -801,10 +671,60 @@
]
},
{
"id": "18e719ada7da042a",
"id": "983943d318a0ef33",
"type": "function",
"z": "f96eea4d4a3a345d",
"name": "Calculate kWh of sum power",
"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 = global.get(\"einspeisung_total_import\");\nvar total_export = global.get(\"einspeisung_total_export\");\nvar check = \"Nothing\";\n\nif (msg.payload < 0) {\n total_export += Math.abs(msg.payload);\n check = \"Export: \" + Math.abs(msg.payload) + \" kWh\";\n}\nif (msg.payload > 0) {\n total_import += Math.abs(msg.payload);\n check = \"Import: \" + Math.abs(msg.payload) + \" kWh\";\n}\n\nglobal.set(\"einspeisung_total_import\", total_import);\nglobal.set(\"einspeisung_total_export\", total_export);\nmsg.payload = {total_import: total_import, total_export: total_export, check: check}\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1530,
"y": 40,
"wires": [
[]
]
},
{
"id": "1504cb346fc652fd",
"type": "watt2kwh",
"z": "f96eea4d4a3a345d",
"format": "kwh",
"maximum": "10",
"maximumunit": "mins",
"name": "",
"x": 1250,
"y": 40,
"wires": [
[
"983943d318a0ef33"
]
]
},
{
"id": "e621c16c10a5eb1d",
"type": "function",
"z": "f96eea4d4a3a345d",
"name": "Init variables",
"func": "global.set(\"einspeisung_total_import\", 0);\nglobal.set(\"einspeisung_total_export\", 0);\nglobal.set(\"einspeisung_l1_import\", 0);\nglobal.set(\"einspeisung_l2_import\", 0);\nglobal.set(\"einspeisung_l3_import\", 0);\nglobal.set(\"einspeisung_l1_export\", 0);\nglobal.set(\"einspeisung_l2_export\", 0);\nglobal.set(\"einspeisung_l3_export\", 0);\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1440,
"y": 580,
"wires": [
[]
]
},
{
"id": "d905c25120cfdfd3",
"type": "inject",
"z": "f96eea4d4a3a345d",
"name": "Calc every minute",
"name": "Inject once",
"props": [
{
"p": "payload"
@ -814,54 +734,118 @@
"vt": "str"
}
],
"repeat": "60",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 190,
"y": 760,
"x": 1250,
"y": 580,
"wires": [
[
"983943d318a0ef33"
"e621c16c10a5eb1d"
]
]
},
{
"id": "983943d318a0ef33",
"id": "1cdb84780936c696",
"type": "watt2kwh",
"z": "f96eea4d4a3a345d",
"format": "kwh",
"maximum": "10",
"maximumunit": "mins",
"name": "",
"x": 1230,
"y": 380,
"wires": [
[
"0b9537e05d7149d3"
]
]
},
{
"id": "074a7fdb9ba59d27",
"type": "watt2kwh",
"z": "f96eea4d4a3a345d",
"format": "kwh",
"maximum": "10",
"maximumunit": "mins",
"name": "",
"x": 1230,
"y": 420,
"wires": [
[
"59bf60635bd06584"
]
]
},
{
"id": "6ff639af913d0a4d",
"type": "watt2kwh",
"z": "f96eea4d4a3a345d",
"format": "kwh",
"maximum": "10",
"maximumunit": "mins",
"name": "",
"x": 1230,
"y": 460,
"wires": [
[
"87d6bf141ff90325"
]
]
},
{
"id": "0b9537e05d7149d3",
"type": "function",
"z": "f96eea4d4a3a345d",
"name": "Phase sum of import and export like EM24",
"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;",
"name": "Calculate kWh of phase 1 power",
"func": "//init counters if not defined\nif (global.get(\"einspeisung_l1_import\") === undefined) {\n global.set(\"einspeisung_l1_import\", 0);\n}\nif (global.get(\"einspeisung_l1_export\") === undefined) {\n global.set(\"einspeisung_l1_export\", 0);\n}\n//get counters from global variable\nvar total_import = global.get(\"einspeisung_l1_import\");\nvar total_export = global.get(\"einspeisung_l1_export\");\nvar check = \"Nothing\";\n\nif (msg.payload < 0) {\n total_export += Math.abs(msg.payload);\n check = \"Export: \" + Math.abs(msg.payload) + \" kWh\";\n}\nif (msg.payload > 0) {\n total_import += Math.abs(msg.payload);\n check = \"Import: \" + Math.abs(msg.payload) + \" kWh\";\n}\n\nglobal.set(\"einspeisung_l1_import\", total_import);\nglobal.set(\"einspeisung_l1_export\", total_export);\nmsg.payload = {total_import: total_import, total_export: total_export, check: check}\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 960,
"y": 760,
"x": 1500,
"y": 380,
"wires": [
[
"9b291dc80aff0a1a"
]
[]
]
},
{
"id": "9b291dc80aff0a1a",
"type": "debug",
"id": "59bf60635bd06584",
"type": "function",
"z": "f96eea4d4a3a345d",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 1460,
"y": 760,
"wires": []
"name": "Calculate kWh of phase 2 power",
"func": "//init counters if not defined\nif (global.get(\"einspeisung_l2_import\") === undefined) {\n global.set(\"einspeisung_l2_import\", 0);\n}\nif (global.get(\"einspeisung_l2_export\") === undefined) {\n global.set(\"einspeisung_l2_export\", 0);\n}\n//get counters from global variable\nvar total_import = global.get(\"einspeisung_l2_import\");\nvar total_export = global.get(\"einspeisung_l2_export\");\nvar check = \"Nothing\";\n\nif (msg.payload < 0) {\n total_export += Math.abs(msg.payload);\n check = \"Export: \" + Math.abs(msg.payload) + \" kWh\";\n}\nif (msg.payload > 0) {\n total_import += Math.abs(msg.payload);\n check = \"Import: \" + Math.abs(msg.payload) + \" kWh\";\n}\n\nglobal.set(\"einspeisung_l2_import\", total_import);\nglobal.set(\"einspeisung_l2_export\", total_export);\nmsg.payload = {total_import: total_import, total_export: total_export, check: check}\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1500,
"y": 420,
"wires": [
[]
]
},
{
"id": "87d6bf141ff90325",
"type": "function",
"z": "f96eea4d4a3a345d",
"name": "Calculate kWh of phase 3 power",
"func": "//init counters if not defined\nif (global.get(\"einspeisung_l3_import\") === undefined) {\n global.set(\"einspeisung_l3_import\", 0);\n}\nif (global.get(\"einspeisung_l3_export\") === undefined) {\n global.set(\"einspeisung_l3_export\", 0);\n}\n//get counters from global variable\nvar total_import = global.get(\"einspeisung_l3_import\");\nvar total_export = global.get(\"einspeisung_l3_export\");\nvar check = \"Nothing\";\n\nif (msg.payload < 0) {\n total_export += Math.abs(msg.payload);\n check = \"Export: \" + Math.abs(msg.payload) + \" kWh\";\n}\nif (msg.payload > 0) {\n total_import += Math.abs(msg.payload);\n check = \"Import: \" + Math.abs(msg.payload) + \" kWh\";\n}\n\nglobal.set(\"einspeisung_l3_import\", total_import);\nglobal.set(\"einspeisung_l3_export\", total_export);\nmsg.payload = {total_import: total_import, total_export: total_export, check: check}\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1500,
"y": 460,
"wires": [
[]
]
}
]