[Addon] HA Skill - an addon to setup Alexa Smart Home integration

I deleted the stacks and now I have everything set up. The skill was added successfully but I don’t have any devices in the Alexa app. I dont get any errors. I even tried giving one of my entities a custom name:

alexa:
  smart_home:
  entity_config:
    switch.baustelle_switch:
      name: "123Baustelle"

Looks like your indentation is off. Take a look at Amazon Alexa Smart Home Skill - Home Assistant → Alexa Smart Home Integration Configuration

Looks like you need

alexa:
  smart_home:
    entity_config:
      switch.baustelle_switch:
        name: "123Baustelle"

Although by default all entities should be included so it’s weird that nothing is showing up.

You can try going to the Lambda console in your AWS account and trigger an invocation with the following input

{
  "directive": {
    "header": {
      "namespace": "Alexa.Discovery",
      "name": "Discover",
      "payloadVersion": "3",
      "messageId": "1bd5d003-31b9-476f-ad03-71d471922820"
    },
    "payload": {
      "scope": {
        "type": "BearerToken"
      }
    }
  }
}

It should succeed and return a list of devices that Alexa exposes.

Yeah I just tried manually configuring the entity so I can see it easily in the app.
After trying your invocation i get the following message:

These are the protocol events in case you need them:

What do the addon logs says when the Lambda response is a 502?

Looks like I might need to make debugging this thing easier as there are 2 sets of logs and by default it doesn’t log much.

These are the logs:


2023-07-06 09:19:41 WARNING SQS Payload: {'body': '{"directive": {"header": {"namespace": "Alexa.Discovery", "name": "Discover", "payloadVersion": "3", "messageId": "1bd5d003-31b9-476f-ad03-71d471922820"}, "payload": {"scope": {"type": "BearerToken"}}}}', 'response_queue': 'https://sqs.us-east-1.amazonaws.com/187902379907/ha-skill-responses-2023_07_06___LATEST_92ce897230c64c90b7689d8de707a29f.fifo', 'group_id': 'bcd96aed-dd5d-4f46-93e7-29523d747373'}
2023-07-06 09:19:41 WARNING Got HA response {'status': 502, 'data': '502: Bad Gateway', 'group_id': 'bcd96aed-dd5d-4f46-93e7-29523d747373'}
2023-07-06 09:24:34 WARNING SQS Payload: {'body': '{"directive": {"header": {"namespace": "Alexa.Discovery", "name": "Discover", "payloadVersion": "3", "messageId": "1bd5d003-31b9-476f-ad03-71d471922820"}, "payload": {"scope": {"type": "BearerToken"}}}}', 'response_queue': 'https://sqs.us-east-1.amazonaws.com/187902379907/ha-skill-responses-2023_07_06___LATEST_216dfcabb3db4814bfd1b5363fb2e21b.fifo', 'group_id': '3fa0d7d0-6c67-4de5-9b15-82636618840f'}
2023-07-06 09:24:34 WARNING Got HA response {'status': 502, 'data': '502: Bad Gateway', 'group_id': '3fa0d7d0-6c67-4de5-9b15-82636618840f'}

I am not sure why the alexa API would cause a 502 when calling it. Have you restarted Home Assistant since adding the alexa entry into your config?

Can you try hitting the Alexa API for another terminal addon (I used the VSCode addon)

curl -s -X POST -H "Authorization: Bearer ${SUPERVISOR_TOKEN}" -H "Content-Type: application/json" http://supervisor/core/api/alexa/smart_home -d '{
  "directive": {
    "header": {
      "namespace": "Alexa.Discovery",
      "name": "Discover",
      "payloadVersion": "3",
      "messageId": "1bd5d003-31b9-476f-ad03-71d471922820"
    },
    "payload": {
      "scope": {
        "type": "BearerToken"
      }
    }
  }
}'

