alexa_media_player: TypeError: can only concatenate str (not "NoneType") to str

Describe the bug

The integration no longer starts. In the past, multiple restarts helped (HA 2024.07 / HA 2024.08), but recently, nothing helps anymore. A complete reinstallation worked for 2 days, but after several restarts, the same problem occurred again.

Same or similar to https://github.com/alandtse/alexa_media_player/issues/1072

TypeError: can only concatenate str (not “NoneType”) to str

Logger: homeassistant.config_entries
Source: config_entries.py:604
First occurred: 11:43:46 (2 occurrences)
Last logged: 12:03:05

Error setting up entry xxx@xxx.de - 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 361, 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 703, in login
    self._site = await self._process_page(await post_resp.text(), site)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/alexapy/alexalogin.py", line 1463, in _process_page
    error_message += list_item.find("span").string
TypeError: can only concatenate str (not "NoneType") to str

To Reproduce

🤷‍♂️

Expected behavior

Screenshots image

System details

  • Home Assistant version: 2024.9.1
  • alexa_media version (from const.py or HA startup log): 4.12.12
  • alexapy version (from pip show alexapy in homeasssistant container or HA startup log): 1.28.2
  • Is Amazon 2FA/2SV enabled <!—We will not debug login issues if unanswered—> (y/n): y
  • Amazon Domain: amazon.de

Debug Logs (alexa_media & alexapy) Please provide logs.


