Multiple thermostats automation

Hello.

I have several Homematic IP thermostats, more precisely one in each room and I would like to make an automation that triggers a relay (which starts my heat pump) when one or more thermostats drops below a setpoint and then, when all thermostats have exceeded the set threshold to turn off the relay and stop the HP.
What would be the simplest and most effective method?