Alexa integration with HomeAssistant Guide

just wanted to add that you can now accomplish some of this with emulated hue + routines in the alexa app. let’s say you have script called “unlock the front door.” in the alexa app you can create a routine that maps “unlock the front door” to “turn on unlock the front door to 50% brightness” (they’re all dimmable lights in emulated hue, but the brightness is irrelevant). so you don’t need custom intents to be able to say “alexa, unlock the front door,” and you don’t need an invocation name.

How do I go about resolving the “undefined” response in the _SessionSpeechlet - Requesting Home Assistant to turn undefined on ? The light does switch on and off.

Is the HA Cloud available to run on your own, i.e. personal cloud instance?

Also, I believe with openHAB Alexa skill, they got around the invocation word. I haven’t yet take a close look at how they did it differently than this other that they use HomeKit bindings:

Items are exposed to Alexa through the use of tags which follow the HomeKit binding tagging syntax

Yes you can do it DIY, use the latest v3 api compatible version of Haaska which in essence is just creating your own ‘test’ Smart Home Skill with all the hard work already done by the devs. You then link your ‘test’ skill in the Alexa app and away you go. As it’s a Smart Home Skill there are no invocation words.

Set up in HA is identical to the HA Cloud version other than you don’t put cloud: before alexa: in your config yaml. You shouldn’t need to do anything to the skill side once set up and it will have exactly the same features as the HA Cloud version.

I did it the other night in an hour whilst watching telly and it works perfectly.

3 Likes

How did you set up the config.json? I am trying to set it up using let’s encrypt and duckdns, but every time I run the test in AWS I get a 404 error?

Exactly as per the instructions, url set to https://my_domain.duckdns.org:8123/api

Was a while ago now but I have a feeling I had the same issue until I specifically added something for it to find so you have to set up Home Assistant config something like…

alexa:
  smart_home:
    filter:
      include_domains:
        - light

Great, I think that may be the issue (the specified entities). Do you remember if you did anything with the ssl_verify and ssl_client in the config.json? Thanks!

More I think about it the more I’m sure it was that.

This is all that’s in config.json…

{
  "url": "https://my_domain.duckdns.org:8123/api",
  "password": "my_ha_password"
}

Ok great, I will give this a try tonight. And just to be certain, you removed the ssl_client and ssl_verify and it didn’t cause any problems with let’s encrypt?

Where are you talking about removing them? They’re in my config.yaml as that’s how you expose HA to the outside world using a letsencrypt certificate via the duckdns add-on but not anywhere else.

Sorry, I am referring to the instructions for installing haaska v3. In the config.json, there are two ssl values in the file, ssl_verify and ssl_client. Ssl_verify is set to True in the sample file, but the docs refer to a certificate going there. I guess that is where I was getting confused

Ah…with you, just checked the instructions and guessing this may have been in the revisions done to that page since I did mine, I do recall it was related to the old version of AWS so had to adlib a few bits, don’t know if it still is. Either way, what I posted above was all I had in my config.json and it’s still working perfectly.

If you have letsencrypt set up correctly, I would’ve thought the certificates should work just like the HA front end and not need any other reference, perhaps the option is just meant for specific use cases not using external certificates.

Thanks! I was able to get it to work. For anyone that finds this in the future, I needed to set up the alexa component with the domain filter and then in the config.json, I used https://myduckdns.org/api as my url and left the ssl_verify and ssl_client alone. Thanks for the help!

Hi all,

I’m trying to configure Alexa with Hasska. I’ve followed all the instructions from a youtube video, and checked with the (not completed yet) documentation.

When I try from the lambda page, the function is successfully executed, and all the devices are returned, however, when I turn on the skill and link it to my Amazon account, the discovery is run, but no device is returned, and I don’t know why…

Did someone use hasska (mike-grant version, compatible with version 3) and knows why this may happen?

Hass version: 0.82.1 running in docker
SSL cert with letsencrypt
Dynamic DNS with Synology DNS
Port 443 open in the router externally
Port 8123 closed in the router externally
Port 8123 and 443 working internally (Internal DNS setup) with SSL Cert

Can I enable any kind of logging that helps me figure out what’s going on?

Edit: I can see this in logs when I execute the test in lambda, but no when I ask alexa to look for new devices…
2018-12-16 02:41:44 DEBUG (MainThread) [ homeassistant.components.api ] STREAM 140248668589712 FORWARDING <Event alexa_smart_home[L]: request=namespace=Alexa.Discovery, name=Discover, response=namespace=Alexa.Discovery, name=Discover.Response>

Thanks!

Hey, do you have the Alexa component configured within homeassistant? There’s a little bit of documentation that can be found here

There isn’t a lot that Haaska really does, HomeAssistant does all the work really. Haaska just provides a simple interface to forward messages from Alexa to Homeassistant and get a reply, which is passed back to Alexa.

Hi mike, thanks for your answer.

My issue is really weird, as I can see in the lambda that my hassio is returning data as expected (I can see lights and switches, with real names), but when I tried to detect devices, it shows nothing…

