Open danielbrunt57 opened 2 weeks ago
I think the problem lies with HA's startup changes and blocking calls during integration import.
this is showing up in beta
async_forward_entry_setup
as something to avoid using and Alexa media player is using that call.
Well, I fixed that on my system and it didn't solve the problem.
So this was your change?
@Petro31 Are you also getting the partitioned cookie error?
@Petro31 Are you also getting the partitioned cookie error?
Yes but I haven't fixed that yet. That requires some more debugging.
The way to fix the beta errors and warnings is to swap to hass.config_entries.async_forward_entry_setups(
and wrap component
in a list [component]
https://github.com/alandtse/alexa_media_player/pull/2294
config_entry.async_create_task(
hass,
hass.config_entries.async_forward_entry_setups(
config_entry, [component]
)
)
or you could move it out of create tasks and await that.
await hass.config_entries.async_forward_entry_setups(
config_entry, [component]
)
Yes but I haven't fixed that yet. That requires some more debugging.
I fixed my error with the cookies.py file from the new python 3.13 work where giles-v has a PR: Add support for 'partitioned' attribute in http.cookies #112714 which adds support for Cookies Having Independent Partitioned State (CHIPS) but now for some strange reason I no longer need it and do not have the error. I'm thinking it's somehow browser related but do not know how I rid myself of my partitioned cookie...
@danielbrunt57 thank you for your suggestion. I confirm that following the above (https://github.com/alandtse/alexa_media_player/issues/2288#issuecomment-2181877003 )recommendation fixed my problem
For me it does not fix the issue. But i could not follow the exact instruction because of the cookies.py location. @danielbrunt57 said it is in
/usr/local/lib/python3.12/http/cookies.py
but i have it in
/usr/lib/python3.12/http/cookies.py
So for me, the only thing that worded was restoring back to version 2024.6.2 and that is where I stayed. Now with 2024.7.0 due to come out soon, I wonder if it will be addressed in it
Comment #2288 didn't work for me. The first few restarts everything was good. After the fourth restart it started failing again and has failed after subsequent restarts. I reverted back to 2024.6.2.
same here on 2024.6.4: restoring back 2024.6.2 solves the issue. Hope HA team will fix this...?
Comment #2288 didn't work for me. The first few restarts everything was good. After the fourth restart it started failing again and has failed after subsequent restarts. I reverted back to 2024.6.2.
Were you getting the 'partitioned' cookie error after the 4th restart? If so, then I suspect "the fix" somehow disappeared...
As I stated earlier, after fixing my partitioned cookie error via comment #2288, I now no longer need the fix and am running 2024.6.4 and the integration just fine . It's beyond me as to what's really going on and why...
@danielbrunt57 Sorry I didn't check for partitioned cookie error before I rolled back. I just tried again and restarted 6 times but have not gotten the error yet. Alexa Media player is still loading as it should. If I do get it later, I will check for error.
There is something very strange going on here and even though I am trouble free now, I am still puzzled as to why this "partitioned cookie" thing has reared it's ugly head. Normally I like "cookies", but not this one!
@danielbrunt57 Sorry I didn't check for partitioned cookie error before I rolled back. I just tried again and restarted 6 times but have not gotten the error yet. Alexa Media player is still loading as it should. If I do get it later, I will check for error.
Is that with or without the "enhanced" cookies,py file?
@danielbrunt57
My alexa instance had just stopped all together. Your suggested fix with edited py fixed it and continues to work after several restarts
@danielbrunt57
My alexa instance had just stopped all together. Your suggested fix with edited py fixed it and continues to work after several restarts
I'm glad it helped but still don't understand why it was/is needed when I no longer need it....
Various back and forth here: can someone be kind enough to give the exact steps to fix this issue ? Thanks in advance.
Well, it's not a "fix" per se as no one so far really knows what is going on (myself included).
If you are getting a "partitioned cookie" error then my # 2288 (comment) should get you running again.
But the question remains, why is partitioned cookie support all of a sudden even necessary.
HA has changed something (a lot?) that I haven't been able to figure out,,,
Thank you Daniel ! I could manage to reauthenticate and it works again. When you know more, keep us posted so that we know what is the right procedure to use on upcoming HA release.
@danielbrunt57 I am now getting the issue with Alexa Media Player loading on restart. I am also seeing the cookie partition issue.
Traceback (most recent call last): 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 335, in async_setup_entry await login.login(cookies=await login.load_cookie()) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/alexapy/alexalogin.py", line 328, in load_cookie cookies = pickle.loads(await myfile.read()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/http/cookies.py", line 312, in setitem raise CookieError("Invalid attribute %r" % (K,)) http.cookies.CookieError: Invalid attribute 'partitioned'
@danielbrunt57 I am now getting the issue with Alexa Media Player loading on restart. I am also seeing the cookie partition issue.
What all have you tried or installed since retrying? Are you on 2024.6.4? Is the "enhanced" cookies.py file still in place? Line 285 should be this:
"partitioned": "Partitioned",
Yes, line 285 has this "partitioned": "Partitioned"
Yes, line 285 has this "partitioned": "Partitioned"
and the file is "/usr/lib/python3.12/http/cookies.py"?
or, if you are inside the homeassistant container, it's "/usr/local/lib/python3.12/http/cookies.py"
In the home assistant container at /usr/local/lib/python3.12/http/cookies.py, "partition": "Partitioned" is in the cookies.py file.
File "/usr/local/lib/python3.12/http/cookies.py", line 312, in setitem raise CookieError("Invalid attribute %r" % (K,)) http.cookies.CookieError: Invalid attribute 'partitioned'
Line 312 in the original cookies.py file is:
raise CookieError("Invalid attribute %r" % (K,))
Line 312 in the PR's cookies.py file is: if not K in self._reserved:
and the raise CookieError("Invalid attribute %r" % (K,))
is line 313!
It would seem your system is somehow executing the original cookies.py which has the raise CookieError at line 312.
I'd suggest trying a full system reboot on your HA system.
When I'm confused about where things are, I use find
to search and print the full path:
cd /
find . -name cookies.py -print
Did a full reboot as you suggested and then did a find and these are the results.
~ cd /
➜ / find . -name cookies.py -print
./usr/lib/python3.12/site-packages/pip/_vendor/requests/cookies.py
./usr/lib/python3.12/http/cookies.py
➜ /
Looking at the cookies.py it has reverted back to an earlier version and the partition": "Partitioned" is not there.
My container looks like this:
homeassistant:/# find . -name cookies.py -print
./root/.cache/uv/archive-v0/ibQyxfM70TC3Fi39bIe8P/requests/cookies.py
./root/.cache/uv/archive-v0/DbZOyLf3AuipJyun0BFT-/jaraco/net/http/cookies.py
./root/.cache/uv/archive-v0/RTXeQ7dvg7towOsFQRLcM/yt_dlp/cookies.py
./root/.cache/uv/archive-v0/KpoWgTwHHzDd6M7RnEhy2/future/backports/http/cookies.py
./root/.cache/uv/archive-v0/KpoWgTwHHzDd6M7RnEhy2/future/moves/http/cookies.py
./usr/local/lib/python3.12/http/cookies.py <-- This is the only one I replaced as all the others do something different.
./usr/local/lib/python3.12/site-packages/requests/cookies.py
./usr/local/lib/python3.12/site-packages/jaraco/net/http/cookies.py
./usr/local/lib/python3.12/site-packages/yt_dlp/cookies.py
./usr/local/lib/python3.12/site-packages/future/backports/http/cookies.py
./usr/local/lib/python3.12/site-packages/future/moves/http/cookies.py
./usr/local/lib/python3.12/site-packages/pip/_vendor/requests/cookies.py
I'm not sure but I think the only thing(s) that would cause a reversion is an HA update & possibly a redownload of the Alexa Media Player integration via HACS.
Have you re-replaced that cookies.py file?
I hadn't replace the cookie file yet. Was waiting to hear back from you. Replaced it this morning and ran command and this is what I got back.
find . -name cookies.py -print ./usr/lib/python3.12/site-packages/pip/_vendor/requests/cookies.py ./usr/lib/python3.12/http/cookies.py find: ./proc/487/task/487/fdinfo: Permission denied find: ./proc/487/fdinfo: Permission denied find: ./proc/488/task/488/fdinfo: Permission denied find: ./proc/488/fdinfo: Permission denied
Alexa media play failed on second restart.
So for those of us that chose to rollback, with the upcoming 2024.7.0 coming today, should we not upgrade?
On Wed, Jul 3, 2024, 12:28 PM wxman60 @.***> wrote:
I hadn't replace the cookie file yet. Was waiting to hear back from you. Replaced it this morning and ran command and this is what I got back.
find . -name cookies.py -print ./usr/lib/python3.12/site-packages/pip/_vendor/requests/cookies.py ./usr/lib/python3.12/http/cookies.py find: ./proc/487/task/487/fdinfo: Permission denied find: ./proc/487/fdinfo: Permission denied find: ./proc/488/task/488/fdinfo: Permission denied find: ./proc/488/fdinfo: Permission denied
Alexa media play failed on second restart.
— Reply to this email directly, view it on GitHub https://github.com/alandtse/alexa_media_player/issues/2288#issuecomment-2206751033, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHOXQZ4EYEV7GXALL2ZKVLTZKQRCJAVCNFSM6AAAAABJN7M7RKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMBWG42TCMBTGM . You are receiving this because you commented.Message ID: @.***>
So for those of us that chose to rollback, with the upcoming 2024.7.0 coming today, should we not upgrade?
I won't know until I get 2024.7.0 and try with the original cookies.py file. There's been zero input from @alandtse on this. Plus I don't understand why there's a partitioned cookie with >= 2024.6.3 but not 2024.6.2.....
Alexa media play failed on second restart.
Is your cookies.py file still the newer one??
I just got 2024.7.0 and it wiped my updated cookies.py file and AMP failed to initialize...
Logger: homeassistant.config_entries
Source: config_entries.py:586
First occurred: 10:39:57 AM (1 occurrences)
Last logged: 10:39:57 AM
Error setting up entry daniel@brunt.ca - amazon.com for alexa_media
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 586, in async_setup
result = await component.async_setup_entry(hass, self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/alexa_media/__init__.py", line 335, in async_setup_entry
await login.login(cookies=await login.load_cookie())
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/alexapy/alexalogin.py", line 328, in load_cookie
cookies = pickle.loads(await myfile.read())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/http/cookies.py", line 312, in __setitem__
raise CookieError("Invalid attribute %r" % (K,))
http.cookies.CookieError: Invalid attribute 'partitioned'
Re-replacing the file...
Yes, it is still the new one after restart. If I do a reboot then it reverts back to the old one.
Yes, it is still the new one after restart. If I do a reboot then it reverts back to the old one.
Are you doing a Restart Home Assistant or a Reboot system? (and I presume you are using Home Assistant Operating System aka Supervised?)
Well, after replacing cookies.py I have now have a different behaviour...a VERY long delay on initializing AMP which eventually gives me...
This error originated from a custom integration.
Logger: alexapy.helpers
Source: custom_components/alexa_media/__init__.py:335
integration: Alexa Media Player (documentation, issues)
First occurred: 10:58:56 AM (1 occurrences)
Last logged: 10:58:56 AM
alexalogin.login((<alexapy.alexalogin.AlexaLogin object at 0xffff5cae1b50>,), {'cookies': {}}): Timeout error occurred accessing AlexaAPI: An exception of type CancelledError occurred. Arguments: ('Global task timeout',)
Logger: homeassistant.bootstrap
Source: bootstrap.py:1042
First occurred: 10:59:12 AM (1 occurrences)
Last logged: 10:59:12 AM
Setup timed out for stage 2 waiting on {<Task pending name='listen alexa_media_relogin_success' coro=<async_setup_entry.<locals>.login_success() running at /config/custom_components/alexa_media/__init__.py:243> wait_for=<_GatheringFuture pending cb=[Task.task_wakeup()]> cb=[set.remove()]>} - moving forward
Logger: alexapy.helpers
Source: runner.py:190
First occurred: 10:59:13 AM (1 occurrences)
Last logged: 10:59:13 AM
alexaapi.get_devices((<alexapy.alexalogin.AlexaLogin object at 0xffff5cae1b50>,), {}): A connection error occurred: An exception of type KeyError occurred. Arguments: ('daniel@brunt.ca',)
I did both, first a restart and the file remained the new one and then a reboot and it reverted back to the old one.
I did both, first a restart and the file remained the new one and then a reboot and it reverted back to the old one.
I dunno...
I just removed the AMP config & re-added it and now I get an Amazon captcha which I complete but it then gives me,.,.
and I can't add it.
I would say this integration unfortunately is now very broken..............
I just received 2024.7 and going to upgrade to that. I already have an automation that reloads AMP after restart. Will just wait to see if @alandtse can find a fix for it.
Thanks for making the attempt to find a work around.
I just switched from Edge to Chrome, logged into HA and was successfully able to reinstall the AMP integration so something is messed up in Edge. ...and someone posted a while back that the browser is not involved in this!
After checking Edge settings, an update was pending and Edge restarted...
I removed and re-added the integration using Edge browser and it successfully completed without that captcha screen. However, I restarted HA and my cookies.py file had reverted to the original and AMP failed to initialize. After re-replacing it, all is well again.
I just received 2024.7 and going to upgrade to that. I already have an automation that reloads AMP after restart. Will just wait to see if @alandtse can find a fix for it.
You may be waiting until 2024.11 or 2024.12 as October is the scheduled release of the next python version which will hopefully address this new partitioned cookie structure, unless @alantse has time to devise and rewrite it to not use the current cookie method. That or someone figures out why HA sees it at restart while an integration reload after-the-fact does not...
Came across this earlier today. Looks like AMP won't be updated for a while or if ever. https://community.home-assistant.io/t/alexa-media-player-custom-integration-on-life-support-help-wanted/725684
Came across this earlier today. Looks like AMP won't be updated for a while or if ever.
Alan is still publishing fixes provided by other developers. So this integration is in maintenance mode. Myself and a few others have been pushing various minor fixes to the integration. He is not actively developing this integration or providing fixes authored by him.
i am no programmer or developer, i am just a dumb user that can follow guides pretty well. so i guess what i don't get is that it works just fine on 2024.6.2 so what is causing it to break on newer versions?
An update from Alan just came across 4.10.3. It's a fix for "warning for async_forward_entry_setup". I just tried it and restarted a few time and Alexa Media Player is still not loading on restart. Hopefully he will address it soon.
An update from Alan just came across 4.10.3. It's a fix for "warning for async_forward_entry_setup". I just tried it and restarted a few time and Alexa Media Player is still not loading on restart. Hopefully he will address it soon.
Yes, I made that fix and that change wasn't going to fix this issue. It was to fix a different issue.
so today i saw that the Alexa Media Player integration had an update. i installed it but i am still on HA 2024.6.2 and have not upgraded to 2024.7.0 yet. anyone on 2024.7.0 and did the AMP upgrade as well? can you confirm if the issue has gone away now?
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
Alexa Media Player is failing to initialize after restarting HA 2024.6.3. If I reload the integration, all is well.
To Reproduce
Restart Home assistant 2014.6.3 and observe that the integration failed to load.
Expected behavior
It should load like it did on 2024.6.2 and older.
Screenshots
System details
const.py
or HA startup): 4.10.2pip show alexapy
or HA startup):Logs
home-assistant_2024-06-17T13-08-27.618Z.log
Additional context