Piston for arrival and iPhone presence

I am having a hard time coding exactly what I want. Also not a cider at all.

What I want to accomplish is:
I have 2 iPhones set up as presence sensors as well as 2 arrival sensors. iPhone and arrival sensor for me and another set for my partner.
My partner doesn’t drive a lot, so his keys and arrival sensor are often left at home, while his phone is always with him.

My thought process is to make 2 pistons,

  1. Using our iPhones and arrival sensors to set the mode from home to away.
    So using all 4 devices to make mode change.
    Example:
    -if my arrival sensor leaves, as well as my phone, mode stay as home
    -If my arrival sensor, my phone and his phone, mode changes to away.
    -If my arrival sensor, my phone, his phone and his arrival sensor leaves, change to away.
    -If any arrival sensor returns, change mode to home

  2. If status changes From away to home, run welcome home automation
    If status change from home to away, run goodbye home automation.

But also :
-if my arrival sensor and iPhone leave, and his are home, lock front door
-if my arrival sensor arrives, unlock front door
-same 2 ifs as above for him

I’m having a hard time thinking about how to lay this out, run smooth, without a bunch of bloat.

Any ideas to point me in the right direction, or better yet, any one have a Similar piston I could use and modify?

Thanks in advance for any help!

You may want to create virtual presence sensors to simply things. That will ease the pain when you discover your multitude of sensors arriving/departing at various times and causing havoc with your rules. Not fun, when one presence sensor arrives and your door unlocks and the second sensor registers as arriving 10 minutes later to unlock your door again.