Trying to create automations based on room occupancies for HVAC

I am trying to create some HVAC automations but I am not 100% clear on how to solve a couple problems. Maybe someone here has done this or can help me.

Scenario:

I have Ecobee smart sensors in 3 rooms upstairs and 3 rooms downstairs.

I have Zigbee dampers in my HVAC ducts, 1 for upstairs air supply and one for downstairs air supply.

Depending on occupancy I want to open the damper for the level that is occupied by someone and the damper closer for the cleared level.
This way I supply more air to the areas that I need it in. (Don’t worry I checked and verified back pressure / load in the two ducts)

Problem 1 : One air damper always has to be open. I can’t have both be closed at any time simultaneously.

Problem 2 : The Ecobee sensors switch to “Clear” at night when we sleep and we don’t move, causing the upstairs damper to close. The downstairs
damper is closed because there is nobody there. => problem 1

My automation is currently doing exactly what it is supposed to do. I am trying to prevent Problem 1 from happening.
The ecobee sensors take about 5 minutes to switch to “Occupied” and about 30 minutes to switch back to “Clear” so these things don’t constantly
switch back and forth.

Is there a way I could set “flags” and or “last switch state” to for example keep the upstairs damper open when one of the rooms are occupied but
remain “Occupied” until a downstairs room becomes “Occupied” even though all three upstairs switches have changed to “Clear” (people sleeping)

Am I making this too complicated or missing something ?

PS: I am fairly new to HA.

Can you post the YAML code for your automation(s).

What are you using for a trigger(s) now?

Since 1 has to be open at all times; what is the logic there if no one is home? Do you want a specific one left open?

Why dont you just focus your automation on opening and closing the downstairs one when any of the sensors detect occupancy and always have the upstairs damper do the opposite to downstairs?

The logic here is that I can’t have both dampers closed as that would put too much back pressure on the blower motor. It would eventually damage the furnace.

When nobody is home the comfort settings of the Thermostat are higher and since the Thermostat is on the lower level I only want to supply air to the lower level to satisfy the Thermostat.

See, that’s why I ask here since many times it is just a simple solution. I sometimes can’t see the forest for the trees. This was one of those times lol.

Thanks !!!

But what if both levels are occupied? Both dampers should be open. But if the upstairs damper always does the opposite this couldn’t work ?