Combining a binary sensor with presence

Recently started using Home assistant under Docker on a QNAP Nas.

A driver for doing so was to make heating (controlled by Tado) more efficient, namely if certain rooms have windows/doors open then cut the heating in there until they close.

In addition to this, I’d like to kill room heating based on whether certain occupants are home or not. EG if son/daughter are out of the house then no need to heat their rooms etc.

I’ve got a basic set of automations (leveraging Tapo door sensors) in place which works nicely. Each room has a helper entity which groups the door/window sensors so automations can be created against that helper, rather than having to explicitly list all the sensors one by one. Idea being if one device is open, the heating will be killed. Only when all are closed will it be restored.

My question however is this.

To simplify the automations when using presence as well, is there a way to create a virtual sensor that:

Returns false/open if the associated occupant has left or
If any windows/doors are open , also returns false/open.

So the sensor should only return true/closed if the occupant is home and all windows etc are closed.

Otherwise I have to add additional conditions in the automations which is feasible, but this seems like a good approach to abstract that away (and also prevent duplicating logic in multiple automations).

Create a template sensor, here are some examples: