Overview of linking Amazon Alexa to openHAB

I hope people find this helpful.
I have written a short overview of how to connect up openHAB and Alexa so that people with Amazon Echoes and the like can control devices connected to openHAB.


It assumes you have a working openHAB setup and will follow the Amazon step-by-step tutorial on creating an Alexa Smart Home Skill. The rest is easy.

1 Like

Could be a nice thread for

I’ve just taken a look and you have given very limited information, not really enough to get the Skill setup. This is a fundamental requirement as it will allow others to quickly get things working without having to either search on here further on the web.

I think it’s great that we are seeing more and more people working on Alexa and OpenHAB working together, but there isn’t enough detail for a less gifted user to just make it work. The fear, for me at least, is that if it’s not straight forward then people just give up and go elsewhere. For me Alexa and OpenHAB integration is the way forward.

It’s great to see more and more people writing openHAB related tutorials! Great effort on your side :wink: I would also like to see your article as an extended tutorial here in the community Tutorials&Examples category.

I have to agree with @Maximo, your article stumbles a bit in the introductional and motivational part. Starting at the “AWS lamba” paragraph you lost me…

Great feedback guys. So glad you took a look. Makes me want to follow up.
Your suggestion is great. I will do a full version to help people get setup completely. I wasn’t sure anyone would be interested at all.
I didn’t have time for a detailed article today, but I wanted to get the key things that tie the two systems together out there. I couldn’t find this information anywhere.

Note for everyone, once you have created an Amazon Developer account and logged on to the developer.amazon.com website, search for the step-by-step article on building a Smart Skill Adaptor. Everything including full source code is there to get Alexa started and all you need is my notes to top it off.

1 Like

Speaking as someone who has been around the block with OpenHab, and I do have an Amazon developer account, your initial effort is a bit “bare bones”.

I think it’s a great start, and I’m glad that you made the effort. I was also looking to implement the same kind of thing (now that the Amazon Dots are really cheap -well except for here in Canada). That’s what led me to find your post.

What is really needed is a write up (with full code) of a working example.

That will encourage people to try it, then expand on it - and who knows where it will go from there.

The really cheap dots are an exciting development, and I think you could lead the way to a great implementation. There are other efforts, but they are very limited, or complex.

You don’t even need to POST to my.Openhab the way you describe (sorry I don’t like my.openhab), there are easier ways, but Amazons security is the usual stumbling block.

A full fledged example would be a great start. In the mean time I’ll try to figure this out myself - I program a lot in Python, and I’m not sure what you mean with “write your code here” (I mean I understand that you need to write methods handleDiscovery and handleControl with arguments context and event, then return Json header and payload), but what specifically these would look like, would help.

It looks like your using requests to POST/GET (which is what I do) is this Python 2.7 or 3.2? Can you GET the status of a switch/dimmer and have Alexa tell you what it is?

How do you identify the item? Believe me trying to differentiate between “light” and “lights” is not that simple, does Alexa handle that, or do we have to handle that?

Do you need one context per item? Group? Both? Is an event, a value, or on/off?, open/close? What’s the json look like? (I’ll go read the Amazon examples, which may make it clear), but a simple Openhab specific example would save people having to go to other places to get quick answers. You’ll lose them at that point.

Looking forward to your next post!

Its also notewothy that this tutorial focuses on the OH 1.8.3 side of things, right?
I just did a OH2 implementation this weekend and it was a snap using the new hue-emulator binding.
No developer account, no custom skill, etc. Just install the binding, add the tags to your items and let them discover by the alexa app. Done.

@waitz_sebastian I’m not running on OH02 yet, that’s in my plans for next year. As such I haven’t done a lot with OH2, are you saying that with the HUE Emulator binding you can make OH2 think that X10 and ZWave devices are Hue devices?

If that’s the case, I’ll have to bring forward my plans to migrate my setup to OH2 as that would be make a very seamless use of Alexa and OH.

Exactly! Not all items are supported yet, but it nicely works for switches and dimmers. I’m in OH2 test phase as well right now. The hue emulator was really easy. Getting used to the OH2 principlas is a bit more work. At least for me :smile:

Not only for you :sunglasses: (at least when you are coming from openHAB1)

Thanks for that. Looks like I’m heading down the OH2 route a lot sooner. Playing around with the Hue skill it seems to be a good natural way of using Alexa and OpenHAB together.

I havent installed the official Alexa Hue skill at all. Could imagine it breaks things, as hue skill will search for Hue bridge and may find the physical one and the OH2 emulated one. But feel free to test and report back :slight_smile:

Just wanted to say thank you to Pop_sharma and the rest of you… You know when you are early when you search and search and find nothing, then you find a small group and limited thread of people exploring the same interests. I am am newbie to rasberry, bb, arduino, but this is going to be huge with IoT. Rather than buying into the masses, was looking to create something original myself. Very happy happy yo find this and will be looking for further development. At the end of the day if I can make my BB or arduino light an LED via “Alexa, turn on LED” Id be happy… :wink: thanks again.

For those who already have an echo:
Is it possible to activate / deactivate Alexa through openhab (like mite the microphones) through Alexa’s API?

It would be helpful to activate it if I arrive at home and deactivate it if my wife arrives :wink:

I am not aware of such a function. But you could add some relay or socket switch to power Echo on/off via a simple openhab rule depending on your and your wife’s presence state.

Thanks for your suggestion.
This solution would definitely work, but I was actually looking for a more straight forward approach (if possible with Alexa’s API).

I will keep this in mind though, in case Alexa is recalcitrant :wink: