alexa_media_player: Version v4.13.3 is making HA fail

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 installed v4.13.3 and shortly after my HA kept loosing connection. I would re boot, it would work fine for a few minutes, then it would disconect.

To Reproduce

I used a full backup for HA for Sept 30th. Before the Alexa update I did a core update, assumed that caused the issue. Once I restored I didn’t do the core update but did do the Alexa update. Few minutes later issue of disconnect started again.

Restored the Sept 30th backup again. This time I did the HA core update, but skipped the v4.13.3 update for Alexa. My HA has been stable for over 30 minutes now.

  1. Go to ‘…’
  2. Click on ‘…’
  3. Scroll down to ‘…’
  4. See error

Expected behavior

I would expect to install v4.13.3 and not have my HA system crash.

Screenshots

No screen shots

System details

  • Home Assistant version: Running HA via proxmox server. Updated to the last version
  • alexa_media version (from const.py or HA startup log): Stable version 4.13.2
  • alexapy version (from pip show alexapy in homeasssistant container or HA startup log):
  • Is Amazon 2FA/2SV enabled <!—We will not debug login issues if unanswered—> (y/n):
  • Amazon Domain:

Debug Logs (alexa_media & alexapy) Please provide logs.

Additional context

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 137
  • Comments: 154 (20 by maintainers)

Commits related to this issue

Most upvoted comments

Same Issue - had to full restore HAS and wasted 2 hours of my life. Alan & the Alexa Media team… Thank you for all you do BUT… DO BETTER!

@lviciedo HOW DARE YOU! FYI, there is no longer a developer, or a team!
And poor you that you wasted 2 hours! That’s only 1/100 of the time I’ve devoted in the last 4 months trying to keep this integration alive. That’s $10,000 of my time that I’ve given back, for free! If you can’t afford to waste 2 hours, why are you using free software. Invest in a commercial product where you have a right to complain!

+1. 4.13.3 kills my HA also. Rolled back to 4.13.2

Silly newbie question: how did you roll back, please? Did you do it from HACS and simply select the earlier version? I get a warning if I do that, but I assume that I ignore that?

Yes in HACS, click on the 3 dots --> download again and then select the old version. grafik

Dont forget to restart HA afterwards.

Same Issue - had to full restore HAS and wasted 2 hours of my life. Alan & the Alexa Media team… Thank you for all you do BUT… DO BETTER!

Do it by yourself or PAY someone to do something. But never ever criticise people which working for free for your stuff!

Same Issue - had to full restore HAS and wasted 2 hours of my life. Alan & the Alexa Media team… Thank you for all you do BUT… DO BETTER!

I’m sorry sorry you all have this issue. I’m glad I saw a post about his in HA Facebook group.

But please understand the Alexa integration is a open source app. That has been life support for the past few months. For the original code owner is not working on it.

Some awesome volunteers have been working on it to get caught up with updating to the new Home assistant standards. This is a free app not coming from a commercial company. So have some understanding and patience.

Same Issue - had to full restore HAS and wasted 2 hours of my life. Alan & the Alexa Media team… Thank you for all you do BUT… DO BETTER!

@lviciedo HOW DARE YOU! FYI, there is no longer a developer, or a team! And poor you that you wasted 2 hours! That’s only 1/100 of the time I’ve devoted in the last 4 months trying to keep this integration alive. That’s $10,000 of my time that I’ve given back, for free! If you can’t afford to waste 2 hours, why are you using free software. Invest in a commercial product where you have a right to complain!

After reading this I just wanted to stop by and say a BIG THANK YOU to @danielbrunt57! I appreciate every single second of the time you’ve put in working on this integration. You are an absolute gentlemen sir! This integration is wonderful and a much enjoyed part of my Home Assistant setup.

Same Issue - had to full restore HAS and wasted 2 hours of my life. Alan & the Alexa Media team… Thank you for all you do BUT… DO BETTER!

Do it by yourself or PAY someone to do something. But never ever criticise people which working for free for your stuff!

You are free not to use the integration, it is not mandatory. As someone said before, if I was paying for this I might criticize, but this is free! This is coming from someone who also wasted 2 hours on this.

Same problem here HA restarts every 5min or when you give any commands to HA.

Rollback to 4.13.2 solves the issue.

The issue is NOT related to 2024.10.0 I am still on 2024.09.03 and have the problem.

