Energy saving: switch off solar pump when Temp1 equals Temp2

Hello friends,
my hot water solar system (> 20 years old) has too long a follow-up time in the evening, whereby the storage tank in the boiler room, which was heated during the day, is cooled down by the solar system for far too long.
My wish/idea:
With NodeRed or better with HA automation, asking at intervals from 3 p.m. whether the pump is running, if so, whether the temperature “solar flow” is lower than “solar return”, if “YES” for 5 minutes, then pump off.

What do you think, is it practical and if so, how could you solve it?

Thank you for your ideas and help!Bildschirmfoto vom 2022-10-05 19-51-58

[{"id":"f5c93860d9e2cc95","type":"comment","z":"5303158a.06509c","name":"Solar Temperaturdifferenz","info":"https://discourse.nodered.org/t/simple-maths-flow-to-create-difference-between-two-temperature-sensors/54898","x":150,"y":3420,"wires":[]},{"id":"bd8a6a7755706190","type":"poll-state","z":"5303158a.06509c","name":"Solar RL Temp","server":"f16080ab.5b606","version":2,"exposeToHomeAssistant":true,"haConfig":[{"property":"name","value":"Solar Maximumwert"},{"property":"icon","value":"mdi:water-minus"}],"updateinterval":"1","updateIntervalType":"num","updateIntervalUnits":"minutes","outputinitially":false,"outputonchanged":false,"entity_id":"sensor.solar_ruecklauf_temperature","state_type":"num","halt_if":"","halt_if_type":"num","halt_if_compare":"is","outputs":1,"x":140,"y":3460,"wires":[["53a1d7f8ea5d12a9"]]},{"id":"42209b803712c507","type":"inject","z":"5303158a.06509c","name":"temp a","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"24","payloadType":"num","x":130,"y":3520,"wires":[["53a1d7f8ea5d12a9"]]},{"id":"e22c8c4e1c1ab1c7","type":"inject","z":"5303158a.06509c","name":"temp b","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"26","payloadType":"num","x":150,"y":3580,"wires":[["e8e4602ac984bed4"]]},{"id":"a2acb7deb2d45375","type":"poll-state","z":"5303158a.06509c","name":"Solar VL Temp","server":"f16080ab.5b606","version":2,"exposeToHomeAssistant":true,"haConfig":[{"property":"name","value":"Solar Maximumwert"},{"property":"icon","value":"mdi:water-minus"}],"updateinterval":"1","updateIntervalType":"num","updateIntervalUnits":"minutes","outputinitially":false,"outputonchanged":false,"entity_id":"sensor.solar_vorlauf_temperature","state_type":"num","halt_if":"","halt_if_type":"num","halt_if_compare":"is","outputs":1,"x":140,"y":3640,"wires":[["e8e4602ac984bed4"]]},{"id":"53a1d7f8ea5d12a9","type":"change","z":"5303158a.06509c","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"tempA","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":380,"y":3520,"wires":[["2a08dedd252d1246"]]},{"id":"e8e4602ac984bed4","type":"change","z":"5303158a.06509c","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"tempB","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":380,"y":3580,"wires":[["2a08dedd252d1246"]]},{"id":"2a08dedd252d1246","type":"join","z":"5303158a.06509c","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":570,"y":3540,"wires":[["30cd17c6bc4cf0c2"]]},{"id":"30cd17c6bc4cf0c2","type":"change","z":"5303158a.06509c","name":"Differenz Solar zu Speicher","rules":[{"t":"set","p":"payload.TempC","pt":"msg","to":"payload.tempA - payload.tempB","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":780,"y":3540,"wires":[["52481d56f95a5b5b","eca53bd30b9f8de7"]]},{"id":"52481d56f95a5b5b","type":"debug","z":"5303158a.06509c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1050,"y":3500,"wires":[]},{"id":"eca53bd30b9f8de7","type":"switch","z":"5303158a.06509c","name":">=3 Grad","property":"payload","propertyType":"msg","rules":[{"t":"gte","v":"2","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":1080,"y":3580,"wires":[["7d1f91d9bb1fd69a"]]},{"id":"f16080ab.5b606","type":"server","name":"Home Assistant","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":"30","areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true}]![NodeRed Temp difference|690x167]

got it solved
Finding the temperature difference and then saying “less than” → turn pump off.