Are you trying to write your own app in groovy, or would a RM rule do what you want?
One rule to turn on a virtual switch when someone comes home, then turn it off 10 minutes later. Another rule to say when virtual switch is on do this, else do that.
One way to do it is to simply have your App subscribe to the presence events from the various sensors. When the App is notified of a change in presence, have it store the Date/Time into a State Variable. That way you always have the latest time that it changed without having to interrogate the device.
Last activity could be a nice way to quickly look at devices that are possibly offline. A nice visual quick glance. Green for online, Yellow to indicate offline for x period, and Red for period expired, device is offline.