Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alexa API / Too many requests #2177

Open
nephrotranz opened this issue Jan 29, 2024 · 144 comments
Open

Alexa API / Too many requests #2177

nephrotranz opened this issue Jan 29, 2024 · 144 comments
Labels
amazonissue Issue needs to have a change made by Amazon

Comments

@nephrotranz
Copy link

nephrotranz commented Jan 29, 2024

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 getting quite a lot of errors saying that there were too many requests and other problems (getting history records). The problem seems to be the Indoor Air Quallity Monitor, at least it is the only Amazon device I use except my Echos.
I am using it as temperature and hygrometer device, I think the device is sending updates every 5 minutes.

To Reproduce

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior

No problem with getting data, not getting the "too many requests error.

Screenshots

image

System details

  • Home-assistant (version): 2024.1.5 // 2023.12.1
  • alexa_media (version from const.py or HA startup): 4.9.0
  • alexapy (version from pip show alexapy or HA startup): Package not found
  • Amazon 2FA is enabled (y/n). <!---We will not debug login issues if unanswered--->: yes

Logs
Please provide logs.
1.)
Dieser Fehler wurde von einer benutzerdefinierten Integration verursacht

Logger: custom_components.alexa_media
Source: helpers/update_coordinator.py:332
Integration: Alexa Media Player (documentation, issues)
First occurred: 18:12:58 (1 occurrences)
Last logged: 18:12:58

Error fetching alexa_media data: Error communicating with API:

2,)
Dieser Fehler wurde von einer benutzerdefinierten Integration verursacht

Logger: alexapy.helpers
Source: custom_components/alexa_media/init.py:756
Integration: Alexa Media Player (documentation, issues)
First occurred: 18:12:58 (2 occurrences)
Last logged: 18:12:58

alexaapi.get_customer_history_records((<alexapy.alexalogin.AlexaLogin object at 0x7f74fc4950>,), {'max_record_size': 10}): An error occurred accessing AlexaAPI: An exception of type AlexapyTooManyRequestsError occurred. Arguments: ('',)
alexaapi.get_last_device_serial((<alexapy.alexalogin.AlexaLogin object at 0x7f74fc4950>,), {}): An error occurred accessing AlexaAPI: An exception of type AlexapyTooManyRequestsError occurred. Arguments: ('',)

3.)
Dieser Fehler wurde von einer benutzerdefinierten Integration verursacht

Logger: alexapy.alexaapi
Source: custom_components/alexa_media/init.py:756
Integration: Alexa Media Player (documentation, issues)
First occurred: 18:12:58 (1 occurrences)
Last logged: 18:12:58

Giving up _static_request(...) after 5 tries (alexapy.errors.AlexapyTooManyRequestsError)

Additional context

@1800Zeta
Copy link

I am also seeing similar behaviour:

Error fetching alexa_media data: Error communicating with API: Too Many Requests 6:23:58 AM – (ERROR) Alexa Media Player (custom integration) - message first occurred at January 29, 2024 at 12:50:17 PM and shows up 7 times alexaapi.get_customer_history_records((<alexapy.alexalogin.AlexaLogin object at 0x7fc34466ca10>,), {'max_record_size': 10}): An error occurred accessing AlexaAPI: An exception of type AlexapyTooManyRequestsError occurred. Arguments: ('Too Many Requests',) 6:23:58 AM – (WARNING) Alexa Media Player (custom integration) - message first occurred at January 29, 2024 at 12:50:17 PM and shows up 16 times Giving up _static_request(...) after 5 tries (alexapy.errors.AlexapyTooManyRequestsError: Too Many Requests) 6:23:58 AM – (ERROR) Alexa Media Player (custom integration) - message first occurred at January 29, 2024 at 12:50:17 PM and shows up 7 times

@serlinGi
Copy link

Hi 👋,
same problem for me; I bring you my experience and the series of facts (coincidences?) that occurred at the same time as the errors appeared:

  1. I had just gotten the "add connected devices" option to get the temperature sensor of one of my 10 alexa devices.
    I deactivated and deleted this entity firstly because these error messages started and secondly because it was not very precise and timely in updating; I prefer to keep the other sensors I have integrated.
    after restoring everything to how it was before the 3 error messages continued to appear.
  2. I looked in core.config_entries for that value (object at 0x7f8879d8d690) reported in the 3 occurrences of the warning message relating to the "Logger: alexapy.helpers" and I discovered that it referred to the "radio browser" integration that I had disabled;
    at this point I re-enabled it but the errors continued; I decided to remove it completely but the result did not change.

