alandtse / alexa_media_player

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

"message":"Invalid handler specified"} #2381

Closed asiersan closed 3 months ago

asiersan commented 3 months ago

I cant configure my account again. I tried a lot of thinks , delete integration, delete hacs. Reinstall all. restarts,..... And every time same error.

On a fresh install no problem. But i restore my backup and same error: "message":"Invalid handler specified"}

System details

`Registrador: homeassistant.loader Fuente: loader.py:1264 Ocurrió por primera vez: 14:55:25 (2 ocurrencias) Último inicio de sesión: 14:55:25

Unexpected exception importing platform custom_components.alexa_media.config_flow Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/loader.py", line 1264, in _load_platform cache[full_name] = self._import_platform(platform_name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/loader.py", line 1296, in _import_platform return importlib.import_module(f"{self.pkg_path}.{platform_name}") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/util/loop.py", line 200, in protected_loop_func return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/importlib/init.py", line 90, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "", line 1387, in _gcd_import File "", line 1360, in _find_and_load File "", line 1310, in _find_and_load_unlocked File "", line 488, in _call_with_frames_removed File "", line 1387, in _gcd_import File "", line 1360, in _find_and_load File "", line 1331, in _find_and_load_unlocked File "", line 935, in _load_unlocked File "", line 995, in exec_module File "", line 488, in _call_with_frames_removed File "/config/custom_components/alexa_media/init.py", line 17, in from alexapy import ( File "/usr/local/lib/python3.12/site-packages/alexapy/init.py", line 41, in maintainer = metadata["maintainer"]


  File "/usr/local/lib/python3.12/site-packages/importlib_metadata/_adapters.py", line 54, in __getitem__
    raise KeyError(item)
KeyError: 'maintainer'`

`Registrador: homeassistant.config_entries
Fuente: config_entries.py:2832
Ocurrió por primera vez: 14:55:25 (1 ocurrencias)
Último inicio de sesión: 14:55:25

Error occurred loading flow for integration alexa_media: Exception importing custom_components.alexa_media.config_flow`

<!---Add any other context about the problem here.--->
rac146 commented 3 months ago

Same issue..

rac146 commented 3 months ago

Not sure what happened, but I deleted my alexa_media entry in my ./storage/core.config_entries file and then downgraded alexa media back to 4.12.1. Restart and then re-added the integration from there and it came back.

Something to do with 4.12.2 perhaps?

ariel-waisman commented 3 months ago

Same problem here

catalam10 commented 3 months ago

Here too on version 4.12.2

KyleStilkey commented 3 months ago

Updated to 4.13.3 and still can't add this. I'm not getting any errors in the logs either but when I try to add this I'm getting a Unknown Error has occurred. Not sure if it's related to this same problem here or not.

catalam10 commented 3 months ago

14.12.3 solved it for me!

rac146 commented 3 months ago

4.12.3 works! Thanks

ariel-waisman commented 3 months ago

Now the message":"Invalid handler specified is gone, but when I try to put my credentials on the integration I get "Unknown error occurred"

jbrown9100 commented 3 months ago

I have fully uninstalled the integration Restarted Home Assistant Re-installed version 4.12.4 and I get having a similar experience I do have 2FA turned on

The integration never launches a web browser to authenticate 2FA

I see the following error in core:

Logger: homeassistant
Source: runner.py:148
First occurred: 20:59:10 (1 occurrences)
Last logged: 20:59:10

Error doing job: Unclosed client session (None)

And this as well:

