[Solved] iCloud Presence Turn on outside light

First off all, please use code fences.

The delay is caused by the binding. You can force the refresh to get the actual location.

There are two ways to prevent the rule turning the light on again. I suggest, 5 minutes is the refresh time of the iCloud binding. So your second rule also turns on the light every 5 minutes. So you can either split the rule in two or change your existing rule a little bit:

rule “Chase_iPhone Home”
when
Item Chase_iPhone_Location changed
then
// specify your home location 1.000 lat 2000 long
// Didn’t want any of you guys seeing where I actually live :slight_smile:
val PointType home_location = new PointType(new DecimalType(1.0000), new DecimalType(2.000))
val PointType phone_location = Chase_iPhone_Location.state as PointType
val int distance = phone_location.distanceFrom(home_location).intValue()
// specify your preferred radius (in meters)
if ( distance < 1000) {
     if(Chase_iPhone_Home != ON){
         Chase_iPhone_Home.postUpdate(ON)
         logInfo(“iPhone Home”, “Chase’s iPhone is at home.”)
         if (sunset == true){
            sendCommand(PorchLight, ON)
            sendCommand(LED_Power,ON)
            Light_Color.sendCommand(“1,0,100”) // White
         }
    }
}
else
{
Chase_iPhone_Home.postUpdate(OFF)
logInfo(“iPhone Home”, “Chase’s iPhone is away.”)
}
end

or two rules

rule “Chase_iPhone Home”
when
Item Chase_iPhone_Location changed
then
// specify your home location 1.000 lat 2000 long
// Didn’t want any of you guys seeing where I actually live :slight_smile:
val PointType home_location = new PointType(new DecimalType(1.0000), new DecimalType(2.000))
val PointType phone_location = Chase_iPhone_Location.state as PointType
val int distance = phone_location.distanceFrom(home_location).intValue()
// specify your preferred radius (in meters)
if ( distance < 1000){
    Chase_iPhone_Home.postUpdate(ON)
} else {
Chase_iPhone_Home.postUpdate(OFF)
logInfo(“iPhone Home”, “Chase’s iPhone is away.”)
}
end
rule “Chase_iPhone Home Lights on”
when
Item Chase_iPhone_Home changed to ON
then
if (sunset == true){
    sendCommand(PorchLight, ON)
    sendCommand(LED_Power,ON)
    Light_Color.sendCommand(“1,0,100”) // White
}
end
1 Like