I highly recommend to completely restart (including OS) after the rollback to version 4.13.2. Otherwise you will still have a higher cpu and memory load than normal.

Please remove the new version as soon as possible, many people are left without access to their Home Assistant

OUT OF MEMORY error and HA reboots every 5 minutes. Now I disabled the integration; I hope is enough.

yes this updates make my system ERROR dont install this update!!!

This is b

@npa-homeassistant The tricky part can be to rollback before your HA stops responding. Seems it starts using up all the CPU and memory. I would guess those running on a raspberry pi would have less time to do the roll back than those that have a more robust system

I suggest to just immediately disable the alexa-media-player integration so you’ve time to roll back to the older version

image

Cheers mate

Having the same issue! Had to reboot in safe mode (which took a few trials) and deactivate the integration.

It seems like then installing the old version makes HA stable again.

Please do not spam the thread! Comments like “same here” or “works after rollback” do not add anything new to the case.

I, too, found my HA crashing repeatedly due to the bug. But I’m not here complaining at the devs who put in their hard work for free. Especially for a HACS integration, which explicitly comes with a level of potential instability or risk that you must accept when installing it. I installed the latest version without waiting, without seeing how other people fared with it, and predictably that made me a Guinea pig. If you don’t want to be a Guinea pig, if you don’t want to be subject to these sorts of bugs, don’t install updates right away. In fact, maybe HACS just isn’t for you. Don’t come here bitching at the devs that put their metaphorical blood, sweat, and tears into free software for you.

I have the same big issue. HA goes to 100% CPU and begins to eat all the RAM. System unusable after few seconds. No time enough to downgrade AMP.

Screenshot 2024-10-03 083906

Same Issue - had to full restore HAS and wasted 2 hours of my life. Alan & the Alexa Media team… Thank you for all you do BUT… DO BETTER!

@lviciedo HOW DARE YOU! FYI, there is no longer a developer, or a team! And poor you that you wasted 2 hours! That’s only 1/100 of the time I’ve devoted in the last 4 months trying to keep this integration alive. That’s $10,000 of my time that I’ve given back, for free! If you can’t afford to waste 2 hours, why are you using free software. Invest in a commercial product where you have a right to complain!

You are absolutely right, in every single word. I really appreciate your work and dedication. Please feel encouraged to further keep this integration alive. Don‘t give a cent on comments of this ungrateful fools which don‘t understand volunteership. It also took me some time to figure out which integration messes up, but thats not your fault but rather mine or the not to easy to read logs from homeassistant.

Same here, --downgraded Alexa to 4.13.2

Version 4.13.3 should be retracted immediately. Was wondering too why my HA kept crashing after updating all my HACS integrations.

This is how I downgraded to the previous version. I was able to do this between reboots if I caught it fast enough.

Go to HACS and choose Alexa Media Player Press 3 button menu in upper right hand corner Select - Redownload Choose - Need different version? Select 4.13.2 download and restart home assistant

When update available comes up for Alexa media player 4.13.3 press it and choose skip to hide that version

It appears they have pulled 4.13.3.

Spent last hour looking why my HA keep crashing every 20 minutes after updated it to 2024.10… I found then this issue!

FYI, everyone saying they were on 14.3.2 and downgraded, and it started working… that’s not what is really happening.

You installed 14.3.3, the release was then pulled, you went and checked hacs and it showed you 14.3.2 even though 14.3.3 was still installed on your system. You then installed 14.3.1 or some other version and everything started working. I’ve helped about 10 people today who ran into this exact sequence of events.

If you updated yesterday, you cannot trust the version in the HACS store. You can only trust the version listed in developer tools -> states page when looking at the update.alexa_media_player_update entity.

image

Before discovering the memory leak issue, I updated Alexa Media Player to v4.13.3, but I haven’t restarted Home Assistant yet. Home Assistant is still running fine. I’m using Home Assistant 2024.9.3 (I haven’t upgraded to 2024.10.0) on a Raspberry Pi 4, 64-bit, with 4GB of RAM. Given the situation, what would be the best course of action?

Edit: After quickly reviewing this thread, I realised that the best course of action might be to roll back to v4.13.2 by selecting ‘🔁 Redownload’ and choosing version v4.13.2 in HACS.