I’ve also used during the free month the cloud integration, and it worked without issues…

This is what I’ve in my configuration:

api:            !include api.yaml               # APi Config
alexa:
   smart_home: 
     filter:
       include_domains:
         - light

api.yaml is empty, and if I add - switch to the included domains, lambda also returns the switches.

Lambda execution is like this:

Blockquote
START RequestId: 74cf67ba-0133-11e9-89ff-XXXXX Version: $LATEST
[DEBUG] 2018-12-16T13:06:52.664Z 74cf67ba-0133-11e9-89ff-XXXXX calling alexa/smart_home with {‘directive’: {‘header’: {‘namespace’: ‘Alexa.Discovery’, ‘name’: ‘Discover’, ‘payloadVersion’: ‘3’, ‘messageId’: ‘1bd5d003-31b9-476f-ad03-XXXXX’}, ‘payload’: {‘scope’: {‘type’: ‘BearerToken’, ‘token’: ‘access-token-from-skill’}}}}
[DEBUG] 2018-12-16T13:06:52.665Z 74cf67ba-0133-11e9-89ff-XXXXX Starting new HTTPS connection (1): HA.DOMAIN.TLD:443
[DEBUG] 2018-12-16T13:06:53.78Z 74cf67ba-0133-11e9-89ff-XXXXX https://HA.DOMAIN.TLD:443 “POST /api/alexa/smart_home HTTP/1.1” 200 11725
END RequestId: 74cf67ba-0133-11e9-89ff-XXXXX
REPORT RequestId: 74cf67ba-0133-11e9-89ff-XXXXX Duration: 416.55 ms Billed Duration: 500 ms Memory Size: 128 MB Max Memory Used: 30 MB

Please note the 200 returned by the POST.

And this is the answer of the function:

{
  "event": {
    "header": {
      "messageId": "4f98a45e-0f99-4a74-98dd-XXXX",
      "name": "Discover.Response",
      "namespace": "Alexa.Discovery",
      "payloadVersion": "3"
    },
    "payload": {
      "endpoints": [
        {
      "additionalApplianceDetails": {},
      "capabilities": [
        {
          "interface": "Alexa.PowerController",
          "properties": {
            "proactivelyReported": false,
            "retrievable": true,
            "supported": [
              {
                "name": "powerState"
              }
            ]
          },
          "type": "AlexaInterface",
          "version": "3"
        },
        {
          "interface": "Alexa.BrightnessController",
          "properties": {
            "proactivelyReported": false,
            "retrievable": true,
            "supported": [
              {
                "name": "brightness"
              }
            ]
          },
          "type": "AlexaInterface",
          "version": "3"
        },
        {
          "interface": "Alexa.ColorController",
          "properties": {
            "proactivelyReported": false,
            "retrievable": false,
            "supported": []
          },
          "type": "AlexaInterface",
          "version": "3"
        },
        {
          "interface": "Alexa.ColorTemperatureController",
          "properties": {
            "proactivelyReported": false,
            "retrievable": false,
            "supported": []
          },
          "type": "AlexaInterface",
          "version": "3"
        }
      ],
      "description": "light.lampara_cocina",
      "displayCategories": [
        "LIGHT"
      ],
      "endpointId": "light#lampara_cocina",
      "friendlyName": "Lámpara Cocina",
      "manufacturerName": "Home Assistant"
    },
...
}

So it returns the expected data.

Apart from that, I’ve disabled cloud in the configuration.yaml, just in case, and obviously I’ve enabled the skill in the alexa app (it appears as developer skill, then I enable it, and link it with my amazon account, which is the same that is configured for alexa)

This is quite weird, the configuration seems to be ok and the process is quite straight forward… but it doesn’t work :S

Regards

Can we set alexa skills using the new long live tokens by home assistant? All of the methods mentioned in the OP require api_password which will be gone soon from HA.

Hi again,

This is interesting… I’ve added a request line in the haaska.py lambda code, to see when it’s being executed, and I can see python calling that URL when I test the lambda, but that URL is never called when I’m executing the discovery from Alexa, so it seems that my skill is not calling the lambda.

I’ve checked, the skill is not published (obviously) but I can see it under development tab in my alexa, and I’ve it enabled and linked with my account. The account I’m using is the same for alexa and for the skill (I’ve used same account for everything).

Another interesting thing, If I use the alexa skill test tab, I can request a discovery, and I can see my alexa light in blue (so it’s connected with my alexa), but no request is executed (the lambda is supposed to be called in that moment?)

I’m really confused, everything seems to be fine, but it doesn’t work at all :S

Regards

Update:

I’ve managed to get it working, but I had to change from Ireland to Virginia (??) to get the lambda called and the skill working :S.

I’m guessing that I’d something wrong in my amazon account somewhere, as I bought an original Amazon Echo when those devices weren’t available in Spain, and I created my account then, but now that Echo is available here, I have the new version, and that I guess is creating problems…

Anyway, seems to be working… Hooray!

Thanks

1 Like

Yes long live tokens are now supported…but I don’t think the documentation has yet to catch up, but see the following thread:

1 Like