Limit how often a rule can be run

OK, but what if for some reason the second phone isn’t updated in that 30 seconds?

timer = createTimer(now.plusSeconds30) [ | 
    // do stuff after 30 seconds
    timer = null
])
if(timer != null) // skip rule bcause there is already a Timer

Honestly, this Rule is already way overly complex IMHO. I would suggest breaking it up quite a bit.

  1. Put the top part of your current Presence rule in a rule and sendCommand to the IsHome Items based on the distance threshold. End of this Rule.
rule "Process Phone Location"
when
    Item MaciejsLocation changed or
    Item PatrycjasLocation changed
then
   // Distance calculation
    var PointType maciejsiPhoneLocation = new PointType(MaciejsLocation.state.toString)
    var maciejDistance = maciejsiPhoneLocation.distanceFrom(new PointType(Home.state.toString))
    MaciejIsHome.sendCommand(if(maciejDistance > distanceThreshold) OFF else ON)

    var PointType patrycjasiPhoneLocation = new PointType(PatrycjasLocation.state.toString)
    var patrycjaDistance = patrycjasiPhoneLocation.distanceFrom(new PointType(Home.state.toString))
    PatrycjaIsHome.sendCommand(if(patrycjaDistance > distanceThreshold) OFF else ON)
end
  1. Use Generic Presence Detection. Set the Present_Timer to 30 seconds instead of 5 minutes.

  2. Trigger a Rule based on Present receiving a command where you do your came/left logic

rule "Presence"
when
    Item Present received command
then

    // Everyone Left
    if(receivedCommand == OFF){
        HarmonyLivingRoomCurrentActivity.sendCommand("PowerOff")
        PlexLivingRoomPause.sendCommand(ON)
        // TODO: Turn off lights
        // TODO: Start Neato Botvac

        logInfo("iphone.rules", "Everybody left Home")
        pushNotification("", "Everybody left Home!")
    }

    // Everone came home in the last 30 seconds
    else if(MaciejIsHome.state == ON && PatrycjaIsHome.state == ON){
        // TODO: Turn on lights
        // TODO: Dock Neato Botvac
        logInfo("iphone.rules", "Everybody came Home now")
        pushNotification("", "Everybody came Home now!")
    }

    // Someone came home to the other, required Persistence
    else if(MaciejIsHome.lastUpdate.isAfter(now.minusSeconds(30) || PatrycjaIsHome.lastUpdate.isAfter(now.minusSeconds(30)) {
        // Actions TBD
        logInfo("iphone.rules", "Everybody is Home now")
    }

    // Somebody comes home to an empty house
    else {
        // TODO: Turn on lights
        // TODO: Dock Neato Botvac
        logInfo("iphone.rules", "Someone came Home now")
        pushNotification("", "Someone came Home now!")
    }
end

By separating the behaviors like this the rules become much simpler and easier to read, reason about, and understand. You can use MapDB for the persistence for this so you don’t have to worry about setting up anything complex or that will grow over time.

The above does exactly what you are after (i.e. will not execute the rule that does stuff until 30 seconds after the first person comes home or everyone leaves) plus it gives you a single Present Item you can use in your other Rules if desired and it lets you transparently add more presence sensors without needing to change the rules.

Since most of the behavior that you do when one person comes home verses both people except for your log statement and alert I recommend only writing that logic once and use a lambda or restructure your if/else statements to you don’t have duplicate code.