maybe they are just coincidences but this is it and unfortunately even by removing what seemed to me to be the cause, the errors continue.

@evilmumi
Copy link

also other smarthome tools like FHEM have problems - Amazon changed something

@Pirol62
Copy link

Pirol62 commented Jan 30, 2024

Hi,

enclose my log entries from different days.
There is no recognizable frequency that leads to a certain automation causing this error:

2024-01-28 22:38:47.309 ERROR (MainThread) [alexapy.alexaapi] Giving up _static_request(...) after 5 tries (alexapy.errors.AlexapyTooManyRequestsError: Too Many Requests)
2024-01-28 22:38:47.311 ERROR (MainThread) [custom_components.alexa_media] Error fetching alexa_media data: Error communicating with API: Too Many Requests
2024-01-28 23:09:16.992 ERROR (MainThread) [alexapy.alexaapi] Giving up _static_request(...) after 5 tries (alexapy.errors.AlexapyTooManyRequestsError: Too Many Requests)
2024-01-28 23:09:16.993 ERROR (MainThread) [custom_components.alexa_media] Error fetching alexa_media data: Error communicating with API: Too Many Requests
2024-01-29 02:26:09.265 ERROR (MainThread) [alexapy.alexaapi] Giving up _static_request(...) after 5 tries (alexapy.errors.AlexapyTooManyRequestsError: Too Many Requests)
2024-01-29 02:26:09.267 ERROR (MainThread) [custom_components.alexa_media] Error fetching alexa_media data: Error communicating with API: Too Many Requests
2024-01-29 03:06:41.212 ERROR (MainThread) [alexapy.alexaapi] Giving up _static_request(...) after 5 tries (alexapy.errors.AlexapyTooManyRequestsError: Too Many Requests)
2024-01-29 03:06:41.213 ERROR (MainThread) [custom_components.alexa_media] Error fetching alexa_media data: Error communicating with API: Too Many Requests
2024-01-29 09:33:14.224 ERROR (MainThread) [alexapy.alexaapi] Giving up _static_request(...) after 5 tries (alexapy.errors.AlexapyTooManyRequestsError: Too Many Requests)
2024-01-29 09:33:14.224 ERROR (MainThread) [custom_components.alexa_media] Error fetching alexa_media data: Error communicating with API: Too Many Requests
2024-01-30 00:43:23.971 ERROR (MainThread) [alexapy.alexaapi] Giving up _static_request(...) after 5 tries (alexapy.errors.AlexapyTooManyRequestsError: Too Many Requests)
2024-01-30 00:43:23.972 ERROR (MainThread) [custom_components.alexa_media] Error fetching alexa_media data: Error communicating with API: Too Many Requests
2024-01-30 07:38:28.368 ERROR (MainThread) [alexapy.alexaapi] Giving up _static_request(...) after 5 tries (alexapy.errors.AlexapyTooManyRequestsError: Too Many Requests)
2024-01-30 07:38:28.369 ERROR (MainThread) [custom_components.alexa_media] Error fetching alexa_media data: Error communicating with API: Too Many Requests

@nephrotranz
Copy link
Author

also other smarthome tools like FHEM have problems - Amazon changed something

Yes, I also think so. I integrated the air quality sensor in December and the errors started approx. 10 days (?) ago. I cannot be precise here as I noted them by coincidence when I saw my dashboard is not showing values for the sensors every now and then.

@enkama
Copy link

enkama commented Jan 30, 2024

Yup. Its getting pretty annoying. Thought I was the only one. To a state where I cant stop my audio player radio over voice command.

