#amazon_devices not working in austria

1 messages · Page 1 of 1 (latest)

stoic plank
#

@austere dew I am writing regarding issue https://github.com/chemelli74/aioamazondevices/issues/217

This is my log:

Traceback (most recent call last):
  File "/home/ccomm/test/aioamazondevices/library_test.py", line 280, in <module>
    asyncio.run(main())
    ~~~~~~~~~~~^^^^^^^^
  File "/usr/lib/python3.13/asyncio/runners.py", line 195, in run
    return runner.run(main)
           ~~~~~~~~~~^^^^^^
  File "/usr/lib/python3.13/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/usr/lib/python3.13/asyncio/base_events.py", line 719, in run_until_complete
    return future.result()
           ~~~~~~~~~~~~~^^
  File "/home/ccomm/test/aioamazondevices/library_test.py", line 158, in main
    login_data = await api.login_mode_interactive(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        args.otp_code or input("OTP Code: "),
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/ccomm/.local/lib/python3.13/site-packages/aioamazondevices/api.py", line 492, in login_mode_interactive
    login_method, login_url = self._get_request_from_soup(login_soup)
                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
  File "/home/ccomm/.local/lib/python3.13/site-packages/aioamazondevices/api.py", line 235, in _get_request_from_soup
    raise TypeError("Unable to extract form data from response")
TypeError: Unable to extract form data from response
2025-06-05 11:01:17.016 ERROR (MainThread) [asyncio] Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x71d59f3446e0>
2025-06-05 11:01:17.016 ERROR (MainThread) [asyncio] Unclosed connector
connections: ['deque([(<aiohttp.client_proto.ResponseHandler object at 0x71d59f3068d0>, 686787.897410918)])', 'deque([(<aiohttp.client_proto.ResponseHandler object at 0x71d59f306e10>, 686788.078384105)])']
connector: <aiohttp.connector.TCPConnector object at 0x71d59f344830>
GitHub

Describe the bug This library does not have a fallback if a country that is not in the list is selected. As this library is used in homeassistant, there is the ability to select any country. To Rep...

#

Interestingly when I use US instead of AT as a country, the login works! Or rather, it crashes in another way:

Traceback (most recent call last):
  File "/home/ccomm/test/aioamazondevices/library_test.py", line 280, in <module>
    asyncio.run(main())
    ~~~~~~~~~~~^^^^^^^^
  File "/usr/lib/python3.13/asyncio/runners.py", line 195, in run
    return runner.run(main)
           ~~~~~~~~~~^^^^^^
  File "/usr/lib/python3.13/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/usr/lib/python3.13/asyncio/base_events.py", line 719, in run_until_complete
    return future.result()
           ~~~~~~~~~~~~~^^
  File "/home/ccomm/test/aioamazondevices/library_test.py", line 183, in main
    devices = await api.get_devices_data()
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ccomm/.local/lib/python3.13/site-packages/aioamazondevices/api.py", line 599, in get_devices_data
    do_not_disturb_node = device[NODE_DO_NOT_DISTURB]
                          ~~~~~~^^^^^^^^^^^^^^^^^^^^^
KeyError: 'doNotDisturbDeviceStatusList'
2025-06-05 11:06:10.307 ERROR (MainThread) [asyncio] Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x73070c13c6e0>
2025-06-05 11:06:10.308 ERROR (MainThread) [asyncio] Unclosed connector
connections: ['deque([(<aiohttp.client_proto.ResponseHandler object at 0x73070c1028d0>, 687079.356090669)])', 'deque([(<aiohttp.client_proto.ResponseHandler object at 0x73070b788cb0>, 687080.297551496)])', 'deque([(<aiohttp.client_proto.ResponseHandler object at 0x73070c102db0>, 687081.386285712)])']
connector: <aiohttp.connector.TCPConnector object at 0x73070c13c830>
#

also, when I click on the pages for the signin, amazon responds with 404

#

i think the problem might be that the URL in germany is https://www.amazon.de/-/en/ap/signin

#

I patched the domain of AT to be "de/-/en" so the code would work correctly but now because of that it fails further down where it tries alexa.amazon.at, which does not exist, as austrian devices also use alexa.amazon.de

#

this is the new error after using DE instead of AT:

Traceback (most recent call last):
  File "/home/ccomm/test/aioamazondevices/library_test.py", line 280, in <module>
    asyncio.run(main())
    ~~~~~~~~~~~^^^^^^^^
  File "/usr/lib/python3.13/asyncio/runners.py", line 195, in run
    return runner.run(main)
           ~~~~~~~~~~^^^^^^
  File "/usr/lib/python3.13/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/usr/lib/python3.13/asyncio/base_events.py", line 719, in run_until_complete
    return future.result()
           ~~~~~~~~~~~~~^^
  File "/home/ccomm/test/aioamazondevices/library_test.py", line 183, in main
    devices = await api.get_devices_data()
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ccomm/.local/lib/python3.13/site-packages/aioamazondevices/api.py", line 584, in get_devices_data
    json_data = {} if len(response_data) == 0 else await raw_resp.json()
                                                   ^^^^^^^^^^^^^^^^^^^^^
  File "/home/ccomm/.local/lib/python3.13/site-packages/aiohttp/client_reqrep.py", line 745, in json
    raise ContentTypeError(
    ...<7 lines>...
    )
aiohttp.client_exceptions.ContentTypeError: 200, message='Attempt to decode JSON with unexpected mimetype: text/html;charset=utf-8', url='https://www.amazon.de/ap/signin?showRmrMe=1&openid.return_to=https://alexa.amazon.de/api/devices-v2/device&openid.identity=http://specs.openid.net/auth/2.0/identifier_select&openid.assoc_handle=amzn_dp_project_dee_de&openid.mode=checkid_setup&openid.claimed_id=http://specs.openid.net/auth/2.0/identifier_select&openid.ns=http://specs.openid.net/auth/2.0&'
austere dew
#

Hi

#

Then logout and login, so we can see exactly the endpoint used for your acocunt

#

We spent a lot of time to fix UK that is a quite particoular country due to the UK/GB dualism

#

and I have confirmation from DE users that everything works for them

austere dew
#

The login URL you posted is from a browser login to the website, not from Alexa App

#

isn't it ?

#

try using DE in library_test.json parameters and report back if if works

stoic plank
#
2025-06-05 14:48:46.196 DEBUG (MainThread) [aioamazondevices] CSRF cookie value: <None>
Traceback (most recent call last):
  File "/home/ccomm/test/aioamazondevices/library_test.py", line 280, in <module>
    asyncio.run(main())
    ~~~~~~~~~~~^^^^^^^^
  File "/usr/lib/python3.13/asyncio/runners.py", line 195, in run
    return runner.run(main)
           ~~~~~~~~~~^^^^^^
  File "/usr/lib/python3.13/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/usr/lib/python3.13/asyncio/base_events.py", line 719, in run_until_complete
    return future.result()
           ~~~~~~~~~~~~~^^
  File "/home/ccomm/test/aioamazondevices/library_test.py", line 183, in main
    devices = await api.get_devices_data()
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ccomm/.local/lib/python3.13/site-packages/aioamazondevices/api.py", line 584, in get_devices_data
    json_data = {} if len(response_data) == 0 else await raw_resp.json()
                                                   ^^^^^^^^^^^^^^^^^^^^^
  File "/home/ccomm/.local/lib/python3.13/site-packages/aiohttp/client_reqrep.py", line 745, in json
    raise ContentTypeError(
    ...<7 lines>...
    )
aiohttp.client_exceptions.ContentTypeError: 200, message='Attempt to decode JSON with unexpected mimetype: text/html;charset=utf-8', url='https://www.amazon.de/ap/signin?showRmrMe=1&openid.return_to=https://alexa.amazon.de/api/devices-v2/device&openid.identity=http://specs.openid.net/auth/2.0/identifier_select&openid.assoc_handle=amzn_dp_project_dee_de&openid.mode=checkid_setup&openid.claimed_id=http://specs.openid.net/auth/2.0/identifier_select&openid.ns=http://specs.openid.net/auth/2.0&'
#

sorry, this last one was because caching via the out folder (did not know that it would also read it back in)

#

maybe it makes sense to add ifs before each key accessing?

austere dew
#

the not disturb is a problem that some users are facing from time to time

#

but reloading fix the issue. Maybe a "too meny requests" issue

#

so just try a few times and it should be good to go

#

Basically the solution is to rename the Country selector to "Amazon Country"

stoic plank
#

how would i retry it in homeassistant?

#

because with the US region the devices are there but they all are unavailable / have no data

#

but with DE / AT i never got through the login stage

#

i always get "a unknown error occured"

austere dew
#

are you on b5 ?

#

also do a "pip list | grep aioamazondevices" on the machine you are running the library_test from

stoic plank
austere dew
austere dew
stoic plank
austere dew
#

Check in info-> system

stoic plank
#

the commands are all ran in the host OS, not inside the container

#

2025.6.0b5

austere dew
#

Ok so latest from HA as well

#

I don’t know why it works from command line and not from HA

#

is the same library that is invoked

stoic plank
#

well, from the command line it also does not work completely

#

in command line the login works, but there is no data

austere dew
#

Please post a fresh log from command line with DE as country

stoic plank
#

The crash happens in here:

Traceback (most recent call last):
  File "/home/ccomm/test/aioamazondevices/library_test.py", line 280, in <module>
    asyncio.run(main())
    ~~~~~~~~~~~^^^^^^^^
  File "/usr/lib/python3.13/asyncio/runners.py", line 195, in run
    return runner.run(main)
           ~~~~~~~~~~^^^^^^
  File "/usr/lib/python3.13/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/usr/lib/python3.13/asyncio/base_events.py", line 719, in run_until_complete
    return future.result()
           ~~~~~~~~~~~~~^^
  File "/home/ccomm/test/aioamazondevices/library_test.py", line 183, in main
    devices = await api.get_devices_data()
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ccomm/.local/lib/python3.13/site-packages/aioamazondevices/api.py", line 599, in get_devices_data
    do_not_disturb_node = device[NODE_DO_NOT_DISTURB]
                          ~~~~~~^^^^^^^^^^^^^^^^^^^^^
KeyError: 'doNotDisturbDeviceStatusList'
#

These are the files in the out folder after running the command that resulted in above error:

total 436K
drwxr-xr-x 1 ccomm ccomm  394 Jun  5 16:27 .
drwxr-xr-x 1 ccomm ccomm  652 Jun  5 16:27 ..
-rw-r--r-- 1 ccomm ccomm 2.7K Jun  5 16:27 api-bluetooth.json
-rw-r--r-- 1 ccomm ccomm  11K Jun  5 16:27 api-device-preferences.json
-rw-r--r-- 1 ccomm ccomm  14K Jun  5 16:27 api-devices-v2.json
-rw-r--r-- 1 ccomm ccomm 1.1K Jun  5 16:27 api-dnd.json
-rw-r--r-- 1 ccomm ccomm 103K Jun  5 16:27 ap-signin_2.html
-rw-r--r-- 1 ccomm ccomm  81K Jun  5 16:27 ap-signin_3.html
-rw-r--r-- 1 ccomm ccomm 180K Jun  5 16:27 ap-signin.html
-rw-r--r-- 1 ccomm ccomm 6.9K Jun  5 16:27 auth-register_2.json
-rw-r--r-- 1 ccomm ccomm 6.9K Jun  5 16:27 auth-register.json
-rw-r--r-- 1 ccomm ccomm 5.3K Jun  5 16:27 login_data.json
-rw-r--r-- 1 ccomm ccomm 5.3K Jun  5 16:27 output-login-data.json
austere dew
#

again, for some devices sometimes this key is not present then it comes present; dunno why

#

try reloading the integration few times

stoic plank
#

Imo we should never assume that some key exists, and what I am guessing is that because my devices are quite old or maybe because it's a German device it doesn't have those properties. I would highly recommend adding if-statements Infront of every key index

austere dew
#

Hi, do you have a fresh debug level log from 2025.7.0 ?

#

I have a good mix of old and new devices and the key are definitively there