2024-09-09 12:25:09.110 DEBUG (MainThread) [custom_components.alexa_media] Nothing to import from configuration.yaml, loading from Integrations
2024-09-09 12:25:09.110 DEBUG (MainThread) [custom_components.alexa_media] 
-------------------------------------------------------------------
alexa_media
Version: 4.12.12
This is a custom component
If you have any issues with this you need to open an issue here:
https://github.com/alandtse/alexa_media_player/issues
-------------------------------------------------------------------
2024-09-09 12:25:09.110 DEBUG (MainThread) [custom_components.alexa_media] Loaded alexapy==1.28.2
2024-09-09 12:25:09.111 DEBUG (MainThread) [custom_components.alexa_media.helpers] XXXXXXXXXXXX: Returning uuid {'uuid': 'e4bb66b28ad9b65ee8bb459f315da469', 'index': 0}
2024-09-09 12:25:09.161 DEBUG (MainThread) [alexapy.alexalogin] Creating TOTP for XXXXXXXXXXXX
2024-09-09 12:25:09.161 DEBUG (MainThread) [alexapy.alexalogin] Generating OTP XXXXXXXXXXXX
2024-09-09 12:25:09.166 DEBUG (MainThread) [alexapy.alexalogin] Login created for XXXXXXXXXXXX - amazon.de
2024-09-09 12:25:09.172 DEBUG (MainThread) [alexapy.alexalogin] Searching for cookies from /config/.storage/alexa_media.XXXXXXXXXXXX.pickle
2024-09-09 12:25:09.173 DEBUG (MainThread) [alexapy.alexalogin] Trying to load cookie from file /config/.storage/alexa_media.XXXXXXXXXXXX.pickle
2024-09-09 12:25:09.203 DEBUG (MainThread) [alexapy.alexalogin] Trying to load aiohttpCookieJar to session
2024-09-09 12:25:09.209 DEBUG (MainThread) [alexapy.alexalogin] Searching for cookies from /config/alexa_media.XXXXXXXXXXXX.pickle
2024-09-09 12:25:09.210 DEBUG (MainThread) [alexapy.alexalogin] Searching for cookies from /config/.storage/alexa_media.XXXXXXXXXXXX.txt
2024-09-09 12:25:09.210 DEBUG (MainThread) [alexapy.alexalogin] Using credentials to log in
2024-09-09 12:25:09.211 DEBUG (MainThread) [alexapy.alexalogin] Attempting oauth login to https://www.amazon.com/ap/signin?openid.return_to=https://www.amazon.com/ap/maplanding&openid.assoc_handle=amzn_dp_project_dee_ios&openid.identity=http://specs.openid.net/auth/2.0/identifier_select&pageId=amzn_dp_project_dee_ios&accountStatusPolicy=P1&openid.claimed_id=http://specs.openid.net/auth/2.0/identifier_select&openid.mode=checkid_setup&openid.ns.oa2=http://www.amazon.com/ap/ext/oauth/2&openid.oa2.client_id=device:653462623636623238616439623635656538626234353966333135646134363932333431333234393536346335363335353634643332353733383331&openid.ns.pape=http://specs.openid.net/extensions/pape/1.0&openid.oa2.response_type=code&openid.ns=http://specs.openid.net/auth/2.0&openid.pape.max_auth_age=0&openid.oa2.scope=device_auth_access&openid.oa2.code_challenge_method=S256&openid.oa2.code_challenge=XXXXXXXXXXXX&language=de_DE
2024-09-09 12:25:09.609 DEBUG (MainThread) [alexapy.alexalogin] GET: 
https://www.amazon.com/ap/signin?openid.return_to=https://www.amazon.com/ap/maplanding&openid.assoc_handle=amzn_dp_project_dee_ios&openid.identity=http://specs.openid.net/auth/2.0/identifier_select&pageId=amzn_dp_project_dee_ios&accountStatusPolicy=P1&openid.claimed_id=http://specs.openid.net/auth/2.0/identifier_select&openid.mode=checkid_setup&openid.ns.oa2=http://www.amazon.com/ap/ext/oauth/2&openid.oa2.client_id=device:653462623636623238616439623635656538626234353966333135646134363932333431333234393536346335363335353634643332353733383331&openid.ns.pape=http://specs.openid.net/extensions/pape/1.0&openid.oa2.response_type=code&openid.ns=http://specs.openid.net/auth/2.0&openid.pape.max_auth_age=0&openid.oa2.scope=device_auth_access&openid.oa2.code_challenge_method=S256&openid.oa2.code_challenge=XXXXXXXXXXXX&language=de_DE returned 200:OK with response <CIMultiDictProxy('Content-Type': 'text/html;charset=UTF-8', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Server': 'Server', 'Date': 'Mon, 09 Sep 2024 10:25:09 GMT', 'x-amz-rid': '04QM1D8MN5HVKGTSDFNN', 'Set-Cookie': 'ap-fid=""; Domain=.amazon.com; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/ap/; Secure', 'Set-Cookie': 'session-id=135-4217245-7778765; Domain=.amazon.com; Expires=Tue, 09-Sep-2025 10:25:09 GMT; Path=/; Secure', 'Set-Cookie': 'session-id-time=2356597509l; Domain=.amazon.com; Expires=Tue, 09-Sep-2025 10:25:09 GMT; Path=/; Secure', 'Set-Cookie': 'ubid-main=135-5053255-1128561; Domain=.amazon.com; Expires=Tue, 09-Sep-2025 10:25:09 GMT; Path=/; Secure', 'Set-Cookie': 'session-token=XXXXXXXXXXXX; Domain=.amazon.com; Expires=Tue, 09-Sep-2025 10:25:09 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 6b284415724869adc9db63c19e48e420.cloudfront.net (CloudFront)', 'X-Amz-Cf-Pop': 'FRA60-P9', 'Alt-Svc': 'h3=":443"; ma=86400', 'X-Amz-Cf-Id': 'WZmbNiolUTU_0MroMmZraGglYeN09LPgflxohl1aZ3_XefY2w-HwKw==')>
2024-09-09 12:25:09.866 DEBUG (MainThread) [alexapy.alexalogin] Processing https://www.amazon.com/ap/signin?openid.return_to=https://www.amazon.com/ap/maplanding&openid.assoc_handle=amzn_dp_project_dee_ios&openid.identity=http://specs.openid.net/auth/2.0/identifier_select&pageId=amzn_dp_project_dee_ios&accountStatusPolicy=P1&openid.claimed_id=http://specs.openid.net/auth/2.0/identifier_select&openid.mode=checkid_setup&openid.ns.oa2=http://www.amazon.com/ap/ext/oauth/2&openid.oa2.client_id=device:653462623636623238616439623635656538626234353966333135646134363932333431333234393536346335363335353634643332353733383331&openid.ns.pape=http://specs.openid.net/extensions/pape/1.0&openid.oa2.response_type=code&openid.ns=http://specs.openid.net/auth/2.0&openid.pape.max_auth_age=0&openid.oa2.scope=device_auth_access&openid.oa2.code_challenge_method=S256&openid.oa2.code_challenge=XXXXXXXXXXXX&language=de_DE
2024-09-09 12:25:10.023 DEBUG (MainThread) [alexapy.alexalogin] Found standard login page
2024-09-09 12:25:10.024 DEBUG (MainThread) [alexapy.alexalogin] Found post url to https://www.amazon.com/ap/register
2024-09-09 12:25:10.024 DEBUG (MainThread) [alexapy.alexalogin] Preparing form submission to https://www.amazon.com/ap/register with input data: {}
2024-09-09 12:25:10.024 DEBUG (MainThread) [alexapy.alexalogin] No 2FA code supplied but will generate.
2024-09-09 12:25:10.025 DEBUG (MainThread) [alexapy.alexalogin] Generating OTP XXXXXXXXXXXX
2024-09-09 12:25:10.499 DEBUG (MainThread) [alexapy.alexalogin] POST: 
https://www.amazon.com/ap/register returned 200:OK with response <CIMultiDictProxy('Content-Type': 'text/html;charset=UTF-8', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Server': 'Server', 'Date': 'Mon, 09 Sep 2024 10:25:10 GMT', 'x-amz-rid': '5R6K5HQTKVW89AFA09VP', 'Set-Cookie': 'session-id=135-4217245-7778765; Domain=.amazon.com; Expires=Tue, 09-Sep-2025 10:25:10 GMT; Path=/; Secure', 'Set-Cookie': 'session-id-time=2356597510l; Domain=.amazon.com; Expires=Tue, 09-Sep-2025 10:25:10 GMT; Path=/; Secure', 'Set-Cookie': 'ubid-main=135-5053255-1128561; Domain=.amazon.com; Expires=Tue, 09-Sep-2025 10:25:10 GMT; Path=/; Secure', 'Set-Cookie': 'session-token=XXXXXXXXXXXX; Domain=.amazon.com; Expires=Tue, 09-Sep-2025 10:25:10 GMT; Path=/; Secure', 'X-XSS-Protection': '1', 'X-Content-Type-Options': 'nosniff', 'x-ua-compatible': 'IE=edge', 'Pragma': 'No-cache', 'Cache-Control': 'max-age=0, no-cache, no-store, must-revalidate', 'Expires': 'Thu, 01 Jan 1970 00:00:00 GMT', 'Content-Security-Policy': "frame-ancestors 'none';", '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 6b284415724869adc9db63c19e48e420.cloudfront.net (CloudFront)', 'X-Amz-Cf-Pop': 'FRA60-P9', 'Alt-Svc': 'h3=":443"; ma=86400', 'X-Amz-Cf-Id': 'BZqqmgn4JvOnJAWaJjhCMFQdD4Eqdtu4Wdo0WlxbCaxxMwToX8zaIw==')>
2024-09-09 12:25:10.572 DEBUG (MainThread) [alexapy.alexalogin] Processing https://www.amazon.com/ap/register
2024-09-09 12:25:10.641 WARNING (MainThread) [alexapy.helpers] alexalogin.login((<alexapy.alexalogin.AlexaLogin object at 0x7fc88f5b5a00>,), {'cookies': {}}): An error occurred accessing AlexaAPI: An exception of type TypeError occurred. Arguments:
('can only concatenate str (not "NoneType") to str',)
2024-09-09 12:25:10.641 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry XXXXXXXXXXXX - 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 361, 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 703, in login
    self._site = await self._process_page(await post_resp.text(), site)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/alexapy/alexalogin.py", line 1463, in _process_page
    error_message += list_item.find("span").string