alexaapi.get_customer_history_records((<alexapy.alexalogin.AlexaLogin object at 0x7fe0e26befd0>,), {'max_record_size': 10}): An error occurred accessing AlexaAPI: An exception of type AlexapyTooManyRequestsError occurred. Arguments: ('Too Many Requests',)
alexaapi.get_last_device_serial((<alexapy.alexalogin.AlexaLogin object at 0x7fe0e26befd0>,), {}): An error occurred accessing AlexaAPI: An exception of type AlexapyTooManyRequestsError occurred. Arguments: ('Too Many Requests',)
alexaapi.get_customer_history_records((<alexapy.alexalogin.AlexaLogin object at 0x7fe0e26befd0>,), {'max_record_size': 10}): Timeout error occurred accessing AlexaAPI: An exception of type CancelledError occurred. Arguments: ()

Giving up _static_request(...) after 5 tries (alexapy.errors.AlexapyTooManyRequestsError: Too Many Requests)

Error fetching alexa_media data: Error communicating with API: Too Many Requests

@micium
Copy link

micium commented Jan 30, 2024

Same problem here from a couple of weeks ago, no HA configuration changed in the last month.
The problem was already succeeded last year, I suppose this is a problem caused by limited resources available in the AWS cloud to the customer without regular subscription, but I could be wrong ..

@driagi
Copy link

driagi commented Feb 1, 2024

Same problem

@DeCysos
Copy link

DeCysos commented Feb 1, 2024

I had the same problem.
I deleted the following file: /homeassistant/.storage/alexa_media.myemailadress@domain.com.pickle

After the integration was reloaded, the error did not reappear. Let's see how it goes now...

@micium
Copy link

micium commented Feb 1, 2024

I had the same problem. I deleted the following file: /homeassistant/.storage/alexa_media.myemailadress@domain.com.pickle

After the integration was reloaded, the error did not reappear. Let's see how it goes now...

Did you need to reconfigure alexa_media or just reloaded the integration?

@DeCysos
Copy link

DeCysos commented Feb 1, 2024

I had the same problem. I deleted the following file: /homeassistant/.storage/alexa_media.myemailadress@domain.com.pickle
After the integration was reloaded, the error did not reappear. Let's see how it goes now...

Did you need to reconfigure alexa_media or just reload the integration?

The integration was automatically reloaded after I pressed CTRL + F5. Nothing more had to be done. But as I said, so far the message hasn't come back, but I'll know tomorrow between 8 and 11 a.m., because it was usually during this time that problems occurred.

@enkama
Copy link

enkama commented Feb 1, 2024

Did not fix it for me. Deleted it, restarted and again got this.

alexaapi.get_customer_history_records((<alexapy.alexalogin.AlexaLogin object at 0x7fc1f7edf800>,), {'max_record_size': 10}): Timeout error occurred accessing AlexaAPI: An exception of type CancelledError occurred. Arguments: ()

@micium
Copy link

micium commented Feb 1, 2024

Did not fix for me. I suppose depend of responsive of AWS cloud.

@jonathan-schmieg
Copy link

Didn't work for me either

@DeCysos
Copy link

DeCysos commented Feb 2, 2024

Unfortunately, it didn't last for me.
It started again this morning at around 1am and then at around 8am.

Logger: alexapy.alexaapi
Source: custom_components/alexa_media/init.py:756
Integration: Alexa Media Player (documentation, issues)
First occurred: 01:30:58 (2 occurrences)
Last logged: 08:41:51
Giving up _static_request(...) after 5 tries (alexapy.errors.AlexapyTooManyRequestsError: Too Many Requests) Giving up _static_request(...) after 5 tries (alexapy.errors.AlexapyTooManyRequestsError)

--

Logger: custom_components.alexa_media
Source: helpers/update_coordinator.py:332
Integration: Alexa Media Player (documentation, issues)
First occurred: 01:30:58 (2 occurrences)
Last logged: 08:41:51
Error fetching alexa_media data: Error communicating with API: Too Many Requests Error fetching alexa_media data: Error communicating with API:

--

