Heating automation

Hello, I just migrated from Domoticz and have some troubles with configuration. Everything works fine, but I have no idea how to make one very important automation. I have 6 generic thermostats. And I want to make one “master” switch, witch will be setting off when ALL of thermostats are idle, but setiting on if one ore more are heating. It is relay witch setting furnace on or off. How can I do it? In Domoticz I just made simple blockly but have no idea how to do it in HASS.

In HA this functionality is called a group