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

Integration can't load with 2024.8.0b0 #2378

Closed
ChristophCaina opened this issue Aug 1, 2024 · 25 comments
Closed

Integration can't load with 2024.8.0b0 #2378

ChristophCaina opened this issue Aug 1, 2024 · 25 comments
Labels
alexapy Issue relates to the API help wanted Extra attention is needed

Comments

@ChristophCaina
Copy link
Contributor

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

The integration can't load with HomeAssistant 2024.8.0b0
The following error will be logged:

Logger: homeassistant.config_entries
Quelle: config_entries.py:604
Erstmals aufgetreten: 07:00:02 (2 Vorkommnisse)
Zuletzt protokolliert: 07:00:29

Error setting up entry c*******h@c******e - amazon.de 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 353, 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 643, in login
    resp = await self._session.get(
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 481, in _request
    raise RuntimeError("Session is closed")
RuntimeError: Session is closed

To Reproduce

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

Expected behavior

image

System details

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

Logs

2024-08-01 07:52:08.931 DEBUG (MainThread) [custom_components.alexa_media.helpers] c*******h@c******e: Returning uuid {'uuid': '60396035782f10e29d05ce91580cb2fe', 'index': 0}
2024-08-01 07:52:08.941 DEBUG (MainThread) [alexapy.alexalogin] Creating TOTP for 7************************************************KHQ
2024-08-01 07:52:08.941 DEBUG (MainThread) [alexapy.alexalogin] Generating OTP 1****7
2024-08-01 07:52:08.941 DEBUG (MainThread) [alexapy.alexalogin] Login created for c*******h@c******e - amazon.de
2024-08-01 07:52:08.941 ERROR (MainThread) [homeassistant] Error doing job: Unclosed client session (None)
2024-08-01 07:52:08.942 DEBUG (MainThread) [alexapy.alexalogin] Searching for cookies from /config/.storage/alexa_media.***@***.de.pickle
2024-08-01 07:52:08.942 DEBUG (MainThread) [alexapy.alexalogin] Searching for cookies from /config/alexa_media.c*******h@c******e.pickle
2024-08-01 07:52:08.942 DEBUG (MainThread) [alexapy.alexalogin] Searching for cookies from /config/.storage/alexa_media.***@***.de.txt
2024-08-01 07:52:08.943 DEBUG (MainThread) [alexapy.alexalogin] Using credentials to log in
2024-08-01 07:52:08.943 WARNING (MainThread) [alexapy.helpers] alexalogin.login((<alexapy.alexalogin.AlexaLogin object at 0x7fed1c4a1df0>,), {'cookies': {}}): An error occurred accessing AlexaAPI: An exception of type RuntimeError occurred. Arguments:
('Session is closed',)
2024-08-01 07:52:08.943 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry c*******h@c******e - amazon.de 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 353, 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 643, in login
    resp = await self._session.get(
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 481, in _request
    raise RuntimeError("Session is closed")
RuntimeError: Session is closed

Additional context

@danielbrunt57
Copy link
Collaborator

FYI, @Petro31 has tried HA 2024.8.0b0 and notified me today that the alexapy Python Package for controlling Alexa devices programatically (hence the Alexa Media integration) is thoroughly FUBAR'd by HA 2024.8.0 and appears on the surface to be something to do with aiohttp changes.

Unfortunately, it might be the end of this integration unless someone can fix alexapy...

@danielbrunt57 danielbrunt57 added help wanted Extra attention is needed alexapy Issue relates to the API labels Aug 1, 2024
@ChristophCaina
Copy link
Contributor Author

raised a ticket there:
https://gitlab.com/keatontaylor/alexapy/-/issues/30

@Petro31
Copy link
Contributor

Petro31 commented Aug 3, 2024

bdraco mentioned that it might be a good start to look in the .close() method, and it looks like alexapy is accessing protected properties and methods. He doesn't know if this is the cause, but it's a good place to start.

https://gitlab.com/keatontaylor/alexapy/-/blob/dev/alexapy/alexalogin.py?ref_type=heads#L432

@Petro31
Copy link
Contributor

Petro31 commented Aug 3, 2024

I may have time tomorrow to look into things on top of what's mentioned above.

@Petro31
Copy link
Contributor

Petro31 commented Aug 3, 2024

Interesting update, the beta is working for me. Without the automation restart fix. Maybe we don't have to do anything, it's possible the last beta in combination with the updates to AMP fixed everything naturally.

@danielbrunt57
Copy link
Collaborator

I'm still without power here (+20 hours now). Their ETA to resolve was 1/2 hour ago!

OUTAGE CAUSE Tree down across our wires
CUSTOMERS AFFECTED 2680
OFF SINCE Aug 2, 4:05 p.m.
CREW STATUS
Crew on-site
EST. TIME ON Aug 3, 12:00 p.m.
LAST UPDATED Aug 3, 7:06 a.m.

@danielbrunt57
Copy link
Collaborator

Interesting update, the beta is working for me.

That would be 2024.8.0b1?
Is it still Python 3.12?

@ChristophCaina
Copy link
Contributor Author

ChristophCaina commented Aug 3, 2024

I'm on 2024.8.0b1 and it's not working for me.
Not with 4.12.1 nor with the latest update 4.12.4

And yes, still Python 3.12 afaik

@barnosell1978
Copy link

Hello! I have updated all components of my Home Assistant setup, but the Alexa media player integration is still not functioning correctly. Here are the current versions I'm running:

Core: 2024.8.0b3
Supervisor: 2024.08.0
Operating System: 12.4
Python: 3.12.3

@jleinenbach
Copy link
Contributor

You'll need to wait for this PR:
#2398

@sambarlick
Copy link

sambarlick commented Aug 7, 2024

I just updated to 4.12.5 which contains the above mentioned PR. The integration still does not load on HA 2024.8.0b5. After the 4.12.5 update HA has a notification that says the integration needs reconfiguring but I cannot reconfigure it in HA integrations page.
Screenshot_20240807-180455

Logger: homeassistant.config_entries
Source: config_entries.py:604
First occurred: 17:59:23 (2 occurrences)
Last logged: 17:59:39

Error setting up entry [email protected] - amazon.com.au 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 360, in async_setup_entry
if await test_login_status(hass, config_entry, login):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/alexa_media/init.py", line 1421, in test_login_status
] = await hass.config_entries.flow.async_init(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1293, in async_init
flow, result = await self._async_init(flow_id, handler, context, data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1323, in _async_init
result = await self._async_handle_step(flow, flow.init_step, data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 516, in _async_handle_step
result: _FlowResultT = await getattr(flow, method)(user_input)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/alexa_media/config_flow.py", line 578, in async_step_reauth
reauth_schema = self._update_schema_defaults()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/alexa_media/config_flow.py", line 815, in _update_schema_defaults
CONF_HASS_URL, default=self.config.get(CONF_HASS_URL, hass_url)
^^^^^^^^
NameError: name 'hass_url' is not defined

@jleinenbach
Copy link
Contributor

@sambarlick
Copy link

I removed the 2 lines and still not working.

Logger: homeassistant.config_entries
Source: config_entries.py:604
First occurred: 18:36:51 (2 occurrences)
Last logged: 18:37:34

Error setting up entry [email protected] - amazon.com.au 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 360, in async_setup_entry
if await test_login_status(hass, config_entry, login):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/alexa_media/init.py", line 1421, in test_login_status
] = await hass.config_entries.flow.async_init(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1293, in async_init
flow, result = await self._async_init(flow_id, handler, context, data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1323, in _async_init
result = await self._async_handle_step(flow, flow.init_step, data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 516, in _async_handle_step
result: _FlowResultT = await getattr(flow, method)(user_input)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/alexa_media/config_flow.py", line 578, in async_step_reauth
reauth_schema = self._update_schema_defaults()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/alexa_media/config_flow.py", line 815, in _update_schema_defaults
CONF_HASS_URL, default=self.config.get(CONF_HASS_URL, hass_url)
^^^^^^^^
NameError: name 'hass_url' is not defined

@jleinenbach
Copy link
Contributor

jleinenbach commented Aug 7, 2024

I removed the 2 lines and still not working.

Error setting up entry [email protected] - amazon.com.au ...

Did you reboot your HA after this change? This is important.

Additionally, I don't think that this fixes your issue, but I can see you don't use amazon.com, you may also need this patch for alexapy 1.28.1:
#2407 (comment)

As this issue is closed, please mention here, that it's still not working for you:
#2408

@PJLLB
Copy link

PJLLB commented Aug 8, 2024

Did integration version v4.12.7 fix this issue? I

@Jarod2801
Copy link

Jarod2801 commented Aug 8, 2024

v4.12.7 looks good on my system.
Commands are working again. E.g. change volume.
Cannot play anything as my family is asleep and I don't want to disturb 😊

@PJLLB
Copy link

PJLLB commented Aug 9, 2024

Is the media player function working too?

@Jarod2801
Copy link

Yes

@PJLLB
Copy link

PJLLB commented Aug 9, 2024

Thank you. With full Alexa Media Player functionality I'm ready to try 2024.8.0, after a full backup of course.

@PJLLB
Copy link

PJLLB commented Aug 9, 2024

Well that was a bust. The Alexa media player is NOT working. Rolling back...

@ChristophCaina
Copy link
Contributor Author

Well that was a bust. The Alexa media player is NOT working. Rolling back...

You could also Support and provide some more Details, such as Error Logs...

@PJLLB
Copy link

PJLLB commented Aug 10, 2024

The error logs were the same as those posted by the initial poster (and on other similar threads). After the fourth try installing 2024.8.0, Alexa Media Player finally came back to life. I have no idea why, but as we rely heavily on Alexa announcing a significant number of house events, we're very relieved.

@ChristophCaina
Copy link
Contributor Author

I was the initial poster - and the issue was reported back with the beta of 2024.8. ... initially with version 4.12.1
TBH - it is unlikely, that the error logs were 100% exactly the same as mentioned here, since a couple of fixes were already made and there were a bunch of different other errors that caused the integration to fail.

At least, with the latest AMP version, the errors should have been different...
The only thing I COULD imagine here would be a cache thing - the integration folder (custom_components/alexa_media_player) includes a "pycache" folder ... which will be used for better performance.

it COULD BE, that this folder was still loading code based on an already outdated version.

But even then this is why it is important to provide as much information as possible, even if your issue "looks like the same" - it could be different... the error messages could be similar or nearly the same - but it could be a different source of failure - a different line of code that failed.

@PJLLB
Copy link

PJLLB commented Aug 10, 2024

Although it may be unlikely the log entries were the same. Your cache explanation makes sense for why it took a few tries with the upgrade. That said, this is my last post in this thread on this topic. Thank you.

@jleinenbach
Copy link
Contributor

At least, with the latest AMP version, the errors should have been different... The only thing I COULD imagine here would be a cache thing - the integration folder (custom_components/alexa_media_player) includes a "pycache" folder ... which will be used for better performance.

My cache files have the same date and time as the integration files, so they are at least not being recreated on reboot (which is what I expected). And I remember that I deleted this folder and I don't have this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
alexapy Issue relates to the API help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

8 participants