alandtse / alexa_media_player

This is a custom component to allow control of Amazon Alexa devices in Home Assistant using the unofficial Alexa API.
Apache License 2.0
1.47k stars 283 forks source link

All devices unavailable after restart, list of device not appearing with new installation #2558

Open samuele2723 opened 1 week ago

samuele2723 commented 1 week ago

IMPORTANT: Please search the issues, including closed issues, and the FAQ before opening a new issue. The template is mandatory; failure to use it will result in issue closure.

Describe the bug

I am using this integration since few years, i was using it without any issue since a month ago, while upgrading to 4.13+ i had authentication issue, so i went back to 4.12.

Then, the 12th of september after a HA restart, all alexa echo devices appear offline ever since. I tried to reinstall the intregration, upgrade and reauthenticate from fresh, but in case of a fresh new installation the list doesn't appear at all (therefore why is unavailable in the list already present since previous)

To Reproduce

i can install a fresh new integration and list of devices not appearing even if the alexa account is active and devices there and working

ì

System details

Debug Logs (alexa_media & alexapy) Please provide logs.

Screenshot 2024-09-22 alle 22 14 54

Additional context

bennydente commented 1 week ago

Same here. on home assistant core 2024.9.2 and alexa media player 4.13.2.

thanks, bye

c2mfj commented 1 week ago

adding another one 2024-09-23 13:14:15.725 WARNING (MainThread) [alexapy.helpers] alexalogin.login((<alexapy.alexalogin.AlexaLogin object at 0x7f30da34bdd0>,), {'cookies': {}}): An error occurred accessing AlexaAPI: An exception of type TypeError occurred. Arguments: ('can only concatenate str (not "NoneType") to str',) 2024-09-23 13:14:15.725 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry <myEmailAddress> - amazon.com for alexa_media

kyleb822 commented 1 week ago

Same here, integration is now saying “Failed setup, will retry: Connection Error during login”

HA core 2024.9.2 AMP 4.13.2

38Cherry commented 1 week ago

same. image Logger: homeassistant.config_entries Source: config_entries.py:604 First occurred: 11:59:31 AM (1 occurrences) Last logged: 11:59:31 AM

