Alexa, no cloud, external port 8123 with events!

  1. I was careful to use the same login (email address) for AWS, Alexa login and Amazon developer.
  2. For the login validation to get the login token, I used a trick. I made a LWA (Login with Amazon) account in Amazon Developer and used that to satisfy the need for Alexa to login to the app. Then, in the lambda function I totally ignored the token sent by Alexa and used the LLAT instead.
  3. You do need a login for send events, but for that you use the login that is created by Amazon in your skill.

I’m fricking thrilled!

I got it working here, I was doing wrong (without LWA), and after I used, it started working perfectly… Thanks!

Are you using HTTPS and SSL from lambda function or HTTP?

hi, i’m struggling with it… i understand what you said, but i don’t know how to create the LWA and how to make the Alexa skill log in that way…
Can you explain it in details?

Thanks…

maybe i find the issue…
i forgot to put the Allowed Return URLs in security profile of LWA… :slight_smile:

Good, 'cause I can’t remember and I’d have to look it up! Are you up and running? Gotta say I’m thrilled with this, and the price is right.

Hello I am fairly new to home assistant and have zero knowledge about codes.

can you please explain how to make changes to lambda. " 1. Edit matt2005 lambda to comment out lines 50 and 51 and outdent 52 to force it to always use the LLAT."

and is llat long lived access token?

and if possible can i have some screenshots for same.

i know im asking a lot .thanks to anyone who can help.

change

    token = scope.get('token')
    if token is None and _debug:
        token = os.environ.get('LONG_LIVED_ACCESS_TOKEN')  # only for debug purpose

to

    token = os.environ.get('LONG_LIVED_ACCESS_TOKEN')  # only for debug purpose

Note that I used July 2,2019 version of matt2005/lambda_function.py and I continue to use it and LOVE it!

Hi mate. Thanks for your post. I successfully followed steps 1 (setup Alexa as per HA instructions), modified the matt2005 Python script to force the use of a LLAT. I have also kept the LLAT in my amazon alexa settings environment variable (as per HA instructions too).

However, I am lost in step 4. I am confident with coding but never used Amazon Developer before, so where exactly do I link my HA using LWA method? Only way I know is using Alexa app normally and logging in, but that fails because I am not using port 443.

Is there a guide which shows me how to setup LWA (I googled this but don’t quite see how HA will work with it) and link my home assistant to my alexa on port 8123? I have successfully added endpoint, client_id, client secret I generated from Amazon login to my configuration file , but how do I go about linking?

Would appreciate the help mate.
Thanks.

First, I will say it is still working perfectly.

Second, I need a bit of time to look at how I did it. I remember it was easy once I understood the pieces and their roles then came up with a good way to do it.

Sounds like you and I have similar computer skills. Many years of programming but no experience with AWD which, of course, is a key component of this solution.

When you get it working, perhaps you and I can both put a bit more meat on the first post of this thread to fill in a few assumptions.

Couple of days, please… Nudge me if it has been more than 1 week.

Note, pretty sure it doesn’t matter but I’m in Canada though I choose to tell Amazon that US is my location 'cause this stuff doesn’t work using Canada. It works in other regions (Ireland etc.) but I don’t know which URLs change for other regions. Search this forum and/or Google to find out.

So as I understand, you have progressed through the HA instructions , editing the matt2005 and keeping (not deleting) the LLAT and now you are at the Linking section and need more detail on differences from the HA instructions:

At the HA instructions Linking section use only the following, slightly edited subset of this post to replace most of the Linking section.

Now continue the HA instructions starting at the screenshot near the end of the Linking section

Screenshot: Account Linking

A small caution. there may be minor mistakes or missing items (though I did look carefully) and there may be more questions you have. Please help others by including me in your struggles so I can edit this post to give the next person a complete and simple HOWTO. I will be happy to you and others.

Useful references:

  1. This documentation on the Alexa integration though it does not use LWA

  2. This thread that diverges from the simple approach in this thread but offers some details about LWA etc.

1 Like

Hi all

I’ve found your thread while looking for options to move away from my current Alexa setup for handling speech interaction with HA. I’m sorry for the dumb question, but what does this solution actually do?

Hi Keith.

Great, appreciate your help. I’ve successfully managed it and it works!

So basically, I think what you replied is already half the job done. You can edit your first post (since I cannot and you are the main champion here ha-ha), just state something along these lines (you can be a bit more informative if you wish but it is actually very simple once we know what we mean by LWA; since I had no idea what LWA was before this):

  1. Configure Alexa as per normal HA instructions normally
    1a. Keep in mind, use the debugging mode of the instructions that keep the LLAT (Long-Lived Access Token) and keep it in Alexa’s developer Environment variable permanently
  2. Follow instructions normally until Account Linking.
  3. Then you can link the reply word-to-word you gave me, its clear enough.

and done!

Great work Keith!

I do have one more question, regarding the events now, into configuration.yml. Did you link the Client ID and Client Secret we got from Alexa’s Developer console (as normally HA instructions) or did you use the AWA login’s client ID and secret?

This is basically integrating Amazon Alexa into your Home Assistant devices.

But the change is this; normally when you need to integrate without Nabu Casa, you MUST use port 443 since the way Amazon Alexa’s API works. However, not everyone can forward 443 or they just do not want to forward a common scanned attack port (like me), so if you want to keep port 8123 or whatever, using LLAT and this method, you can use any port for linking Alexa.

1 Like

Thank you for that info! I was hoping it might of been so voice commands given to Alexa bypass their cloud services and instead went elsewhere, possibly to a local voice command server… I’ll have to keep looking into that, but this info I’ll definitely keep in the back of my mind!

That’s what I wanted to hear! Thanks for being patient with my getting back to you. It’s been a couple of years since I’ve looked at it because it has been rock solid.

From your experience, I will edit the first post so others can benefit as well.

As for the Client ID and Secret for Proactive mode (i.e. the ones that go into configuration.yaml in HA), you use the ones from the Developer’s console.

I am actually interested in that myself, that is my next step. I’ve successfully done that via Google Home using their local mDNS service (guide available on HA instructions normally for Google).

For Alexa, I am yet to find out. Let me know if you find something!

Thanks to everybody on this thread, all this stuff helped me to resolve a big issue with my home assistant installation. Just for reference, some moths ago I started to have problems with my Movistar+ TV IP TV service from Telefonica, it to freezed the streaming ramdomly. I opened an incidence an they changed my router and my deco, It works at first, but as soon as I tried to load my backup configuration with the port forwarding of 443 to 8123 in my internal HASSIO it started to fail again. I suspected that the provider have commenced to use the 443 port to configurate/monitorize some features of the deco and when I made manually this port-forwarding probably I was impacting some of this. Thanks to this thread I could resolve the integration with Alexa using the 8123 directly because the problem with the Amazon Skills API having to use 443 to authenticate. Again many thanks to the community, hope this comment can helps others.

Regards.

So glad it works for you. If I was of help I’m very glad. I’ve had soooo many people help me with various things that any time I can help I am thrilled!

1 Like