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.5k stars 286 forks source link

Notify stopped working (Sorry, let's start over again...) #1052

Closed maminx closed 3 years ago

maminx commented 3 years ago

Describe the bug My notify service stopped working, I have tested the service notify.alexa_media, and nothing happens, no errors whatsoever.

To Reproduce

  1. Go to “developer tools”
  2. Click on "Services"
  3. Call service “notify.alexa_media”
  4. Type these service data: target: "media_player.game_room" message: "test message" Data: type: "tts"
  5. The “call service” button turns green, but nothing happens.

Expected behavior Alexa saying “test message”

Screenshots Just get a green button after pressing “call service”

System details

Logs

previews entries shows my cookies so I'm not including it
2020-12-17 13:38:04 DEBUG (MainThread) [alexapy.alexawebsocket] Encoding WebSocket Handshake MSG.
2020-12-17 13:38:05 DEBUG (MainThread) [alexapy.alexawebsocket] Encoding Gateway Handshake MSG.
2020-12-17 13:38:05 DEBUG (MainThread) [alexapy.alexawebsocket] Encoding Gateway Register MSG.
2020-12-17 13:38:05 DEBUG (MainThread) [alexapy.alexawebsocket] Initating Async Handshake.
2020-12-17 13:38:05 DEBUG (MainThread) [alexapy.alexawebsocket] Starting message parsing loop.
2020-12-17 13:38:05 DEBUG (MainThread) [alexapy.alexawebsocket] WebSocket Connection Closed. <Task finished name='Task-1197' coro=<WebsocketEchoClient.process_messages() done, defined at /usr/local/lib/python3.8/site-packages/alexapy/alexawebsocket.py:138> result=None>
2020-12-17 13:38:05 DEBUG (MainThread) [alexapy.alexawebsocket] Encoding PING.
2020-12-17 13:38:05 DEBUG (MainThread) [alexapy.alexawebsocket] Encoding WebSocket Handshake MSG.
2020-12-17 13:38:05 DEBUG (MainThread) [alexapy.alexawebsocket] Encoding Gateway Handshake MSG.
2020-12-17 13:38:05 DEBUG (MainThread) [alexapy.alexawebsocket] Encoding Gateway Register MSG.
2020-12-17 13:38:05 DEBUG (MainThread) [alexapy.alexawebsocket] Encoding PING.
2020-12-17 13:38:06 DEBUG (MainThread) [alexapy.alexaapi] static GET: https://alexa.amazon.com/api/devices-v2/device returned 200:OK:application/json
2020-12-17 13:38:06 DEBUG (MainThread) [alexapy.alexaapi] static GET: https://alexa.amazon.com/api/bootstrap returned 200:OK:application/json
2020-12-17 13:38:06 DEBUG (MainThread) [alexapy.alexaapi] static GET: https://alexa.amazon.com/api/dnd/device-status-list returned 200:OK:application/json
2020-12-17 13:38:06 DEBUG (MainThread) [alexapy.alexaapi] static GET: https://alexa.amazon.com/api/notifications returned 200:OK:application/json
2020-12-17 13:38:06 DEBUG (MainThread) [alexapy.alexaapi] static GET: https://alexa.amazon.com/api/device-preferences returned 200:OK:application/json
2020-12-17 13:38:06 DEBUG (MainThread) [alexapy.alexaapi] static GET: https://alexa.amazon.com/api/bluetooth?cached=false returned 200:OK:application/json
2020-12-17 13:38:06 DEBUG (MainThread) [alexapy.alexaapi] static GET: https://alexa.amazon.com/api/activities?startTime=&size=10&offset=1 returned 200:OK:application/json
2020-12-17 13:38:07 DEBUG (MainThread) [alexapy.alexaapi] GET: https://alexa.amazon.com/api/np/player?deviceSerialNumber=a1716dbb5f0c44aa9982ee49675d2407&deviceType=A3C9PE6TNYLTCH&screenWidth=2560 returned 200:OK:application/json
2020-12-17 13:38:07 DEBUG (MainThread) [alexapy.alexaapi] GET: https://alexa.amazon.com/api/np/player?deviceSerialNumber=G090U509849623WN&deviceType=A32DOYMUN6DTXA&screenWidth=2560 returned 200:OK:application/json
2020-12-17 13:38:07 DEBUG (MainThread) [alexapy.alexaapi] GET: https://alexa.amazon.com/api/np/player?deviceSerialNumber=G090VC0985030W41&deviceType=A32DOYMUN6DTXA&screenWidth=2560 returned 200:OK:application/json
2020-12-17 13:38:07 DEBUG (MainThread) [alexapy.alexaapi] GET: https://alexa.amazon.com/api/np/player?deviceSerialNumber=G090U5099145005P&deviceType=A32DOYMUN6DTXA&screenWidth=2560 returned 200:OK:application/json
2020-12-17 13:38:08 DEBUG (MainThread) [alexapy.alexaapi] GET: https://alexa.amazon.com/api/np/player?deviceSerialNumber=B0F00712521302HC&deviceType=AB72C64C86AW2&screenWidth=2560 returned 200:OK:application/json
2020-12-17 13:38:08 DEBUG (MainThread) [alexapy.alexaapi] static GET: https://alexa.amazon.com/api/phoenix returned 400:Bad Request:application/octet-stream
2020-12-17 13:38:08 WARNING (MainThread) [alexapy.helpers] alexaapi.get_guard_details((<alexapy.alexalogin.AlexaLogin object at 0x7f331df9c520>,), {}): An error occured accessing AlexaAPI: An exception of type TypeError occurred. Arguments:
("'NoneType' object is not subscriptable",)
2020-12-17 13:38:16 DEBUG (MainThread) [alexapy.alexaapi] static GET: https://alexa.amazon.com/api/devices-v2/device returned 200:OK:application/json
2020-12-17 13:38:16 DEBUG (MainThread) [alexapy.alexaapi] static GET: https://alexa.amazon.com/api/dnd/device-status-list returned 200:OK:application/json
2020-12-17 13:38:16 DEBUG (MainThread) [alexapy.alexaapi] static GET: https://alexa.amazon.com/api/notifications returned 200:OK:application/json
2020-12-17 13:38:16 DEBUG (MainThread) [alexapy.alexaapi] static GET: https://alexa.amazon.com/api/device-preferences returned 200:OK:application/json
2020-12-17 13:38:16 DEBUG (MainThread) [alexapy.alexaapi] static GET: https://alexa.amazon.com/api/bluetooth?cached=false returned 200:OK:application/json
2020-12-17 13:38:16 DEBUG (MainThread) [alexapy.alexaapi] static GET: https://alexa.amazon.com/api/activities?startTime=&size=10&offset=1 returned 200:OK:application/json
2020-12-17 13:38:18 DEBUG (MainThread) [alexapy.alexaapi] GET: https://alexa.amazon.com/api/np/player?deviceSerialNumber=G090VC0985030W41&deviceType=A32DOYMUN6DTXA&screenWidth=2560 returned 200:OK:application/json
2020-12-17 13:38:18 DEBUG (MainThread) [alexapy.alexaapi] GET: https://alexa.amazon.com/api/np/player?deviceSerialNumber=G090U509849623WN&deviceType=A32DOYMUN6DTXA&screenWidth=2560 returned 200:OK:application/json
2020-12-17 13:38:18 DEBUG (MainThread) [alexapy.alexaapi] GET: https://alexa.amazon.com/api/np/player?deviceSerialNumber=G090U5099145005P&deviceType=A32DOYMUN6DTXA&screenWidth=2560 returned 200:OK:application/json
2020-12-17 13:38:18 DEBUG (MainThread) [alexapy.alexaapi] GET: https://alexa.amazon.com/api/np/player?deviceSerialNumber=B0F00712521302HC&deviceType=AB72C64C86AW2&screenWidth=2560 returned 200:OK:application/json
2020-12-17 13:38:18 DEBUG (MainThread) [alexapy.alexaapi] GET: https://alexa.amazon.com/api/np/player?deviceSerialNumber=a1716dbb5f0c44aa9982ee49675d2407&deviceType=A3C9PE6TNYLTCH&screenWidth=2560 returned 200:OK:application/json
2020-12-17 13:39:23 DEBUG (MainThread) [alexapy.alexaapi] Creating sequence for 1 items
2020-12-17 13:39:23 DEBUG (MainThread) [alexapy.alexaapi] 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\": \"AB72C64C86AW2\", \"deviceSerialNumber\": \"B0F00712521302HC\", \"locale\": \"en-us\", \"customerId\": \"A2M2Q5VWCMFUQ0\", \"textToSpeak\": \"New notification: this is a test\", \"target\": {\"customerId\": \"A2M2Q5VWCMFUQ0\", \"devices\": [{\"deviceSerialNumber\": \"B0F00712521302HC\", \"deviceTypeId\": \"AB72C64C86AW2\"}]}, \"skillId\": \"amzn1.ask.1p.saysomething\"}}]}}", "status": "ENABLED"}
2020-12-17 13:39:23 DEBUG (MainThread) [alexapy.alexaapi] POST: https://alexa.amazon.com/api/behaviors/preview returned 400:Bad Request:application/octet-stream

