Using Alexa and openHAB 2 to Control Your Home

Today we’re going to have some fun and try using Amazon Alexa to control our light.

You will need:

 

This update is going to be quite simple as openHAB has done pretty much all the work for us. There is also a comprehensive guide here.

myopenhab.org

The way openHAB have implemented their Alexa integration is via their cloud hosted service https://myopenhab.org/ this is great for us as most of the hard work is done. Some people may not like the fact we’re using an online service, but hey why are you using Alexa?

First we need to install the openHAB Cloud Connector

  1. So back to the Paper UI at http://openhabianpi:8080.
  2. Navigate to Add-ons in the left hand menu, then the MISC tab.
  3. Find openHAB Cloud Connector in the list and install it.cloud connector
  4. Lastly we need to check configuration Configuration>Services>IO>openHAB Cloud.cloud connector config

Now the cloud connector is installed we can create our account over at https://myopenhab.org/.

To register we’re going to need a couple of bits of information the UUID and Secret.myopenhab register Fortunately they are easy to find.

  1. To get the UUID ssh into your openHABian machine.
  2. Execute the following command cat /var/lib/openhab2/uuid.
  3. Copy the string of characters shown.
  4. Next get the secret in a similar way cat /var/lib/openhab2/openhabcloud/secret.
  5. You can now register for your account at https://myopenhab.org/.
  6. Annoyingly I needed to reboot in order for my device to show up.

You can now remotely access your openHAB UI.

Items

The Alexa integration uses a tagging syntax to identify which items it can control.

We need to edit our items file: \\OPENHABIANPI\openHAB-share\openhab2-conf\items\sonoff.items, and add the Lighting tag:

Switch My_Light "My Light" <light> (gLight) ["Lighting"]
 { mqtt=">[mybroker:cmnd/sonoff-mylamp/power:command:*:default],
 <[mybroker:stat/sonoff-mylamp/POWER:state:default]" }

Alexa

Lastly in you Alexa app navigate to Skills and search for openHAB, and tap Enable. You will be prompted to enter the username and password you just used to create your myopenhab.org account, and authorise the Alexa to use the service.

Alexa will spend a few minutes searching for devices then you’re good to go.Alexa Items.PNG

Try saying “Alexa turn on my light”.

Alexa Groups

One last tip. The Alexa app will allow you to create smart home groups. These can be used to associate a number of devices with a specific Echo device.

Whats the point? Well lets create a group for the room we’re in, in my case the study. Then add the Echo Dot located in my study to the group, and also our light.

Now we can control all the lights in a room together. Even better the Echo knows which group it’s part of so can control the lights without you having to define which ones.study group.PNG

Try saying “Alexa turn the lights on”.

Lastly if you change Alexa’s wake word to Computer, you can say “Computer turn the lights on”. It’s almost we’re living Star Trek!

One thought on “Using Alexa and openHAB 2 to Control Your Home

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 )

Connecting to %s