Thanks to Rich, I have a working presense system that I’d like to build on. The intention is when presence is set to ON, turn on a series of lights. This is to ensure the house is lite when its dark.
The intention though is to use a timer, so that this only occurs legitimately when you’ve been away, for say 60minutes and when its night. I can use the time of day checks for night, but the timer is the confusing one.
The theory was:
when item gPesenceScd .ensors changed to ON
if = greater than 60minutes && vTimeOfDay.state !=Day
then
turn on lights.
Has anyone got something working that’s similar for the timer component? Or potentially a smarter way to avoid false positives.
Hi,
for the timer you need to use a persistance for the item gPresence and than the command in a rule :
if !(gPresence.changedSince(now.minusMinutes(60)) && …)
Regards
Lorenzo
Another way would be to create a new Item. Set the Item to ON when presence turns ON. Then use the Expire binding to turn it back OFF after 60 minutes. In your Rule you just need to check whether that Item is ON or OFF to know whether 60 minutes has expired (if it’s ON, it’s been less than 60 minutes).
Yes. Just want to avoid false positives but I cant imagine that would ever happen with a 60minute timer! ill give it a whirl. Unforunately theres no smart lock or other device to trigger entrance.
The changes i’ve made. I feel im missing something. Once its on, wont it just switch off after 60minutes? I only want it switched off, if presence changes to off ie: thats when the 60minute timer starts.
The new Switch item is called
Presence_Arrival
ITEMS:
Switch Presence_Arrival { expire="60m,command=OFF" } // Timer for the arrival scene
NEW RULE:
rule "Turn on arrival lights when guests arrive home after being out for 60minutes"
when
Item gPresenceSensors changed to ON
then
if (Presence_Arrival.state == OFF && vTimeOfDay.state != "DAY"){
Bird_Light.sendCommand(ON)
WallPendant_Light.sendCommand(ON)
FrontDoor_Light.sendCommand(ON)
}
end
And the updated rule that sets the new Switch on, when presence is on.
rule "A presence sensor updated"
when
Item gPresenceSensors changed
then
if(Presence_Timer.state == ON && gPresenceSensors.state == Presence.state) {
logInfo("Presense", "Timer is running but group and proxy are the same, cancelling timer")
Presence_Timer.postUpdate(OFF)
}
else if(gPresenceSensors.state == Presence.state) {
logInfo("Presense", "No timer and both group and proxy are the same, nothing to do")
return;
}
if(gPresenceSensors.state == OFF) {
logInfo("Presense", "Everyone is away, setting anti-flapping timer")
Presence_Timer.sendCommand(ON)
}
else if(gPresenceSensors.state == ON) {
logInfo("Presense", "Someone came home, setting presence to ON")
Presence.sendCommand(ON)
Presence_Arrival.sendCommand(ON)
}
end
Nothing stands out. Is gPresenceSensors changing a lot? Every time you sendCommand to Presence_Arrival the 60 minute timer gets reset. It will only go to OFF 60 minutes after the last time it receives an ON command.