Friday, April 15, 2016

Using Cisco Spark as notification channel for Openhab

Notify from Openhab using Cisco Spark

I'm using Openhab for my home automation for a couple years now and am very happy with it.  One of the things it can do it notify you on various events around the house.  I had XMPP configured to send messages to my Google account, but the last months this has been failing.  Some error about pinning certificates.  There's some information on the internet about how to solve this, but I'm using a Google account with a custom DNS name which seems to complicate matters a bit.

Since Cisco added APIs to the Cisco Spark service (try it!!), I wanted to use Spark instead for my notifications.  The proper way of integration with Openhab is to develop an Openhab plugin, but I wanted something more versatile. So I started the development of a CLI interface for Spark: sparkcli.  Let's get going!

Install and configure sparkcli

First download a copy of sparkcli here: .  Make sure the binary is on the PATH for the OS user that's running Openhab.  Typically /usr/local/bin will do just fine.

Once downloaded, following the configuration instructions here: https://github.com/tdeckers/sparkcli
In short these are the steps you'll follow:

  1. Set up Cisco Spark developer account and configure an app
  2. Go through the OAuh authorization process
  3. Create a configuration file.  Note: easiest is if you create this in the home directory of the OS user that's running Openhab.
  4. Login once using sparkcli to get access tokens.
That's it.

Use sparkcli in Openhab rules

Now you can use this in any rule that you define in Openhab.

rule "Notify alarm"
when
  Item o_alarmFull changed
then
  if (o_alarmFull.state == ON) {
    //sendXMPP("you@yourplace.com", "Alarm aan")
    executeCommandLine("sparkcli@@m@@create@@-@@Alarm@@aan")
  } else {
    executeCommandLine("sparkcli@@m@@create@@-@@Alarm@@uit")
  }
end

Openhab has some weird syntax about spaces in command lines, but it works.

Later!

I might get around building a proper Cisco Spark plugin for Openhab, so stay tuned!

4 comments:

  1. I’m going to mosey on over to your blog and take a look under the hood. I’m sure it will be as good as this post.Absolutely great post here. It has a lot of key elements that truly makes it work.
    XMPP

    ReplyDelete
  2. This is a very Nice Blog Thank you For sharing.
    Devops

    ReplyDelete
  3. AWS Training in Bangalore - Live Online & Classroom
    myTectra Amazon Web Services (AWS) certification training helps you to gain real time hands on experience on AWS. myTectra offers AWS training in Bangalore using classroom and AWS Online Training globally. AWS Training at myTectra delivered by the experienced professional who has atleast 4 years of relavent AWS experince and overall 8-15 years of IT experience. myTectra Offers AWS Training since 2013 and retained the positions of Top AWS Training Company in Bangalore and India.

    IOT Training in Bangalore - Live Online & Classroom
    IOT Training course observes iot as the platform for networking of different devices on the internet and their inter related communication. Reading data through the sensors and processing it with applications sitting in the cloud and thereafter passing the processed data to generate different kind of output is the motive of the complete curricula. Students are made to understand the type of input devices and communications among the devices in a wireless media.

    ReplyDelete
  4. Hadoop concepts, Applying modelling through R programming using Machine learning algorithms and illustrate impeccable Data Visualization by leveraging on 'R' capabilities.With companies across industries striving to bring their research and analysis (R&A) departments up to speed, the demand for qualified data scientists is rising.
    data science training in bangalore
    Big Data and Hadoop training Unlike traditional systems, Big Data and Hadoop enables multiple types of analytic workloads to run on the same data, at the same time, at massive scale on industry-standard hardware.myTectra Big Data and Hadoop training is designed to help you become a expert Hadoop developer. myTectra offers Big Data Hadoop Training in Bangalore using Class Room.
    hadoop training in bangalore
    Looking for best Machine Learning Training in Bangalore then join myTectra the leader in Machine Learning Training in Bangalore. Classroom & Online Training
    machine learning training in bangalore

    ReplyDelete