TypeError: can only concatenate str (not "NoneType") to str
2024-09-09 12:25:38.006 DEBUG (MainThread) [custom_components.alexa_media] Completing remaining startup tasks.

Additional context

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 3
  • Comments: 77 (5 by maintainers)

Commits related to this issue

Most upvoted comments

ChatGPT:

The error you’re encountering is a TypeError caused by trying to concatenate a string with a NoneType object during the login process for the alexa_media integration in Home Assistant. The error occurs in this code snippet:

error_message += list_item.find("span").string

Breakdown of the Issue:

  1. Cause:
    The program is trying to append text from an HTML span element, but list_item.find("span").string is returning None. This happens when the expected span element is either missing or empty, potentially due to an unexpected or malformed response from Amazon’s login page.

  2. Potential Causes:

    • Amazon Service Disruption: Amazon recently had an issue with its Identity and Access Management (IAM) service, which affected authentication processes globally. This could have led to incomplete or incorrect HTML being returned, resulting in the login loop and the error you’re seeing.
    • OAuth Login Attempt: The login process involves an OAuth flow, where the system uses a time-based one-time password (TOTP) and cookies to authenticate the session. In this case, the issue likely arises when the response page doesn’t load properly, interrupting the OAuth process and redirecting incorrectly to a registration page, as seen in your earlier logs.
  3. Solution:

    • Modify the Python Code: The program needs to handle cases where no text is found in the span element:

      span_text = list_item.find("span").string
      if span_text:  # Only append if span_text is not None
          error_message += span_text
      

      This simple check ensures the program won’t break if the element is empty, preventing the TypeError.

    • Clear Cookies: Old or corrupted cookies could cause faulty authentication attempts. You can delete the saved cookie files and restart the login process, allowing fresh cookies to be generated:

      rm /config/.storage/alexa_media.*.pickle
      
    • Wait for Stabilization: Given Amazon’s recent IAM issues, retrying after services fully stabilize may resolve the problem without requiring further changes.

