Hi,
I want to set check who is at home by triple checking
- ping to phone
- with region trigger from own tracks
- location from iCloud
if any of the three is ON then the person is in the house, if all of the above is OFF then the person is not in the house
and I want that on the sitemap I will able to see who is in the house and send notification one that person arrive or leave the house
I have copy from the community here some items and rules file that seems to me that can help
I need help to modify it to my need and is possible to clarify the logic behind the rule
thanks a lot for your help
items:
Group:Switch:OR(ON, OFF) Presence (Persist)
Group gPresence (Persist)
Group:Switch:OR(OFF, ON) gPresence_Barak (gPresence)
Group:Switch:OR(OFF, ON) gPresence_Almog (gPresence)
Switch Presence_Barak "Barak [MAP(presence.map):%s]" <parents> (Presence)
Switch Presence_Almog "Almog [MAP(presence.map):%s]" <parents> (Presence)
//Pings
Switch Presence_Barak_PhoneWifiHome (gPresence_Barak) { channel="network:pingdevice:4d7798cd:online" }
Switch Presence_Almog_PhoneWifiHome (gPresence_Almog) { channel="network:pingdevice:192_168_0_6:online" }
//iCloud
Location Presence_Barak_iCloud (gPresence_Barak){channel="icloud:device:8389ea07:d7b5aab3:location"}
//Owntracks
Switch Presence_Barak_Owntracks (gPresence_Barak) { channel="gpstracker:tracker:3983d18f:regionTrigger" [profile="gpstracker:trigger-geofence", regionName="Home"] }
Switch Presence_Almog_Owntracks (gPresence_Almog) { channel="gpstracker:tracker:??:regionTrigger" [profile="gpstracker:trigger-geofence", regionName="Home"] }
rules
rule "gPresence Item updated"
when
Member of gPresence changed
then
sendNotification("michaelibarak@gmail.com", "Member of gPresence changed")
val state = triggeringItem.state.toString // to force item update
val name = triggeringItem.name.split("_").get(1)
var timerString = "Presence_" + name + "_Timer"
val SwitchItem presenceItem = Presence.members.filter[ i | i.name.contains(name) ].head as SwitchItem
if (state == "ON") {
postUpdate(timerString, "OFF") // cancel the timer if necessary
if (presenceItem.state != ON) {
sendCommand(presenceItem.name, "ON")
}
}
// Not at home
if (state == "OFF" && presenceItem.state != OFF) {
sendCommand(timerString, "ON") // start the timer
}
end
rule "Presence Timer expired"
when
Item Presence_Barak_Timer received command OFF or
Item Presence_Almog_Timer received command OFF
then
var String itemName = triggeringItem.name.split("_").get(0) + "_" + triggeringItem.name.split("_").get(1)
postUpdate(itemName, "OFF")
//Presence_Barak.postUpdate(OFF)
end
sitemap:
sitemap default label="Home" {
Frame {
Text item=gGF label="Ground Floor" icon="groundfloor"{
Text item=GF_Living label="Living Room" icon="sofa" {
Frame label="Reciver"{
Switch item=VSX923_Zone1Power
Switch item=VSX923_Zone1SetInputSource mappings=[06="Yes", 15="AppleTV", 22="PlayStation"] visibility=[ VSX923_Zone1Power==ON]
Slider item=VSX923_Zone1VolumeDimmer visibility=[ VSX923_Zone1Power==ON]
Setpoint item=VSX923_Zone1VolumeDb minValue=-80 maxValue=0 step=1 visibility=[ VSX923_Zone1Power==ON]
Switch item=VSX923_Zone1Mute mappings=[ON="Mute", OFF="Un-Mute"] visibility=[ VSX923_Zone1Power==ON]
}
}
}
Text item=gFF label="First Floor" icon="firstfloor"
Text item=Garden icon="garden"
}
Frame label="Weather" {
Text item=CurrentCondition
Text item=Weather_Temperature
Text item=CurrentHumidity
Text item=CurrentWindSpeed
Text item=CurrentRain
Text item=Sunrise_Time
Text item=Sunset_Time
}
Frame label="Who Is At Home ?" {
?????
}
}