Amazon Echo Skill for OpenHAB available!

As I am quite new to Amazon Echo, but not new to OH, I also have a question regarding the difference of the (easy) Hue Emulation and the (probably more powerful) Echo Skill for OH:

As I live in Germany, I want to talk to Alexa in german. Can use the binding emulation in german language? Think so. But can I also use this skill in german?

And I’ve seen anywhere around that this skill is mainly developed for OH1. Is that true?

Are there any users around here who have tested both solutions? Any recommendations which one to choose? I am mainly looking for some hue and temperature control functions.

1 Like

Holy crap. This is awesome. Great work!! I haven’t started the install yet, but your documentation is very thorough!

In reading through, it looks like there is no way to tell ASK to use a non standard port? I was hoping to obscure things as much as possible with a different port, but based on my reading it is not an issue with your Skill.

In any case, I’ll definitely be checking this out!!

1 Like

is it possible to tell nginx to do the forwarding stuff? nginx could be accessed via 443. (in my environment)

How can i convert the commands to German?

I will start controlling Kodi with Alexa, but i want to use it with OH too.
(alexa-ha is configured and could be acessed via a reverse proxy)

Hi!

Excited about setting up my amazon dot with openhab, and customizing it, I’m really glad when I found this
app. However I’m struggling with the setup and have a couple of questions…

  1. patch -p1 < ./alexa-utterances_custom_slot_support.patch.txt
    patching file README.md
    Reversed (or previously applied) patch detected!

Is the patch already applied? I can’t seem to apply (starting fresh), maybe instructions here are outdated?

  1. I’m using server.js from example:
var AlexaAppServer = require("../index.js");
AlexaAppServer.start( {
	app_dir:"apps",
        app_root:"/api/",
        port : 30001,
        httpsEnabled : true,
        httpsPort : 30000,
        privateKey:'privkey.pem',
        certificate:'cert.pem',
        preRequest: function(json,req,res) {
          // Include password value from URL parameter, so Alexa-HA can validate it...
          json.password = req.param('password').toString();

          // Extract the IP address of the client (handles IPv4 and IPv6)
          var IPFromRequest = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
          var indexOfColon = IPFromRequest.lastIndexOf(':');
          var address = IPFromRequest.substring(indexOfColon+1,IPFromRequest.length);
          json.remoteAddress = address;

        },
        postRequest: function(json,req,res) {
        }
} );
When starting I get the following:
alexa@drake:~/node_modules/alexa-app-server/api> node server.js 
Serving static content from: public_html
Loading server-side modules from: server
   Loaded /home/alexa/node_modules/alexa-app-server/api/server/login.js
Loading apps from: apps
   App [Alexa-HA] is not an instance of alexa-app
httpsEnabled is true. Reading HTTPS config
Listening on HTTPS port 30000
Listening on HTTP port 30001

Pointing my webbrowser to:
https://localhost:30000
=> alexa-app-server is running

Pointing to
https://localhost:30000/api/
Cannot GET /api

Pointing to
https://localhost:30000/api/alexa-ha
Cannot GET /api/alexa-ha

What could be wrong?

Regards S

Thanks a lot, @nomadic-squirrel!

Unfortunately the standard port for SSL (443) is a hard requirement here. It can be proxy’d behind an existing webserver, but Amazon expects all endpoints will be listening on 443 for SSL…

I have not implemented internationalization and today it is assumed all code and commands are in English. Ideally I’d love to add support other languages too. Are you will to assist with this? I can already envision how to stub it out to support many languages but need native speakers to assist with development/debugging…

I believe this patch is no longer required as its likely been resolved in the upstream project; should not be a problem to skip this step. Action item - test and remove this from the Alexa HA documentation :slight_smile:

This one is new to me… I’d suggest double checking your paths and directory structure; if the problem persists share more details with me via github or PM. On the surface it looks like something wrong the Alexa App install as the /api endpoint is not working for you, which is not Alexa-HA specific!

Glad to help otherwise.
.

Hi Stefan,

