Outdoor compensated supply temperature:
Found a way of making X and Y as setpoints from HA to calculate the supplytemperature according to the outdoor temperature, sharing the code below for others in the mean time. Y4, Y5 and Y6 setpoints are given some “test” values just to display/show that the calculated supplytemp. actually follows the calculated line between the points. Normally i would want the calculated supplytemp to be 22 degrees with the given outdoor temperature.
// X :Y(ute temp) og X (ønsket tilluft) plot:
// X1 :5,0, Y6 :22,0 (Eks.) - Slope 1
// X2 :7,5, Y5 :21,0 (Eks.) - Slope 1
// X3 :10,0, Y4 :20,0 (Eks.) - Slope 2
// X4 :12,5, Y3 :18,0 (Eks.) - Slope 2
// X5 :15,0, Y2 :17,0 (Eks.) - Slope 3
// X6 :20,0, Y1 :15,0 (Eks.) - Slope 3
// Slope = "change in Y/change in X=deltaY/deltaX"
var x= msg.payload; // utetemp.
var Y_output; // Ønsket tilluftstemp.
// Utetmp plot:
var X1 = flow.get ("vtr300_tilluftstemp_utekomp_x1","default"); // Henter settpunkt fra HA, lagrer i memory.
var X2 = flow.get ("vtr300_tilluftstemp_utekomp_x2","default");
var X3 = flow.get ("vtr300_tilluftstemp_utekomp_x3","default");
var X4 = flow.get ("vtr300_tilluftstemp_utekomp_x4","default");
var X5 = flow.get ("vtr300_tilluftstemp_utekomp_x5","default");
var X6 = flow.get ("vtr300_tilluftstemp_utekomp_x6","default");
// Ønsket tillufts temp. plot:
var Y6 = flow.get ("vtr300_tilluftstemp_utekomp_y6","default"); // Henter settpunkt fra HA, lagrer i memory.
var Y5 = flow.get ("vtr300_tilluftstemp_utekomp_y5","default");
var Y4 = flow.get ("vtr300_tilluftstemp_utekomp_y4","default");
var Y3 = flow.get ("vtr300_tilluftstemp_utekomp_y3","default");
var Y2 = flow.get ("vtr300_tilluftstemp_utekomp_y2","default");
var Y1 = flow.get ("vtr300_tilluftstemp_utekomp_y1","default");
var slope_1 = (Y6-Y5)/(X1-X2);
var slope_2 = (Y4-Y3)/(X3-X4);
var slope_3 = (Y2-Y1)/(X5-X6);
var Y_out_1 = Y6+slope_1*(x-X1);
var Y_out_2 = Y4+slope_2*(x-X3);
var Y_out_3 = Y2+slope_3*(x-X5);
// Sjekker for "isNotNumber, ved "isNan" tidlig "exit" (ved evt. feil ved HA reconnect ell.) (prøv igjen).
if (isNaN(Y_out_1) || isNaN(Y_out_2) || isNaN(Y_out_3)) {
return;
}
// Bruker Y6 som for max ytterpunkt
if (x < X1) {
Y_output = Y6;
}
//Rak linje for X1, X2, Y1 & Y2
else if (x >= X1 && x < X3) {
Y_output = Y_out_1;
}
//Rak linje for X3, X4, Y3 & Y4
else if (x >= X3 && x < X5) {
Y_output = Y_out_2;
}
//Rak linje for X5, X6, Y5 & Y6
else if (x >= X5 && x <= X6) {
Y_output = Y_out_3;
}
// Bruker Y1 som min ytterpunkt
else if (x > X6) {
Y_output = Y1;
}
// Bruker Y6 som min ytterpunkt
else {
Y_output = Y6;
}
msg.payload = parseFloat((Y_output).toFixed(1));
return msg;