586837r / node-red-contrib-alexa-remote2

MIT License
88 stars 72 forks source link

How to send to multiple devices #20

Closed BassTeQ closed 5 years ago

BassTeQ commented 5 years ago

If I want to control or send TTS to multiple devices, does this require an "alexa sequence" for each device?

586837r commented 5 years ago

Do you get the same error when File Path is blank? This File Path option is just an extra feature that automatically saves the result of the authentication. It should not affect the success of the authentication! Note that you can manually initialise the Alexa Account node with a Alexa Init node and use it to save that result any way you want, to later initialise the account again with that result.

The result of the Proxy authentication is not just the cookie, it looks something like this:

{
    "loginCookie": "...",
    "frc": "...",
    "map-md": "...",
    "deviceId": "...",
    "deviceSerial": "...",
    "refreshToken": "...",
    "tokenDate": 1234,
    "amazonPage": "...",
    "localCookie": "...",
    "csrf": "..."
}

I don't think there is a way to fill this manually.

Also note: This project is just an interface to alexa-remote2. All functionality comes from it. I don't know how everything of it works. To get to the root of the problem i suggest you try to use alexa-remote2 separately and if you still encounter proxy problems open an issue over there.

ThomasPoett commented 5 years ago

Hi, if i leave the path "undefined" i receive the same error with Auth failed. Well, seem a little complex getting the json correctly. since its a proxy, maybe i can try "fetcher" it? But it seem to be easier if i run a node-red windows setup and try. (24.06: I'm going to use a Dev-System on Windows now too)

BassTeQ commented 5 years ago

Proxy method is working again. I now have a weird issue in this flow. If I inject a json string it works fine, alexa will speak the text contained in flow.HSPayload.text however populating a mq topic with a json string causes alexa to speak "undefined"

image

Here's my change node image

Alexa Sequence image

NovaGL commented 5 years ago

That topic does not contain json it is a mqtt path? If that's the only problem add a delete rule for msg.topic. Also the MQTT node outputs JSON so don't know why you have a separate JSON node.

BassTeQ commented 5 years ago

Thanks @NovaGL , does this look right? I'm still hearing "that device wasn't found"

image

Also the MQTT node outputs JSON so don't know why you have a separate JSON node.

Sorry still new to this, I thought I had to do that when using the inject node to convert it to json?

NovaGL commented 5 years ago

You'll improve in no time so many shortcuts your code will be half. You only need one change node you can do the delete in that one.

Ok, so I did some testing I don't have a problem with the topics

Try a basic example like this and then build from there to find your problem

Inject node

{
    "speak": "Testing 1 2 3",
    "device": "Echo Dot"
}

Alexa Sequence

device = msg.payload.device speak = msg.payload.speak

Basically what I am saying is define the device name in the message.

For MQTT you can do + as a wildcard or # for a multi-level wildcard

BassTeQ commented 5 years ago

Thanks for the tips, much appreciated!

Adding the delete to the existing change node seems to have done the trick :)

image

ThomasPoett commented 5 years ago

So, @586837r installed Dev System on Windows. with the same result in using the Proxy method. image image

I'm not sure whats acutally going on. its version 2.3.1. Can I do further logging for you? I really wanna figure out what causing the issue.

586837r commented 5 years ago

What is 'Dev System' ? Do you just mean that you installed node-red on Windows?

What would be very helpful is creating a minimal example of the error. That means using alexa-remote2 directly. Try running this script and see if you get an error or SUCCESS: https://gist.github.com/586837r/5f94080c265dd63fa5b9c00a65ca4320

Here is how you can execute it:

It will prompt you to go to localhost:3456. After that if you see SUCCESS then there is clearly something wrong with how I interface with alexa-remote2. If you get an Error instead then it would make sense to create an issue over there. In that case Apollon77 is more likely to be able help you out.

BassTeQ commented 5 years ago

Any idea whats causing this error? The flows just stop working after a period of time.

1 Jul 13:49:12 - [info] Started flows
(node:16052) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 status listeners added. Use emitter.setMaxListeners() to increase limit

I start seeing errors with the remote sequence

2 Jul 12:11:46 - [error] [alexa-remote-sequence:Bedroom] Error: no JSON
2 Jul 12:11:46 - [error] [alexa-remote-sequence:Kitchen] Error: no JSON
2 Jul 12:11:46 - [error] [alexa-remote-sequence:Study] Error: no JSON

Thanks

586837r commented 5 years ago

The first thing is an expected warning. It should not cause any issues. The Error: no JSON is a Cookie issue, so try reinitialising: If you use a file path, delete the file or choose a new path.

586837r commented 5 years ago

TTS to multiple devices is now easily possible in version 3 with an Alexa Routine node. Also: speaking at a volume and then setting the volume back to the previous value is not built in with Speak At Volume of the Alexa Routine node.

BassTeQ commented 5 years ago

Could that functionality be added? It would be very useful! If I have music playing at level 30, I wouldn't want to make an announcement at level 80, then have the music continue at level 80 :~ Thanks

586837r commented 5 years ago

Oh i meant this is now built in with Speak at Volume of the Alexa Routine node. It will play at the volume you entered and then set it back to the original volume. Unfortunately getting the volume fails for some Echo devices if music hasn't played on them for a while... Please update 3.0.4 because there was a bug in saving the Alexa Routine node configuration.

BassTeQ commented 5 years ago

Excellent, thanks! Will try this out in my flow.