Logger: aiohttp.server
Source: /usr/local/lib/python3.11/site-packages/aiohttp/web_protocol.py:421
First occurred: 02:10:54 (2 occurrences)
Last logged: 08:58:11
Error handling request

Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/aiohttp/web_protocol.py", line 350, in data_received
messages, upgraded, tail = self._request_parser.feed_data(data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "aiohttp/_http_parser.pyx", line 557, in aiohttp._http_parser.HttpParser.feed_data
aiohttp.http_exceptions.BadStatusLine: 400, message:
Invalid method encountered:

b'\x03'
  ^

--

Logger: alexapy.helpers
Source: custom_components/alexa_media/init.py:756
Integration: Alexa Media Player (documentation, issues)
First occurred: 01:30:58 (9 occurrences)
Last logged: 10:40:42

alexaapi.get_customer_history_records((<alexapy.alexalogin.AlexaLogin object at 0x7f1b1d522e90>,), {'max_record_size': 10}): An error occurred accessing AlexaAPI: An exception of type AlexapyTooManyRequestsError occurred. Arguments: ('Too Many Requests',)
alexaapi.get_last_device_serial((<alexapy.alexalogin.AlexaLogin object at 0x7f1b1d522e90>,), {}): An error occurred accessing AlexaAPI: An exception of type AlexapyTooManyRequestsError occurred. Arguments: ('Too Many Requests',)
alexaapi.get_customer_history_records((<alexapy.alexalogin.AlexaLogin object at 0x7f1b1d522e90>,), {'max_record_size': 10}): Timeout error occurred accessing AlexaAPI: An exception of type CancelledError occurred. Arguments: ()
alexaapi.get_customer_history_records((<alexapy.alexalogin.AlexaLogin object at 0x7f1b1d522e90>,), {'max_record_size': 10}): An error occurred accessing AlexaAPI: An exception of type AlexapyTooManyRequestsError occurred. Arguments: ('',)
alexaapi.get_last_device_serial((<alexapy.alexalogin.AlexaLogin object at 0x7f1b1d522e90>,), {}): An error occurred accessing AlexaAPI: An exception of type AlexapyTooManyRequestsError occurred. Arguments: ('',)

@Joo01
Copy link

Joo01 commented Feb 3, 2024

Same issues in the log.
But to be honest, I don't see any limitations in functionality, at least none that I noticed.
What impact do you have as a result of the error?

2024-02-03 06:16:08.325 ERROR (MainThread) [custom_components.alexa_media] Error fetching alexa_media data: Error communicating with API: Too Many Requests
2024-02-03 06:26:19.769 ERROR (MainThread) [alexapy.alexaapi] Giving up _static_request(...) after 5 tries (alexapy.errors.AlexapyTooManyRequestsError: Too Many Requests)
2024-02-03 06:26:19.769 WARNING (MainThread) [alexapy.helpers] alexaapi.get_customer_history_records((<alexapy.alexalogin.AlexaLogin object at 0x7ff11c835fd0>,), {'max_record_size': 10}): An error occurred accessing AlexaAPI: An exception of type AlexapyTooManyRequestsError occurred. Arguments:
('Too Many Requests',)
2024-02-03 06:26:19.769 WARNING (MainThread) [alexapy.helpers] alexaapi.get_last_device_serial((<alexapy.alexalogin.AlexaLogin object at 0x7ff11c835fd0>,), {}): An error occurred accessing AlexaAPI: An exception of type AlexapyTooManyRequestsError occurred. Arguments:
('Too Many Requests',)

@micium
Copy link

micium commented Feb 3, 2024

sometimes the Echo are unavailable, the related service not available and repair required

@nephrotranz
Copy link
Author

Error fetching alexa_media data: Error communicating with API: Too Many Requests

After this error I a having a 5 minute gap in history data for my air quality monitor, in the dashboard it is shown as unavailable for the same time.
My Echos are then not capable to execute HA scripts using tts.

@Moxser
Copy link

Moxser commented Feb 3, 2024

Error fetching alexa_media data: Error communicating with API: Too Many Requests

After this error I a having a 5 minute gap in history data for my air quality monitor, in the dashboard it is shown as unavailable for the same time.

My Echos are then not capable to execute HA scripts using tts.

same thing for me too

@DeCysos
Copy link

DeCysos commented Feb 3, 2024

What impact do you have as a result of the error?

I don't actually have any problems that I would notice.
But as the others here have just reported, it is also the case with me that various Alexa devices (in my case Echo) sometimes seem to lose the connection or recording.
This happens at the times when the error message appears.

This happens more often with an Echo in the kitchen than with other devices and the recording time is then interrupted for about 10 minutes. Unfortunately, I can only see this in the temperature recording.
Screenshot 2024-02-03 104758

Logger: alexapy.helpers
Source: custom_components/alexa_media/init.py:756
Integration: Alexa Media Player (documentation, issues)
First occurred: 04:57:40 (6 occurrences)
Last logged: 09:56:47

alexaapi.get_customer_history_records((<alexapy.alexalogin.AlexaLogin object at 0x7fb8f2194490>,), {'max_record_size': 10}): Timeout error occurred accessing AlexaAPI: An exception of type CancelledError occurred. Arguments: ()
In this case, however, it is only a warning, not an error message.

The other Echo devices in the apartment (living room, 2x bedroom) only have two interruptions, while the one in the kitchen has 6 interruptions.

It is a pity that certain error messages / warnings cannot simply be suppressed. :)
The warning/error messages only appeared with the updates this year, I didn't have such messages before. It's either due to HA or Amazon itself.

