Opening light based on location change (based on time) and door locks

Hi everyone :slightly_smiling_face: I hope you’re all doing good!
I’m trying to create an automation that will open some lights inside my house when I get home and unlock my front door. TO be more specific, I only want to open some lights if both my wife and I gets home (Wife/Me : Any Zone / Not Home → Home) or if one of us arrives home and the other person isn’t there (Me: Any Zone / Not Home → Home, Wife not Home OR Wife : Any Zone / Not Home → Home Me not home). I thought about adding a condition when I unlock my front door and check who’s home, but I’d also love to use the zone change because I don’t want to open the light only based on unlocking the door if we’re already home. The thing is, I’m assuming it will detect that I’m home before I get to my door, which means the timing is an issue.
Do you have an idea on how I can implement something like:

if ((Wife and I / Wife without Me / Me without Wife) arrived home now or in the last 5 mins && door unlock)
{
    turn lights on
} 

It seems easy to do, but I don’t know if there’s a mechanism already in place to start a timer when I arrive in the “Home” zone and verify it’s state when I unlock my door.

I’d really appreciate some help!

Thanks.