Delaying valve closure with generic thermostat (I'm missing generic switch device)

Hey, I’m having an issue with gaining some finer control over my heating setup.

I have MQTT switches driving 3 different zone valves and another MQTT switch controlling the heater itself. Currently I have generic thermostat instances that control zone switches and heater switch being turned on and off by automation:

  • if there is heating demand (any of the zone vales got opened [by an instance of generic thermostat]), turn on the heater after 20 seconds (allow motorised valve to open)
  • if demand is gone (all valves are closed [by all instances of generic thermostat]) or any window gets open, turn the heater off immediately

So when last valve is closed, heater demand switch turns the heater off, but my heater’s circulation pomp still runs for about 3 minutes. And here is the problem, it runs 3 minutes with all valves closed, that is very unhealthy for it. Generic thermostat needs a toggle device, but there is nothing like a virtual switch that I can just track demand for heating. Any ideas how to solve it?

I know I can create any switch and make a dummy on and off action, but I find it very ugly solution.