Additional context I'm getting error on alexa guard, since I have Ring alarm system.

alexaapi.get_guard_details((<alexapy.alexalogin.AlexaLogin object at 0x7f5b4457a280>,), {}): An error occured accessing AlexaAPI: An exception of type TypeError occurred. Arguments: ("'NoneType' object is not subscriptable",)
1:44:15 PM – /usr/local/lib/python3.8/site-packages/alexapy/helpers.py (WARNING)

but yet, the controls I use on Ring alarm works as excpected.

maminx commented 3 years ago

Just to confirm, this is the error every time I ask for notify service

2020-12-17 16:18:10 DEBUG (MainThread) [alexapy.alexaapi] 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\": \"AB72C64C86AW2\", \"deviceSerialNumber\": \"B0F00712521302HC\", \"locale\": \"en-us\", \"customerId\": \"A2M2Q5VWCMFUQ0\", \"textToSpeak\": \"New notification: this is a test\", \"target\": {\"customerId\": \"A2M2Q5VWCMFUQ0\", \"devices\": [{\"deviceSerialNumber\": \"B0F00712521302HC\", \"deviceTypeId\": \"AB72C64C86AW2\"}]}, \"skillId\": \"amzn1.ask.1p.saysomething\"}}]}}", "status": "ENABLED"}
2020-12-17 16:18:10 DEBUG (MainThread) [alexapy.alexaapi] POST: https://alexa.amazon.com/api/behaviors/preview returned 400:Bad Request:application/octet-stream
alandtse commented 3 years ago

