Opentherm Multi Room brainstorming / ideas

I was wondering if you ever turn off one of the thermostats? Because if you would, the template would still take it into account and possibly use it to set the main heater. I am trying to integrate windows sensors for each thermostat, but running into this problem. I fixed this now by changed the template a bit:

{% if states('climate.anna') == 'heat' %}
  {% set anna_td = (state_attr('climate.anna','temperature') - states('sensor.tempsensor_anna_temperature') | float) %}
{% else %}
  {%set anna_td ='0' | float %}
{% endif %}

But I would still need to turn off the main thermostat when all of the sub thermostats are on idle or turned off.