Regarding the voice output of the Echo devices caused by HA, I don't notice anything. Because the voice output only comes as soon as windows are opened or closed in connection with the heating. And so far everything has worked without any problems.

Perhaps this will also change in the future so that the extension (Alexa Media Player) will soon no longer work at all and you will have to do it via the Nabu Casa service.

@AnonBit
Copy link

AnonBit commented Feb 8, 2024

Same problem

@M4v3r1cK87
Copy link

Same problem too

@enkama
Copy link

enkama commented Feb 9, 2024

Okay, can we please stop writing me too? Getting an email notification just because someone can't press thumbs up and instead has to write "same problem" isn't helping. Thanks.

@micium
Copy link

micium commented Feb 10, 2024

Hi 👋, same problem for me; I bring you my experience and the series of facts (coincidences?) that occurred at the same time as the errors appeared:

  1. I had just gotten the "add connected devices" option to get the temperature sensor of one of my 10 alexa devices.
    I deactivated and deleted this entity firstly because these error messages started and secondly because it was not very precise and timely in updating; I prefer to keep the other sensors I have integrated.
    after restoring everything to how it was before the 3 error messages continued to appear.
  2. I looked in core.config_entries for that value (object at 0x7f8879d8d690) reported in the 3 occurrences of the warning message relating to the "Logger: alexapy.helpers" and I discovered that it referred to the "radio browser" integration that I had disabled;
    at this point I re-enabled it but the errors continued; I decided to remove it completely but the result did not change.

maybe they are just coincidences but this is it and unfortunately even by removing what seemed to me to be the cause, the errors continue.

with reference to point 2. of your note, I am not finding in the core.config_entries file or other HA file any reference to the object reported in the error log (e.g. object at 0x7f4f5e6090 ), where am I going wrong?

@serlinGi
Copy link

Hi 👋, same problem for me; I bring you my experience and the series of facts (coincidences?) that occurred at the same time as the errors appeared:

  1. I had just gotten the "add connected devices" option to get the temperature sensor of one of my 10 alexa devices.
    I deactivated and deleted this entity firstly because these error messages started and secondly because it was not very precise and timely in updating; I prefer to keep the other sensors I have integrated.
    after restoring everything to how it was before the 3 error messages continued to appear.
  2. I looked in core.config_entries for that value (object at 0x7f8879d8d690) reported in the 3 occurrences of the warning message relating to the "Logger: alexapy.helpers" and I discovered that it referred to the "radio browser" integration that I had disabled;
    at this point I re-enabled it but the errors continued; I decided to remove it completely but the result did not change.

maybe they are just coincidences but this is it and unfortunately even by removing what seemed to me to be the cause, the errors continue.

with reference to point 2. of your note, I am not finding in the core.config_entries file or other HA file any reference to the object reported in the error log (e.g. object at 0x7f4f5e6090 ), where am I going wrong?

I @micium,
I think that "0x7f4f5e6090" is the object string in my log; you search this? if yes, you need to look for the string that appears in your log.

@micium
Copy link

micium commented Feb 10, 2024

with reference to point 2. of your note, I am not finding in the core.config_entries file or other HA file any reference to the object reported in the error log (e.g. object at 0x7f4f5e6090 ), where am I going wrong?

I @micium, I think that "0x7f4f5e6090" is the object string in my log; you search this? if yes, you need to look for the string that appears in your log.