Is it for any echo device you have or just this one? Does any other service to the same device work?

One thing to test is to create a routine in the Alexa app that does the same thing you are trying to do and then find it on the behavior's page. We can then compare it with the failing call.

maminx commented 3 years ago

Same problem with all my devices (1 echo 1st gen & 3 echo dots [2019] ) Also same error calling any services related with alexa_media, playing jokes, music, etc. Funny thing, is that commands like pair with a Bluetooth device, or setting DND works as expected.

I'm trying to reach alexapy team, just to see if they know if anything has changed from Amazon's side.

alandtse commented 3 years ago

Alexapy is me too so no need

alandtse commented 3 years ago

Are you able to test making a routine too? A 400 error indicates it's rejecting the request for some reason and I want to see if Amazon has changed the format.

maminx commented 3 years ago

by routine, do you mean a routine in the Alexa app?, sorry, kinda new on this.

maminx commented 3 years ago

Ok, so I created a routine on alexa's app, based on a sensor in the stairs, if it detects movement it will make my alexa to say custom phrase: "Motion detected at stairs". Just as have on Home Assistant. And yes, that new routine created on alexa's app works as expected.

alandtse commented 3 years ago

Please pull the json data from the behavior page I linked above.

maminx commented 3 years ago

there you go:

{
      "@type":"com.amazon.alexa.behaviors.model.Automation",
      "automationId":"amzn1.alexa.automation.d5990284-7e3c-4325-9c1c-98f13a662a69",
      "name":"test",
      "triggers":[
         {
            "payload":{
               "customerId":"A2M2Q5VWCMFUQ0",
               "value":"DETECTED",
               "target":"716c662d-7660-47d6-91e0-fbde59c9d00a"
            },
            "id":"amzn1.alexa.trigger.d1e67dcb-6f69-40f6-a704-821c47517d3f",
            "type":"motionSensorDetectionStateTrigger",
            "skillId":"amzn1.ask.1p.smarthome",
            "timeLapse":null,
            "presentationDataList":null,
            "imageUrl":null,
            "clientData":null,
            "context":null
         }
      ],
      "sequence":{
         "@type":"com.amazon.alexa.behaviors.model.Sequence",
         "sequenceId":"amzn1.alexa.sequence.fd9e0c7a-d94e-41d1-a376-f43caba73be6",
         "startNode":{
            "@type":"com.amazon.alexa.behaviors.model.OpaquePayloadOperationNode",
            "nodeState":null,
            "name":null,
            "type":"Alexa.Speak",
            "skillId":"amzn1.ask.1p.saysomething",
            "operationPayload":{
               "customerId":"A2M2Q5VWCMFUQ0",
               "deviceType":"AB72C64C86AW2",
               "deviceSerialNumber":"B0F00712521302HC",
               "textToSpeak":"somone is on the stairs",
               "locale":"en-US"
            },
            "presentationDataList":null,
            "clientData":null,
            "context":null,
            "tag":null
         }
      },
      "owner":{
         "@type":"OwnerId",
         "ownerType":"CUSTOMER",
         "id":"A2M2Q5VWCMFUQ0"
      },
      "clientAlias":null,
      "condition":null,
      "status":"ENABLED",
      "creationTimeEpochMillis":1608341533870,
      "lastUpdatedTimeEpochMillis":1608341533870
   },
