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.51k stars 289 forks source link

notify.alexa_media_this_device is not working #2054

Closed master-kenobi closed 10 months ago

master-kenobi commented 1 year ago

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

"This Device" device is from the Alexa app in my phone. The media player entity is media_player.this_device and the notify service is notify.alexa_media_this_device. I tried to send TTS message to this device but nothing happened.

To Reproduce

  1. Go to Developer tools > Service
  2. Select notify.alexa_media_this_device from the list
  3. Enter a message in the field
  4. Leave title and target empty
  5. Select data and enter type: tts
  6. Then click on Call Service button

Alternatively, you can select notify.alexa_media as the service and enter media_player.this_device as target.

Expected behavior

My phone's Alexa should say out the message, but it is not.

System details

Logs Please provide logs.

2023-10-02 16:04:31.864 DEBUG (MainThread) [custom_components.alexa_media.notify] Message: Hello, kwargs: {'target': ['media_player.this_device'], 'data': {'type': 'tts'}}
2023-10-02 16:04:31.864 DEBUG (MainThread) [custom_components.alexa_media.notify] Target type: <class 'list'>
2023-10-02 16:04:31.864 DEBUG (MainThread) [custom_components.alexa_media.notify] Processing: media_player.this_device
2023-10-02 16:04:31.864 DEBUG (MainThread) [custom_components.alexa_media.notify] Processed Target by string: ['media_player.this_device']
2023-10-02 16:04:31.865 DEBUG (MainThread) [custom_components.alexa_media.notify] TTS by <entity media_player.this_device=standby> : Hello
2023-10-02 16:04:33.367 DEBUG (MainThread) [alexapy.alexaapi] p***p@x********m: Creating sequence for 1 items
2023-10-02 16:04:33.367 DEBUG (MainThread) [alexapy.alexaapi] p***p@x********m: 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\": \"XXXXXXXXXXXXXX\", \"deviceSerialNumber\": \"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\", \"locale\": \"en-us\", \"customerId\": \"XXXXXXXXXXXXXX\", \"textToSpeak\": \"Hello\", \"target\": {\"customerId\": \"XXXXXXXXXXXXXX\", \"devices\": [{\"deviceSerialNumber\": \"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\", \"deviceTypeId\": \"XXXXXXXXXXXXXX\"}]}, \"skillId\": \"amzn1.ask.1p.saysomething\"}}]}}", "status": "ENABLED"}
2023-10-02 16:04:33.367 DEBUG (MainThread) [alexapy.alexaapi] p***p@x********m: Trying post: https://alexa.amazon.com/api/behaviors/preview : with uri: /api/behaviors/preview 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": "XXXXXXXXXXXXXX", "deviceSerialNumber": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "locale": "en-us", "customerId": "XXXXXXXXXXXXXX", "textToSpeak": "Hello", "target": {"customerId": "XXXXXXXXXXXXXX", "devices": [{"deviceSerialNumber": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "deviceTypeId": "XXXXXXXXXXXXXX"}]}, "skillId": "amzn1.ask.1p.saysomething"}}]}}', 'status': 'ENABLED'} query None
2023-10-02 16:04:33.755 DEBUG (MainThread) [alexapy.alexaapi] p***p@x********m: POST: https://alexa.amazon.com/api/behaviors/preview returned 200:OK:application/octet-stream
2023-10-02 16:04:33.823 DEBUG (MainThread) [alexapy.alexahttp2] Received raw message: Content-Type: application/json

