Need some logic help please guys

Guys,

Just transitioning our home hesting system from a Gas Boiler to an Electric Heat Pump and using this as an opportunity to redo all my code into Node Red and Tasmota and away from Arduinos that i used to use for Temperature Gathering and Relay control.

Our house is heated by a hydronic system - where we heat a 5000 Litre tank of water and that is then used to pump through our concrete slab and walls (we do not use any radiators) - so the inertia is quite large.

I do have Zone control where i can turn on an off certain sections of the house in the event that i overshoot the temperatures in a specific area of the house - but i also need to implement a general off function for the main circulating pump in the event that multiple areas of the house overheat.

This is where i am coming unstuck at the moment.

Essentially i want to listen to an incoming MQTT topic and if the value is over a certain threshold - then turn the pump off for 30 minutes - at the end of 30 minutes then turn the pump back on.

I have tried using a series of Global Variables to reflect the states of the Pump and the fact that the house is in overheat - but am going around in circles where i come of out from the Pump Off loop after 30 minutes, then turn the pump back on, but immediately on the next cycle turn the pump back off again because i am still in overheat.

It is not a variable speed pump so i can not ramp it up and down - it is either on or off.

Anyone got a custom node or Sub routine that they use for this sort of thing that i could study ?

Craig

That can be done with a Trigger node.

So what do you want to happen if still in overheat?

I am wondering whether you have the basic requirement right. Perhaps you want to hold it off until not in overheat and then wait another 30 mins before turning it on. In which case that an also be handled by a trigger node, with Extend Delay set.

Colin,

Thanks for the quick reply.

Based on how quickly the house loses heat !! I know that if i essentially only run the circulaitng pump at a 50% duty cycle, the temperature will slowly settle and come back down - without the flors feeling like they are freezing cold !

So as a crude first step being able to back off for 30 minutes, then run for 30 minutes will enable the house to slowly come down to the set point in the event of an overshoot.

I have been messing around with a number of nodes people have suggested (including the trigger node) but i seem to run into the same problem that when i come out of the power off phase, i turn back on for 1 cycle and then immediately turn back off again because i am still in overheat.

I think i am looking for some sort of loop within a loop i..e if in Overheat run this on/off routine and then revert to normal - but i just cant get my head around it

Craig

That isn't what you asked for the first time, you didn't say you wanted it to stay on for 30 mins. In that case use two trigger nodes in series, with first and second message on the first one going to different outputs. The first sends Off to the boiler then after 30 mins sends a message on the second output which goes to the second Trigger, which sends On to the boiler then after 30 mins sends an output to its second output which you can use to allow the normal operation to resume.

1 Like

Hey Colin,

Thanks for this - sorry for not being clearer in the first post.

I will study what you have written and have a go at setting this up - will report back

Craig

It seems to me essentially you are looking for a flip flop with a duration of 30 minutes, with a few more controls thrown in. The flow below does this in a absolutely in-elegant and horribly written method but perhaps you can use this as a bad example and improve upon it.

[{"id":"60461b6e.5ed67c","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"74afe7dd.4678c","type":"inject","z":"60461b6e.5ed67c","name":"30 minute flip flop","props":[{"p":"payload"},{"p":"topic","v":"1","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1","payloadType":"num","x":160,"y":140,"wires":[["7524187f.8d992"]]},{"id":"7524187f.8d992","type":"function","z":"60461b6e.5ed67c","name":"set time","func":"let z = msg.payload;\n\nif (msg.topic == \"off\"){\n    msg.payload = \"cancel\";\n    return msg;\n}\n\nlet y = flow.get(\"pump\");\nif (typeof y == 'undefined'){\n    flow.set(\"pump\",\"off\");\n}\n\nmsg = {\n    payload: 'on',\n    timeout: 5,  //set 30 minutes in seconds 3600\n    warning: 0,\n    }\n    \nnode.status({fill:\"blue\",shape:\"dot\",text:msg.payload});\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":380,"y":140,"wires":[["bf68b0d5.76baa"]]},{"id":"bf68b0d5.76baa","type":"mytimeout","z":"60461b6e.5ed67c","name":"timeout","outtopic":"timer","outsafe":"on","outwarning":"Warning","outunsafe":"off","warning":"0","timer":"30","debug":false,"ndebug":false,"ignoreCase":false,"repeat":false,"again":false,"x":500,"y":200,"wires":[["7524187f.8d992"],["e2a90d2f.b3d7a"]]},{"id":"e2a90d2f.b3d7a","type":"function","z":"60461b6e.5ed67c","name":"on or off","func":"let z = msg.payload;\n\nif (z > 0){\n    return null;\n}\n\n\nlet y = flow.get(\"pump\");\n\nif (y == \"off\"){\n    flow.set(\"pump\",\"on\");\n    z = \"on\";\n} else if (y == \"on\"){\n    flow.set(\"pump\",\"off\");\n    z = \"off\";    \n}\n\n\nmsg = {\n    payload: y,\n    }\n    \nnode.status({fill:\"blue\",shape:\"dot\",text:msg.payload});\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":720,"y":200,"wires":[[]]},{"id":"42608b57.626dd4","type":"inject","z":"60461b6e.5ed67c","name":"turn pump off","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"off","payload":"1","payloadType":"num","x":170,"y":240,"wires":[["7524187f.8d992"]]}]

EDIT: the flow uses a node called
Node-red-contrib-mytimeout so be warned

Why use that node when the core Trigger node will do exactly the same thing, as far as I can see?

Personal preference

Why don't you test for overheat before turning the pump on?

Hi,
This type of code is covered in PID controller logic: PID controller - Wikipedia

Because you have a large thermal inertia it might take some time to get the adjustments to the logic correct. Don't forget to integrate outside air temperature / weather etc. if you want more accuracy.

Cheers,

Paul

Steve,

Because you will end up with spots cooling down faster than others - nothing worse than walking on a nice warm floorin bare feet and then hittng a freezing cold patch. !

I do also plan to turn on and off zones - so this part of the code is a sledgehammer for when we get a couple of days of very sunny weather and everything starts to overshoot.

Craig

Yep understand the PID control - and indeed Colin who has replied to this thread has posted PID logic previously, but as it is only an on off pump it could end up putting too much strain into the on off cycling of the pump.

Craig

Thanks Gerry - i already use Neils MyTimeout node so all good

Craig

Guys,

Just to close the loop on this one - i have gone with the trigger node idea that Colin provided and it is working well. It is nice and simple and did not require external nodes or any function blocks.

Thanks everyone for all the help on this one

Craig

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.