I wonder when the developer will react on this issue. Just something like we’re looking in to it.

@Starf0x It seems the main issue is that there isn’t a dedicated “developer” at the moment. The guy that started it is not working on it anymore. From what I’ve read there is a bunch of random people trying to keep it working but no one has taken “ownership” of the program. I’ve read some comments of folks talking smack about the developers (not implying you are one of those) but at this time who ever is trying to keep it alive is doing it out of their kindness.

Crazy the world we live in where often people expert “more” from free stuff.

Experienced same issue, fixed by downgrading. This should be revoked to prevent others suffering the same issue.

Same, issue HA unavailabe after a few minute. Managed to roll back to v4.13.2 image

Not likely is it?

There’s already a PR which fixes it.

One line code change:

https://github.com/alandtse/alexa_media_player/pull/2589/files

Would be helpful if others would try it, and confirm this resolves it for them too.

Before discovering the memory leak issue, I updated Alexa Media Player to v4.13.3, but I haven’t restarted Home Assistant yet. Home Assistant is still running fine. I’m using Home Assistant 2024.9.3 (I haven’t upgraded to 2024.10.0) on a Raspberry Pi 4, 64-bit, with 4GB of RAM. Given the situation, what would be the best course of action?

Edit: After quickly reviewing this thread, I realised that the best course of action might be to roll back to v4.13.2 by selecting ‘🔁 Redownload’ and choosing version v4.13.2 in HACS.

This is the way.

So I could not get the UI to load at all… My raspberry pi just failed to boot HA’s UI after this update. So to get into safe mode I plugged a HDMI mini into the Pi and a keyboard, used the on screen console and manged to run core restart --safe-mode

It took a few command attempts, but it did reboot into safe mode and I manged to disable the alexa integration.

For those looking to get out of the boot loop, the fastest way I found was to unplug my device and plug it back in, and sit refreshing this page: http://{local-ip-for-ha}:8123/config/integrations/integration/alexa_media

Then as soon as it’s available, before the integration has had time to load, click the three dots next to the Alexa Media Player entry and hit disable, since the SSH add-on often won’t have launched yet to give you other options before the hardware runs out of resources and stops functioning.

If it’s just not happening, you might be able to change your Amazon account password/turn on/off 2FA or reset your 2FA device and that may keep the integration from authing in the first place which might kick you out of the boot loop.

Some feedback on this : I have HA 2024.9.3 with v4.13.3. Same problem, one reboot every 15 minutes.

I applied the one line fix #2589. Seems stable again, no reboot since.

If you’ve come here to say “ME TOO”:

There is a proposed fix, it is a simple change to one file. This integration is maintained by volunteers, so please help them by trying the fix rather than just disabling the integration. I can tell you it has worked for me.

https://github.com/alandtse/alexa_media_player/pull/2589/files

It appears to be specific to certain devices, so a community effort here would get the fix verified more quickly. The code maintainers obviously don’t have the affected devices.

I had the same issue. I started HA in safe mode and disabled the integration. Since I was only using for Alexa voice notifications I decided not to use it going forward. My solution is to use helpers and pass the value to Alexa. When the value is on I have Alexa play the message. When I have HA Voice setup I will use that. I eventually want to move away from Amazon altogether.

Extending a list whilst iterating it. This will infinite loop and endlessly grow the list until it eats all memory and crashes.

custom_components/alexa_media/helpers.py:245

         for serial in existing_serials:
           device = device_data.get(serial, {})
           if "appDeviceList" in device and device["appDeviceList"]:
               apps = [
                   x["serialNumber"]
                   for x in device["appDeviceList"]
                   if "serialNumber" in x
               ]
               existing_serials.extend(apps)

Simple fix is to change the iterator to operate on a copy:

for serial in existing_serials[:]:

Have tested it and now have a slightly modified 4.13.3 running with no problems. PR follows.

I’m sorry sorry you all have this issue. I’m glad I saw a post about his in HA Facebook group.

But please understand the Alexa integration is a open source app. That has been life support for the past few months. For the original code owner is not working on it.

Some awesome volunteers have been working on it to get caught up with updating to the new Home assistant standards. This is a free app not coming from a commercial company. So have some understanding and patience.

All true and very much appreciated. However the reboots of Home Assistant are the most serious issue with an integration I have ever had.

Seems it would be wise to quickly remove 4.13.3

