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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
| // >> trigger 1
// DHW / Sterilisation? This is defined in the topic
// Topic: DHW or topic: Sterilization
// payload 1 > initiate sequence.
// 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)
// Declaration of the variables.
var msg1 = {}, msg2 = {}, msg3 = {}, msg4 = {}, msg99 = {};
msg99.topic = 'Scheduler';
// msg1 Output towards Operation mode
// msg2 Output towards Force DHW mode on/off
// msg3 output towards Force Sterilization on/off
// msg4 empty
//var TOP20_ThreeWay_Valve_State =global.get('TOP20_ThreeWay_Valve_State'); // valvue position
var TOP10_DHW_Temp =global.get('TOP10_DHW_Temp'); // Current temperature of DHW vessel.
var TOP9_DHW_Target_Temp =global.get('TOP9_DHW_Target_Temp',"file"); // Programmed DHW target temperature
var TOP2_Force_DHW_State =global.get('TOP2_Force_DHW_State'); // Current DHW state (on / off).
if (TOP2_Force_DHW_State === undefined) { return null; }
var TOP4_Operating_Mode_State =global.get('TOP4_Operating_Mode_State',"file"); // get Current OperationMode
var TOP69_Sterilization_State =global.get('TOP69_Sterilization_State',"file"); // Current sterilization state (on / off)
if (TOP69_Sterilization_State === undefined) { return null; }
// var TOP70_Sterilization_Temp =global.get('TOP70_Sterilization_Temp',"file"); // Programmed sterilization target temperature
var DHW_threshold_upper =global.get('DHW_threshold_upper',"file"); // Programmed treshold DHW tank temperature set from GUI
var DHW_boost_state =global.get('DHW_boost_state',"file");
var F_stored_next_operating_mode=global.get('F_stored_next_operating_mode',"file");
var F_SOLAR = global.get('F_SOLAR',"file");
var Sterilization_active = global.get('Sterilization_active', "file");
var Force_DHW_active = global.get('Force_DHW_active', "file");
var old_OM; // create empty variable.
var new_OM; // create empty variable.
if (TOP4_Operating_Mode_State === undefined || F_SOLAR === undefined || F_SOLAR.function_active_state === undefined || TOP10_DHW_Temp === undefined ) { return null; }
/*
Information about default Panasonic behaviour:
What happens if on the remote controller (not node red) you :
////////////////////
// Press ForceDHW //
////////////////////
1 - Current OperatingMode is stored.
2 - Pump goes to DHW-Only
3 - Threewayvalve to position DHW
4 - Compressor on
*** do DHW Run ***
When the target temperature is reached, then:
5 - Pump OperatingMode goes back to stored mode
6 - Threeway valve to position HEAT
7 - ForceDHW is disabled (automatically)
8 - Continue normal operation in HEAT.
But what happens if you send through MQTT the command:
topic:"panasonic_heat_pump/commands/SetDHWTemp" with payload:"1"
Step 1, 2 and 5 are not done. So these need to be done manually....
But step 7 is done. For the end of the ForceDHW run, listening to the state change of ForceDHW from 1 to 0 is working.
Same applies for the sterelization run!
When the compressor stops and the ellecric heater continues to to heat up water to the target temperature.
When temperature is reached:
- The Threeway valve goes to HEAT mode,
- The water flow stops.
- When the temperature drops low enough, the Sterelization run toggle is set to 0.
Soo...
This function manages the missing steps for the node red users.
IF a user presses ForceDHW on the NodeREd flow, the ForceDHW 1 command will be sent, but also the missing steps 1, 2 and 5 will be taken care of!
*/
////////////////////////////////////////////////////////////////////////////////
// START OF THE CYCLE //
////////////////////////////////////////////////////////////////////////////////
// START Force DHW cycle
if (msg.topic === 'DHW' && msg.payload === 1 && TOP10_DHW_Temp < DHW_threshold_upper && F_SOLAR.function_active_state !== 1) { // There is a temperature condition to start DHW heating or not. Change to your own desire.
// 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)
global.set('TOP2_Force_DHW_State', undefined, "file"); // To prevent early DHW-END trigger
old_OM = TOP4_Operating_Mode_State;
if (TOP4_Operating_Mode_State === 7) { old_OM = 2; }
if (TOP4_Operating_Mode_State === 8) { old_OM = 6; }
if (F_stored_next_operating_mode === undefined) { global.set('F_stored_next_operating_mode', old_OM, "file"); msg99.payload = 'Stored next operating mode is set to ' + old_OM; node.send([null, null, null, null, msg99]); }
setTimeout(function() { // Operation mode change
msg1.payload = 3;
if (TOP4_Operating_Mode_State === 3) { msg99.payload = 'Operation mode already (3)DHW-Only'; }
if (TOP4_Operating_Mode_State !== 3) { msg99.payload = 'Operation mode change to (3)DHW-Only'; }
node.send([null, null, null, null, msg99]); // send new_OM
if (TOP4_Operating_Mode_State !== 3) { node.send([msg1,null]); }
}, 2500);
setTimeout(function () { // Set ForceDHW
msg2.payload = 1;
global.set('F_RTC.automation_active', 0, "file");
msg99.payload = 'Enable ForceDHW';
node.send([null, msg2, null, null, msg99]);
global.set('Force_DHW_active', 1, "file");
}, 5000);
// global.set('Force_DHW_active', 1, "file");
return null;
}
// START Force Sterilization cycle
if (msg.topic === 'Sterilization' && msg.payload === 1 && F_SOLAR.function_active_state !== 1) {
// 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)
global.set('TOP69_Sterilization_State', undefined, "file"); // To prevent early Sterelization-End trigger
old_OM = TOP4_Operating_Mode_State;
if (TOP4_Operating_Mode_State === 7) { old_OM = 2; }
if (TOP4_Operating_Mode_State === 8) { old_OM = 6; }
if (F_stored_next_operating_mode === undefined) { global.set('F_stored_next_operating_mode', old_OM, "file"); msg99.payload = 'Stored next operating mode is set to ' + old_OM; node.send([null, null, null, null, msg99]); }
setTimeout(function () { // Operation mode change
msg1.payload = 3;
if (TOP4_Operating_Mode_State === 3) { msg99.payload = 'Operation mode already (3)DHW-Only'; }
if (TOP4_Operating_Mode_State !== 3) { msg99.payload = 'Operation mode change to (3)DHW-Only'; }
node.send([null, null, null, null, msg99]); // send new_OM
if (TOP4_Operating_Mode_State !== 3) { node.send([msg1, null]); }
}, 2500);
setTimeout(function () { // Set ForceSterilization
msg2.payload = 1; msg2.topic = 'Sterilization';
//global.set('Sterilization_active', 1, "file");
global.set('F_RTC.automation_active', 0, "file");
msg99.payload = 'Enable ForceSterilization';
node.send([null, null, msg2, null, msg99]);
}, 5000);
global.set('Sterilization_active', 1, "file");
return null;
}
////////////////////////////////////////////////////////////////////////////////
// END OF THE CYCLE //
////////////////////////////////////////////////////////////////////////////////
// END FORCE DHW cycle
//////////////////////
if (Force_DHW_active === 1 && (TOP2_Force_DHW_State === 0 || (msg.topic == 'DHW' && msg.payload === 0))) {
// 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)
new_OM = F_stored_next_operating_mode;
global.set('Force_DHW_active', 0, "file");
var delay = 1000*60*15; // 15 minutes delay
if (TOP2_Force_DHW_State === 1) { // This means that the user disabled ForceDHW via GUI.. Should react fast instead of timely.
msg2.payload = 0;
msg99.payload = 'Manually stopped ForceDHW. Reverting Operating Mode in 10 seconds';
node.send([null, msg2, null, null, msg99]);
delay = 1000*10; // 10 seconds
}
else { msg99.payload = 'End ForceDHW cycle detected. Reverting Operating Mode in 15 minutes...'; node.send([null, null, null, null, msg99]); }
setTimeout(function() { // Revert Operating Mode
msg1.payload = new_OM;
global.set('F_stored_next_operating_mode', undefined, "file");
if (msg1.payload !== undefined) {
msg99.payload = 'Revert to previous operating mode: ' + new_OM;
node.send([msg1, null, null, null, msg99]);
}
}, delay);
return null;
}
// END Sterilization cycle (Automatic)
//////////////////////////////////////
if (Sterilization_active === 1 && (TOP69_Sterilization_State === 0 || (msg.payload === 0 && msg.topic === 'Sterilization'))) {
// 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)
new_OM = F_stored_next_operating_mode;
global.set('Sterilization_active', 0, "file");
var delay = 1000 * 10; // 10 seconds delay
if (TOP69_Sterilization_State === 1) { // This means that the user disabled ForceSterilization via GUI.. Should react fast instead of timely.
msg3.payload = 0;
if (new_OM !== undefined) {msg99.payload = 'Manually stopped ForceSterilization. Reverting Operating Mode in 10 seconds'; node.send([null, null, null, null, msg99]) ; }
node.send([null, null, msg3, null, null]);
}
else { msg99.payload = 'End ForceSterilization cycle detected. Reverting Operating Mode in 10 seconds...'; node.send([null, null, null, null, msg99]); }
setTimeout(function () { // Revert Operating Mode
msg1.payload = new_OM;
global.set('F_stored_next_operating_mode', undefined, "file");
if (new_OM !== undefined) {
msg99.payload = 'Revert to previous operating mode: ' + new_OM;
node.send([msg1, null, null, null, msg99]);
}
}, delay);
return null;
}
var TOP9_DHW_Target_Temp_Secondairy = global.get('TOP9_DHW_Target_Temp_Secondairy', "file");
var DHW_boost_state = global.get('DHW_boost_state', "file");
// END DHW_boost_state cycle (Automatic)
if (DHW_boost_state === 1 && Force_DHW_active === 1) {
if ((TOP2_Force_DHW_State === 0) || (msg.topic === 'DHW' && msg.payload === 0)) {
new_OM = F_stored_next_operating_mode;
// 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)
if (TOP4_Operating_Mode_State !== F_stored_next_operating_mode && F_stored_next_operating_mode !== undefined)
{setTimeout(function(){
msg1.payload = new_OM; // set operationmode to remove DHW
node.send([msg1,null,null,null]); // send msg1 only, other outputs are null
}, 5000);}
global.set('Force_DHW_active',0,"file");
global.set('F_stored_next_operating_mode',undefined,"file");
msg99.payload = 'Stored next operating mode is removed'; node.send([null, null, null, null, msg99]);
msg2.payload = 0; // Turn off Force DHW mode
msg2.topic = 'DHW End';
var dhw_sp_low = global.get('F_SOLAR.dhw_sp_low',"file");
if (dhw_sp_low === undefined){ dhw_sp_low = null;}
msg4.payload = dhw_sp_low; msg4.topic = 'dhw_sp'
return [null, msg2,null,msg4];
}
} |