iCloud binding with multiple phone rules optimization help!

Look at Design Pattern: Working with Groups in Rules.

There might be some useful info in Generic Presence Detection.

But one thing you will run into I suspect is that in order to write good Rules that don’t require changing them to add new phones, you will need to get a bit of understanding for Rules.

At a high level, put all the location Items in a Group:Location Group.
Trigger the Rule with Member of PhoneLocations changed
Use a map/reduce to get the phone distance that is furthest from home. Then update and log as approraite.

val PointType home_location = new PointType(new DecimalType(xx.05135920063), new DecimalType(xx.6613793811))

rule "allPhone_Rules"
when
    Member of PhoneLocations changed
then
    val furthest = PhoneLocations.members.map[ state as PointType].reduce[max=0, phone |
        distance = phone.distanceFrom(home_location)
        if(distance > max) max = distance
    ] 
    if(furthest < 200) {
        iCloud_Group.postUpdate(ON)
        logInfo("allPhone", "home!")
    }
    else {
        iCloud_Grouop.postUpdate(OFF)
        logInfo("allPhone", "away!")
    }    
end

I’m not 100% certain I have the syntax right on the map/reduce but it should be pretty close.