OAuth Context:

During the login process, the system initiates an OAuth login attempt, where it exchanges credentials for access tokens via an external service (Amazon). If the response during this attempt is malformed or incomplete, the login process could fail, leading to the errors you are seeing. Properly handling these scenarios by checking for missing elements or corrupted session data can help prevent these issues.

By following these steps, you should be able to resolve the error and avoid the login loop caused by this unexpected behavior.

I just updated HA from 2024.7.3 to 2024.9.1 and immediately encountered this error. Alexa has previously been working fine for months. Reloading integration and rebooting HA had no effect, nor did deleting my pickle and rebooting. I eventually restored from backup to 2024.7.3 and Alexa is working again. (This makes me wonder how this can be an Amazon problem, it must be something on our end). Following this for a fix.

Hello, I have an installation of Home Assistan OS and after trying all the proposed solutions I always got the TypeError: can only… Yesterday I rolled back to the Core 2024.7.3 version and it seems to be maintained and working correctly

there is a new alexapy version that fixes cookie issues, i just changed the version in the manifest to “alexapy==1.29.2” and then restarted, then reset back up and ensured i added the code for 2fa and all seems to be back up and running

It’s merged but I don’t see it in the latest Hass changes log, am I wrong?

alexapy is a python package that is used by HA, but does not belong to HA

I also updated to v4.13.5 and the integration failed some time after doing a log-in, also for me…

I’ve updated to v4.13.5 and still the integration fails some time after doing a log-in.

I think now I am on this bandwagon https://github.com/alandtse/alexa_media_player/issues/2453

Did anybody on this thread has been able to fully solve their issue with this update?

Thanks for this! What do you mean with need time ?

See alexapy merge request !391 which is already two weeks old now.

in log error is same can only concatenate str (not “NoneType”) to str

That is coming from an errorbox window which AMP is no longer able to process as Amazon has likely changed the formatting. Editing /usr/local/lib/python3.12/site-packages/alexapy/alexalogin.py to this should allow it to process that errorbox without an error, but there really should not be an errorbox window if everything succeeded.

        # pull out Amazon error message

        if errorbox:
            error_message = errorbox.find("h4").string
            if error_message is None:
                error_message = "unknown"
            for list_item in errorbox.findAll("li"):
                span_text = list_item.find("span").string
                if span_text:
                    error_message += span_text
            _LOGGER.debug("Error message: %s", error_message)
            status["error_message"] = error_message

