Alexa Media Player - Custom Integration - On Life Support - Help wanted

It has come to my attention that the custom integration Alexa Media Player no longer has an active developer fixing issues. The custom integration appears to be on life-support. Fixes will not occur without community member intervention.

Please head over to Alexa Media Player and start assisting with issues if you can replicate them. It appears that the the current owner of the repository is only reviewing PRs and is not actively developing any more features or fixing issues.

Lastly, do not create issues in the repository to make complaints about the owners decision to stop development.

3 Likes

I know that one well known dev that has started forking it … schemelli

2 Likes

Yes chemelli started work on it a few weeks ago. But this is still the early stages and help is still needed.

3 Likes

I have a very initial coding of the new library at aioamazondevices

I’m interested in people testing the login process and confirming is working:

  • install the library: “pip install aioamazondevices”
  • download the test script library_test.py
  • run it "python library_test.py --country XX --email [email protected] --password ZZZ " where country is the 2 digit international code, like IT or Italy

Thank you for your help!

3 Likes

Running the script, I get to the OTP prompt, but never get a OTP sent. I tested in the browser and was able to get an OTP sent. I tested with both US and us and two different accounts.

Testing again in a browser, https://www.amazon.com/ap/signin?<snip> also sends an OTP code where the script doesn’t.

Also tested in both a venv and straight terminal.

There should be a log, don’t post it here. But there should be details on what’s stopping it.

Worse case if you can’t find the log, change the bottom of the script to…

if __name__ == "__main__":
    logging.basicConfig(filename='example.log', encoding='utf-8', level=logging.DEBUG)
    logging.getLogger("asyncio").setLevel(logging.WARNING)
    logging.getLogger("httpcore").setLevel(logging.WARNING)
    logging.getLogger("httpx").setLevel(logging.WARNING)
    logging.getLogger("charset_normalizer").setLevel(logging.WARNING)
    asyncio.run(main())

Assuming chemeli added logs :slight_smile:

1 Like

never get a OTP sent.

How is your OTP usually generated ? Google authenticator or similar app ?

SMS from Amazon.

DEBUG:aioamazondevices:Logging-in for [email protected] [otp code 123456]
DEBUG:aioamazondevices:Creating HTTP ClientSession
DEBUG:aioamazondevices:Build oauth URL
DEBUG:aioamazondevices:GET request: https://www.amazon.DE/ap/signin[...] 
DEBUG:aioamazondevices:Get request data from HTML source
Traceback (most recent call last):
  File "/share/alexa_test/library_test.py", line 89, in <module>
    asyncio.run(main())
  File "/usr/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/base_events.py", line 654, in run_until_comp                                                                                                             lete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/share/alexa_test/library_test.py", line 63, in main
    await api.login(args.otp_code or input("OTP Code: "))
  File "/share/alexa_test/lib/python3.11/site-packages/aioamazondevices/api.py",                                                                                                              line 194, in login
    login_method, login_url = self._get_request_from_soup(login_soup)
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/share/alexa_test/lib/python3.11/site-packages/aioamazondevices/api.py",                                                                                                              line 153, in _get_request_from_soup
    method = form["method"]
             ~~~~^^^^^^^^^^
  File "/share/alexa_test/lib/python3.11/site-packages/bs4/element.py", line 157                                                                                                             3, in __getitem__
    return self.attrs[key]
           ~~~~~~~~~~^^^^^
KeyError: 'method'

My result (GET request cut by me)

It seems to work, if the country is written in small letters (de instead of DE).
I had to escape some special characters in the password though (also in the previous attempt).
Do you need any output?

1 Like

It seems to work, if the country is written in small letters (de instead of DE).

Thx, this is an important feedback.

I had to escape some special characters in the password though (also in the previous
attempt).

This is due only to the nature of the test, via script, will not be a problem with the integration itself.

Do you need any output?

No thx, was enough a “is working” feedback.

SMS from Amazon.

I got one more report that SMS is sometimes slower nowsdays.
I bet Amazon is somehow trying to move users to an authenticator app.

That might be the case, but from my browser tests, they were fast. The one from the library didn’t ever come at all. I will try a little later to run the script in my Container and see if that has better results. I originally tested it just from a quick venv I setup locally.

So, as soon as I changed from SMS for OTP to an MFA app, I was able to get in and see my devices… However, with that said, there’s still an issue with the SMS MFA provider. Not sure where it might be though.

I’m going to try a couple more tests and see if I can figure it out.

EDIT: So, oddly enough, after I enter in the OTP from a MFA app, THEN I get an SMS from Amazon with another OTP code. :roll_eyes:

Released v0.1.1 that will take care of country code if in upper case.

1 Like

Just noticed this thread.

I was using this addon before I beleive or something similar on homebridge.

Doesn’t nabu casa provide most of the same functionality or am I missing something.

Not a developer but I’m willing to help if I can.

Alexa Media Player exposes Alexa devices to home assistant to be controlled (and i some minor cases the things directly connected to those Echos.

The integratjon/Nabu Casa things you’re thinking of work the other way - exposing HA to Amazon.

FYI, if you run dev container, it’s pretty easy.

Just make a json file in the root directory named library_test.json with the following contents filled out:

{
    "country": "xx",
    "email": "[email protected]",
    "password": "xxxx"
}

You can even add your otp_code in there if you want but the debug launch will also ask for it.