I also published a new version of the HA Skill addon (v1.0.4) that includes a debug option in the addon configuration. You can try enabling that to see if the addon logs show anything useful.

Somehow it now works. When i enter the code it returns my devices. However I still dont have them in my alexa app. Is it possible that it may take a while? I tried deactivating and reconfiguring my skill.

Now I see that the response is empty:

2023-07-07 10:21:07 DEBUG  Recieved response []

If I invoke the Test in VSCode or as a lambda test in aws I get devices in the return:

2023-07-07 10:22:42 DEBUG  Recieved response [sqs.Message(queue_url='https://sqs.us-east-1.amazonaws.com/187902379907/ha-skill-requests.fifo', receipt_handle...

The empty response is expected. The addon is constantly polling for any requests. If there are no requests after 20 seconds, it’ll return an empty list.

Did you setup the Alexa skill in the same Amazon account that you use for your Alexa devices? That’s the only reason I can think of for the Lambda finding devices but them not showing up in Alexa.

Yes I am using the same account for everything.

I deleted everything and set up the addon and skill and everything in lambda. Same issue. The tests return the devices but alexa doesnt find any. Can I provide you with any more information for trouble shooting?

Unfortunately I’m not sure where else to look to debug this. If the Lambda is finding devices the addon logic is working. Best I can tell is there is something wrong with how you registered / setup the Alexa skill - either picking the wrong account, wrong region, or wrong Lambda function. Double check that the Lambda being used by the skill is the one the addon setup (arn is in the addon logs). And make sure you selected the correct region for the addon (if you are in the US then us-east-1).

When you ask Alexa to discover devices, does the Lambda get invoked (do you see logs)?

Sorry to burst your bubble and all of your hard work. Anything dealing with AWS is hard work.

The easiest way to use Alexa on Home Assistant is with the Home Assistant Cloud. All of the AWS stuff is taken care of for you.

If a cloud subscription is an issue (what do you think AWS is?), then just install the Node-RED add-on, and in Node-RED install “node-red-contrib-alexa-cakebaked” to the pallette. Done. I use a free (contributions appreciated) service provided by Ben Hardill to create most of my Alexa devices.

After installing a device in ESPHome, I can have Alexa controlling it in five minutes.

Hi @adamirr,
Thanks for your addon.
I used for the last years haaska without problems.
But since some days alexa could not control my devices anymore.
So I tried your addon.
But unfortunately I could not complete the setup in „alexa developer console“.
If I put in „AWS Lambda ARN - default endpoint“ the “AlexaEndpoint” from your addon and click save, I get the following error:

Failed to save skill information
  • Please make sure that “Alexa Smart Home” is selected for the event source type, for provided arn [Invalid value] : arn:aws:lambda:eu-west-1:xxxxxxxxxxxxxx:function:ha-skill

Did I do something wrong during setup?
How can I solve this error?

EDIT: here a screenshot:

Did you get this working? I have the same problem.

Hi, If interested, I’ve found a solution :slight_smile:
On AWS, go to your function, delete the alexia trigger, and add a new one, you will have the choice between Alexa skill kit or smart home, choice smart home, and it worked for me

1 Like

Hi, when trying to install I got the error:
Failed to to call /addons/a11dcb03_ha_skill/install - The command '/bin/ash -o pipefail -c pip3 install --upgrade pip' returned a non-zero code: 1

It seems a typo on /bin/bash

I’m on

  • Core2024.1.0
  • Supervisor2023.12.0
  • Operating System
  • Frontend20240103.3

Hi,

I just merged a pull request that should fix this error. Please try removing and adding the addon again.

Hi Adam,
thanks for the quick reply…
Unfortunately I still get the error.
The addon wasn’t installed so I can only “install” it. Am I wrong?
Let me know if you need other infos…

Just pushed another change to increment the version to 1.0.5. Try again and ensure that’s the version being installed.

If it still doesn’t work, is there more in the logs? If so, paste the whole thing.