I also have a side problem. Right now the integration is not going. so notify.alexa_media does not exist. All my automations that use that service (action) now no longer work.

Has anyone found a way to put a try catch without removing the service altogether?

I tried with continue_on_error: true creating a proxy service but nothing always crashes for “action does not exist”

@r1si Elia,

I am using a python script which will issue a persistent notification if the notify.alexa_media action fails. Install HA’s Python Scripts Create these files in the <config>/python_scripts/ folder:

# notify_alexa_media.py
domain = "notify"
service = data.get("service")
message = data.get("message")
flag = False

if service is not None and message is not None:
    service_data = {"message": message }
    try:
        hass.services.call(domain, service, service_data, flag)
    except:
        hass.services.call(
            "persistent_notification", "create", {
                "message": "Failed to call notify.{service}",
                "title": "Notify Alexa Media",
                "notification_id": "notify.alexa_media"
            }
        )
else:
    if service is None:
        hass.services.call(
            "persistent_notification", "create", {
                "message": "Missing required parameter \"service:\"",
                "title": "Notify Alexa Media",
                "notification_id": "notify.alexa_media"
            }
        )
    if message is None:
        hass.services.call(
            "persistent_notification", "create", {
                "message": "Missing required parameter \"message:\"",
                "title": "Notify Alexa Media",
                "notification_id": "notify.alexa_media"
            }
        )
# services.yaml
notify_alexa_media:
  name: notify.alexa_media
  description: Send a notification via Alexa Media Notification actions
  fields:
    service:
      description: The alexa_media notification service to append to "notify."
      example: "alexa_media_last_called"
    message:
      description: The message to be sent
      example: "Hello, this is a test"

In Developer tools > Actions, execute python_script.reload. Test the script in Dev Tools: python_script.notify_alexa_media. Once working, you can replace your notify.alexa_media_xyz actions with python_script.notify_alexa_media:

action: python_script.notify_alexa_media
data:
  service: alexa_media_last_called
  message: Hello, this is a test

Daniel is a god! @danielbrunt57

I removed the integration, rebooted, added the integration again, went into endless login loop, used the Daniel method to try to create a new account with the same email, it failed as planned, logged in again and this time got to the 2FA page. After this everything started working! It’s 3am and it took 3 hours to fix but it’s working!!! 😃

Daniel’s Method

Has everyone tried deleting the integration config entry and setting it up again?

I didnt want to be that guy 🤣🤣🤣 but, “its working for me” after doing that 😃

I deleted the pickl file and removed the addon. If i now try to reinstall and configure it, i also get a loop on login page on amazon.

Reboot again, then try Daniel’s sequence

I deleted the pickl file and removed the addon. If i now try to reinstall and configure it, i also get a loop on login page on amazon.

I had the same error, reinstalled the integration from HACS (after deleting the pickle file in the .storage folder of HA) and now is working ok for 3 days.

On Fri, Sep 13, 2024 at 8:46 AM deifel @.***> wrote:

Hello everyone, I’ve also had the error (TypeError: can only concatenate str (not “NoneType”) to str) for 3 days or one of the last updates. Is there a solution now or is it being worked on? Currently, some automations are no longer working because of this. Thank you very much

— Reply to this email directly, view it on GitHub https://github.com/alandtse/alexa_media_player/issues/2515#issuecomment-2348156386, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEUCREIEI6DSMNKUW6YZ2XLZWKC4PAVCNFSM6AAAAABN4HX5QGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNBYGE2TMMZYGY . You are receiving this because you commented.Message ID: @.***>

If it helps, I get the same type of error in my logs. My Alexa Media is asking to re-authenticate and when I try to do so, I get to visit the Amazon website login screen. I click “Continue” on the screen pre-populated with my email address and I get back to that (I think there was a second page but I forgot). In the logs I see:

