Apollon77 / alexa-remote

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Sample to send TTS or Announce

guilhermelirio opened this issue · comments

Hi! First, congratulations on the project!

I'm trying to develop a personal project, to send a simple TTS to my alexa.

I would like to know if there is any example of this, as I am not able to execute the function (it always gives the same error):

Unknown Device or Serial number

I got it using Alexa.init (from the example file), but I wanted to understand how to call the function to send a TTS, from some other .js file.

Can you show your code?

you first need to create a Sequence object using https://github.com/Apollon77/alexa-remote/blob/master/alexa-remote.js#L1674
After that use https://github.com/Apollon77/alexa-remote/blob/master/alexa-remote.js#L1909 to send it. The first parameter here is the device object or the serialnumber of the device.
For simply commands you can also use the second method only and pass command and value and the sequence object is created automatically

Hi @Apollon77 , thanks for support!

My sample code:
https://gist.github.com/guilhermelirio/6a899550fa684ca03e1ca9cef8fa060d

The cookie I am using (I took it from the code) is the localCookie (when logging in via proxy - port 3001).

And when I use it with this cookie, it shows this error:

Alexa-Remote: Sending Request with {"host":"pitangui.amazon.com","path":"/api/behaviors/preview","method":"POST","timeout":10000,"headers":{}} and data={"behaviorId":"PREVIEW","sequenceJson":"{\"@type\":\"com.amazon.alexa.behaviors.model.Sequence\",\"startNode\":{\"@type\":\"com.amazon.alexa.behaviors.model.OpaquePayloadOperationNode\",\"operationPayload\":{\"deviceType\":\"A1Z88NGR2BK6A2\",\"deviceSerialNumber\":\"G0916D10040203L8\",\"locale\":\"pt-BR\",\"customerId\":\"A2C36ZUGQ0JTWW\",\"textToSpeak\":\"hello\"},\"type\":\"Alexa.Speak\"}}","status":"ENABLED"}
Alexa-Remote: Response: No body
error: Error: no body

In general looks ok, also the response might be that way. Did you have "Do Not Disturb" enabled on the device maybe?

In general looks ok, also the response might be that way. Did you have "Do Not Disturb" enabled on the device maybe?

No, It is disabled.

And a speak done via a rtoutine test in alexa app is working?

Yes, it works normally. I have Alexa Media Player integration, via Home Assistant, and it works perfectly.

But I wanted to develop a system for my own use!

An observation:
when I login via http://localhost:3001, the audio comes out normally.

But when I use the provided localCookie, it doesn't work.

This works!!

I'm used a CookieData object and works any time!! =)

So it was "Just" the coolie data you used and we can close here?

So it was "Just" the coolie data you used and we can close here?

Yes, I used all of CookieData and it worked. You can close and thanks for the help!

If you like please make a PR for Readme, maybe that helps other users