No, the 0x7f4f5e6090 is the object in my log but i did not find it in my HA files

@serlinGi
Copy link

with reference to point 2. of your note, I am not finding in the core.config_entries file or other HA file any reference to the object reported in the error log (e.g. object at 0x7f4f5e6090 ), where am I going wrong?

I @micium, I think that "0x7f4f5e6090" is the object string in my log; you search this? if yes, you need to look for the string that appears in your log.

No, the 0x7f4f5e6090 is the object in my log but i did not find it in my HA files

I' m sorry, I don't know.
In this time I can't find it in my file either; maybe it really was a coincidence
Screenshot_2024-02-10-21-56-52-64_c3a231c25ed346e59462e84656a70e50

@alandtse alandtse added the amazonissue Issue needs to have a change made by Amazon label Feb 11, 2024
@alandtse
Copy link
Owner

In case it wasn't obvious, this is an Amazon issue and there's nothing we can do about it here. I'll leave this open for reference.

@ultimo678
Copy link

ok. I understand it's a problem with Amazon's servers. But I ask you, is there any solution to limit the frequency of the problem? In other words... Does the problem depend on the number of requests made on single session (so the more devices you have, the more the problem occurs) or on the frequency with which each account connects to the servers to check the status of the devices?
Is there a chance that the situation can be resolved somehow or will we have to learn to live with this aspect?

@danielbrunt57
Copy link
Collaborator

Mine is error free and I am back to the default of 60 seconds. But then again, I don't say much to Alexa except Good morning and Good night.

Have you tried saying "Alexa, I'm sorry, it's all my fault and I'll try not to upset you again" or "Alexa, I love you and only you!"?

@danielbrunt57
Copy link
Collaborator

I tried clearing the history and recordings as advised

Did you also change the retention period?

@danielbrunt57
Copy link
Collaborator

danielbrunt57 commented Jul 27, 2024

I'm looking for beta testers for my current WIP which seems to address:

Make sure you are running AMP latest release v4.11.5.
Download this zip file: alexa_media.zip.
Unzip it and drop the files into your /config/custom_components/alexa_media folder and restart HA.

If you have any issues with it, you can just redownload the custom component in HACS (which will overwrite custom_components/alexa_media with v4.11.5) and then restart HA.

Thanks!

@clavius11
Copy link

I'd like to join the beta test. Not sure how to verify my AMP release, but I'm running the latest HA OS on a Raspberry Pi, so I'll guess I'm good to go.

@Geoff571
Copy link

Geoff571 commented Jul 27, 2024

I'll help with the beta test. I can't drop it in until next weekend however.

@tbclark3
Copy link

So far so good. It failed initially due to partitioned cookie error, but has run for several hours without other errors.

@tbclark3
Copy link

It's still happening with the beta.

This error originated from a custom integration.

Logger: custom_components.alexa_media
Source: helpers/update_coordinator.py:344
integration: Alexa Media Player (documentation, issues)
First occurred: July 27, 2024 at 11:29:02 PM (1 occurrences)
Last logged: July 27, 2024 at 11:29:02 PM

Error fetching alexa_media data: Error communicating with API: Too Many Requests

@clavius11
Copy link

I'm also seeing the "Too Many Requests" error with the beta version.

@SConaway
Copy link

I'm looking for beta testers for my current WIP which seems to address:

Make sure you are running AMP latest release v4.11.5. Download this zip file: alexa_media.zip. Unzip it and drop the files into your /config/custom_components/alexa_media folder and restart HA.

If you have any issues with it, you can just redownload the custom component in HACS (which will overwrite custom_components/alexa_media with v4.11.5) and then restart HA.

Thanks!

@danielbrunt57 still need tests from 4.12.1? (I can diff/repatch with the current file)

@vjbalex
Copy link

vjbalex commented Jul 30, 2024

Daniel, I reverted to 4.11.5 with yout original patch but I will install 4.12.1 and test if you will post or send me the repatch.

@vjbalex
Copy link

vjbalex commented Jul 31, 2024

Is the repatch compatible with 4.12.1 available somewhere?

@lanyar
Copy link

lanyar commented Aug 1, 2024

