Blower fan for circulation

Hello all, hoping I can find some help on here. I have a d1 mini with 3 relays attached to my hvac system. 1 relay for heating, 1 relay for cooling and 1 relay for the blower fan. From talking with my hvac company, when (gas) heating is turned on, the hvac board knows to turn on the blower fan onwithout any interaction from a thermostat. From a cooling perspective, I am using the dual smart thermostat in HA to turn on the compressor and then just a basic automation in HA when the compressor turns on, turn on blower fan, when it turns off turn off blower fan. All of this so far seems to run fine without any issues. My problem is I am struggling to find something that monitors how often i want to run my blower fan to circulate air. I like to run the blower fan for 3-5 minutes every 20 minutes. Currently I am just looking for a basic script, HA automation or node red but long term would like to be able to build a complete node red automation to handle hvac, attic fans on and off, ceiling fans, low to high and bathroom vent fans to vent heat. One issue I have tried with is in node red i created a flow to check the last time the blower fan was on, if it hasn’t come on in 20 minutes, run blower fan for 3 min, turn off and reset counter. The issue with this script is that now that its summer and hot, my compressor runs longer and i noticed the script turns off the fan even when the ac compressor is still running.

Why are you not turning off the ac when the blower is shut off? If you want to do this in node red post your flow. Select all the nodes in the flow, right click on one of the selected nodes and choose export. Copy to clip board, go to an empty line in the reply box and press the code block button </> and paste the code where indicated.

image