2024-09-11 08:34:41.292 WARNING (MainThread) [alexapy.helpers] alexaapi.get_state((<alexapy.alexaapi.AlexaAPI object at 0x7f0b1e7837a0>,), {}): An error occurred accessing AlexaAPI: An exception of type AlexapyLoginError occurred. Arguments:
2024-09-11 08:34:41.296 WARNING (MainThread) [alexapy.helpers] alexaapi.get_state((<alexapy.alexaapi.AlexaAPI object at 0x7f0b1e7b28d0>,), {}): An error occurred accessing AlexaAPI: An exception of type AlexapyLoginError occurred. Arguments:
2024-09-11 08:34:42.805 WARNING (MainThread) [alexapy.helpers] alexaapi.run_behavior((<alexapy.alexaapi.AlexaAPI object at 0x7f0b1e7b28d0>, {'@type': 'com.amazon.alexa.behaviors.model.OpaquePayloadOperationNode', 'type': 'Alexa.DeviceControls.Volume', 'operationPayload': {'deviceType': 'A2DS1Q2TPDJ48U', 'deviceSerialNumber': 'G************0CK', 'locale': 'it-it', 'customerId': 'A**********M8E', 'value': 54.0}}), {'queue_delay': 1.5}): An error occurred accessing AlexaAPI: An exception of type AlexapyLoginError occurred. Arguments:
2024-09-11 08:34:42.805 WARNING (MainThread) [alexapy.helpers] alexaapi.send_sequence((<alexapy.alexaapi.AlexaAPI object at 0x7f0b1e7b28d0>, 'Alexa.DeviceControls.Volume'), {'customer_id': 'A3I6JFYIK91M8E', 'value': 54.0, 'queue_delay': 1.5}): An error occurred accessing AlexaAPI: An exception of type AlexapyLoginError occurred. Arguments:
2024-09-11 08:34:42.805 WARNING (MainThread) [alexapy.helpers] alexaapi.set_volume((<alexapy.alexaapi.AlexaAPI object at 0x7f0b1e7b28d0>, 0.54), {}): An error occurred accessing AlexaAPI: An exception of type AlexapyLoginError occurred. Arguments:
  File "/usr/local/lib/python3.12/site-packages/alexapy/helpers.py", line 137, in wrapper
  File "/usr/local/lib/python3.12/site-packages/alexapy/alexaapi.py", line 1111, in set_volume
  File "/usr/local/lib/python3.12/site-packages/alexapy/helpers.py", line 137, in wrapper
  File "/usr/local/lib/python3.12/site-packages/alexapy/alexaapi.py", line 512, in send_sequence
  File "/usr/local/lib/python3.12/site-packages/alexapy/helpers.py", line 137, in wrapper
  File "/usr/local/lib/python3.12/site-packages/alexapy/alexaapi.py", line 434, in run_behavior
  File "/usr/local/lib/python3.12/site-packages/alexapy/alexaapi.py", line 226, in _post_request
  File "/usr/local/lib/python3.12/site-packages/alexapy/alexaapi.py", line 199, in _request