I see the following...
2024-08-01 08:12:22.075 ERROR (MainThread) [alexapy.alexaapi] Giving up _static_request(...) after 5 tries (alexapy.errors.AlexapyTooManyRequestsError: Too Many Requests)

2024-08-01 08:12:22.076 ERROR (MainThread) [custom_components.alexa_media] Error fetching alexa_media data: Error communicating with API: Too Many Requests)

@danielbrunt57
Copy link
Collaborator

So, in the last 2 weeks & my many (MANY) hours of doing this, that, and the other inside alexa_media, I've come to the realization that the too many requests error seems to have nothing to do with voice history or the record size in alexapy. It seems to simply be too many frequent requests to the API. I've been triggering it a lot recently while coding my numerous ideas to somehow get last_alexa updated in a timely fashion. With the architecture of alexa_media/alexapy and the limitations imposed by Amazon, plus their recent removal of the PUSH_ACTIVITY command via the http2 connection, I think it's best that the integration's internal automatic updates of last_alexa be removed while leaving the service call alexa_media.update_last_called for us to use when we've programmatically determined that we are about to use notify.alexa_media_last_called. I've not yet given up completely on my last approach , but I think I'm very close to throwing in the towel...

@Geoff571
Copy link

Geoff571 commented Aug 2, 2024

I appreciate the effort you've put in and I can support your idea of the reduced calls for the last_update, it seems unnecessary to use the API when most of the time that info isn't needed. We can always call for an update when/if needed.

@danielbrunt57
Copy link
Collaborator

Please try v4.12.5 just released and advise your findings.
Thanks.

@clavius11
Copy link

I'm still seeing "Too many request" errors with v4.12.5. They average about one every hour.

@antisane
Copy link

antisane commented Aug 7, 2024

Approx 12 hours with the newest version and I haven't seen any "too many" errors yet. And on top of that my script that checks the "last alexa" when run actually worked for the first time in a while this morning!

@lanyar
Copy link

lanyar commented Aug 11, 2024

I have completely removed the Alexa integration from Home Assistant. It was causing issue where "reauthentication" was required and I would reauthenticate, it would be good for a few days and then repeat. While it was requiring reauthentication, some of my automations would not run because it would error when trying to notify (announce) something. This is in addition to the above issues as well. Had enough of it... blah

@rjdalga
Copy link

rjdalga commented Aug 24, 2024

Okay, can we please stop writing me too? Getting an email notification just because someone can't press thumbs up and instead has to write "same problem" isn't helping. Thanks.

Well then...how about a solution to fix the problem?

@danielbrunt57
Copy link
Collaborator

danielbrunt57 commented Aug 27, 2024

Well then...how about a solution to fix the problem?

I wish it were that simple! If I had one, I'd submit it, like yesterday! Oh wait a minute, I have one...abandon Amazon, completely!

@rjdalga
Copy link

rjdalga commented Aug 27, 2024

Well then...how about a solution to fix the problem?

I wish it were that simple! If I had one, I'd submit it, like yesterday! Oh wait a minute, I have one...abandon Amazon, completely!

Okay. So Amazon doesn't play nice with HA, how about Google? Same thing?

@danielbrunt57
Copy link
Collaborator

No idea since no Google devices here. What I do know is that the similar integration for Google devices doesn't even have anything like last_called as I remember reading someone asking for it and that Google doesn't record a timestamp to ascertain it...

@xabix
Copy link

xabix commented Sep 4, 2024

Hi all,

I have also these errors:
`This error originated from a custom integration.

Logger: alexapy.alexaapi
Source: custom_components/alexa_media/init.py:786
integration: Alexa Media Player (documentation, issues)
First occurred: 5:19:04 PM (1 occurrences)
Last logged: 5:19:04 PM

Giving up _static_request(...) after 5 tries (alexapy.errors.AlexapyTooManyRequestsError: Too Many Requests)`

`This error originated from a custom integration.

Logger: custom_components.alexa_media
Source: helpers/update_coordinator.py:386
integration: Alexa Media Player (documentation, issues)
First occurred: 5:19:04 PM (1 occurrences)
Last logged: 5:19:04 PM

Error fetching alexa_media data: Error communicating with API: Too Many Requests`

and

