HowTo: Christmas Cookie Alert - Catching the "Weihnachtsmaus"

Some Christmas fun …

Every year the same trouble:
You prepare cookies and sweets for Christmas, hide them well, but when it´s time to
proudly present them, someone (in Germany its called “Die Weihnachtsmaus”) has already
eaten them.
As a (more or less) skilled openHAB user you come up with a solution to prevent this
cookie draining once and for all.

So I put on my ugly Christmas sweater to come into the mood and put this together within
some minutes. As it requires no hardware hacking it´s quite simple to follow if you know how to install a binding, create items and set up rules.

What your need (or what I used as it was available):

  • Hue Motion Sensor
  • Amazon Alexa
  • Telegram Client

So obviously you have to install the Philips Hue Binding, Amazon Echo Control binding and the
Telegram action.

Follow the steps described in each of the bindings to connect your Echo and the Hue sensor
to openHAB, but I guess you already did this if you own the devices.
Then create a bot in Telegram, again check the manual of the Telegram action about the
steps required. I named my bot simply “bot1”

Create items for the following channels (Proper channel id to be found at the Things Channel in paper UI) in a
items file. I used an Echo Show, but this works with other echos as well.

//Echo channels (just the TTS and the alarm channel)
String Echo_TTS  "Text to Speech {channel="amazonechocontrol:echoshow:xxxxxxxx:XXXXXXXXXXXXXXXX:textToSpeech"}
String Echo_PlayAlarmSound  "Play Alarm Sound {channel="amazonechocontrol:echoshow:yyyyyyyy:YYYYYYYYYYYYYYYY:playAlarmSound"}
//Hue channel (Presence sensor)
Switch CookieAlarm "Cookie Alarm" {channel="hue:zzzz:zzzzzzzzzzzz:z:presence"}

Now create a simple rule in a .rules file:

var Timer stopAlarmTimer = null
rule "CookieAlert"
when
	Item CookieAlarm changed from OFF to ON
then
	sendTelegram("bot1", "!!! Cookie Alert !!!!")
	Echo_TTS.sendCommand('Stay away from the cookies!')
	Echo_PlayAlarmSound.sendCommand('ECHO:system_alerts_repetitive01')
    if (stopAlarmTimer === null)
    {
        stopAlarmTimer = createTimer(now.plusSeconds(10)) [|
            stopAlarmTimer.cancel()
            stopAlarmTimer = null
            Echo_PlayAlarmSound.sendCommand('')            
        ]
    }
end

Now, as the final part, put the motion sensor into the cupboard or box where you store
your treasure - make sure to have the sensor facing towards the door or the top of the box.
Maybe its better not to use a tin box as it may block the sensors radio.
Close the box.

From now on whenever someone opens the box your Echo will start screaming and you will
be informed on Telegram that the “Weihnachtsmaus” tries to allocate its share.

We had massive fun when our youngest child secretly tried to get away with some cookies
and the alarm went off. The face she made was priceless. (Nevertheless she was allowed to
pick some :slight_smile: )

Feel free to enhance this e.g. by taking a picture of the thief, flashing lights etc. Of course it can be put together for much less money e.g. using an ESP or an Arduino, but as I said those parts were already available and it was a quick win…

Merry Christmas and lots of cookies to all of you !
Oggerschummer

11 Likes