alexa_media_player: TTS Stopped Working

Describe the bug After upgrading to 2022.7 TTS stopped working. Subsequent updates have not resolved the issue. I have uninstalled and reinstalled alexa media player with no difference. Setting the type to notify does work.

To Reproduce Steps to reproduce the behavior: 2 Methods

  1. Go to ‘developer tools’
  2. Click on ‘services’
  3. fill in the relevant information
  4. click call service
service: notify.alexa_media_office_echo
data:
  message: Test Test
  data:
    type: tts
service: notify.alexa_media_office_echo
data:
  message: Test Test
  data:
    type: tts

Second Method

  1. create an automation to send a tts message after a button press from a zigby button

Screenshots Method 1 image

Method 2 image

System details

  • Home-assistant (version): core-2022.7.7
  • Hassio (Yes/No): Yes
  • alexa_media (version from const.py or HA startup): 4.1.0
  • alexapy (version from pip show alexapy or HA startup): 1.26.1
  • Amazon 2FA is enabled (y/n). We will not debug login issues if unanswered: Yes

Logs 2022-08-04 19:38:00 INFO (MainThread) [custom_components.alexa_media] Loaded alexapy==1.26.1 2022-08-04 19:38:00 DEBUG (MainThread) [custom_components.alexa_media.helpers] [SANATIZED]: Returning uuid {‘uuid’: ‘[SANATIZED]’, ‘index’: 0} 2022-08-04 19:38:00 DEBUG (MainThread) [alexapy.alexalogin] Creating TOTP for H************************************************N7A 2022-08-04 19:38:00 DEBUG (MainThread) [alexapy.alexalogin] Generating OTP 076257 2022-08-04 19:38:00 DEBUG (MainThread) [alexapy.alexalogin] Login created for [SANATIZED] - amazon.com 2022-08-04 19:38:00 DEBUG (MainThread) [alexapy.alexalogin] Searching for cookies from /config/.storage/alexa_media.[SANATIZED].pickle 2022-08-04 19:38:00 DEBUG (MainThread) [alexapy.alexalogin] Trying to load cookie from file /config/.storage/alexa_media.[SANATIZED].pickle 2022-08-04 19:38:01 DEBUG (MainThread) [alexapy.alexalogin] Trying to load aiohttpCookieJar to session 2022-08-04 19:38:01 DEBUG (MainThread) [alexapy.alexalogin] Loaded 9 cookies 2022-08-04 19:38:01 DEBUG (MainThread) [alexapy.alexalogin] Searching for cookies from /config/alexa_media.[SANATIZED].pickle 2022-08-04 19:38:01 DEBUG (MainThread) [alexapy.alexalogin] Using cookies to log in 2022-08-04 19:38:01 DEBUG (MainThread) [alexapy.alexalogin] Attempting to register with amazon.com 2022-08-04 19:38:11 DEBUG (MainThread) [alexapy.alexalogin] auth response <ClientResponse(https://api.amazon.com/auth/register) [200 OK]> <CIMultiDictProxy(‘Server’: ‘Server’, ‘Date’: ‘Fri, 05 Aug 2022 00:38:10 GMT’, ‘Content-Type’: ‘application/json;charset=UTF-8’, ‘Content-Length’: ‘5604’, ‘Connection’: ‘keep-alive’, ‘x-amz-rid’: ‘GJH4AWTCJYSC5Q23ZJDV’, ‘x-amzn-RequestId’: ‘d489bfe9-5b24-4f97-9103-981b6b8880fb’, ‘X-Amz-Date’: ‘Fri, 05 Aug 2022 00:38:10 GMT’, ‘Cache-Control’: ‘no-cache, no-store, must-revalidate’, ‘Pragma’: ‘no-cache’, ‘Vary’: ‘Content-Type,Accept-Encoding,X-Amzn-CDN-Cache,X-Amzn-AX-Treatment,User-Agent’, ‘Permissions-Policy’: ‘interest-cohort=()’)> with {“requested_extensions”: [“device_info”, “customer_info”], “cookies”: {“website_cookies”: [SANATIZED] 2022-08-04 19:38:11 DEBUG (MainThread) [alexapy.alexalogin] Successfully registered Erik’s 2nd Alexa Media Player device with Amazon 2022-08-04 19:38:11 DEBUG (MainThread) [alexapy.alexalogin] New access token received which expires at 2022-08-04 20:38:11.610162 in 0:59:59.999675 2022-08-04 19:38:15 DEBUG (MainThread) [alexapy.alexalogin] 5 cookies successfully exchanged for refresh token for domain .amazon.com 2022-08-04 19:38:15 DEBUG (MainThread) [alexapy.alexalogin] CSRF already exists; no need to discover 2022-08-04 19:38:17 DEBUG (MainThread) [alexapy.alexalogin] GET: https://alexa.amazon.com/api/bootstrap returned 200:OK with response <CIMultiDictProxy(‘Content-Type’: ‘application/json’, ‘Content-Length’: ‘145’, ‘Connection’: ‘keep-alive’, ‘Server’: ‘Server’, ‘Date’: ‘Fri, 05 Aug 2022 00:38:16 GMT’, ‘x-amz-rid’: ‘66NH139QJAM8Q4CFVDFQ’, ‘x-amzn-RequestId’: ‘0635ff7f-07f0-4dcc-ad54-70a8bc9b7e5d’, ‘Content-Encoding’: ‘gzip’, ‘Vary’: ‘Content-Type,Accept-Encoding,X-Amzn-CDN-Cache,X-Amzn-AX-Treatment,User-Agent’, ‘Permissions-Policy’: ‘interest-cohort=()’, ‘X-Cache’: ‘Miss from cloudfront’, ‘Via’: ‘1.1 648a9cc121d040a230a7c3a6982dca90.cloudfront.net (CloudFront)’, ‘X-Amz-Cf-Pop’: ‘DFW50-C1’, ‘X-Amz-Cf-Id’: ‘MrgSvX96VuiDTfARUcN9ZQPxOV84_r9VCC-bIIcvRWbK9Q5AJBHgdQ==’)> 2022-08-04 19:38:17 DEBUG (MainThread) [alexapy.alexalogin] Logged in as [SANATIZED] to amazon.com with id: [SANATIZED] 2022-08-04 19:38:18 DEBUG (MainThread) [alexapy.alexalogin] Domain amazon.com matches reported account domain: https://www.amazon.com 2022-08-04 19:38:18 DEBUG (MainThread) [alexapy.alexalogin] Login confirmed for [SANATIZED] - amazon.com; saving cookie to /config/.storage/alexa_media.[SANATIZED].pickle 2022-08-04 19:38:18 DEBUG (MainThread) [custom_components.alexa_media] Testing login status: {‘login_successful’: True} 2022-08-04 19:38:18 DEBUG (MainThread) [custom_components.alexa_media] Setting up Alexa devices for [SANATIZED] 2022-08-04 19:38:18 DEBUG (MainThread) [custom_components.alexa_media] [SANATIZED]: Websocket created: <alexapy.alexawebsocket.WebsocketEchoClient object at 0x7f7258a380> 2022-08-04 19:38:18 DEBUG (MainThread) [alexapy.alexawebsocket] Connecting to wss://dp-gw-na-js.amazon.com/tcomm/ with {‘Cookie’: [SANATIZED] 2022-08-04 19:38:19 DEBUG (MainThread) [custom_components.alexa_media] [SANATIZED]: Websocket successfully connected 2022-08-04 19:38:19 DEBUG (MainThread) [custom_components.alexa_media] [SANATIZED]: Creating coordinator 2022-08-04 19:38:19 DEBUG (MainThread) [custom_components.alexa_media] [SANATIZED]: Refreshing coordinator 2022-08-04 19:38:19 DEBUG (MainThread) [alexapy.alexawebsocket] Starting message parsing loop. 2022-08-04 19:38:19 DEBUG (MainThread) [alexapy.alexawebsocket] Received raw WebSocket: b’0x37a1b607 0x0000009c {“protocolName”:“A:F”,“parameters”:{“AlphaProtocolHandler.maxFragmentSize”:“16000”,“AlphaProtocolHandler.receiveWindowSize”:“16”}}TUNE’ 2022-08-04 19:38:19 DEBUG (MainThread) [alexapy.alexawebsocket] Encoding WebSocket Handshake MSG. 2022-08-04 19:38:19 DEBUG (MainThread) [alexapy.alexawebsocket] 0xfe88bc52 0x0000009c {“protocolName”:“A:F”,“parameters”:{“AlphaProtocolHandler.receiveWindowSize”:“16”,“AlphaProtocolHandler.maxFragmentSize”:“16000”}}TUNE 2022-08-04 19:38:19 DEBUG (MainThread) [alexapy.alexawebsocket] A:F Initialization Msg 2 sent: 307866653838626335322030783030303030303963207b2270726f746f636f6c4e616d65223a22413a46222c22706172616d6574657273223a7b22416c70686150726f746f636f6c48616e646c65722e7265636569766557696e646f7753697a65223a223136222c22416c70686150726f746f636f6c48616e646c65722e6d6178467261676d656e7453697a65223a223136303030227d7d54554e45 2022-08-04 19:38:19 DEBUG (MainThread) [alexapy.alexawebsocket] Encoding Gateway Register MSG. 2022-08-04 19:38:19 DEBUG (MainThread) [alexapy.alexawebsocket] bytearray(b’MSG\x00\x00\x03b\x10i.\xb4f\x00\x00\x00\x01\xcd5\xd5\x7f\x00\x00\x00\xe4GWM MSG 0x0000b479 0x0000003b urn:tcomm-endpoint:device:deviceType:0:deviceSerialNumber:0 0x00000041 urn:tcomm-endpoint:service:serviceName:DeeWebsiteMessagingService {“command”:“REGISTER_CONNECTION”}FABE’) <trimed>2022-08-04 19:38:22 DEBUG (MainThread) [custom_components.alexa_media] Office Echo: Locale en-us timezone America/Chicago 2022-08-04 19:38:22 DEBUG (MainThread) [custom_components.alexa_media] Office Echo: DND False 2022-08-04 19:38:22 DEBUG (MainThread) [custom_components.alexa_media] Loading config entry for media_player 2022-08-04 19:38:22 DEBUG (MainThread) [custom_components.alexa_media] Finished fetching alexa_media data in 3.004 seconds (success: True) 2022-08-04 19:39:46 DEBUG (MainThread) [custom_components.alexa_media.notify] Message: This is a test, kwargs: {‘target’: [‘[SANATIZED]’], ‘data’: None} 2022-08-04 19:39:46 DEBUG (MainThread) [custom_components.alexa_media.notify] Target type: <class ‘list’> 2022-08-04 19:39:46 DEBUG (MainThread) [custom_components.alexa_media.notify] Processing: [SANATIZED] 2022-08-04 19:39:46 DEBUG (MainThread) [custom_components.alexa_media.notify] Processed Target by string: [‘[SANATIZED]’] 2022-08-04 19:39:57 DEBUG (MainThread) [custom_components.alexa_media.notify] Message: This is a test, kwargs: {‘target’: [‘[SANATIZED]’], ‘data’: None} 2022-08-04 19:39:57 DEBUG (MainThread) [custom_components.alexa_media.notify] Target type: <class ‘list’> 2022-08-04 19:39:57 DEBUG (MainThread) [custom_components.alexa_media.notify] Processing: [SANATIZED] 2022-08-04 19:39:57 DEBUG (MainThread) [custom_components.alexa_media.notify] Processed Target by string: [‘[SANATIZED]’] 2022-08-04 19:40:03 DEBUG (MainThread) [custom_components.alexa_media.notify] Message: This is a test, kwargs: {‘target’: [‘[SANATIZED]’], ‘data’: {‘type’: ‘tts’}} 2022-08-04 19:40:03 DEBUG (MainThread) [custom_components.alexa_media.notify] Target type: <class ‘list’> 2022-08-04 19:40:03 DEBUG (MainThread) [custom_components.alexa_media.notify] Processing: [SANATIZED] 2022-08-04 19:40:03 DEBUG (MainThread) [custom_components.alexa_media.notify] Processed Target by string: [‘[SANATIZED]’] 2022-08-04 19:40:03 DEBUG (MainThread) [custom_components.alexa_media.notify] TTS by <Entity Office Echo: standby> : This is a test 2022-08-04 19:40:05 DEBUG (MainThread) [alexapy.alexaapi] [SANATIZED]: Creating sequence for 1 items 2022-08-04 19:40:05 DEBUG (MainThread) [alexapy.alexaapi] [SANATIZED]: Running behavior with data: {“behaviorId”: “PREVIEW”, “sequenceJson”: “{"@type": "com.amazon.alexa.behaviors.model.Sequence", "startNode": {"@type": "com.amazon.alexa.behaviors.model.SerialNode", "nodesToExecute": [{"@type": "com.amazon.alexa.behaviors.model.OpaquePayloadOperationNode", "type": "Alexa.Speak", "operationPayload": {"deviceType": "A32DOYMUN6DTXA", "deviceSerialNumber": "[SANATIZED]", "locale": "en-us", "customerId": "[SANATIZED]", "textToSpeak": "This is a test", "target": {"customerId": "[SANATIZED]", "devices": [{"deviceSerialNumber": "[SANATIZED]", "deviceTypeId": "A32DOYMUN6DTXA"}]}, "skillId": "amzn1.ask.1p.saysomething"}}]}}”, “status”: “ENABLED”} 2022-08-04 19:40:05 DEBUG (MainThread) [alexapy.alexaapi] [SANATIZED]: POST: https://alexa.amazon.com/api/behaviors/preview returned 200:OK:application/octet-stream

Additional context Add any other context about the problem here.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 61 (2 by maintainers)

Most upvoted comments

I’ve been using TTS/Announcements with this component since 2019, without any issues until recently. I spent the last few days diagnosing the issue and I’m including what I found in my personal setup.

I mostly use announcements since I include SSML markup in my messages. I’m not sure what update broke the announcements, if it was Home Assistant, this component, or the Alexa API; but I discovered the inclusion of the <speak> tags in my messages no longer produced announcements. Logs showed the POST with 200 response but nothing else. Removing the <speak> tag and leaving all other SSML untouched resolved most of my issues.

Sample log that doesn’t produce announcement, initiated from HA Services tab in Dev Tools

2023-02-02 21:25:48.612 DEBUG (MainThread) [alexapy.alexaapi] REDACTED: Running behavior with data: {"behaviorId": "PREVIEW", "sequenceJson": "{"@type": "com.amazon.alexa.behaviors.model.Sequence", "startNode": {"@type": "com.amazon.alexa.behaviors.model.SerialNode", "nodesToExecute": [{"@type": "com.amazon.alexa.behaviors.model.OpaquePayloadOperationNode", "type": "AlexaAnnouncement", "operationPayload": {"deviceType": "REDACTED", "deviceSerialNumber": "REDACTED", "locale": "en-US", "customerId": "REDACTED", "expireAfter": "PT5S", "content": [{"locale": "en-US", "display": {"title": "Home Assistant", "body": "<speak>\n <amazon:effect name='whispered'>\n Good morning. It's almost time to wake up.\n </amazon:effect>\n</speak>"}, "speak": {"type": "text", "value": "<speak>\n <amazon:effect name='whispered'>\n Good morning. It's almost time to wake up.\n </amazon:effect>\n</speak>"}}], "target": {"customerId": "REDACTED", "devices": [{"deviceSerialNumber": "REDACTED", "deviceTypeId": "REDACTED"}]}, "skillId": "amzn1.ask.1p.routines.messaging"}}]}}", "status": "ENABLED"}
2023-02-02 21:25:48.802 DEBUG (MainThread) [alexapy.alexaapi] REDACTED: POST: https://alexa.amazon.com/api/behaviors/preview returned 200:OK:application/octet-stream

In addition to discovering the <speak> tag issue. I also have my messages in separate files, and !include them in my yaml configuration.

example automation:

action:
  - service: notify.alexa_media
    data:
      message: !include morning_workday_wakeup_alexa_whisper.j2
      target: media_player.nightstand
      data:
        type: announce
        method: speak

example message include:

<speak>
    <amazon:effect name="whispered">
        Good morning. It's almost time to wake up.
    </amazon:effect>
    <break time="4s"/>
    <p>It's {{ now().strftime('%I:%M %p') }}</p>
    <p>{{ [
          'Get your butt out of bed!',
          '<say-as interpret-as="interjection">cock a doodle doo</say-as>'
        ] | random }}</p>
</speak>

Having to remove the <speak> tags that surrounded all the jinja2 templating created new yaml import/parsing/template parsing errors that I had to correct in each file.

Hope this helps someone else 👍

Seems there was an issue with my configuration. After the completely remove of the integration and reinstall with the right region (amazon.it for me not amazon.com), the integration works correctly.