edterbak / NodeRed_Heishamon_control

a Node Red flow to interact with Heishamon (a panasonic heatpump through an ESP board)
35 stars 6 forks source link

Smoothing setpoint jumps to prevent unnecessary short-term compressor shutdowns #160

Open WP-Rue opened 5 months ago

WP-Rue commented 5 months ago

As switching on night-reduction with offset -3 I got a 5 min compressor shutdown... To avoid this I put a 10 min smoothing function into your flow... Maybe you have a better idea for the right place... My implementation only works for the switch and global.var: NightReductionWaterTemp.state and only for the reduction of the setpoint temperature... Bildschirmfoto vom 2024-01-17 19-25-09 Greetings Rue

edterbak commented 5 months ago

I will put this logic in the tab WP Control, [Function NightReduction] node. Not now, directly, but a bit later.

WP-Rue commented 5 months ago

I will put this logic in the tab WP Control, [Function NightReduction] node. Not now, directly, but a bit later.

:-) Thank you. Hm- I wonder, if this is the right place.. The easing node should be active to build new setpoints in the moment of activation (switch on) night reduction..so it has to jump in, where the actual setpoint is calculated ..? . but you are the expert with your flow ;-)

edterbak commented 5 months ago

Ease node, i can recreate the logic in a function node. I will try that first.

WP-Rue commented 5 months ago

Hello, I searched for this kind of function and found first the following code in Nodered forum- maybe as a suggestion… and than found the ease-node. Regards Rue

// Limits the slew rate incoming payload values// optionally sending intermediate values at specified ratelet maxRate = 2/60; // max slew rate units/minutelet sendIntermediates = false; // whether to send intermediate valueslet period = 1000; // period in millisecs to send new values (if sendIntermediates)let jumpThreshold = 0.25; // if the step asked for is more that this then goes immediately to that valuevar newValue = Number(msg.payload);var timer = context.get('timer') || 0;// check the value is a numberif (!isNaN(newValue) && isFinite(newValue)) { var target = msg.payload; context.set('target', target); // set last value to new one if first time through var lastValue = context.get('lastValue'); if (typeof lastValue == "undefined" || lastValue === null) { lastValue = newValue; context.set('lastValue', newValue); } // calc new value msg.payload = calcOutput(); // stop the timer if (timer) { clearTimeout(timer); context.set('timer', null); } // restart it if required to send intermediate values if (sendIntermediates) { timer = setInterval(function(){ // the timer has run down calculate next value and send it var newValue = calcOutput(); if (newValue != context.get('lastValueSent')) { context.set('lastValueSent', newValue); node.send({payload: newValue}); } },period); context.set('timer', timer); } context.set('lastValueSent', msg.payload);} else { // payload is not a number so ignore it // also stop the timer as we don't know what to send any more if (timer) { clearTimeout(timer); context.set('timer', null); } msg = null;}return msg;// determines the required output valuefunction calcOutput() { var lastValue = context.get('lastValue'); var target = context.get('target'); // set to current value if first time through or step > threshold if (typeof lastValue == "undefined" || lastValue === null) lastValue = target; var now = new Date(); var lastTime = context.get('lastTime') || now; // limit value to last value +- rate time var maxDelta = (now.getTime() - lastTime.getTime()) maxRate / (60 * 1000); if (Math.abs(target - lastValue) > jumpThreshold) { // step > threshold so go there imediately newValue = target; } else if (target > lastValue) { newValue = Math.min( lastValue + maxDelta, target); } else { newValue = Math.max( lastValue - maxDelta, target); } context.set('lastValue', newValue); context.set('lastTime', now); return newValue;}Gesendet mit der GMX Mail AppAm 18.01.24 um 13:50 schrieb Ed ter Bak

                Von: "Ed ter Bak" ***@***.***>Datum: 18. Januar 2024An: "edterbak/NodeRed_Heishamon_control" ***@***.***>Cc: "WP-Rue" ***@***.***>,"Author" ***@***.***>Betreff: Re: [edterbak/NodeRed_Heishamon_control] [BUG]:Smoothing setpoint jumps to prevent unnecessary short-term compressor shutdowns (Issue #160)

Ease node, i can recreate the logic in a function node. I will try that first.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>

edterbak commented 5 months ago

Alternative;

I need to clean the night reduction function. It has now 2 methods to achieve the same

I think a good replacement is to be able to use the scheduler to set the value of night reduction. At your set time. In your case, you set2 or 3 times a different value at different moments. If i do this, wil this work for you?

WP-Rue commented 5 months ago

I would prefer to have the switch for manual control too.. or additional with external link in node.. Sorry this answer is not the one leading to the simple solution..🤪 But my 1st suggestion doesn't work. It is not the right place to interact. My original idea was to make a branch for the outgoing setpoint, if the night reduction, state is set to "1" and generate several new setpoints over eg 10min.