Error setting up entry xxx@gmail.com - amazon.com for alexa_media Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 604, in async_setup result = await component.async_setup_entry(hass, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/alexa_media/init.py", line 361, in async_setup_entry await login.login(cookies=await login.load_cookie()) File "/usr/local/lib/python3.12/site-packages/alexapy/helpers.py", line 137, in wrapper return await func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/alexapy/alexalogin.py", line 713, in login self._site = await self._process_page(await post_resp.text(), site) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/alexapy/alexalogin.py", line 1506, in _process_page error_message += list_item.find("span").string TypeError: can only concatenate str (not "NoneType") to st

and

This error originated from a custom integration.

Logger: alexapy.helpers Source: custom_components/alexa_media/init.py:361 integration: Alexa Media Player (documentation, issues) First occurred: 11:59:31 AM (1 occurrences) Last logged: 11:59:31 AM

alexalogin.login((<alexapy.alexalogin.AlexaLogin object at 0x7fbe9f8be120>,), {'cookies': {}}): An error occurred accessing AlexaAPI: An exception of type TypeError occurred. Arguments: ('can only concatenate str (not "NoneType") to str',)

dersch81 commented 1 week ago

Same here

Dieser Fehler wurde von einer benutzerdefinierten Integration verursacht

Logger: alexapy.helpers
Quelle: custom_components/alexa_media/__init__.py:361
Integration: Alexa Media Player (Dokumentation, Probleme)
Erstmals aufgetreten: 23:34:56 (3 Vorkommnisse)
Zuletzt protokolliert: 23:41:56

alexalogin.login((<alexapy.alexalogin.AlexaLogin object at 0x7fcd9dd922d0>,), {'cookies': {}}): An error occurred accessing AlexaAPI: An exception of type TypeError occurred. Arguments: ('can only concatenate str (not "NoneType") to str',)

AMP 4.13.2 HASS 2024.9.2

stefanomarino75 commented 1 week ago

Same problem Too Many Requests

ruralleafowner commented 1 week ago

Same issue. Have spent hours on it, as do NOT want to delete and reinstall, worried it will get rid of all the automations I have setup.

Is it possible to re-authenticate the media player as I think this may be the issue? (I do not get the option to do this sadly!)

![Uploading Screenshot 2024-09-24 at 14.49.10.jpg…]()

darioz90 commented 1 week ago

Same issue after 20/30 min -> “All devices unavailable”

i try time polling to 500 , but don’t work

HA core 2024.9.2 AMP 4.13.2

mifraburneo commented 1 week ago

Exact same issue. HA core 2024.9.2 AMP 4.13.2

Poorly tried changing public domain to local ip and adding and removing trailing / Also to reinstall the integration Nothing so far...

delboydell commented 1 week ago

Same here for me in the UK Logger: homeassistant.config_entries Source: config_entries.py:604 First occurred: 08:51:19 (1 occurrences) Last logged: 08:51:19

Error setting up entry p.p.@net.com - amazon.co.uk for alexa_media Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 604, in async_setup result = await component.async_setup_entry(hass, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/alexa_media/init.py", line 361, in async_setup_entry await login.login(cookies=await login.load_cookie()) File "/usr/local/lib/python3.12/site-packages/alexapy/helpers.py", line 137, in wrapper return await func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/alexapy/alexalogin.py", line 671, in login site = await self._process_page(html, site) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/alexapy/alexalogin.py", line 1506, in _process_page error_message += list_item.find("span").string

This error originated from a custom integration.

Logger: alexapy.helpers Source: custom_components/alexa_media/init.py:361 integration: Alexa Media Player (documentation, issues) First occurred: 08:51:19 (1 occurrences) Last logged: 08:51:19

alexalogin.login((<alexapy.alexalogin.AlexaLogin object at 0x7fe1963f2150>,), {'cookies': {}}): An error occurred accessing AlexaAPI: An exception of type TypeError occurred. Arguments: ('can only concatenate str (not "NoneType")

121Westlife212 commented 1 week ago

Same here for me (Spain)

Registrador: homeassistant.config_entries Fuente: config_entries.py:604 Ocurrió por primera vez: 07:48:50 (1 ocurrencias) Última vez registrado: 07:48:50

Error setting up entry joe***@*.com - amazon.es for alexa_media Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 604, in async_setup result = await component.async_setup_entry(hass, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/alexa_media/init.py", line 361, in async_setup_entry await login.login(cookies=await login.load_cookie()) File "/usr/local/lib/python3.12/site-packages/alexapy/helpers.py", line 137, in wrapper return await func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/alexapy/alexalogin.py", line 713, in login self._site = await self._process_page(await post_resp.text(), site) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/alexapy/alexalogin.py", line 1506, in _process_page error_message += list_item.find("span").string TypeError: can only concatenate str (not "NoneType") to str

cagnulein commented 1 week ago

Same issue unfortunately :(

JamesIrish commented 1 week ago

Same issue here from UK. Error for me is: TypeError: can only concatenate str (not "NoneType") to str as others have posted above as opposed to the TooManyRequests 429 issue.

c2mfj commented 1 week ago

I got mine working by updating to HA Core 2024.9.3. (that seemed to remove the "none type" error I was getting before) but then I was getting a generic authentication failure error in the logs.

I removed the AMP integration, restarted Home Assistant, and re-added it. Ran through the setup and everything is working again. For those who said they are worried about automations, the devices picked right back up and I didn't miss a beat.

PV-Joe commented 1 week ago

Same problem here in Germany. Please fix.

I tried to uninstall and reinstall and now I'm in a endless loop on the Amazon Login website during setup.

bennydente commented 1 week ago

Hi, there is a workaround for endless loop signin here. https://github.com/alandtse/alexa_media_player/issues/2514 In my scenario, after uninstall and reinstall, the integration stop working after some minutes and I receive this error """ An error occurred accessing AlexaAPI: An exception of type AlexapyLoginError occurred. Arguments: ('Login error detected; not contacting API',)""""

PV-Joe commented 1 week ago

I did use that workaround. After the next restart AMP was disconnected again.

Accidentally logging into amazon.com instead of amazon.de didn't have any issue.

This is really annoying. Hope for a fix.

zav13r commented 1 week ago

I think linked to this issue, after removing and reinstalling integration and following the workaround for the login loop, I receive a blank 'Error' dialogue back in HA at the final step and nothing is added.

This is using 2SV and both amazon.com and amazon.co.uk domains in setup.

CommittotheIndian commented 1 week ago

I'm in the same boat. I've tried removing the component completely, reinstalling, and now I get an error when trying to log in. I've gone back all the way to v12.2

mattia93cz commented 1 week ago

using AMP version 4.12.7 and 2024.9.3 for HA I don't encounter any problems. To resolve the authentication loop: instead of entering the data and logging in, just go to register new account and by entering the data the error "user already registered" will be returned. Once this step has been carried out, simply log in by entering the correct data and everything will work correctly.

CommittotheIndian commented 1 week ago

using AMP version 4.12.7 and 2024.9.3 for HA I don't encounter any problems. To resolve the authentication loop: instead of entering the data and logging in, just go to register new account and by entering the data the error "user already registered" will be returned. Once this step has been carried out, simply log in by entering the correct data and everything will work correctly.

I've done this multiple times. Its when I get returned to HA that HA just shows a blank error screen.

zav13r commented 1 week ago

using AMP version 4.12.7 and 2024.9.3 for HA I don't encounter any problems. To resolve the authentication loop: instead of entering the data and logging in, just go to register new account and by entering the data the error "user already registered" will be returned. Once this step has been carried out, simply log in by entering the correct data and everything will work correctly.

I've done this multiple times. Its when I get returned to HA that HA just shows a blank error screen.

This ^

It is not the Amazon login or 2SV that's the issue. The workaround for create new, then login works. It's back in HA at the final step that the error is generated and setup of thr integration fails.

mattia93cz commented 1 week ago

using AMP version 4.12.7 and 2024.9.3 for HA I don't encounter any problems. To resolve the authentication loop: instead of entering the data and logging in, just go to register new account and by entering the data the error "user already registered" will be returned. Once this step has been carried out, simply log in by entering the correct data and everything will work correctly.

I've done this multiple times. Its when I get returned to HA that HA just shows a blank error screen.

This ^

It is not the Amazon login or 2SV that's the issue. The workaround for create new, then login works. It's back in HA at the final step that the error is generated and setup of thr integration fails.

By following this procedure I was able to get the installation to work several times. Using chrome and trying to create a new account before logging in has always worked for me. Importantly, you do not need to refresh the web page

zav13r commented 1 week ago

I don't know what to tell you - it's great that it works for you, I'm simply saying that it doesn't for me, and others.

This is on the latest AMP version, and up to date HA install.

CommittotheIndian commented 6 days ago

using AMP version 4.12.7 and 2024.9.3 for HA I don't encounter any problems. To resolve the authentication loop: instead of entering the data and logging in, just go to register new account and by entering the data the error "user already registered" will be returned. Once this step has been carried out, simply log in by entering the correct data and everything will work correctly.

I've done this multiple times. Its when I get returned to HA that HA just shows a blank error screen.

This ^ It is not the Amazon login or 2SV that's the issue. The workaround for create new, then login works. It's back in HA at the final step that the error is generated and setup of thr integration fails.

By following this procedure I was able to get the installation to work several times. Using chrome and trying to create a new account before logging in has always worked for me. Importantly, you do not need to refresh the web page

This was even after completely removing AMP, removing config files, clearing cookies, removing alexa and .pickle within .storage.

I reinstalled at AMP 4.12.11 and on HA 2024.8.2.

As you can see the Amazon login/workaround for creating an account works. It's when we get back to HA, we get the error.

image

Toxo666 commented 6 days ago

Maybe this helps?

https://github.com/alandtse/alexa_media_player/issues/2554#issuecomment-2381869404

zav13r commented 6 days ago

Maybe this helps?

https://github.com/alandtse/alexa_media_player/issues/2554#issuecomment-2381869404

Oh, thank you!! This was it for me, using pi hole. Disabling blocking didn't seem to work but adding the new regex fixed it. AMP seems to be working again.

bennydente commented 6 days ago

Thanks, but trying adding whitelist regex filter or disabling blocking for exact domain not working for me. I have same error after some minutes.

" An error occurred accessing AlexaAPI: An exception of type AlexapyLoginError occurred. Arguments: ('Login error detected; not contacting API',)"

Eric-boop commented 5 days ago

I found the answer on github!: "Are any of you using an ad blocker/firewall such as Pi-hole or AdGuard by chance? Some adlists were recently updated to block the Amazon Alexa API. This is solved by adding ^api(.[a-z]+)?.amazonalexa.com$ to your Pi-hole whitelist or @@||api*.amazonalexa.com^ for AdGuard. This regex is not region specific and should work for all endpoints"

chesterflaps commented 4 days ago

Same issue for me. Suddenly all alexa devices are showing as unavailable.

elbrondor commented 4 days ago

In my installation of Home Assistant 2024.9 and AMP 4.13.2, I have encountered both errors. The first issue is with the authentication process. During the initial installationof AMP, the window asking for the account name and password appears in a loop. If I don't use the workaround, the OTP window never shows up. This issue occurs only with amazon.de and not when I try with amazon.com.

However, with amazon.com, I am unable to control any devices, though all of my devices are available when using amazon.com. If I try with amazon.de, no devices are shown.

I have tested this with Pi-hole disabled, and I have completely opened my firewall.

Hopefully, someone can help.

danielbrunt57 commented 4 days ago

However, with amazon.com, I am unable to control any devices, though all of my devices are available when using amazon.com. If I try with amazon.de, no devices are shown.

You can't play games with Amazon Alexa as she doesn't know how to play!

If your devices are registered via your account at amazon.com then you need to use amazon.com.

image

If your devices are registered via your account at amazon.de then you need to use amazon.de.

image

danielbrunt57 commented 4 days ago

with amazon.com, I am unable to control any devices

@elbrondor What devices are you trying to _control_? AMP does not _control_ any devices, only notify.alexa_media and media_player.xyz commands...

itzalgd24 commented 4 days ago

I can confirm that whitelisting ^api(.[a-z]+)?.amazonalexa.com$ in Pi-Hole fixed the issue for me.

elbrondor commented 3 days ago

Hello All, i like to control my Amazon Echo devicves. All of them are registerd to Amazon.de grafik but in Home assistant AMP is see: grafik

elbrondor commented 2 days ago

Here are the related log lines:

2024-10-04 15:22:38.796 DEBUG (MainThread) [custom_components.alexa_media] Discovered new media_player G****09G 2024-10-04 15:22:38.922 DEBUG (MainThread) [alexapy.alexaapi] J*r@g***e: static GET: https://alexa.amazon.de/api/phoenix returned 429:Too Many Requests:application/json 2024-10-04 15:22:38.923 INFO (MainThread) [alexapy.alexaapi] Backing off _static_request(...) for 0.6s (alexapy.errors.AlexapyTooManyRequestsError: Too Many Requests) 2024-10-04 15:22:38.958 DEBUG (MainThread) [alexapy.alexaapi] Jr@ge: static GET: https://alexa.amazon.de/api/bootstrap returned 200:OK:application/json 2024-10-04 15:22:39.023 DEBUG (MainThread) [alexapy.alexaapi] J*r@ge: static GET: https://alexa.amazon.de/api/devices-v2/device returned 200:OK:application/json 2024-10-04 15:22:39.033 DEBUG (MainThread) [alexapy.alexaapi] J*r@ge: static GET: https://alexa.amazon.de/api/dnd/device-status-list returned 200:OK:application/json 2024-10-04 15:22:39.196 DEBUG (MainThread) [alexapy.alexaapi] J*r@ge: static GET: https://alexa.amazon.de/api/bluetooth?cached=false returned 200:OK:application/json 2024-10-04 15:22:39.423 DEBUG (MainThread) [alexapy.alexaapi] J*r@ge: static GET: https://alexa.amazon.de/api/device-preferences returned 200:OK:application/json 2024-10-04 15:22:39.591 DEBUG (MainThread) [alexapy.alexaapi] J*r@ge: static GET: https://alexa.amazon.de/api/phoenix returned 429:Too Many Requests:application/json 2024-10-04 15:22:39.592 INFO (MainThread) [alexapy.alexaapi] Backing off _static_request(...) for 1.5s (alexapy.errors.AlexapyTooManyRequestsError: Too Many Requests) 2024-10-04 15:22:41.191 DEBUG (MainThread) [alexapy.alexaapi] J*r@ge: static GET: https://alexa.amazon.de/api/phoenix returned 429:Too Many Requests:application/json 2024-10-04 15:22:41.191 INFO (MainThread) [alexapy.alexaapi] Backing off _static_request(...) for 3.9s (alexapy.errors.AlexapyTooManyRequestsError: Too Many Requests) 2024-10-04 15:22:45.127 DEBUG (MainThread) [alexapy.alexaapi] J*r@ge: static GET: https://alexa.amazon.de/api/phoenix returned 429:Too Many Requests:application/json 2024-10-04 15:22:45.128 INFO (MainThread) [alexapy.alexaapi] Backing off _static_request(...) for 3.9s (alexapy.errors.AlexapyTooManyRequestsError: Too Many Requests) 2024-10-04 15:22:49.120 DEBUG (MainThread) [alexapy.alexaapi] J*r@g****e: static GET: https://alexa.amazon.de/api/phoenix returned 429:Too Many Requests:application/json 2024-10-04 15:22:49.120 ERROR (MainThread) [alexapy.alexaapi] Giving up _static_request(...) after 5 tries (alexapy.errors.AlexapyTooManyRequestsError: Too Many Requests) 2024-10-04 15:22:49.120 WARNING (MainThread) [alexapy.helpers] alexaapi.get_guard_details((<alexapy.alexalogin.AlexaLogin object at 0x7f550664b4d0>,), {}): An error occurred accessing AlexaAPI: An exception of type AlexapyTooManyRequestsError occurred. Arguments: ('Too Many Requests',) 2024-10-04 15:22:49.121 WARNING (MainThread) [alexapy.helpers] alexaapi.get_network_details((<alexapy.alexalogin.AlexaLogin object at 0x7f550664b4d0>,), {}): An error occurred accessing AlexaAPI: An exception of type AlexapyTooManyRequestsError occurred. Arguments: ('Too Many Requests',) 2024-10-04 15:22:49.122 DEBUG (MainThread) [custom_components.alexa_media] Finished fetching alexa_media data in 10.336 seconds (success: False)