Arbeitsweise wie folgt:
Es laufen 4 Sensoren für die Erkennung: zwei lokale mittels Wifi, zwei "Area Sensoren" (ca. 500 m um die Whg / Haus herum)
Ist kein Sensor aktiv läuft ein Timer an, Hauptstatus gpresent ist OFF.
Ist ein Sensor aktiv wird der jeweilige Timer ausgeschaltet, der Hauptstatus "gpresent" wird auf ON gesetzt
Vorbereitung:
1. IFTTT Konto erstellen und anmelden
1a. In IFTTT zwei Widget's anlegen: eines "Verlassen der Area" und eines "Betreten der Area". Beide arbeiten mit iOS "Location"
Manage Applets - IFTTT.png
Turn Presence on when entering your home area - IFTTT.png
2. IFTTT App auf Handy installieren und Konto konfigurieren, Abfragen durch iOS zulassen
3. OpenHAB Cloud Service einrichten (lokal auf deinem Server)
Du musst die beiden Schalter "Person1_loc und Person2_Loc (hier im Bild mit "Alex_Loc" bezeichnet) in die OH Cloud Config eintragen.
Paper UI.png
4. Auf myopenhab.org anmelden und Applikation IFTTT zulassen
--> siehe nächsten Kommentar, sieht so aus als ob man nur 3 Screenshots in einen Kommentar schreiben darf (Kann man das ändern?= Eher lästig, oder?)
presense_detection.items:
Code: Alles auswählen
// IFTTT Detection using Location
// presense Detection using Wifi only is not working good enough therefore IFTTT Applet in addition
// Optionally one can create additional groups to aggregate all the sensors for
// each person if that matters to you, but the sensors need to all be members of
// gPresent as well
Switch Present "Jemand zuhause" <present> // Master presence switch
Group:Switch:AND(OFF,ON) gPresent <present> (Whg) // all presence sensors belong to this group
Switch Present_Timer { expire="3m,command=OFF" }
Group:Switch:AND(OFF,ON) gPerson1Present <present>
Switch Person1_Present "Person1" <present> // Master Person1 present switch
Switch Person1_Present_Timer { expire="2m,command=OFF" }
Group:Switch:AND(OFF,ON) gPerson2Present <present>
Switch Person2_Present "Person2" <present> // Master Person2 present switch
Switch Person2_Present_Timer { expire="2m,command=OFF" }
Switch Person1_iphone "Person1 iPhone" (gPresent,gPerson1Present) {fritzboxtr064="maconline:11-22-33-44-55-66"}
Switch Person1_Loc "Person1 Area" (gPresent,gPerson1Present)
Switch Person2_iphone "Person2 iPhone" (gPresent,gPerson2Present) {fritzboxtr064="maconline:11-22-33-44-55-66"}
Switch Person2_Loc "Person2 Area" (gPresent,gPerson2Present)
presense_detection.rules
Code: Alles auswählen
import org.eclipse.xtext.xbase.lib.Functions
val String filename = "presense_mobiles.rules"
val Functions$Function3 <GroupItem, SwitchItem, SwitchItem, Boolean> processPresence = [grp, sw, timer |
// someone came home
if(gPresent.state == ON && Present.state != ON) {
Present_Timer.postUpdate(OFF) // cancel the timer if necessary
Present.sendCommand(ON)
//sendBroadcastNotification(sw.label + " returned home")
}
// nobody at home
else if(gPresent.state == OFF && Present.state != OFF) {
Present_Timer.sendCommand(ON) // start the timer
}
true
]
val Functions$Function1 <SwitchItem, Boolean> processTimer = [sw |
Present.sendCommand(OFF)
//sendBroadcastNotification(sw.label + " has left home")
true
]
rule "System started"
when
System started
then
// assume no one is home on startup
Present.sendCommand(OFF)
Person1_Present.sendCommand(OFF)
Person2_Present.sendCommand(OFF)
Person1_Loc.sendCommand(OFF)
Person2_Loc.sendCommand(OFF)
end
rule "gPresent updated, at least one sensor changed state"
when
Item gPresent received update
then
processPresence.apply(gPresent, Present, Present_Timer )
end
rule "gMPerson1Present updated, at least one sensor changed state"
when
Item gPerson1Present received update
then
processPresence.apply(gPerson1Present, Person1_Present, Person1_Present_Timer )
end
rule "gPerson2Present updated, at least one sensor changed state"
when
Item gPerson2Present received update
then
processPresence.apply(gPerson2Present, Person2_Present, Person2_Present_Timer )
end
rule "Present_Timer expired"
when
Item Present_Timer received command OFF
then
processTimer.apply(Present)
end
rule "Person1_Present_Timer expired"
when
Item Person1_Present_Timer received command OFF
then
processTimer.apply(Person1_Present)
end
rule "Person2_Present_Timer expired"
when
Item Person2_Present_Timer received command OFF
then
processTimer.apply(Person2_Present)
end