Hello to you all.
I am using OpenHab some years now and I am having great success.
The one thing I struggle a little bit is presence. The way I have set it up now is:
When a physical button is pressed (to open a light of a fan or whatever) or a PIR sensor is activated the presence is set to ON and with the expire binding set to 20mins. Even the pets do not set off the PIRs since they are high on and detect only human movement. Anyway It works exactly as planed except at night. At night there are times that we don’t move for enough time so the PIRs won’t catch a movement and presence will then be set to OFF after 20 mins. It happens 1-2 times every night
So, my Idea is as follows.
Tie the presence detection with the doors opening and closing.
Example 1: Door opens and then closes, person comes in and PIR sensors trigger so ->Presence is set to ON
Example 2: Door opens and then closes, and presence is already set to ON but for the next 5 min no PIRs or physical button fire up, so we deduce that the person has left and thus set presence OFF
Example 3: Presence is ON but there is no movement detected for the last 20 minutes. Also no doors opened in that time frame so no one could have left the house, so we deduce that they are standing still or sleeping so we leave presence set to ON until time comes that a door opens again.
Any idea how to implement this in rules?
Hopefully, all this makes sense.
Switch Presence "Someone is Present" <present> { expire="30m,command=OFF" }// master presence switch, represents to the rest of OH where someone is home
Group:Switch:AND(OFF,ON) gPresence_Sensors <present> // all presence sensors belong to this group
rule "Presence detect"
when
Member of gPresence_Sensors changed
then
var numberOfPresses = triggeringItem.state.toString()
switch(numberOfPresses) {
case "NULL": {return;}
case "HOLD": {Presence.sendCommand(ON)}
case "SINGLE": {Presence.sendCommand(ON)}
case "DOUBLE": {Presence.sendCommand(ON)}
case "TRIPLE": {Presence.sendCommand(ON)}
case "QUAD": {Presence.sendCommand(ON)}
case "PENTA": {Presence.sendCommand(ON)}
case "OPEN": {Presence.sendCommand(ON)}
case "ON": {Presence.sendCommand(ON)}
default :{ }
}
end