added presence detection

This commit is contained in:
2017-11-13 09:05:08 +01:00
commit d42317e342
6 changed files with 218 additions and 0 deletions

59
presence/presence.rules Normal file
View File

@@ -0,0 +1,59 @@
rule "Presence Person1 online"
when
Item Smartphone1_Fritzbox received command ON or
Item Smartphone1_DDWRT1 received command ON or
Item Smartphone1_DDWRT2 received command ON
then
postUpdate(Presence_Person1, ON)
end
rule "Presence Person1 offline"
when
Item Smartphone1_Fritzbox received command OFF or
Item Smartphone1_DDWRT1 received command OFF or
Item Smartphone1_DDWRT2 received command OFF
then
Thread::sleep(180000) // Warte 3 Minuten
if (Smartphone1_Fritzbox.state==OFF && Smartphone1_DDWRT1.state==OFF && Smartphone1_DDWRT2.state==OFF) {
postUpdate(Presence_Person1, OFF)
}
end
rule "Presence Person2 online"
when
Item Smartphone2_Fritzbox received command ON or
Item Smartphone2_DDWRT1 received command ON or
Item Smartphone2_DDWRT2 received command ON
then
postUpdate(Presence_Person2, ON)
end
rule "Presence Person2 offline"
when
Item Smartphone2_Fritzbox received command OFF or
Item Smartphone2_DDWRT1 received command OFF or
Item Smartphone2_DDWRT2 received command OFF
then
Thread::sleep(180000) // wait for 3 minutes
if (Smartphone2_Fritzbox.state==OFF && Smartphone2_DDWRT1.state==OFF && Smartphone2_DDWRT2.state==OFF) {
postUpdate(Presence_Person2, OFF)
}
end
rule "Presence Overall online"
when
Item Presence_Person1 changed to ON or
Item Presence_Person2 changed to ON
then
postUpdate(Presence_Overall, ON)
end
rule "Presence Overall offline"
when
Item Presence_Person1 changed to OFF or
Item Presence_Person2 changed to OFF
then
if (Presence_Person1.state==OFF && Presence_Person2.state==OFF) {
postUpdate(Presence_Overall, OFF)
}
end