`This error originated from a custom integration.

Logger: alexapy.helpers
Source: custom_components/alexa_media/init.py:786
integration: Alexa Media Player (documentation, issues)
First occurred: 5:08:50 PM (4 occurrences)
Last logged: 5:29:19 PM

alexaapi.get_customer_history_records((<alexapy.alexalogin.AlexaLogin object at 0x7fbf72865040>,), {'max_record_size': 10}): Timeout error occurred accessing AlexaAPI: An exception of type CancelledError occurred. Arguments: ()
alexaapi.get_customer_history_records((<alexapy.alexalogin.AlexaLogin object at 0x7fbf72865040>,), {'max_record_size': 10}): An error occurred accessing AlexaAPI: An exception of type AlexapyTooManyRequestsError occurred. Arguments: ('Too Many Requests',)
alexaapi.get_last_device_serial((<alexapy.alexalogin.AlexaLogin object at 0x7fbf72865040>,), {}): An error occurred accessing AlexaAPI: An exception of type AlexapyTooManyRequestsError occurred. Arguments: ('Too Many Requests',)`

I am on 4.12.11

@danielbrunt57
Copy link
Collaborator

danielbrunt57 commented Sep 19, 2024

This is an issue with Amazon's rate limit throttling which we have no control over other than to abide and back off our requests. I know that doesn't help but I offer this automation which will alert you to a problem via a persistent notification so you can at least be more aware of the error when it has occured...
(two items are disabled - your choice as to whether to enable them or not!)

alias: "System Log Event: alexapy.alexaapi"
description: ""
trigger:
  - platform: event
    event_type: system_log_event
    event_data:
      name: alexapy.alexaapi
condition:
  - condition: template
    value_template: "{{ \"Too Many Requests\" in trigger.event.data.message[0] }}"
    enabled: false
action:
  - action: persistent_notification.create
    data:
      title: alexapy.alexaapi
      message: "{{ trigger.event.data.message[0] }}"
  - action: homeassistant.reload_config_entry
    data: {}
    enabled: false
    target:
      entity_id: media_player.echo
mode: single

@alexruffell
Copy link

I have 280 "Too Many Requests" errors in 24hrs and am not sure on what is causing them. I actually don't use Alexa Media Player in any automation even though it is installed, but do use a Node Red Alexa integration for playing all the notifications, etc. in the house. Is this error specific to Alexa Media Player? If it is, why am I seeing it so much if I don't use it?

At its peak there were 23 devices in AMP but I removed some that make no sense having (phones, tablets, echo auto, etc) and am left with 15 echos around the house. Is the number of devices a contributing factor? The error appear to be querying amazon for the last x things played... but we NEVER play music on the echos.

I am trying to understand what I can do to mitigate the issue. @danielbrunt57 - I tried implementing the automation you shared but failed to do so in both "Automations" and in NR. Something about that trigger.event.data.message not existing. Surely my mistake... Does anything come to mind on why that might be?

@stefanomarino75
Copy link

same problem

@displaced
Copy link

displaced commented Oct 8, 2024

Just as another datapoint,

AMP had been running just fine apart from my timers failing to update. So I thought I'd remove and re-add the integration.

Since then, although I can complete the 2FA login flow (with the 'hack' of choosing the option to create a new account, seeing the message that my email address already has an account, then switching back to login as an existing user -- that gets past the webpage login loop).

But, no devices are detected and I see the 'too many requests' errors in the logs.

I don't know why Amazon had no problem with the number of requests before I uninstalled and reinstalled the integration. But now they do.

I've left the integration uninstalled for two weeks before attempting to re-add it, but immediately I get 'too many requests'. Perhaps the speed of the initial login actions are triggering it? If I get some time I'll dig into AMP (or rather alexapy) and scatter some delays around the login code and see what happens.

(this is using amazon.co.uk)

edit:

My logs show that at least some calls succeed. And I note that alexapy does do some backing-off. But it doesn't back-off by much: 0.7, 0.1 seconds, for instance.

image

Been fiddling with the 'backoff' option on alexapy's API calls. No joy. Will try some more after work.

@samuele2723
Copy link

hello, please seems we have same issue on another thread can somebody check it out? #2558

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
amazonissue Issue needs to have a change made by Amazon
Projects
None yet
Development

No branches or pull requests