{"directive":{"header":{"namespace":"InteractionModel","name":"NewDialogRequest","interactionId":"amzn1.alexa.skillConnections.tzullz.xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx","messageId":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx","dialogRequestId":"amzn1.alexa.skillConnections.tzullz.xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx"},"payload":{"dialogRequestId":"amzn1.alexa.skillConnections.tzullz.xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx"}}}
--------abcde123

2023-10-02 16:04:34.168 DEBUG (MainThread) [alexapy.alexahttp2] Received raw message: Content-Type: application/json

{"directive":{"header":{"namespace":"SpeechSynthesizer","name":"Speak","interactionId":"amzn1.alexa.skillConnections.tzullz.xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx","messageId":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx","dialogRequestId":"amzn1.alexa.skillConnections.tzullz.xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx"},"payload":{"caption":"Hello","url":"cid:Terminal_amzn1.ask.skill.xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx_xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx_CloudInitiated_xxxxxxxxxxx","format":"AUDIO_MPEG","token":"amzn1.as-ct.v1.ThirdPartySdkSpeechlet#ACRI#Terminal_amzn1.ask.skill.xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx_CloudInitiated#ACRI#[[ENCRYPTED_WITH_AlexaServiceKeyMasterUtil]]xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx+xxxxxxxx+xxxxxxxxx+xxxxxxxxxx+xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx+xxxxxxxxxxxxxxxxx/20","ssml":"<speak><prosody volume=\"x-loud\">Hello</prosody><metadata><promptMetadata><promptId>OutputSpeech.Ssml.Message</promptId><namespace>Echo.SDK</namespace><locale>en_US</locale><overrideId>default</overrideId><variant>xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx</variant><condition/><weight>1</weight><stageVersion/></promptMetadata></metadata></speak>"}}}
--------abcde123
Content-ID: <Terminal_amzn1.ask.skill.xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx_xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx_CloudInitiated_xxxxxxxxxxx>
Content-Type: application/octet-stream

ID3     #TSSE     Lavf58.76.100           ID3    0TXXX  &  data [{"time":0,"type":"sentence","start":32,"end":37,"value":"Hello"},{"time":6,"type":"word","start":32,"end":37,"value":"Hello"},{"time":6,"type":"viseme","value":"k"},{"time":51,"type":"viseme","value":"E"},{"time":93,"type":"viseme","value":"t"},{"time":161,"type":"viseme","value":"o"}] ��d� �
c   ����-�_w$�qhp��SJiX�ҟXa��=�8��M�;&��p�d��B6@їS �'��!$-�F@��^LTy�(I��5$�v^Ә|�@�݇�

2o�8T��>(�`�L� T�� �B����d�ڢqfI�H][��R��9m7�<� ����a��A�3G �F~F�E��r)�B��<�|��t&s�H�s���9p}g���������S�Db��׬\�]��ú2ɹIAt�k��JUyP��)�p��b��d�.&�j��bGpa|AY<��ئ
�E��d��h���0�o�W����.�vQ\�&$�� cm�Ѷ�{���&�R�+
z�cg��;C��  �9�����    �2��@
�����8?X��?�� ��b�%�Rh�qaP+)X��d�!�j��х0&X{�
!-`��Q]M�:�����K�5��Zꮕ�ĝPx&��D���{���L�;'He����w�N�<�Hs� ��������YO�������WS�9�Ԑ\�����H*�L(a5)�"԰��d�9�����*[H��M��-�1�vK���l��Wڬ�&������E�(�K��i@��z��������R���ő-`Y@&j3G���k���u�v�d�����T{Z�Yw����,H`I�� ˠ�O�o��pn E7Kn��s���d�!,:Ŗ��8��󶡷���b����)V���RM�X���5� u��ܵ��K��P���2�Ba�O����c#"fMC"�����C;a�B�e/����{d�������΍?���n��<P(r�  ��B�N�9�F�#��B���d� ������� ƒGdz1 �v���<X�@�?��3fI����%�RV:�ImUFA�r"�k�A1�x3�z1C3��"%sL��C5�l������OVT �%��Q�Ǭ#�L�������|B���  �Tm�bU�pN��?&��d�!���^y�H`i�t��/��c[h:��l�Ӫe2��>M����m̆3B�;��,��e����|DT��x�%8�{[PI�T�!����N��?�X�����
�A�����Y�����P���"͠P?�G**�,��/�ID3     =TXXX   3  data [{"time":421,"type":"viseme","value":"sil"}] ��d���6�j���Z��O
V�º�d�Zye]����I��,�R��Q�uW�!�<�����(�.i�t2F(1K!�_�z}ȧX�\�C����,.b1���`�e�����l��*M�`:�&�%
[�s�hФpWF���d��:�6{����jp�l��q(��kQH����u�־�+U���å؆;�Ϸ}����hޭK��+Ԁ��qOo�����m+n�YX�տ��c�������VW
1a�*v���)Y>�w����J�\=b���d�,�v�ʐ��m8��4�����    �Y�ؙ�Sz2��M! �q����+�Ӷ��z�B�����������q�oտ��DdBo�����P��̒�  ���[ƫpK�r��\Q��
&n�Q��=C���^R��d�(    �Ѷx�4�R�cD�%h�<�bQHZN` 0�vy�����S2��y�Ef�i��L����h�?q �����Ȑ�a4�ե��x���V�2�������R*���窠����~ˆ>iߣ��S">�2�``�C+���d�:�N�>zD��)fW`����("ʿ����Ahz�%L�;�F*g_/����?�>�J�4I��&��K���Ɍ_I�j�    ra�F��'����
��t��<H"X��c=�$o�������%���0�PG��AG5„��j��d�Qڹ���t�D����Wƕ���T����-��G�(|��,�(RO�n�X�g�V�.��68K�bnVU]Fmx�
#lV���}��e -^ʪQ�c0&b!2���Z��F`�����(��e�W������g>)[�N���d�d
�^x��`��� ����!��Jh"�]n��  @�3a�$��nuq�$
��l���&V�Ģ�T��U���#=�E"�N�U��UU}59�j8Eea`A���^���[9����t�e�EGRJe�Q�������~^�GP�j����d�r���^{[j��,qt�f� � #��d�f�^���IK�����a��"��CJY�WR�)H�J�1��n�BײK�d�u9�J�����d���_�>��k�S���g���[����<�$��T6���j�I6���)n0ΖJ��dĂ��zJX0�-Z>Qu�t�
�d���賩.�LjW��³V��CLE�X�C)ROY>r�O���lM"+X2�վ����r��0���7}5��u�JY��a�,f�b"|�4��pb�u�W�rh�*�y�7�(�5��stn�j
��dĘQ��^y�|�(ƾ�����1�� �P�r��C>�5   yQS���?w-oʻ�_׆�j���]���@���VŢ0�*�c��!,q��%V*t��˰Ҥ�,,.�$�S$BK�2��!q��qQF�b�O��<�Y묋����dı�zT��<����L*a_�Q�#d$iXUГ�LAME3.100UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU��d�� �{UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU
--------abcde123

2023-10-02 16:04:34.256 DEBUG (MainThread) [alexapy.alexahttp2] Received raw message: Content-Type: application/json

{"directive":{"header":{"namespace":"Alexa.Mobile.Push","name":"RenderUpdate","messageId":"xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx"},"payload":{"renderingUpdates":[{"route":"EventBus:tcomm::message","resourceId":"PUSH_ACTIVITY","resourceMetadata":"{\"command\":\"PUSH_ACTIVITY\",\"timeStamp\":1696233874104,\"payload\":\"{\\\"timestamp\\\":1696233874094,\\\"key\\\":{\\\"registeredUserId\\\":\\\"XXXXXXXXXXXXXX\\\",\\\"entryId\\\":\\\"XXXXXXXXXXXXX#XXXXXXXXXXXXXX#xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\\\"},\\\"destinationUserId\\\":\\\"XXXXXXXXXXXXXX\\\"}\"}"}]}}}
--------abcde123

2023-10-02 16:04:34.257 DEBUG (MainThread) [custom_components.alexa_media] p***p@x********m: Received http2push command: PUSH_ACTIVITY : {'timestamp': 1696233874094, 'key': {'registeredUserId': 'XXXXXXXXXXXXXX', 'entryId': 'XXXXXXXXXXXXX#XXXXXXXXXXXXXX#xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'}, 'destinationUserId': 'A*********7ER'}
2023-10-02 16:04:34.723 DEBUG (MainThread) [alexapy.alexaapi] p***p@x********m: static GET: https://alexa.amazon.com/api/dnd/device-status-list returned 200:OK:application/json
2023-10-02 16:04:34.813 DEBUG (MainThread) [alexapy.alexaapi] p***p@x********m: static GET: https://alexa.amazon.com/api/devices-v2/device returned 200:OK:application/json
2023-10-02 16:04:34.987 DEBUG (MainThread) [alexapy.alexaapi] p***p@x********m: static GET: https://alexa.amazon.com/api/device-preferences returned 200:OK:application/json
2023-10-02 16:04:35.027 DEBUG (MainThread) [alexapy.alexaapi] p***p@x********m: static GET: https://alexa.amazon.com/api/bluetooth?cached=false returned 200:OK:application/json
alandtse commented 1 year ago

Do notifications work using the alexa app itself? I don't recall that ever working.

master-kenobi commented 1 year ago

Do notifications work using the alexa app itself? I don't recall that ever working.

It seemed buggy for me at first, but I managed to get it working by following these steps:

  1. Delete the existing Alexa Media Player integration in HA.
  2. Restart HA.
  3. Go to Amazon > Account > Manage Content and Devices > Devices > Amazon Apps Installed on Devices > Alexa, and deregister "Alexa Media Player."
  4. Reinstall the Alexa Media Player integration in HA.

It worked when I tested it in Developer Tools > Services and entered:

service: notify.alexa_media_this_device
data:
  message: "Hello"

After restarting HA, a new entity called "media_player.this_device_2" appeared. Now I have both "media_player.this_device" and "media_player.this_device_2," and that's when it stopped working.

After one more HA restart, "media_player.this_device" disappeared, leaving only "media_player.this_device_2." It still fails to work, even when I call this service:

service: notify.alexa_media_this_device_2
data:
  message: "Hello"
alandtse commented 1 year ago

Interesting. I guess you can debug it by looking at the supposed serial number. I'll mark this as a bug and maybe someone will be able to track it down for you.

daknightuk commented 1 year ago

I had an issue like this, steps I folllowed to resolve, Reauthenticate Alexa media player, Reboot HA, (Still not working) read your post then tryed another reboot of HA. All my entities are now back with the names as they have always been. I've had a similar issue with other integrations in the past and get the feeling that sometimes they get "stuck" in HA even though you can't see them so Bulb becomes Bulb_2 etc.

github-actions[bot] commented 1 year ago

This bug report has been labelled as help wanted since there has been no activity in the last 3 weeks. It will not be closed automatically.

github-actions[bot] commented 10 months ago

The issue has received no activity for 60 days and will be closed in a week.