This is not tested, and BTW Alexa HA is not a ‘true’ OpenHAB binding yet… It is a standalone app which can interface with your OH instance over REST API.

Yes. Quite a few others have gotten it to work with OH2 for basic functionality but OH1 is what I use today; robust OH2 support is certainly on our roadmap going forward.

Yes, I have used both and you can use both the Skill and the Bridge at the same time. IF you need anything beyond switch/dim controls via Echo than Alexa HA is better suited (i.e. temp/lighting colors/voice feedback/etc). It can be done with the bridge but it may require some awkward voice syntax and some heavy OH rules to trigger the desired actions/behaviors.

@d0t

Thanks for the input. I reinstalled everything and switched to branch develop.
Now it works (master branch seems to be problems for me)

Regards, S

Hi Mike,
I am a native german speaker and willing to help with translation, testing and debugging but I need some advice.
Would be glad, if you point me into the right direction.

1 Like

@d0t

EDIT
I got it working, the ECHO processed etc are for the custom voice commands.
Working great! And simple to add rules to give statues reports etc.

//HA Switch Item which determines if the latest request been processed
config.HA_item_processed = ‘ECHO_Processed’;
// HA String Item which stores the voice command
config.HA_item_voicecmd = ‘ECHO_VoiceCMD’;
// HA String Item which stores the servers response/answer, to be spoken by ECHO
config.HA_item_answer = ‘ECHO_Answer’

Regards, S

Hi, I’m new to OH. I’m currently exploring / comparing OH and Smartthings. One of them is Alexa support. Frankly it took me significantly more time to set up Alexa-HA working so far (sort of) than for Smartthings. I can see from log that Restful request come in by speaking “ask openHab to …” to my Echo. And the next step for me is to finish config.js by putting in my openHab items.

Question: How do you avoid “Tell/ask openhab to” syntax? In SmartThings, I configure items to be exposed through smartApp, then I can simply asking Alexa to discover new things. After that all things are shown in Alexa app. And I can speak to action on them directly. e.g. “Alexa, turn on the kitchen light”, “Alexa, setting kitchen light to 30%”. From what I read about Alexa-HA, it’s a Alexa skill. So does it mean I have to “ask openHab to turn on” all the time? Can I achieve SmartThings kind of exposure of my Items?

I’m pretty new to Alexa programming, from my quick reading, Smartthings might be using Smart Home Skill API instead of custom skill. Can Alexa-HA work that way? Or is it only possible through some kind of services supporting OAuth?

Thanks!

Hi Mike,

I tried to build an alexa skill yesterday and I selected German as language. Unfortunately amazon then tells me, that literals are not allowed in German skills. With a quick research I found this:

"Important: English (US) skills using the AMAZON.LITERAL slot type should be updated to use custom slots as described here. Starting February 6, 2017, you will no longer be able to use AMAZON.LITERAL when saving a new or updated skill. Existing skills that already use AMAZON.LITERAL will continue to work, but you will be unable to make any changes to the skill configuration until you remove AMAZON.LITERAL.

English (UK) and German skills do not support AMAZON.LITERAL and cannot use the AMAZON.LITERAL slot type."

https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/migrating-to-the-improved-built-in-and-custom-slot-types#replacing-literal-with-custom-slot-types

So the translation from the US English to German will require more changes then just the translation. Am I right?

Just another thougt: Nobody will be able to setup a new instance of ALEXA-HA after the date mentioned above.

Hi!

Just started to implement the custom voice commands. So far I have only added a weather report.
Thought I would share my rules.

val String STATUS_UPDATE_CMD = "status"
val String WEATHER_CMD = "weather"
val String PLANTS_CMD = "plants"
val String LOG_NAME = "Alexa"
val String UNRECOGNIZED_CMD = "Command is not recognized by openhab"

val Functions$Function2 postAlexaResponse = [String logName, String message | 
    ECHO_Answer.postUpdate(message)
    logInfo(logName, "Sending Alexa Response: " + message)
    ECHO_Processed.sendCommand(ON)
] 