Logger: aiohttp.server
Source: /usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py:426
First occurred: 20:51:43 (1 occurrences)
Last logged: 20:51:43

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 456, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_app.py", line 537, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_middlewares.py", line 114, in impl
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 92, in security_filter_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 83, in forwarded_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 26, in request_context_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 85, in ban_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 242, in auth_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 32, in headers_middleware
    response = await handler(request)
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/http.py", line 73, in handle
    result = await handler(request, **request.match_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/decorators.py", line 81, in with_admin
    return await func(self, request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 222, in post
    return await super().post(request, flow_id)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 74, in wrapper
    return await method(view, request, data, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 122, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 366, in async_configure
    result = await self._async_configure(flow_id, user_input)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 413, in _async_configure
    result = await self._async_handle_step(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  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 344, in async_step_user
    return await self.async_step_start_proxy(user_input)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/alexa_media/config_flow.py", line 358, in async_step_start_proxy
    str(URL(self.config.get(CONF_HASS_URL)).with_path(AUTH_PROXY_PATH)),
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/yarl/_url.py", line 179, in __new__
    raise TypeError("Constructor parameter should be str")
TypeError: Constructor parameter should be str
danielbrunt57 commented 3 months ago
  File "/config/custom_components/alexa_media/config_flow.py", line 358, in async_step_start_proxy
    str(URL(self.config.get(CONF_HASS_URL)).with_path(AUTH_PROXY_PATH)),
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

See PR #2398 which addresses an issue with CONF_HASS_URL and is waiting to be merged and then released. Here are the files from that PR: PR #2398.zip

danielbrunt57 commented 3 months ago

FYI, the first URL to access Home Assistant can be just http://homeassistant:8123 / http://homeassistant.local:8123 or your internal URL as it's just for the initial proxy authentication callback from your local browser to HA, unless you are installing the integration via an external/remote connection to your HA.

image

jbrown9100 commented 3 months ago

FYI, the first URL to access Home Assistant can be just http://homeassistant:8123 / http://homeassistant.local:8123 or your internal URL as it's just for the initial proxy authentication callback from your local browser to HA, unless you are installing the integration via an external/remote connection to your HA.

image

@danielbrunt57 thanks for the files and the tip. After installing the files and rebooting I'm able to get it set up as intended however as soon as Homeassistant is rebooted it stops working again. Here is a redacted log.

2024-08-05 11:02:35.052 DEBUG (MainThread) [custom_components.alexa_media.helpers] j********0@h*********m: Returning uuid {'uuid': 'b3bc090f0dd78e50977ca9b2109a3681', 'index': 0}
2024-08-05 11:02:35.089 DEBUG (MainThread) [alexapy.alexalogin] Login created for xxxxxxxxxx@hotmail.com - amazon.com
2024-08-05 11:02:35.090 ERROR (MainThread) [homeassistant] Error doing job: Unclosed client session (None)
2024-08-05 11:02:35.093 DEBUG (MainThread) [alexapy.alexalogin] Searching for cookies from /config/.storage/alexa_media.jbrown9100@hotmail.com.pickle
2024-08-05 11:02:35.094 DEBUG (MainThread) [alexapy.alexalogin] Trying to load cookie from file /config/.storage/alexa_media.jbrown9100@hotmail.com.pickle
2024-08-05 11:02:35.111 DEBUG (MainThread) [alexapy.alexalogin] Trying to load aiohttpCookieJar to session
2024-08-05 11:02:35.112 DEBUG (MainThread) [alexapy.alexalogin] Searching for cookies from /config/alexa_media.jbrown9100@hotmail.com.pickle
2024-08-05 11:02:35.113 DEBUG (MainThread) [alexapy.alexalogin] Searching for cookies from /config/.storage/alexa_media.jbrown9100@hotmail.com.txt
2024-08-05 11:02:35.113 DEBUG (MainThread) [alexapy.alexalogin] Using credentials to log in
2024-08-05 11:02:35.113 DEBUG (MainThread) [alexapy.alexalogin] Loaded last request to https://www.amazon.com/ap/mfa?ie=UTF8&arb=c5f30aa5-432a-4498-b697-d82f15aaf2f4&mfa.arb.value=c5f30aa5-432a-4498-b697-d82f15aaf2f4&mfa.arb.key=arb 
2024-08-05 11:02:35.114 DEBUG (MainThread) [alexapy.alexalogin] Processing https://www.amazon.com/ap/mfa?ie=UTF8&arb=c5f30aa5-432a-4498-b697-d82f15aaf2f4&mfa.arb.value=c5f30aa5-432a-4498-b697-d82f15aaf2f4&mfa.arb.key=arb
2024-08-05 11:02:35.149 DEBUG (MainThread) [alexapy.alexalogin] 2FA requested
2024-08-05 11:02:35.150 DEBUG (MainThread) [alexapy.alexalogin] Found post url to https://www.amazon.com/ap/signin
2024-08-05 11:02:35.150 DEBUG (MainThread) [alexapy.alexalogin] Preparing form submission to https://www.amazon.com/ap/signin with input data: {}
2024-08-05 11:02:35.325 DEBUG (MainThread) [alexapy.alexalogin] POST: 
https://www.amazon.com/ap/signin returned 200:OK with response <CIMultiDictProxy('Content-Type': 'text/html;charset=UTF-8', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Server': 'Server', 'Date': 'Mon, 05 Aug 2024 15:02:35 GMT', 'x-amz-rid': 'N0AQGM3G4YW93R5BPAZC', 'Set-Cookie': 'ap-fid=""; Domain=.amazon.com; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/ap/; Secure', 'Set-Cookie': 'session-id=131-6306774-4332343; Domain=.amazon.com; Expires=Tue, 05-Aug-2025 15:02:35 GMT; Path=/; Secure', 'Set-Cookie': 'session-id-time=2353590155l; Domain=.amazon.com; Expires=Tue, 05-Aug-2025 15:02:35 GMT; Path=/; Secure', 'Set-Cookie': 'lc-main=en_US; Domain=.amazon.com; Expires=Tue, 05-Aug-2025 15:02:35 GMT; Path=/; Secure', 'X-XSS-Protection': '1', 'X-Content-Type-Options': 'nosniff', 'x-ua-compatible': 'IE=edge', 'Content-Security-Policy': "frame-ancestors 'none';", 'Pragma': 'No-cache', 'Cache-Control': 'max-age=0, no-cache, no-store, must-revalidate', 'Expires': 'Thu, 01 Jan 1970 00:00:00 GMT', 'Strict-Transport-Security': 'max-age=47474747; includeSubDomains; preload', 'Vary': 'Content-Type,Accept-Encoding,User-Agent', 'p3p': 'policyref="http://www.amazon.com/w3c/p3p.xml",CP="CAO DSP LAW CUR ADM IVAo IVDo CONo OTPo OUR DELi PUBi OTRi BUS PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA HEA PRE LOC GOV OTC "', 'X-Frame-Options': 'SAMEORIGIN', 'X-Cache': 'Miss from cloudfront', 'Via': '1.1 427fa1db55773ddac607ef6d347ce462.cloudfront.net (CloudFront)', 'X-Amz-Cf-Pop': 'ATL59-P3', 'Alt-Svc': 'h3=":443"; ma=86400', 'X-Amz-Cf-Id': 'ilITzMtkg_CMtVjoaDa5s-ZkjWk_fi4zu-gPjOwIDjGl5sC1xl4sEg==')>
2024-08-05 11:02:35.359 DEBUG (MainThread) [alexapy.alexalogin] Processing https://www.amazon.com/ap/signin
2024-08-05 11:02:35.376 DEBUG (MainThread) [alexapy.alexalogin] Error page detected:
2024-08-05 11:02:35.376 DEBUG (MainThread) [alexapy.alexalogin] Found post url to get; forcing get to https://www.amazon.com/ap/signin/131-6306774-4332343?ie=UTF8&openid.pape.max_auth_age=0&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&accountStatusPolicy=P1&otpDeviceId=############
2024-08-05 11:02:35.377 DEBUG (MainThread) [custom_components.alexa_media] Testing login status: {'ap_error': True, 'force_get': True, 'ap_error_href': 'https://www.amazon.com/ap/signin/131-6306774-4332343?ie=UTF8&openid.pape.max_auth_age=0&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&accountStatusPolicy=P1&
2024-08-05 11:02:35.377 DEBUG (MainThread) [custom_components.alexa_media] Logging in: {'url': 'amazon.com', 'email': 'j********0@h*********m', 'password': 'REDACTED 14 CHARS', 'public_url': 'https://9qf8gvipjs99252nfu1xz9daeqjur622.ui.nabu.casa', 'scan_interval': 60, 'queue_delay': 1.5, 'include_devices': '', 'exclude_devices': '', 'extended_entity_discovery': False, 'debug': False, 'oauth': {'access_token': 'A********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************Cvk', 'refresh_token': 'A********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************k7g', 'expires_in': 1722871608.5423, 'mac_dms': {'device_private_key':##########}{serial:Mg==}'}, 'code_verifier': 'aAAZZklm6lZL_o5gPSGyEZfaZhfv-SV13RkCqFHqOEk', 'authorization_code': 'ANskkxayEeBeWmbXStqrDkEM'}} set()
2024-08-05 11:02:35.377 DEBUG (MainThread) [custom_components.alexa_media] Login stats: {'login_timestamp': datetime.datetime(1, 1, 1, 0, 0), 'api_calls': 0}
2024-08-05 11:02:35.378 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry jbrown9100@hotmail.com - amazon.com for alexa_media
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 604, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/alexa_media/__init__.py", line 361, in async_setup_entry
    if await test_login_status(hass, config_entry, login):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/alexa_media/__init__.py", line 1398, in test_login_status
    async_create_persistent_notification(
TypeError: async_create() missing 1 required positional argument: 'hass'

I'm certain that I'm doing something else wrong.

asiersan commented 3 months ago

I don´t know what is the problem realy. If i put my acount in a clear install the integration is ok. If i clear teh integratio, hacs,... and I clear the file in .storage. is the same. so may be another config file in other folder.

asiersan commented 3 months ago

Same problem: Registrador: homeassistant.config_entries Fuente: config_entries.py:2832 Ocurrió por primera vez: 08:58:23 (1 ocurrencias) Último inicio de sesión: 08:58:23

`Registrador: homeassistant.loader Fuente: loader.py:1264 Ocurrió por primera vez: 08:58:23 (2 ocurrencias) Último inicio de sesión: 08:58:23

Unexpected exception importing platform custom_components.alexa_media.config_flow Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/loader.py", line 1264, in _load_platform cache[full_name] = self._import_platform(platform_name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/loader.py", line 1296, in _import_platform return importlib.import_module(f"{self.pkg_path}.{platform_name}") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/util/loop.py", line 200, in protected_loop_func return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/importlib/init.py", line 90, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "", line 1387, in _gcd_import File "", line 1360, in _find_and_load File "", line 1310, in _find_and_load_unlocked File "", line 488, in _call_with_frames_removed File "", line 1387, in _gcd_import File "", line 1360, in _find_and_load File "", line 1331, in _find_and_load_unlocked File "", line 935, in _load_unlocked File "", line 995, in exec_module File "", line 488, in _call_with_frames_removed File "/config/custom_components/alexa_media/init.py", line 17, in from alexapy import ( File "/usr/local/lib/python3.12/site-packages/alexapy/init.py", line 41, in maintainer = metadata["maintainer"]


  File "/usr/local/lib/python3.12/site-packages/importlib_metadata/_adapters.py", line 54, in __getitem__
    raise KeyError(item)
KeyError: 'maintainer'`