alexapy.errors.AlexapyLoginError: Login error detected; not contacting API
2024-09-11 08:45:08.860 WARNING (MainThread) [alexapy.helpers] alexaapi.get_customer_history_records((<alexapy.alexalogin.AlexaLogin object at 0x7f0b35a1cd40>,), {'max_record_size': 10}): An error occurred accessing AlexaAPI: An exception of type AlexapyLoginError occurred. Arguments:
2024-09-11 08:45:08.860 WARNING (MainThread) [alexapy.helpers] alexaapi.get_last_device_serial((<alexapy.alexalogin.AlexaLogin object at 0x7f0b35a1cd40>,), {}): An error occurred accessing AlexaAPI: An exception of type AlexapyLoginError occurred. Arguments:
2024-09-11 10:00:48.712 WARNING (MainThread) [alexapy.helpers] alexaapi.get_state((<alexapy.alexaapi.AlexaAPI object at 0x7f0b1e7837a0>,), {}): An error occurred accessing AlexaAPI: An exception of type AlexapyLoginError occurred. Arguments:
2024-09-11 10:00:48.716 WARNING (MainThread) [alexapy.helpers] alexaapi.get_state((<alexapy.alexaapi.AlexaAPI object at 0x7f0b1e7b28d0>,), {}): An error occurred accessing AlexaAPI: An exception of type AlexapyLoginError occurred. Arguments:
2024-09-11 10:00:50.226 WARNING (MainThread) [alexapy.helpers] alexaapi.run_behavior((<alexapy.alexaapi.AlexaAPI object at 0x7f0b1e7b28d0>, {'@type': 'com.amazon.alexa.behaviors.model.OpaquePayloadOperationNode', 'type': 'Alexa.DeviceControls.Volume', 'operationPayload': {'deviceType': 'A2DS1Q2TPDJ48U', 'deviceSerialNumber': 'G************0CK', 'locale': 'it-it', 'customerId': 'A**********M8E', 'value': 54.0}}), {'queue_delay': 1.5}): An error occurred accessing AlexaAPI: An exception of type AlexapyLoginError occurred. Arguments:
2024-09-11 10:00:50.226 WARNING (MainThread) [alexapy.helpers] alexaapi.send_sequence((<alexapy.alexaapi.AlexaAPI object at 0x7f0b1e7b28d0>, 'Alexa.DeviceControls.Volume'), {'customer_id': 'A3I6JFYIK91M8E', 'value': 54.0, 'queue_delay': 1.5}): An error occurred accessing AlexaAPI: An exception of type AlexapyLoginError occurred. Arguments:
2024-09-11 10:00:50.226 WARNING (MainThread) [alexapy.helpers] alexaapi.set_volume((<alexapy.alexaapi.AlexaAPI object at 0x7f0b1e7b28d0>, 0.54), {}): An error occurred accessing AlexaAPI: An exception of type AlexapyLoginError occurred. Arguments:
  File "/usr/local/lib/python3.12/site-packages/alexapy/helpers.py", line 137, in wrapper
  File "/usr/local/lib/python3.12/site-packages/alexapy/alexaapi.py", line 1111, in set_volume
  File "/usr/local/lib/python3.12/site-packages/alexapy/helpers.py", line 137, in wrapper
  File "/usr/local/lib/python3.12/site-packages/alexapy/alexaapi.py", line 512, in send_sequence
  File "/usr/local/lib/python3.12/site-packages/alexapy/helpers.py", line 137, in wrapper
  File "/usr/local/lib/python3.12/site-packages/alexapy/alexaapi.py", line 434, in run_behavior
  File "/usr/local/lib/python3.12/site-packages/alexapy/alexaapi.py", line 226, in _post_request
  File "/usr/local/lib/python3.12/site-packages/alexapy/alexaapi.py", line 199, in _request