alandtse commented 3 years ago

Please create an utterance and post it too. The format for automations may be different.

maminx commented 3 years ago

Please create an utterance and post it too. The format for automations may be different.

Sorry for my ignorance, but how do I do that?

alandtse commented 3 years ago

You can setup a routine that responds to your voice. That is what came first and what a lot of the functionality is based on. The other actions came layer and may vary the format.

maminx commented 3 years ago

there you go:

{
      "@type":"com.amazon.alexa.behaviors.model.Automation",
      "automationId":"amzn1.alexa.automation.70ddaec2-f972-4f34-9bb3-64ad56cbc4d2",
      "name":"boiler on",
      "triggers":[
         {
            "payload":{
               "customerId":"A2M2Q5VWCMFUQ0",
               "utterance":"turn boiler on",
               "locale":"en-US",
               "marketplaceId":"ATVPDKIKX0DER"
            },
            "id":"amzn1.alexa.trigger.555a2a9a-d8eb-480a-bb05-c03c1af31d66",
            "type":"CustomUtterance",
            "skillId":"amzn1.ask.1p.customutterance",
            "timeLapse":null,
            "presentationDataList":null,
            "imageUrl":null,
            "clientData":null,
            "context":null
         }
      ],
      "sequence":{
         "@type":"com.amazon.alexa.behaviors.model.Sequence",
         "sequenceId":"amzn1.alexa.sequence.13f5e70d-666e-484e-a141-b525569195c7",
         "startNode":{
            "@type":"com.amazon.alexa.behaviors.model.SerialNode",
            "name":null,
            "nodesToExecute":[
               {
                  "@type":"com.amazon.alexa.behaviors.model.OpaquePayloadOperationNode",
                  "nodeState":null,
                  "name":null,
                  "type":"Alexa.SmartHome.Batch",
                  "skillId":"amzn1.ask.1p.smarthome",
                  "operationPayload":{
                     "target":"f218d194-a742-492e-b281-b4fc47d0b2b5",
                     "customerId":"A2M2Q5VWCMFUQ0",
                     "operations":[
                        {
                           "type":"turnOn"
                        }
                     ]
                  },
                  "presentationDataList":null,
                  "clientData":null,
                  "context":null,
                  "tag":null
               }
            ]
         }
      },
      "owner":{
         "@type":"OwnerId",
         "ownerType":"CUSTOMER",
         "id":"A2M2Q5VWCMFUQ0"
      },
      "clientAlias":null,
      "condition":null,
      "status":"ENABLED",
      "creationTimeEpochMillis":1583706897450,
      "lastUpdatedTimeEpochMillis":1583706897450
   },

Just wondering, am I the only one with this problem?

alandtse commented 3 years ago

Sorry, could you please do an utterance using an Alexa says?

Yes, you're the only one who's reported this problem.

maminx commented 3 years ago

Weird that I'm the only one, I tried with a fresh install on a VM and same problem, must be something on my devices configuration, not sure if it is because my location (in México).

Don't worry, I will close this, since I'm the only one, must be other thing, thanks anyways!

maminx commented 3 years ago

One more thing, I tried the solution on node-red (node-red-contrib-alexa-remote2), and it is working as it was with your component I was analyzing the code, and they are posting (https://github.com/586837r/node-red-contrib-alexa-remote2/blob/master/lib/alexa-remote-ext.js) line 630, same structure, almost same data, (you are putting some extra values, I tried removing those extra values, but same result, no alexa speaking) :( not sure why your component stopped working on my environment

Thanks pal!

alandtse commented 3 years ago

If your device is registered in Mexico that can do that too. You may need to login to alexa.mx. But if you have a solution then no biggie.

pipip commented 3 years ago

I came accross this while setting up my alexa media devices these days. I also did not manage to get notify working in the beginning because I selected the wrong country. Everything else seem to work but I could not get TTS to work. As I said, for me it was related to the country, the country has to be the country your device is registered in (not language or anything else)... then TTS works as intended :)

maminx commented 3 years ago

After a big BLUNT! (LOL) I just managed to fix it, and yes, it was kinda the country, I just deleted all .mx domains from my cookie (the one I paste into integration to login), and voila! the integration is working again! thanks a lot pals!