1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
| [
{
"id": "0d996033de2ed84e",
"type": "function",
"z": "a938de76db0b71f6",
"g": "d2b7e1d6e85a96cf",
"name": "Function CCC (zone1)",
"func": "// All these functions ONLY need to be executed when the heatpump is in HEAT mode. \nvar msg1 = {}; // pin 1 - SP_CCC (function on)\nvar msg99 = {}; // pin 2 - Log information\n\n//******************************************************************************\nvar TOP20_ThreeWay_Valve_State = global.get('TOP20_ThreeWay_Valve_State'); // Get the global variable for current possition of the three way valve. ROOM or DHW mode. (0=HEAT / 1=DHW)\n\tif (TOP20_ThreeWay_Valve_State === undefined) { return null; }\nvar Operating_Mode = global.get('TOP4_Operating_Mode_State', \"file\");\n\tif (Operating_Mode === undefined) { return null; }\nvar current_sp = global.get('TOP42_Z1_Water_Target_Temp', \"file\"); // TOP27 >> TOP42\n\tif (current_sp === undefined) { return null; }\nvar TOP76_Heating_Mode = global.get('TOP76_Heating_Mode', \"file\"); // TOP76 - Compensation curve or DIRECT mode\n\tif (TOP76_Heating_Mode === undefined) { return null ; }\nvar ccc_state = global.get('F_CCC.z1.state', \"file\"); // Get the global variable. Used to see if the WAR function is enabled.\n\tif (ccc_state === undefined) { ccc_state = 0; global.set('F_CCC.z1.state', 0, \"file\"); }\nvar TOP94_Zones_State = global.get(\"TOP94_Zones_State\",\"file\");\n if (TOP94_Zones_State === undefined) { return null ; }\n\n\n//******************************************************************************\nvar war_ot1 = global.get('F_CCC.z1.ot1', \"file\"); // Outside temperature high (warm outside)\nvar war_ot2 = global.get('F_CCC.z1.ot2', \"file\"); // Outside temperature intermediate (intermediate outside temperature)\nvar war_ot3 = global.get('F_CCC.z1.ot3', \"file\"); // Outside temperature low (cold outside)\n\nvar war_wt1 = global.get('F_CCC.z1.wt1', \"file\"); // Water temperature low (cold water)\nvar war_wt2 = global.get('F_CCC.z1.wt2', \"file\"); // Water temperature intermediate (intermediate water temperature)\nvar war_wt3 = global.get('F_CCC.z1.wt3', \"file\"); // Water temperature high (warm water)\n\n//******************************************************************************\n\nvar SP_start = global.get('F_CCC.z1.SP_DIRECT_virt', \"file\"); // Get the global variable for SP_DIRECT_virt. Value is set through the dashboard\nif (TOP76_Heating_Mode === 1 && (SP_start < 20 || SP_start === undefined || TOP94_Zones_State === 1)) {\n SP_start = 20;\n global.set('F_CCC.z1.SP_DIRECT_virt', 20, \"file\");\n}\nif (TOP76_Heating_Mode === 0 && (SP_start > 5 || SP_start === undefined || TOP94_Zones_State === 1)) {\n SP_start = -5;\n global.set('F_CCC.z1.SP_DIRECT_virt', 0, \"file\");\n}\n\n\nvar check = (war_ot1 + war_ot2 + war_ot3 + war_wt1 + war_wt2 + war_wt3);\nif (isNaN(check) || check === undefined) // if the variables are added to eachother and the result is Not a Number, produce an error message.\n{\n msg99.payload = \"<font color=red>Profile temperatures are not correctly set in the dashboard. Waiting for Panasonic import or user input</font>\";\n msg99.topic = \"Function CCC (Zone 1)\";\n global.set('F_CCC.z1.state', 0, \"file\");\n global.set('F_CCC.z1.setpoint', SP_start, \"file\");\n return [null, msg99];\n}\n\nif (war_wt2 < war_wt1 || war_wt3 < war_wt1) {\n msg99.payload = \"<font color=red>Temperature profile is inverted and not setup correctly. This requires your attention. CCC-function disabled</font>\";\n msg99.topic = \"Function CCC (Zone 1)\";\n global.set('F_CCC.z1.state', 0, \"file\");\n global.set('F_CCC.z1.setpoint', SP_start, \"file\");\n return [null, msg99, msg99];\n}\n\nvar SP_ccc; // set empty starting variable\n\nvar war_Tb = global.get('T_outside', \"file\"); // Outdoor temperature.\nif (isNaN(war_Tb) || war_Tb === undefined || war_Tb < -50) // if the variable is Not a Number, produce an error message.\n{\n msg99.payload = \"T_outside is not valid. Waiting for correct value.\";\n msg99.topic = \"Function CCC (Zone 1)\";\n //global.set('F_CCC.z1.setpoint', SP_start, \"file\");\n return [null, msg99, msg99];\n}\n\nvar F_CCC_old_SP = global.get('F_CCC.z1.setpoint',\"file\");\nif (F_CCC_old_SP === undefined) {\n F_CCC_old_SP = SP_start;\n global.set('F_CCC.z1.setpoint', SP_start, \"file\");\n}\n\n\n////////////////////////////////////////////////////////////////////////////////\n// Calculation of the NR WAR Setpoint\n////////////////////////////////////////////////////////////////////////////////\n\n\n\nif (war_Tb >= war_ot1) { SP_ccc = war_wt1; } // Range 1\n\nif (war_Tb < war_ot1 && war_Tb > war_ot2) // Range 2\n{ SP_ccc = (((war_wt1 - war_wt2) * ((war_Tb - war_ot1) / (war_ot1 - war_ot2))) + war_wt1); }\n\n\nif (war_Tb <= war_ot2 && war_Tb > war_ot3) // Range 3\n{ SP_ccc = (((war_wt2 - war_wt3) * ((war_Tb - war_ot2) / (war_ot2 - war_ot3))) + war_wt2); }\n\nif (war_Tb <= war_ot3) // Range 4\n{ SP_ccc = war_wt3; }\n\nSP_ccc = Number(SP_ccc).toFixed(1);\nSP_ccc = parseFloat(SP_ccc);\n\n\n////////////////////////////////////////////////////////////////////////////////\n// Compensation curve being used. WAR function not allowed.\n////////////////////////////////////////////////////////////////////////////////\nif (TOP76_Heating_Mode === 0) { // Compensation Curve\n if (ccc_state === 1) {\n global.set('F_CCC.z1.state', 0, \"file\");\n msg99.payload = \"Compensation curve active. Using internal Panasonic WAR function. NodeRed WAR function is now disabled\";\n msg99.topic = \"Function CCC (Zone 1)\";\n return [null, msg99];\n }\n //if (ccc_state === 0 || ccc_state === undefined) { SP_ccc = SP_start; }\n global.set('F_CCC.z1.setpoint', SP_ccc,\"file\");\n msg1.payload = SP_ccc;\n return [msg1, null];\n}\n////////////////////////////\n\n// Operating mode (0=Heat only, 1=Cool only, 2=Auto(Heat), 3=DHW only, 4=Heat+DHW, 5=Cool+DHW, 6=Auto(Heat)+DHW, 7=Auto(Cool), 8=Auto(Cool)+DHW)\n////////////////////////////////////////////////////////////////////////////////\n// Direct mode > WAR function allowed.\n////////////////////////////////////////////////////////////////////////////////\nif (TOP76_Heating_Mode === 1) { // Direct\n if (Operating_Mode === undefined || \n current_sp === 0 || \n Operating_Mode === 1 || \n //Operating_Mode === 3 || \n Operating_Mode === 5 || \n Operating_Mode === 7 || \n Operating_Mode === 8\n ){\n return null; // If state is 1 (DHW mode), correction 0 is direclty exported to the message and the function ends here.\n }\n\n msg1.payload = SP_ccc; // required\n msg1.topic = 'SP_war';\n msg1.source = 'WAR';\n\n if (ccc_state === 0) { // If the state is 1 (enabled), AND outside temperature contains a value.\n global.set('F_CCC.z1.setpoint', SP_start,\"file\");\n msg1.payload = SP_start;\n return [msg1, null];\n }\n\n if (ccc_state === 1) {\n msg1.payload = SP_ccc;\n if (SP_ccc === F_CCC_old_SP) {\n return [msg1, null];\n }\n else {\n global.set('F_CCC.z1.setpoint', SP_ccc,\"file\");\n\n msg99.payload = \"Setpoint change: From \" + F_CCC_old_SP + \" to \" + SP_ccc + \" °C\";\n msg99.topic = \"Function CCC (Zone 1)\";\n\n return [msg1, msg99];\n }\n }\n ////////////////////////////////////////////////////////////////////////////////\n\n}",
"outputs": 3,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1100,
"y": 820,
"wires": [
[
"d16f38ef74db786a"
],
[
"663fd79ce5a1610d"
],
[
"e06c72be3ce79609"
]
],
"outputLabels": [
"SP_WAR (function on)",
"ToLog",
"ToToggle_CCC"
],
"info": "# ALL IN ONE FUNCTION\n\nThis function takes care of WAR, RTC and SoftStart. Comments are within"
},
{
"id": "51a6bac27fdf889f",
"type": "function",
"z": "a938de76db0b71f6",
"g": "56ad661c12898edd",
"name": "Function CCC (zone2)",
"func": "// All these functions ONLY need to be executed when the heatpump is in HEAT mode. \nvar msg1 = {}; // pin 1 - SP_CCC (function on)\nvar msg99 = {}; // pin 2 - Log information\n\n//******************************************************************************\nvar TOP20_ThreeWay_Valve_State = global.get('TOP20_ThreeWay_Valve_State'); // Get the global variable for current possition of the three way valve. ROOM or DHW mode. (0=HEAT / 1=DHW)\n\tif (TOP20_ThreeWay_Valve_State === undefined) { return null; }\nvar Operating_Mode = global.get('TOP4_Operating_Mode_State', \"file\");\n\tif (Operating_Mode === undefined) { return null; }\nvar current_sp = global.get('TOP43_Z2_Water_Target_Temp',\"file\"); // TOP27\n\tif (current_sp === undefined) { return null; }\nvar TOP76_Heating_Mode = global.get('TOP76_Heating_Mode', \"file\"); // TOP76 - Compensation curve or DIRECT mode\n\tif (TOP76_Heating_Mode === undefined) { return null; }\nvar ccc_state = global.get('F_CCC.z2.state', \"file\"); // Get the global variable. Used to see if the WAR function is enabled.\n\tif (ccc_state === undefined) { ccc_state = 0; global.set('F_CCC.z2.state', 0, \"file\"); }\nvar TOP94_Zones_State = global.get(\"TOP94_Zones_State\",\"file\");\n if (TOP94_Zones_State === undefined) { return null ; }\n\n//******************************************************************************\nvar war_ot1 = global.get('F_CCC.z2.ot1', \"file\"); // Outside temperature high (warm outside)\nvar war_ot2 = global.get('F_CCC.z2.ot2', \"file\"); // Outside temperature intermediate (intermediate outside temperature)\nvar war_ot3 = global.get('F_CCC.z2.ot3', \"file\"); // Outside temperature low (cold outside)\n\nvar war_wt1 = global.get('F_CCC.z2.wt1', \"file\"); // Water temperature low (cold water)\nvar war_wt2 = global.get('F_CCC.z2.wt2', \"file\"); // Water temperature intermediate (intermediate water temperature)\nvar war_wt3 = global.get('F_CCC.z2.wt3', \"file\"); // Water temperature high (warm water)\n\n//******************************************************************************\n\nvar SP_start = global.get('F_CCC.z2.SP_DIRECT_virt', \"file\"); // Get the global variable for SP_DIRECT_virt. Value is set through the dashboard\nif (TOP76_Heating_Mode === 1 && (SP_start < 20 || SP_start === undefined || TOP94_Zones_State === 0)) {\n SP_start = 20;\n global.set('F_CCC.z2.SP_DIRECT_virt', 20, \"file\");\n}\nif (TOP76_Heating_Mode === 0 && (SP_start > 5 || SP_start === undefined || TOP94_Zones_State === 0)) {\n SP_start = -5;\n global.set('F_CCC.z2.SP_DIRECT_virt', 0, \"file\");\n}\n\n\nvar check = (war_ot1 + war_ot2 + war_ot3 + war_wt1 + war_wt2 + war_wt3);\nif (isNaN(check) || check === undefined) // if the variables are added to eachother and the result is Not a Number, produce an error message.\n{\n msg99.payload = \"<font color=red>Profile temperatures are not correctly set in the dashboard. Waiting for Panasonic import or user input</font>\";\n msg99.topic = \"Function CCC (Zone 2)\";\n global.set('F_CCC.z2.state', 0, \"file\");\n global.set('F_CCC.z2.setpoint', SP_start, \"file\");\n return [null, msg99];\n}\n\nif (war_wt2 < war_wt1 || war_wt3 < war_wt1) {\n msg99.payload = \"<font color=red>Temperature profile is inverted and not setup correctly. This requires your attention. CCC-function disabled</font>\";\n msg99.topic = \"Function CCC (Zone 2)\";\n global.set('F_CCC.z2.state', 0, \"file\");\n global.set('F_CCC.z2.setpoint', SP_start, \"file\");\n return [null, msg99, msg99];\n}\n\nvar SP_ccc; // set empty starting variable\n\nvar war_Tb = global.get('T_outside', \"file\"); // Outdoor temperature.\nif (isNaN(war_Tb) || war_Tb === undefined || war_Tb < -50) // if the variable is Not a Number, produce an error message.\n{\n msg99.payload = \"T_outside is not valid. Waiting for correct value.\";\n msg99.topic = \"Function CCC (Zone 2)\";\n //global.set('F_CCC.z2.setpoint', SP_start, \"file\");\n return [null, msg99];\n}\n\nvar F_CCC_old_SP = global.get('F_CCC.z2.setpoint', \"file\");\nif (F_CCC_old_SP === undefined) {\n F_CCC_old_SP = SP_start;\n global.set('F_CCC.z2.setpoint', SP_start);\n}\n\n\n////////////////////////////////////////////////////////////////////////////////\n// Calculation of the NR WAR Setpoint\n////////////////////////////////////////////////////////////////////////////////\n\n\n\nif (war_Tb >= war_ot1) { SP_ccc = war_wt1; } // Range 1\n\nif (war_Tb < war_ot1 && war_Tb > war_ot2) // Range 2\n{ SP_ccc = (((war_wt1 - war_wt2) * ((war_Tb - war_ot1) / (war_ot1 - war_ot2))) + war_wt1); }\n\n\nif (war_Tb <= war_ot2 && war_Tb > war_ot3) // Range 3\n{ SP_ccc = (((war_wt2 - war_wt3) * ((war_Tb - war_ot2) / (war_ot2 - war_ot3))) + war_wt2); }\n\nif (war_Tb <= war_ot3) // Range 4\n{ SP_ccc = war_wt3; }\n\nSP_ccc = Number(SP_ccc).toFixed(1);\nSP_ccc = parseFloat(SP_ccc);\n\n\n////////////////////////////////////////////////////////////////////////////////\n// Compensation curve being used. WAR function not allowed.\n////////////////////////////////////////////////////////////////////////////////\nif (TOP76_Heating_Mode === 0) { // Compensation Curve\n if (ccc_state === 1) {\n global.set('F_CCC.z2.state', 0, \"file\");\n msg99.payload = \"Compensation curve active. Using internal Panasonic WAR function. NodeRed WAR function is now disabled\";\n msg99.topic = \"Function CCC (Zone 2)\";\n return [null, msg99];\n }\n //if (ccc_state === 0 || ccc_state === undefined) { SP_ccc = SP_start; }\n global.set('F_CCC.z2.setpoint', SP_ccc, \"file\");\n msg1.payload = SP_ccc;\n return [msg1, null];\n}\n////////////////////////////\n\n\n////////////////////////////////////////////////////////////////////////////////\n// Direct mode > WAR function allowed.\n////////////////////////////////////////////////////////////////////////////////\nif (TOP76_Heating_Mode === 1) { // Direct\n if (TOP20_ThreeWay_Valve_State === 1 || Operating_Mode === undefined || current_sp === 0 || TOP76_Heating_Mode === 0 || Operating_Mode === 1 || Operating_Mode === 3 || Operating_Mode === 5 || Operating_Mode === 7 || Operating_Mode === 8) {\n return null; // If state is 1 (DHW mode), correction 0 is direclty exported to the message and the function ends here.\n }\n\n msg1.payload = SP_ccc; // required\n msg1.topic = 'SP_war';\n msg1.source = 'WAR';\n\n if (ccc_state === 0) { // If the state is 1 (enabled), AND outside temperature contains a value.\n global.set('F_CCC.z2.setpoint', SP_start, \"file\");\n msg1.payload = SP_start;\n return [msg1, null];\n }\n\n if (ccc_state === 1) {\n msg1.payload = SP_ccc;\n if (SP_ccc === F_CCC_old_SP) {\n return [msg1, null];\n }\n else {\n global.set('F_CCC.z2.setpoint', SP_ccc, \"file\");\n\n msg99.payload = \"Setpoint change: From \" + F_CCC_old_SP + \" to \" + SP_ccc + \" °C\";\n msg99.topic = \"Function CCC (Zone 2)\";\n\n return [msg1, msg99];\n }\n }\n ////////////////////////////////////////////////////////////////////////////////\n\n}",
"outputs": 3,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 2700,
"y": 820,
"wires": [
[
"d625be872191a9a8"
],
[
"663fd79ce5a1610d"
],
[
"161478f41649a6fa"
]
],
"outputLabels": [
"SP_CCC_Z2 (function on)",
"ToLog",
""
]
}
] |