Home Assistant offers many possibilities to control your connected home. One of the most practical advantages is its compatibility with voice assistants like Amazon Alexa, Google Assistant, Siri and Snips.
This local server is more than complete, so pair it with the charming voice ofAlexa allows us to go further. Indeed, our server freshly installed home assistant will allow us to make our routines more complex and we will also be able to control devices natively incompatible with the voice. Alexa.
Prerequisites for using Home Assistant with Alexa
This installation is totally free but takes a little longer than usual integration.
There is also Nabu House which allows you to control your instance from the outside as well as connect your server to the various voice assistants. Obviously all of this is very secure, however this service is offered at 5 € / month.
Do you want to choose the free solution? Perfect ! Let's see this in more detail.
Requirements for your setup
- API Alexa Smart Home requires your Home Assistant instance to be accessible from the Internet over HTTPS, DNS Duck is the easiest method.
- A developer account Amazon
- An account Amazon Web Services (AWS) is required to host the Lambda function for your skill Alexa. AWS Lambda is free for up to 1 million requests and 1 GB of outgoing data transfer per month. (More than enough for what we're going to do with it 🙂)
- Download my document in order to simplify the search for certain data
Create a skill Amazon Alexa Smart Home
Once your account developer Amazon created, connect to the consul Alexa developer then go to the tab " skills " if you are not, click on the button « Create Skill ".
Give it a name, for example "Lesalexiens"then select « Smart Home » et "Provision your own".
You can now create your skill by clicking on the button "Create Skill" at the top right of the screen.
Make sure "v3 (preferred)" is selected.
Create an AWS Lambda Function
Your skill Alexa Smart Home will trigger a function AWS Lambda who will process the request. We're going to copy / paste (yeah..we are not developers!) A little piece of code hosted as a Lambda function that will redirect the request to our Home Assistant server, then the integration ofAlexa in Home Assistant will process the request and provide a response. It is therefore our Lambda function that will provide the response to Alexa.
Didn't you understand anything? It does not matter, we will copy paste a few lines of code and Alexa will work 🙂
- First, log into your AWS console. Don't have an AWS account yet? You can create a new user
Download and prepare our skill Alexa Adapter
Start by download the latest version of the project, it will be our AWS Lambda function.
The file is at the bottom of the page, choose the file in ".zip" format:
Once the file is downloaded, go to file editor, we will add some lines to the file configuration.yaml :
fire:
alexa:
smart_home:
Save the file then restart your server
Creating a Home Assistant long-term token
You will now need to obtain a long-lasting token, you can create one from your Home Assistant interface very easily:
- Log in to your Home Assistant interface
- Click on your profile (the blue circle at the bottom left of the page)
- Scroll to block Long-term access tokens
- Click on create a token
- A window will open, give it a name (For example: lesalexiens)
- Once a name is added, a token will appear. Paste it in the help file, we'll use this token later.
Connection configuration with Amazon
Connect to your consul Amazon developer then click on the link Login with Amazon :
Click on create a security profile :
Then you just have to create the profile as below:
- Enter your profile name desired security, for example "lesalexiens"
- Write a brief description, for example "Profile for the use of my home assistant server"
- Add the URL you want for the privacy notice, for example "https://lesalexiens-tutoriel.duckdns.org"
Click on Save then on your new profile, click on the small gear and choose Web settings.
Note theCustomer ID and client secret code in the help file made available to you.
Kit configuration Alexa cv
From a new window, open the developer console.
From Alexa Skills Kit, select your skill and get your Skill ID (Paste it in your help file)
Preparing for AWS Lambda Access
Connect to your AWS console by selecting the profile IAM User
After logging into your AWS console, the tab Services appears at the top left of the page. Click on it then search I AM
Once the page I AM open, click Rôles then then on Create a role
You should see this page appear:
- Select AWS Services
- Click on Lambda
- Validate by clicking on the button Next: Permissions
You should see this new page appear:
Look up the word basic you should see a single line appear with the name AWSLambdaBasicExecutionRole. Check this line then click on the button Next: Tags
On this page do not enter any tags and click directly on the button Next: Verification
Here we are on the last step of creating our role. You just need to give it the name lambda_basic_execution then validate by clicking on the button create a role as below:
Your role is created, return to the main page by clicking on the AWS logo at the top left of your page
Region configuration
At the top right of the screen there is your username (certainly your email address) and next to it you will find a menu listing different regions, select the region Europe (Ireland) eu-west-1 and only this region.
If you live in the United States or Canada select the region US East (N. Virginia) us-east-1
Configuring the AWS Lambda Service
Search calculation from the search bar in the AWS Services block. The list will show different services, select the Lambda service.
Once the Lambda page appears click on the orange button Create a function.
Make sure the sticker Author from scratch is selected then set the following options :
- Function name : lesalexiens
- Runtime environment : Python 3.6
- Execution role : Use an existing role
- Existing role : lambda_basic_execution
The function is ready you can create it by clicking on the button Create a function.
Trigger configuration Alexa Smart Home
Once your function has been created, you should see a block appear with the name Designers. There you will find a button Add a trigger, click on it then select Alexa Smart Home.
Once Alexa Smart Home selected, paste your Skill ID (You will find it very easily thanks to your help file)
Be sure that Activate trigger is checked then click on the button Add.
Once Alexa Smart Home added, click on the name of your function (Our function is named the alexians). Further down the page you will find the section Function code :
Select Upload a .zip file in Code entry type. From the download button select the .zip file on your computer that we downloaded earlier.
Once the file has downloaded, replace what is in the box Manager by haaska.event_handler
Click on Save at the top right of the window and wait a few seconds that the file is loaded.
Configuring your function
In the section Function codeyou will find a list of files. Double click on the file config.json:
And add the following two attributes:
- url : The URL of your Home Assistant server (for example here, https://lesalexiens-tutoriel.duckdns.org:8123/api)
- bearer_token : The long-term access token (which you will easily find in your help file)
You can now record from the button at the top right.
Link AWS with the kit Alexa
Once the file is saved, return to the top of the page. You will find a RNA, paste it into your help file.
From the developer console Alexa, select your skill and insert your RNA in the zone default endpoint :
Example of RNA to paste in Default endpoint :
arn: aws: lambda: eu-west-1: 1234567891011: function: lesalexiens
You can select the region Europe, India and also paste your RNA :
Save by clicking on the button SAVE
Login Alexa Smart Home à Amazon
Down the developer console Alexa you will find a button Setup account linking
Click on the button then enter the following information:
- Authorization URI : https: // www.amazon.com / ap / oa
- Access Token URI : https: // api.amazon.com / auth / o2 / token
- Your Customer ID : Your Client ID (You will find it in the help file)
- Your Secret : Your Client Secret (You will find it in the help file)
- Your Authentication Scheme : HTTP Basic (Recommended)
- Scope : Create a scope by clicking on Add Scope and add profile
Save your changes by clicking on the save button at the top right of the page.
To finalize the configuration, go to console Amazon then click Login with Amazon
Your skill will appear, you will then have to hover your mouse over the gear and click on web settings.
Click on Edit at the bottom right of your page:
Paste the three URIs in the section Allowed return urls as below:
All you have to do is save your changes.
Test our Lambda function
At the top of your Lambda function configuration page, there is the button Tests, click on it.
You can Configure a new test event using the following data:
Give your event a name (for example, my event).
{"directive": {"header": {"namespace": "Alexa.Discovery "," name ":" Discover "," payloadVersion ":" 3 "," messageId ":" 1bd5d003-31b9-476f-ad03-71d471922820 "}," payload ": {" scope ": {" type " : "BearerToken", "token": "YOUR_LONG_DURITY_ACCES_CASE"}}}}
You just need to create your test by clicking on Create at the end of the page. Once your test is created, select it from the drop-down menu to the left of the test button.
Click on the button Tests, and if the test is successful, a green message will appear.
Final configuration in Home Assistant
From file editor, go to your file configuration.yaml in order to finalize our integration ofAlexa.
Previously we had the following three lines for Alexa :
fire: alexa: smart_home:
You must modify them in order to have the following configuration:
fire: alexa: smart_home: locale: fr-FR endpoint: https://api.eu.amazonalexa.com / v3 / events client_id: YOUR_CLIENT_ID client_secret: YOUR_SECRET_CLIENT
your client_id et client_secret are available in your help file. Save and restart your Home Assistant server.
Add our skill in the application Alexa
Last step! See you in your application Amazon Alexa
You just have to go to Skill and games then select the tab Your Skills.
Your Skill will appear (for example, the alexiens), you just have to click on it and identify yourself with your account Amazon. : )
In the next tutorial we will see how to add our Echo devices to Home Assistant in order to control the media player and use the voice system to alert or inform us. 🙂
Excellent article and very good - hot enough to make but it works great.
Thank you for the feedback ! More than hot, it's a bit long, but Aurélien guided us perfectly I think. 🙂
youpiiiiiiiiiiiiiiiiiiii I succeeded
thank you aurelien
Well done!: D We must admit that Aurélien's tutorial is perfect. 🙂
a great tutorial ... many thanks
Hello, when I test my function I have the following error message:
"ErrorMessage": "404 Client Error: Not Found for url: https://rom*****ox.duckdns.org:8123/api/alexa/smart_home",
An idea of the problem?
- The address is correct because I access my machine when I type it without the / api /alexa/smart/ home.
- In HA's yaml config, I added the following lines:
fire:
alexa:
smart_home:
I don't know, when it screwed up.
Thanks for your help
Thank you, Tuto very well done.
A little advice for those having problems with the test or the search for equipment (pb access token) -> Remember to also check the ports access of your box (with duckdns). 8123 (or 443….)
Hello,
HA can not be piloted Alexa with voice. But is the reverse possible?
That is to say, can HA control the connected objects via Alexa ?
thank you in advance
Hi,
In general, your objects connected to Alexa will automatically go up in Alexa because it uses the same applications. If you're talking about ZigBee Echo hubs, on the other hand, we don't have an answer for now, we hadn't thought of that possibility yet, but we'll check that out. 🙂
Good night
Hello, I got the same error
I copied to the configuration.yaml file
fire:
alexa:
smart_home:
instead of
fire:
alexa:
smart_home:
The space at the start of api was problematic, after removing the space everything works fine.
Hello, thank you for your feedback! I just corrected the indentation error 🙂
Frankly, thank you for this great tutorial, it is really well detailed. I didn't succeed the first time, I missed the haaska.event_handler manager, I had an error on the test that I finally resolved.
I thought I had slobbered to integrate my google home but it was a bit of a laugh compared to this one ..
I don't understand why it's so complicated, but hey if it saves € 5 per month I guess that's a lesser evil.
Thank you again, hoping that the screens are not obsolete quickly as for the integration of google home.
Personally my Smart home skill has been running for some time, and works for all the lights in my house (personal dev which transfers requests to my PLC).
I also manage to detect the shutters, and to control them from the application Alexa.. But impossible to control them by speaking directly to Alexa.. Strange!
Indeed, it is weird. And in routine, with a personalized sentence, does it work?
Wow! Thank you Aurélien, it works… ..at the top !!
Does anyone manage to drive anything other than lamps and sockets? I have the impression that the boolean input cannot be activated. I see the scripts but since most of the time it takes 2 (1 to turn on and 1 to turn off), she tells me that she sees several and asks me which one to activate.
I couldn't find a doc on how to turn a boolean input into a switch. In short, the possibilities are a bit limited, it's a shame.
hello, I have an error in the tests,
during the step of loading the haaska_1.1.0.zip file in the lambda> function> function code part, I did not find in the screens the possibility of changing the Manager (action 3 of the screen), I maybe be missing something or a window, so it is possible that the error message during testing:
Response:
{
"ErrorMessage": "Unable to import module 'lambda_function'"
}
be linked to this step which is not as described in this very good tutorial.
merci de votre aide
Hi, great tutorial! I have a silly question, once the tutorial is realized how I can ask alexa to close my shutters for example
Hello,
I am having a problem activating for use. The account association does not work and for good reason, in the details I have an Unknown client_id. indeed, the ID I see does not match the one I have in on amazon develop. And at no time during the activation I have a request to enter my ID / password. Do you have an idea?
Thank you very much and thank you for this site that I have just discovered.
Greg
Hello,
I encountered the same concern. The capture no longer matches what is there now. Further down the page of your function, you have a "Basic parameters" block. you make “modify” and in the manager part, you replace by haaska.event_handler.
Your test should work.
Months I remain blocked on the activation in the application. If it works for you, I'm a taker.
Greg
Hello Greg,
Indeed, HA evolves quickly and we need to update the tutorial, we will look into the issue. 😉
the possibility of changing manager has changed location and is no longer in the download window as shown in the screenshots, but lower in a separate area, if like me you have not scrolled to the bottom, then you do not see this part, which is blocking if not updated, once updated it is OK it works.
hello, after setting up and associating the skill, I still have an error message in HA:
Error when sending ChangeReport to Alexa: INVALID_ACCESS_TOKEN_EXCEPTION: Access token is not valid.
as specified in the HA doc, I dissociated then re-associated the skill, then restarted HA, but it's the same, am I the only one? is there a fix?
Note: in the Account linking part: the HA documentation and the tutorial give different values for authorization URI and authorization Token as well as for Authentication scheme ==> who is right?
@Greg, no I did not have this problem, on the other hand I remain with the problem: Error when sending ChangeReport to Alexa: INVALID_ACCESS_TOKEN_EXCEPTION: Access token is not valid.
nobody has this problem? INVALID_ACCESS_TOKEN_EXCEPTION
Hello,
Thank you for this guide, but I have a problem, probably an error on my part, but I cannot find my skill in the application Alexa Amazon, I don't see the skil dev tab on the app.
Do you have any idea why or how? I specify that the test works well, I think I have done the guide well.
Thank you.
Hello,
Thank you already for this guide, but I have a problem, surely an error on my part, but I cannot find my skill in the application Alexa Amazon, I don't see the skil dev tab on the app.
Do you have any idea why or how? I specify that the test works well, I think I have done the guide well.
Thank you.
Edit: it's good, I got confused with the accounts
I just configured Alexa on HomeAsstsant following this guide and, although it works, I have the same concerns
Hello everybody
During the test small problem "errorMessage": "2020-09-12T16: 20: 07.883Z 7eb1ef0f-ab00-4730-bb20-83f42334f119 Task timed out after 3.00 seconds"
however everything else is ok, has anyone had the same problem?
thank you in advance
Hello, I have the same error. can someone help us?
Same problem with me, could you have found a solution?
Hello, all niquel until I activate the skill and… no device found!
however from the aws console the test is a success and I can see all my devices in the log.
but the application alexa does not discover any ..
Great tutorial !!
I now order my amp and co with Alexa !!!
Thank you !!!!
For those who have a problem of the type:
Error when sending ChangeReport to Alexa: INVALID_ACCESS_TOKEN_EXCEPTION: Access token is not valid.
1 - In the securiy profile "login with amazon ", Add your HA url + port in" Allowed Origins "
2 - in the skill alexa, permission tab: check "send alexa event ”and copy the alexa client ID and client secret which appear below
3 - from the conf.yaml file: replace client id and client_secret by those we copied just before
4 - also make sure that the external url is configured for HASS (configuration tab> general> external url> your domain: port) (in your profile, the advanced parameters must be activated)
5- deactivate / reactive skil / redemare hass as much as necessary
and no more mistakes for me….
Thanks for the info Julien! 🙂
great everything works thank you !!!!
Thank you for your feedback Steven! See you soon on the group…;) '
Hello,
I followed the instructions to the letter and it worked the first time! Pure happiness when it works like that, in addition to the captures, the tutorial is great!
A big thank you for this great job!
Hello, I have the same thing as you, have you found a solution?
Hello,
it does not work for me, I have this error which appears every time in the dHA logs:
Error when sending ChangeReport to Alexa: INVALID_ACCESS_TOKEN_EXCEPTION: Access token is not valid.
Hello,
I have an error "` {
"ErrorMessage": "HTTPConnectionPool (host = 'localhost', port = 8123): Max retries exceeded with url: / api /alexa/smart_home (Caused by NewConnectionError (': Failed to establish a new connection: [Errno 111] Connection refused',)) »,
"ErrorType": "ConnectionError",
"StackTrace": [
[
"/Var/task/haaska.py",
111,
"Event_handler",
'Return ha.post ('alexa/smart_home ', event, wait = True) "
],
[
"/Var/task/haaska.py",
65,
"Post",
"Timeout = (None, read_timeout))"
],
[
"/Var/task/requests/sessions.py",
581,
"Post",
"Return self.request ('POST', url, data = data, json = json, ** kwargs)"
],
[
"/Var/task/requests/sessions.py",
533,
"Request",
"Resp = self.send (prep, ** send_kwargs)"
],
[
"/Var/task/requests/sessions.py",
646,
"Send",
"R = adapter.send (request, ** kwargs)"
],
[
"/Var/task/requests/adapters.py",
516,
"Send",
"Raise ConnectionError (e, request = request)"
]
]
} "` |
I have the skill dev in Alexa.
merci pour votre aide
I didn't have to deploy the script 🙂
For my part, I followed the tutorial and it generally worked apart from Account Linking. Skill Alexa just did not want to associate.
For this part, I followed the official tutorial and it solved my problem: https://www.home-assistant.io/integrations/alexa.smart_home/#account-linking
Hello,
I had the same error and it comes from a long token info which does not have to put in the "account linking" step in token you must put nothing and after that I no longer have this error but unfortunately you have to erase all to start over
Hello,
I have exactly the same concerns.
Did you find a solution?
Thanks in advance
Hello,
Busy for more than 6 hours redoing and redoing and redoing the procedure that I know almost by heart now.
IMPOSSIBLE to have a correct test.
Here is the answer.
{
"ErrorMessage": "HTTPSConnectionPool (host = 'did ****. Duckdns.org', port = 8123): Max retries exceeded with url: / api /alexa/smart_home (Caused by SSLError (SSLError (1, '[SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c: 852)'),)) ”,
"ErrorType": "SSLError",
"StackTrace": [
[
"/Var/task/haaska.py",
111,
"Event_handler",
'Return ha.post ('alexa/smart_home ', event, wait = True) "
],
[
"/Var/task/haaska.py",
65,
"Post",
"Timeout = (None, read_timeout))"
],
[
"/Var/task/requests/sessions.py",
581,
"Post",
"Return self.request ('POST', url, data = data, json = json, ** kwargs)"
],
[
"/Var/task/requests/sessions.py",
533,
"Request",
"Resp = self.send (prep, ** send_kwargs)"
],
[
"/Var/task/requests/sessions.py",
646,
"Send",
"R = adapter.send (request, ** kwargs)"
],
[
"/Var/task/requests/adapters.py",
514,
"Send",
"Raise SSLError (e, request = request)"
]
]
}
If anyone has an answer, before I definitely give up on the project.
thanking you in advance.
Nothing to do, 10 times that I redo the procedure, always INVALID_ACCESS_TOKEN_EXCEPTION ...
Something has changed on the side ofAmazon, this tutorial is no longer relevant it's not possible otherwise
personally I removed the last 3 line of the yaml file and it works correctly I have all my sensors including deconz. is your test working?
I made a mixture of the 2 videos and this one does not put the last of the yaml files
https://youtu.be/dmeIEEKmv58
try to get into your home assistant from the outside to see if it works
Hello, Super tutorial! Thanks a lot. Did I make a mistake somewhere?
the test gives me this error
{
"ErrorMessage": "Unable to import module 'lambda_function'"
}
Lambda cannot find the lambda_function.py file. Check that your handler follows the file-name.method format.
Do you see where it can come from?
Thank you
Clt
we need more info Nicolas. I also had problems at the beginning because I was missing information. so I also took the tutorial from Dzzz see youtube link above.
Check the settings again.
thanks for your return
Hello Sébastien, thank you for your return. Can I redo the whole procedure without it upsetting everything?
Hello Sébastien, thank you for your return. Do you think that it is possible to redo the whole procedure without causing a mess?
please
no you can but above all erase the previous one each time, personally I put a different name and erase the old one. keep me informed
It works very well! In addition, I added a few lines in the configuration.yaml file in order not to allow Alexa to control some well-defined devices. Only this last step does not seem to want to work.
attached the added lines:
alexa:
smart_home:
locale: fr-FR
endpoint: https://api.eu.amazonalexa.com/v3/events
filter:
include_entities:
- light.toto
- light.tata
I answered myself: you have to apply the filter to the block smart_home and not in the OR alexa like I was doing (indentation)
alexa:
smart_home:
locale: fr-FR
endpoint: https://api.eu.amazonalexa.com/v3/events
filter:
include_entities:
- light.toto
- light.tata
I have the same error, could you solve it? (In the manager, I put haaska.event_handler)
Hello, I have the same concerns, so how could you test the function?
Hello, the test does not work ... it tells me:
"ErrorMessage": "Unable to import module 'lambda_function': No module named 'lambda_function'"
If I change to haaska.event_handler, same error 😕
And now :
Response
{
"ErrorMessage": "Unable to import module 'haaska': No module named 'haaska'",
"ErrorType": "Runtime.ImportModuleError"
}
Help
A big thank you for this additional info which allowed me to activate the skill.
In the tutorial, point n ° 2 is not specified.
Point n ° 3 contradicts what is indicated in the tutorial (the latter does not make us take the correct ID / Secret for the configuration file)
It might be good to update for the next 😉
Anyway a big thank you I was able to go to the end of the activation 🙂
Hello Hello,
Great tutorial. it must have taken some time. Unfortunately for me it doesn't work.
I also have a little problem during the test (see below). I wonder if this is not related to multi factor authentication?
When I connect to HA from my app it asks me for a 2nd security key.
I imagine it's the same here? or is it just managed by the token?
I do not understand the comment from Romain Denis (13/05/2020) with the spaces in front of api :. I don't see any spaces in his post.
I had the problem by downloading the zip that there is a haaska-1.1.0.zip and a haaska_1.1.0. Obviously I took the wrong one.
My access works fine from the outside but I have this error:
Response
{
"ErrorMessage": "Expecting value: line 4 column 12 (char 266)",
"ErrorType": "JSONDecodeError",
"StackTrace": [
[
"/Var/task/haaska.py",
106,
"Event_handler",
"Config = Configuration ('config.json')"
],
[
"/Var/task/haaska.py",
80,
"__Init__",
"Self._json = json.load (f)"
],
[
"/Var/lang/lib/python3.6/json/__init__.py",
299,
"Load",
"Parse_constant = parse_constant, object_pairs_hook = object_pairs_hook, ** kw)"
],
[
"/Var/lang/lib/python3.6/json/__init__.py",
354,
"Loads",
"Return _default_decoder.decode (s)"
],
[
"/Var/lang/lib/python3.6/json/decoder.py",
339,
"Decode",
"Obj, end = self.raw_decode (s, idx = _w (s, 0) .end ())"
],
[
"/Var/lang/lib/python3.6/json/decoder.py",
357,
"Raw_decode",
"Raise JSONDecodeError (\" Expecting value \ ", s, err.value) from None"
]
]
}
Function Logs
START RequestId: 41535708-afbe-4e16-b2c0-4ee2ace1a89b Version: $LATEST
Expecting value: line 4 column 12 (char 266): JSONDecodeError
Traceback (most recent call last):
File "/var/task/haaska.py", line 106, in event_handler
config = Configuration ('config.json')
File "/var/task/haaska.py", line 80, in __init__
self._json = json.load (f)
File "/var/lang/lib/python3.6/json/__init__.py", line 299, in load
parse_constant = parse_constant, object_pairs_hook = object_pairs_hook, ** kw)
File "/var/lang/lib/python3.6/json/__init__.py", line 354, in loads
return _default_decoder.decode (s)
File "/var/lang/lib/python3.6/json/decoder.py", line 339, in decode
obj, end = self.raw_decode (s, idx = _w (s, 0) .end ())
File "/var/lang/lib/python3.6/json/decoder.py", line 357, in raw_decode
raise JSONDecodeError ("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 4 column 12 (char 266)
END RequestId: 41535708-afbe-4e16-b2c0-4ee2ace1a89b
REPORT RequestId: 41535708-afbe-4e16-b2c0-4ee2ace1a89b Duration: 0.83 ms Billed Duration: 1 ms Memory Size: 128 MB Max Memory Used: 53 MB
RequestID
41535708-afbe-4e16-b2c0-4ee2ace1a89b
Have a good day,
L.
Hello hello,
It works really well. All erased, all started again -> it works nickel
Have a good day,
Ludo
Arf! It is sometimes the solution… The ways of data processing are sometimes impenetrable. ; p
Great i'm happy for you
Great article that helped me a lot because the French version of the hass help without illustrative images is too complicated for a novice. I got a pb at the end of the integration, check your duckdns if it doesn't work well. thanks again
Thanks for the feedback Vincent! 😀
Small additional question. Since I activated the duckdns I can no longer access the ha only from the DNS (the external duckdns address) and no longer from the internal IP with the App.
I have to cut my phone's wifi to switch to data. However
-I have correctly configured the two addresses and the ssid in the App
- I have correctly configured the two addresses in the config> generalities of ha
- with the web interface (via web browser) both addresses work
An idea ?
Have a good day
Wow, super technical but it works… incredible. WELL DONE !!
But it would be cool if the HA developers and the teams Amazon Alexa has a better shared API to avoid this kind of manipulation that is accessible to a few enthusiasts, or budding geek like me.
And thank you Berno for your qq advice which helped me to get out of the Final Test which was faulty at the start.
Like you I missed replacing "haaska.event_handler" in the handler, just after the Lambda function code.
Hello and thank you for this tutorial.
everything went well until the test 🙁
this is what I have in return:
{
"ErrorMessage": "Unable to import module 'lambda_function'"
}
Function Logs
START RequestId: 7778cefc-e7a6-408e-9120-53f242c98a6d Version: $LATEST
Unable to import module 'lambda_function': No module named 'lambda_function'
END RequestId: 7778cefc-e7a6-408e-9120-53f242c98a6d
REPORT RequestId: 7778cefc-e7a6-408e-9120-53f242c98a6d Duration: 0.41 ms Billed Duration: 1 ms Memory Size: 128 MB Max Memory Used: 43 MB Init Duration: 1.10 ms
RequestID
7778cefc-e7a6-408e-9120-53f242c98a6d
Do you have any idea of the problem
Thank you
Cdlt
Stéphane.
great tutorial (not easy must be said) to update but ok for me: good galley on the test but functional after having clicked on Deploy once the changes have been made in the frame "function code" and the modification of the manager " haaska.event_handler "in the frame" execution parameters "
Hello everyone
I executed the manipulation well and it works.
I noticed that after some time the new devices added after are no longer detected by Alexa .
devices removed fromalexa are no longer discovered either.
after test the lambda function sees all the devices. I deactivated then reactivated the skill but no changes.
on the console Amazon the number of users indicator fell to zero while before a single user.
it had happened to me before and I had done a reinstal fresh and everything was back.
an idea of why?
Hello everybody
Excellent tutorial and rather well detailed. I had a bit of trouble at the start, because I didn't want to go through DuckDNS but through Gandi but I had problems with the certificate so I preferred to get back on track. My lambda works perfectly and sends me back the list of devices.
On the other hand, when I go to see my skills in the app Alexa, it shows me my skills in dev mode with a message "this skill requires the association of an account" and when I try to activate it for use, it does not work with a message: "the authorization server returned an "error" parameter. And they specify that they encounter a problem connecting with the skill to associate my account.
Do you have an idea ?
Hello,
see Greg's response of June 21, 2020: on the lambda function declaration page, in the "Execution parameters" section, you must specify the manager: haaska.event_handler
Everything worked on the first try, thank you for this super complete tutorial!
Thank you for the feedback ! 🙂
Bonjour à tous
Thank you very much for this work.
Runs flawlessly.
Small problem because of the interface change of the development platform Amazon but by reading the comments one finds oneself there.
Have a nice day and keep it up.
Thanks for the feedback… 😀
Have a nice week end !
Hi how did you do your reinstal fresh
thanks for your return
Hello,
everything works fine until the skill is activated… Impossible to activate and no error message
Hello everybody
a big thank you for this very well detailed tutorial but I am desperately stuck in the test and do not know what to do except start again from zero! Can any of you tell me where to look after the following error please:
START RequestId: 91a9b0ed-2e79-47cb-be53-9e945771e97a Version: $LATEST
HTTPConnectionPool (host = 'localhost', port = 8123): Max retries exceeded with url: / api /alexa/smart_home (Caused by NewConnectionError (': Failed to establish a new connection: [Errno 111] Connection refused',)): ConnectionError
Traceback (most recent call last):
File "/var/task/haaska.py", line 111, in event_handler
return ha.post ('alexa/smart_home ', event, wait = True)
File "/var/task/haaska.py", line 65, in post
timeout = (None, read_timeout))
File "/var/task/requests/sessions.py", line 581, in post
return self.request ('POST', url, data = data, json = json, ** kwargs)
File "/var/task/requests/sessions.py", line 533, in request
resp = self.send (prep, ** send_kwargs)
File "/var/task/requests/sessions.py", line 646, in send
r = adapter.send (request, ** kwargs)
File "/var/task/requests/adapters.py", line 516, in send
raise ConnectionError (e, request = request)
requests.exceptions.ConnectionError: HTTPConnectionPool (host = 'localhost', port = 8123): Max retries exceeded with url: / api /alexa/smart_home (Caused by NewConnectionError (': Failed to establish a new connection: [Errno 111] Connection refused',))
END RequestId: 91a9b0ed-2e79-47cb-be53-9e945771e97a
REPORT RequestId: 91a9b0ed-2e79-47cb-be53-9e945771e97a Duration: 128.87 ms Billed Duration: 129 ms Memory Size: 128 MB Max Memory Used: 49 MB Init Duration: 79.49 ms
It could be related to the config of my router (Freebox revolution) but I manage to connect in 4G, which seemed to me to exclude this option?
Thank you in advance for your help (fingers crossed)!
Good evening everyone,
A BIG thank you for this tutorial ... but I am desperately stuck on the test phase of the Lambda function with the following error message:
Test Event Name
MyEvent
Response
{
"ErrorMessage": "HTTPConnectionPool (host = 'localhost', port = 8123): Max retries exceeded with url: / api /alexa/smart_home (Caused by NewConnectionError (': Failed to establish a new connection: [Errno 111] Connection refused',)) »,
"ErrorType": "ConnectionError",
"StackTrace": [
[
"/Var/task/haaska.py",
111,
"Event_handler",
'Return ha.post ('alexa/smart_home ', event, wait = True) "
],
[
"/Var/task/haaska.py",
65,
"Post",
"Timeout = (None, read_timeout))"
],
[
"/Var/task/requests/sessions.py",
581,
"Post",
"Return self.request ('POST', url, data = data, json = json, ** kwargs)"
],
[
"/Var/task/requests/sessions.py",
533,
"Request",
"Resp = self.send (prep, ** send_kwargs)"
],
[
"/Var/task/requests/sessions.py",
646,
"Send",
"R = adapter.send (request, ** kwargs)"
],
[
"/Var/task/requests/adapters.py",
516,
"Send",
"Raise ConnectionError (e, request = request)"
]
]
}
Function Logs
START RequestId: 46cadfd5-2405-4882-bb7b-b9f07bf15cb1 Version: $LATEST
HTTPConnectionPool (host = 'localhost', port = 8123): Max retries exceeded with url: / api /alexa/smart_home (Caused by NewConnectionError (': Failed to establish a new connection: [Errno 111] Connection refused',)): ConnectionError
Traceback (most recent call last):
File "/var/task/haaska.py", line 111, in event_handler
return ha.post ('alexa/smart_home ', event, wait = True)
File "/var/task/haaska.py", line 65, in post
timeout = (None, read_timeout))
File "/var/task/requests/sessions.py", line 581, in post
return self.request ('POST', url, data = data, json = json, ** kwargs)
File "/var/task/requests/sessions.py", line 533, in request
resp = self.send (prep, ** send_kwargs)
File "/var/task/requests/sessions.py", line 646, in send
r = adapter.send (request, ** kwargs)
File "/var/task/requests/adapters.py", line 516, in send
raise ConnectionError (e, request = request)
requests.exceptions.ConnectionError: HTTPConnectionPool (host = 'localhost', port = 8123): Max retries exceeded with url: / api /alexa/smart_home (Caused by NewConnectionError (': Failed to establish a new connection: [Errno 111] Connection refused',))
END RequestId: 46cadfd5-2405-4882-bb7b-b9f07bf15cb1
REPORT RequestId: 46cadfd5-2405-4882-bb7b-b9f07bf15cb1 Duration: 139.76 ms Billed Duration: 140 ms Memory Size: 128 MB Max Memory Used: 49 MB Init Duration: 78.74 ms
RequestID
46cadfd5-2405-4882-bb7b-b9f07bf15cb1
Can you direct me to the error I made please?
Thank you in advance for your help !
If all the tutorials in the world could be like this one, that would be great! I have rarely seen such clear and precise explanations, especially on such a sharp subject. Hats off guys, this is a great job! 20/20!
Same problem as Dabo (above)… connection pb.
If somebody has an idea !!!
Hello, I can only reiterate the congratulations on this excellent tutorial! I have reached the end and the test is working (several information about my devices on HASS are displayed). On the other hand in Alexa, after adding my skill, no device is discovered 🙁 I therefore cannot control my robot vacuum cleaner for example. What did I miss? Help. Thank you
Just an info on device discovery on Alexia, when I had to install google backup on ha I was unable to discover my devices so I restored my system before installing google drive backup. and I constantly test the discovery of devices with each update of ha and addons
Hello, I cannot find or download this haaska.zip file ??? I looked all over the page ... Where is it?
Thank you
Hello,
However, there is good: Hasska 1.1.0 on Github. The archive can be downloaded directly here.
Hello, great tutorial, but it seems that the pages amazon have changed a bit.
I can't find the "login with amazon »And therefore I do not manage to finish the tutorial.
can someone tell me where it is?
Hello,
Thank you !
It's circled on the capture, and I just checked, the tab is still in the same place… Are you on the site develop.amazon.com ?
I will try the procedure again tonight or tomorrow (hard to be concentrated with the children: p)
Subsidiary questions, my Echo is on the account (mail /amazon) of my spouse, can we link it? or do I have to create the AWS account with his email?
To tell the truth, I always use the same account, I have not tried with different accounts… 😉
Hello,
it no longer works at home since yesterday (I switched to fiber)
I don't quite understand why ...
I updated my ip on duckdns (they have changed)
I'm not sure where to look, it has always worked so far
not much if I retest the aws function:
START RequestId: 9e76d30b-2845-449f-a4cc-a11344c12fbc Version: $ LATEST
END RequestId: 9e76d30b-2845-449f-a4cc-a11344c12fbc
REPORT RequestId: 9e76d30b-2845-449f-a4cc-a11344c12fbc Duration: 3003.65 ms Billed Duration: 3000 ms Memory Size: 128 MB Max Memory Used: 19 MB
2021-12-01T18:41:41.307Z 9e76d30b-2845-449f-a4cc-a11344c12fbc Task timed out after 3.00 seconds
There, if anyone has an idea?
Well I found the solution, I can't really explain why but here is what I did:
- New address on duckdns to force an update of the certificate (I had a problem for almost 1 year ^^)
- in configuration.yalm I removed (comment suddenly) the line with the address:
http:
#base_url: https://*****************
ssl_certificate: /ssl/fullchain.pem
ssl_key: /ssl/privkey.pem
- I have modified the redirection port of my box because in the freebox interface it said to me "must be greater than 16384".
Before, I had 8123… don't understand… and it was written in red so good.
hence my new value 21876 for example (must be between 16384 to 65535)….
so I have :
start port = 21876
end port = 21876
destination port = 8123
The problems happened exactly the day I switched from adsl to fiber .. no idea if there is a link ...
There you go .. in any case if it can help someone else….
Good evening Robin,
Thank you for the feedback ! No doubt it will be useful for others ... 🙂
Is it the same box?
(Hello again ,
So I succeeded 🙂, I took the time and a corruption of SD in the meantime, but it is not obvious because the pages have changed a lot on the sites amazon , but we end up finding our way around if we stay methodical.
I had the Unable to import module 'lambda_function' error, but when reading the comments it is the handler which was not put (same, it is hard to find: p)
and to answer my question above (even if it seems obvious in the end), it must be on the account where the alexa (but we can link several accounts a priori).
at the end, we do not have the message in green during the test, but assuming that we have no error…. 🙂
alexa I just found a hundred or so periphery, I'm going to have some sorting to do, but as it is aptly named, it should be fine.
subsidiary question, HomeAssistant can talk alexa ? (I found it practical since jeedom)
Hello,
Thank you for the feedback ! 🙂
Of course, it is also possible to do Text-To-Speech with HA.
For example, I use this code for a welcome message:
- service: media_player.alexa_tts
data:
entity_id:
- media_player.dot_entree
message: "Bienvenue à la maison"
It is of course possible to add several entities so that the sound is broadcast on several Echo. 🙂
Hello,
Impossible to detect anything tonight on the side ofAlexa for my part ... However my lambda function works, I have many entities which go up when I execute the discover via the test of the Haaska function, I have my skill which is linked as trigger of this function, I have linked my skill to my app Alexa but no device appears. An idea ? Thank you 🙂
Try in the haaska config when you import JSON to put you in http://ton duck.dns.org account instead of https: // it happened to me then if it works, put https back to test
Hmm, my reverse proxy doesn't serve http, only https, don't really want to expose http in addition 🙁
No, it's as if my skill couldn't trigger the lambda function, is there a way to see in the lambda logs if the function was triggered and when? #awsnoob 🙂
(Hello again
after a week of operation, (everything works fine) and not yet tested to talk alexa, but I write down the code 🙂 I see this in my log files:
Logger: homeassistant.components.alexa.state_report
Source: components /alexa/state_report.py:166
Integration: Amazon Alexa (documentation, issues)
First occurred: 10:57:58 (231 occurrences)
Last logged: 11:36:36
Error when sending ChangeReport to Alexa: INVALID_ACCESS_TOKEN_EXCEPTION: Access token is not valid.
is it normal ?
Hello,
Thank you BCP for this tutorial,
I have the following error: "errorMessage": "2022-02-19T16:00:39.608Z a5d4f630-9a12-4471-8115-1e244943f0f6 Task timed out after 3.01 seconds"
Someone found the solution to fix this error,
Thank you for your reply,
Fred
Hats off to the tutorial!
A little long and a few hassles but only my fault and when I wanted to customize Otherwise it works perfectly.
Thanks for the tutorial
Great ! Thank you for the feedback. It is indeed a bit long… But free! 😉