OpenHAB: Using notification services

In the past I often used Email as a way to notify me whenever something happens in my home automation. At first this seemed like a good idea: No extra app needed, I could receive notifications on mobile phone and desktop and even the wife-factor wasn’t very high – she’s using email anyways.

However I stumbled upon unforeseen issues, especially after the update to OpenHAB2:

  • Emails were automatically put into my spam folder, since the text never changes
  • I used my GMail account to send the mails, which forced me to allow unsecure apps
  • Since I used my GMail account, messages sent by OpenHAB were always handled as “Sent”. My wife was getting notifications, but I did not
  • In the past I used a GMX account instead, but this service was not as reliable as GMail
  • Google put my mails into some sort of automatic spam filter, which prevented OpenHAB from sending any emails

Of course I could solve all these problems, and most of them I have. But I was never really satisfied and recently looked for an alternative. I looked into the following services, but found some disqualifying issues:

  • Notify my Android: This app has a lot of bad reviews lately. There is a premium service, but even that seems to be unreliable
  • Prowl: I heard a bit about this service, but it seems as if there is no built-in Android support
  • Pushover: This service looks really nice by looking at their homepage. But a premium subscription is needed to use it. I do not mind paying for a good service, but if there’s a free alternative available I see no reason to use the paid one
  • Twitter: Seems not to be a good idea to have notifications publicly available. I also really don’t like their Android App

In the end I went with Telegram. Telegram is a messaging app like Whatsapp or Threema, but with a major twist: It is possible to define your own bots, these are then usable via an API. I really like the concept and can see this being really useful. Another cool thing about Telegram is that it is available for every platform, not just mobile. Whatsapp and Threema provide this too, but by connecting via the phone. The Telegram web client connects directly to their servers instead of routing via the App. Overall I really like what I’ve seen so far, bummer that all my contacts are using Whatsapp and Threema.

I configured it the following way:

  • Activate Telegram via
    Habmin/Config/Extensions/Actions
  • Create a Telegram Bot by following these steps
  • Open a chat with the bot and write a message
  • Request the latest updates by querying
    api.telegram.org/botKEY/getUpdates
  • Open the service config in
    services/telegram.cfg
  • Put the id from the getUpdates call as chatId
    result.message.from.id
  • Put the key into the token attribute

My config looks like the following:

bots=stettiner
stettiner.chatId=12345678
stettiner.token=9999999999:AAABBBCCCDDDEEEFFF

It is then possible to write via the configured bot by using

sendTelegram("stettiner", "This is a test notification!")

The notifications appear on the phone instantly. Cool thing is that it is possible to set the chatId of a group chat, so I have my wife and me in the same group and the bot notifies us.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s