alexapy.errors.AlexapyLoginError: Login error detected; not contacting API
2024-09-11 10:00:52.718 WARNING (MainThread) [alexapy.helpers] alexaapi.get_state((<alexapy.alexaapi.AlexaAPI object at 0x7f0b1e7837a0>,), {}): An error occurred accessing AlexaAPI: An exception of type AlexapyLoginError occurred. Arguments:
2024-09-11 10:00:52.720 WARNING (MainThread) [alexapy.helpers] alexaapi.get_state((<alexapy.alexaapi.AlexaAPI object at 0x7f0b1e7b28d0>,), {}): An error occurred accessing AlexaAPI: An exception of type AlexapyLoginError occurred. Arguments:
2024-09-11 10:00:54.228 WARNING (MainThread) [alexapy.helpers] alexaapi.run_behavior((<alexapy.alexaapi.AlexaAPI object at 0x7f0b1e7b28d0>, {'@type': 'com.amazon.alexa.behaviors.model.OpaquePayloadOperationNode', 'type': 'Alexa.DeviceControls.Volume', 'operationPayload': {'deviceType': 'A2DS1Q2TPDJ48U', 'deviceSerialNumber': 'G************0CK', 'locale': 'it-it', 'customerId': 'A**********M8E', 'value': 54.0}}), {'queue_delay': 1.5}): An error occurred accessing AlexaAPI: An exception of type AlexapyLoginError occurred. Arguments:
2024-09-11 10:00:54.228 WARNING (MainThread) [alexapy.helpers] alexaapi.send_sequence((<alexapy.alexaapi.AlexaAPI object at 0x7f0b1e7b28d0>, 'Alexa.DeviceControls.Volume'), {'customer_id': 'A3I6JFYIK91M8E', 'value': 54.0, 'queue_delay': 1.5}): An error occurred accessing AlexaAPI: An exception of type AlexapyLoginError occurred. Arguments:
2024-09-11 10:00:54.228 WARNING (MainThread) [alexapy.helpers] alexaapi.set_volume((<alexapy.alexaapi.AlexaAPI object at 0x7f0b1e7b28d0>, 0.54), {}): An error occurred accessing AlexaAPI: An exception of type AlexapyLoginError occurred. Arguments:
  File "/usr/local/lib/python3.12/site-packages/alexapy/helpers.py", line 137, in wrapper
  File "/usr/local/lib/python3.12/site-packages/alexapy/alexaapi.py", line 1111, in set_volume
  File "/usr/local/lib/python3.12/site-packages/alexapy/helpers.py", line 137, in wrapper
  File "/usr/local/lib/python3.12/site-packages/alexapy/alexaapi.py", line 512, in send_sequence
  File "/usr/local/lib/python3.12/site-packages/alexapy/helpers.py", line 137, in wrapper
  File "/usr/local/lib/python3.12/site-packages/alexapy/alexaapi.py", line 434, in run_behavior
  File "/usr/local/lib/python3.12/site-packages/alexapy/alexaapi.py", line 226, in _post_request
  File "/usr/local/lib/python3.12/site-packages/alexapy/alexaapi.py", line 199, in _request
alexapy.errors.AlexapyLoginError: Login error detected; not contacting API
2024-09-11 10:01:05.023 WARNING (MainThread) [alexapy.helpers] alexalogin.login((<alexapy.alexalogin.AlexaLogin object at 0x7f0b35a1cd40>,), {'data': OrderedDict({'otp_secret': 'U************************************************7OQ', 'email': 'f**m@h*********m', 'password': 'REDACTED 10 CHARS', 'url': 'amazon.it', 'scan_interval': 60, 'include_devices': '', 'exclude_devices': '', 'debug': False, 'reauth': True})}): An error occurred accessing AlexaAPI: An exception of type TypeError occurred. Arguments:
2024-09-11 10:01:05.023 WARNING (MainThread) [custom_components.alexa_media.config_flow] Unknown error: can only concatenate str (not "NoneType") to str


Hello, everybody.

I dont’ know if it helps the discussion (I didnt read it), but I ended up in this page while browsing for the error:

alexalogin.login((<alexapy.alexalogin.AlexaLogin object at 0x7fc88f5b5a00>,), {'cookies': {}}): An error occurred accessing AlexaAPI: An exception of type TypeError occurred. Arguments:
('can only concatenate str (not "NoneType") to str',)

My alexa media player integration was not working because of this error. I fixed up just by updating everything on my raspberry pi.

sudo apt-get update
suddo apt-get upgrade -y

And them everything was back to normal.

Hope it helps

http.cookies.CookieError: Invalid attribute ‘partitioned’

That is the 3 month old “partitioned cookie problem”.

I’m working on a possible new solution for that but another solution is to replace /usr/local/lib/python3.12/http/cookies.py with the version proposed in a Python 3.13 PR: Ref: Support for Partitioned cookies attribute #112713 and gh-112713 : Add support for ‘partitioned’ attribute in http.cookies Download the file here.

So, I deleted everything again and re-added it. Now everything is working again. I was at the same point two days ago. And after the 10th restart or so, it will probably break again. 🤷‍♂️

image

It looks like your Amazon accounts do not have 2SV enabled using Authenticator App…

Active for months too. It worked till now.