Some feedback on this : I have HA 2024.9.3 with v4.13.3. Same problem, one reboot every 15 minutes.

I applied the one line fix #2589. Seems stable again, no reboot since.

Same for me - seems to be stable for at least an hour

I had some mixed results earlier today, but I just rebooted again with the one line change and all seems well.

I also added a log within the loop to output the device variable, and I get just 1 log for each of my devices each time the loop is executed. So it seems to be a good fix, at least for me.

Did the one line change in the helper.py file. It’s working without any issues since last 4 hours. No crashing any more.On Oct 5, 2024, at 2:50 PM, Petro31 @.***> wrote:

Not likely is it?

There’s already a PR which fixes it.

One line code change:

https://github.com/alandtse/alexa_media_player/pull/2589/files

Would be helpful if others would try it, and confirm this resolves it for them too.

I do not see how that PR would fix the infinite loop. Adding [:] to a list keeps the list identical and that’s the only change in the PR.

e.g.

items = [‘a’,‘b’]

for item in items:

…

is identical to

items = [‘a’,‘b’]

for item in items[:]:

…

I think we have too many people relying on AI to submit PRs on this.

It’s not the same. The [:] means it’s going to be iterating over a copy of the list and that’s the critical difference. This is not an AI fix. I found it myself by analysis and testing. I do however share your wider concern. If you mean the original code is misusing HA by doing blocking calls then you’re right, but that’s a separate issue, or have I misunderstood what you meant?

Yes I meant the original PR. And yes I amended my comment about it being the same.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>

same here reboot automatically every minutes …

