Java Runtime Environment: compliant with OH2.4 update
openHAB version: 2.4
Issue of the topic:
Hello Everyone,
Let’s start laughing…my cat loves ham and he can open the fridge to steel it! But he don’t close the door!
I placed a Xiaomi Aqara contact in the fridge door and I need a rule that warns me by broadcast notification to OH app, that the fidge door is opened more then 2 minutes.
I have read a lot of posts but nothing works well… can someone help me writing a rule for this?
var Timer tDoorAlarm = null
rule "door alarm"
when
Item MyDoorContact changed
then
if(MyDoorContact.state == OPEN)
if(tDoorAlarm === null)
tDoorAlarm = createTimer(now.plusMinutes(2), [|
// sendMail("mail@address", "Fridge Alarm!", "Fridge door is open since two minutes..." )
])
else {
tDoorAlarm?.cancel
tDoorAlarm = null
}
end
Of course you can do other forms of notification, sendMail is just an example of how to do it.
What’s really needed is a lock bar which can’t be opened by the cat, but that’s another thing
Would be nice to implement it with an ID3 Tag, installed to the collar of the cat, so the fridge is locked whenever the cat comes near… never do it low tech when there is a high tech option
The mechanism from a chip reading catflap, no collar needed. You could get the kids chipped as well, work out a timed permission schedule.
It’ll all go wrong when the cat figures out how to coerce the kid, though.
Thank you so much Udo.
It’s working but now I have a new problem: everytime we open the fridge, I receive a notification, even when is open and close in a few seconds. How I cancel the timer if the door is open less then 2 minutes?