rule "CustomVoiceCommands"
when
  Item ECHO_VoiceCMD received update
then
    logInfo(LOG_NAME, "Got command " + ECHO_VoiceCMD.state)
    if (ECHO_VoiceCMD.state.toString.contains(STATUS_UPDATE_CMD)) {
        postAlexaResponse.apply(LOG_NAME, "Status is good!")
    } else if (ECHO_VoiceCMD.state.toString.contains(WEATHER_CMD)) {
        var String weather = 
        "In Gothenburg the temperature outside is " + MqttOutdoorTemp1.state + " degrees." 
        weather += " Humidity is at " + MqttOutdoorHum1.state + "."
        weather += " Finally air pressure is at " + MqttPressure1.state + " hPa"
        logInfo(LOG_NAME, "Applying response" + weather)
        postAlexaResponse.apply(LOG_NAME, weather)
    } else if (ECHO_VoiceCMD.state.toString.contains(PLANTS_CMD)) {
        postAlexaResponse.apply(LOG_NAME, "Command yet to be implemented")
    } else {
        postAlexaResponse.apply(LOG_NAME, UNRECOGNIZED_CMD)
    }
end

I’ve shifted towards naming my custom rule in alexa from “hab” to “openhab”. The good thing with the name “hab” is
that you can say “Open hab” to issue commands, but I now tend to go "Ask openhab about / tell openhab " and so on.

Some ideas so far for me to integrate with Alexa.

  1. White goods report (How long time has the dryer been running and what is the current status)
  2. Tell me if any batteries are running low
  3. Plant flower report (Which plants are running dry and need water)
  4. If any light bulbs are damaged and need repalcement
  5. Any door or windows that are open.

Can’t wait for Alexa Push notifications, that would be awesome.

Regards S

Thanks for highlighting this. I noticed this Amazon Skills Kit change was coming (albeit not the hard cut-off date!). I’ll remove the LITERAL’s soon and when time permits transition Alexa-HA to supporting OH2 too… The move to custom slots is not that hard, but splitting the Alexa HA OH1/OH2 logic will require focused development and testing to get ‘right’ for everyone.

If anyone here would be willing to assist with this process (both OH1/OH2 alike), please chime in on our GitHub issue here.

Thanks all,
.

Hey @mythbai,

Alexa-HA is a custom skill as the Amazon Skills Kit has numerous advantages. This does require the ask/tell syntax, unfortunately, though Its capable of much more than simply switch/dim/temp commands, and can provide customizable feedback (i.e. verbal responses) on our Echo(s).

We do have another project in the works which leverages the Smart Home API, my.openhab.org and oauth. This makes it much easier to setup and ‘discover’ and use your devices on the network without needing to host the skill locally. We will release this for the new myopenhab.org service and as an official OpenHAB Skill, but no timelines on that just yet!

Best regards,
.

@Seaside - thanks for sharing; glad you are up 'n running, and extending! Cool stuff :slight_smile: I’m curious - can you share this ‘postAlexaResponse’ function(s)? Might be better to post it on our github issue tracker…

Gearing up to further improve the Alexa-HA code over the holiday (see the ‘call to action’) and would like to see what others have done with this…

Agreed there - its a game changer :sunglasses:

.

Thanks d0t!

I think I may get used to it. Just hope one day Alexa can be “smarter”. And as Seaside mentioned Push will be one feature I’d really like to see. And I also like to see Alexa can do “action” without voice trigger. e.g. IFTTT’s DO instead of IF: connect bluetooth, announce arrival etc.

Glad you mentioned that. I just registered for myopenhab.org today, and received email saying
This new service will bring along with it enhanced features like the official openHAB Alexa Smart Home skill, as well as new hardware and the ability to have the community assist and enhance its capabilities.
Really looking forward to it. Great works!

Hey all,

To everyone that uses Alexa-HA regularly, please share your thoughts for improvement! I’m brainstorming and prioritizing the next batch of development and would like to hear your feedback. :wink:

Thanks,
.