024-10-05 21:18:08.113 WARNING (MainThread) [homeassistant.util.loop] Detected blocking call to load_verify_locations with args (<ssl.SSLContext object at 0x7f36073302d0>, ‘/usr/local/lib/python3.12/site-packages/certifi/cacert.pem’, None, None) inside the event loop by custom integration ‘alexa_media’ at custom_components/alexa_media/init.py, line 341: AlexaLogin( (offender: /usr/local/lib/python3.12/ssl.py, line 708: context.load_verify_locations(cafile, capath, cadata)), please create a bug report at https://github.com/alandtse/alexa_media_player/issues

For developers, please see https://developers.home-assistant.io/docs/asyncio_blocking_operations/#load_verify_locations

Traceback (most recent call last):

File “<frozen runpy>”, line 198, in _run_module_as_main

File “<frozen runpy>”, line 88, in _run_code

File “/usr/src/homeassistant/homeassistant/main.py”, line 223, in <module>

sys.exit(main())

File “/usr/src/homeassistant/homeassistant/main.py”, line 209, in main

exit_code = runner.run(runtime_conf)

File “/usr/src/homeassistant/homeassistant/runner.py”, line 189, in run

return loop.run_until_complete(setup_and_run_hass(runtime_config))

File “/usr/local/lib/python3.12/asyncio/base_events.py”, line 674, in run_until_complete

self.run_forever()

File “/usr/local/lib/python3.12/asyncio/base_events.py”, line 641, in run_forever

self._run_once()

File “/usr/local/lib/python3.12/asyncio/base_events.py”, line 1990, in _run_once

handle._run()

File “/usr/local/lib/python3.12/asyncio/events.py”, line 88, in _run

self._context.run(self._callback, *self._args)

File “/usr/src/homeassistant/homeassistant/setup.py”, line 165, in async_setup_component

result = await _async_setup_component(hass, domain, config)

File “/usr/src/homeassistant/homeassistant/setup.py”, line 461, in _async_setup_component

await asyncio.gather(

File “/usr/src/homeassistant/homeassistant/setup.py”, line 463, in <genexpr>

create_eager_task(

File “/usr/src/homeassistant/homeassistant/util/async_.py”, line 45, in create_eager_task

return Task(coro, loop=loop, name=name, eager_start=True)

File “/usr/src/homeassistant/homeassistant/config_entries.py”, line 742, in async_setup_locked

await self.async_setup(hass, integration=integration)

File “/usr/src/homeassistant/homeassistant/config_entries.py”, line 594, in async_setup

result = await component.async_setup_entry(hass, self)

File “/config/custom_components/alexa_media/init.py”, line 341, in async_setup_entry

AlexaLogin(

https://github.com/alandtse/alexa_media_player/pull/2589/files

Not likely is it?

There’s already a PR which fixes it.

One line code change:

https://github.com/alandtse/alexa_media_player/pull/2589/files

Would be helpful if others would try it, and confirm this resolves it for them too.

I do not see how that PR would fix the infinite loop. Adding [:] to a list keeps the list identical and that’s the only change in the PR.

e.g.

items = [‘a’,‘b’]

for item in items:

…

is identical to

items = [‘a’,‘b’]

for item in items[:]:

…

I think we have too many people relying on AI to submit PRs on this.

It’s not the same. The [:] means it’s going to be iterating over a copy of the list and that’s the critical difference.

This is not an AI fix. I found it myself by analysis and testing. I do however share your wider concern.

If you mean the original code is misusing HA by doing blocking calls then you’re right, but that’s a separate issue, or have I misunderstood what you meant?

Yes I meant the original PR. And yes I amended my comment about it being the same.

First have you subscribed to Nabu Kasa cloud. This gives the HA voice assistant  connections to Amazon Alexa for devices. (Not part of media player) but part of HA. Second I created an input Boolean toggle helper from within devices and services. Then I exposed it to the Alexa voice assistant this will now be a toggle switch usable in both HA and Alexa. Then create your automation to turn on the toggle. Example I turn it on when the washer starts and off when it is done. (Using power from a smart energy plug. In Alexa I created a routine when the switch goes to off it will say a message on the selected device. On Oct 4, 2024, at 12:42 PM, florismetzner @.***> wrote: I’m really interested how to do the voice notifications in such a way… That’s the only thing I need

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>

Can confirm memory leak crashing home assistant on virtual machine

rollback this update asap! mahine was non stop crashing.

I did this, yes. I also have a HA-Blue. Not 100% sure if it helped on a technical level, but it made me feel better!

if the problem comes from Alexa media player hacs 4.13.3 is it possible to remove the update ?

On my RPi4 this update is still available.

A better approach would be to have a virtual machine with snapshots. Fortunately, I use this approach and make a snapshot before I run any update so it’s always easy to roll back

Same here. OutOfMemory every couple of minutes and HA reboot. AMP v4.13.3 HA: 2024.9.3

Did a rollback to AMP v4.13.2

I’ve had v4.13.2 running for about an hour now on HASS 2024.10.0 and all good. So definitely related to thev4.13.3 release.

I assume to just immediately disable the alexa-media-player integration so you’ve time to roll back to the older version

This is definitely true, I can confirm this. Running HA as a virtual machine on a Synology NAS I had to ramp up the VMs memory to be fast enough to react inside HA.

Can confirm, do not pull the trigger on this update : o

Core 2024.10.0 Supervisor 2024.09.1 Operating System 13.1 Frontend 20241002.2

@ChristophCaina The update just came out a few hours ago. One solution for now is to “deactivate” Alexa Media Player, but other solution would be to roll back to the previous version of AMP which is still working fine.

thanks for that information. Seems that this is still ongoing and caused issues with 2024.10.0

Alexa MediaPlayer is now deactivated…

HA seems to hang as soon as this integration receives an event from Alexa. With debug logging enabled one of the last log messages is:

2024-10-03 09:53:23.680 DEBUG (MainThread) [alexapy.alexahttp2] Received raw message: Content-Type: application/json

{"directive":{"header":{"namespace":"Alexa.Mobile.Push","name":"RenderUpdate","messageId":"df03efc2-4369-46b3-b7c6-32407db0bf1e"},"payload":{"renderingUpdates":[{"route":"EventBus:tcomm::message","resourceId":"PUSH_VOLUME_CHANGE","resourceMetadata":"{\"command\":\"PUSH_VOLUME_CHANGE\",\"timeStamp\":1727942003611,\"payload\":\"{\\\"dopplerId\\\":{\\\"deviceSerialNumber\\\":\\\"523316EAF02E455EA280802DDFD3C6DB\\\",\\\"deviceType\\\":\\\"A2IVLV5VM2W81\\\"},\\\"volumeSetting\\\":25,\\\"isMuted\\\":false,\\\"destinationUserId\\\":\\\"ABLUB65K429CX\\\"}\"}"}]}}}
--------abcde123

I’m able to reproduce this either by opening the Alexa app or by saying “Alexa, what’s the time?”