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

MIT License
88 stars 71 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?

ThomasPoett commented 5 years ago

Hi you can actually do it in two ways. Either lopping and sending the Alexa device name, else you connect a function node to multiple device

BassTeQ commented 5 years ago

Could you share a screenshot of such examples?

Thanks

On Tue, 4 Jun. 2019, 18:30 ThomasPoett, notifications@github.com wrote:

Hi you can actually do it in two ways. Either lopping and sending the Alexa device name, else you connect a function node to multiple device

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/586837r/node-red-contrib-alexa-remote2/issues/20?email_source=notifications&email_token=AHZN53PXMCHS5AO6BBKNDEDPYYR2ZA5CNFSM4HSYWXNKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODW32RLY#issuecomment-498575535, or mute the thread https://github.com/notifications/unsubscribe-auth/AHZN53JUU45IVGD727QEQZLPYYR2ZANCNFSM4HSYWXNA .

NovaGL commented 5 years ago

@BassTeQ I'm using this node to resend the msg. https://flows.nodered.org/node/node-red-contrib-msg-resend

Then a switch node with msg.count, so 1 goes to bedroom, 2 goes to kitchen, 3 goes study,

I think that's the easiest way. A function node does similar but this way uses less code.

BassTeQ commented 5 years ago

Thanks @NovaGL will give this a try!

ThomasPoett commented 5 years ago

image sure it could look like this

BassTeQ commented 5 years ago

Every time I deploy my flow I have to re-authenticate, is this expected behaviour?

NovaGL commented 5 years ago

I have that too. Store a cookie in a file that way it won't re-authenticate it will just use the cookie.

I'm using a init node and it seems to work.

BassTeQ commented 5 years ago

@NovaGL , this is what I have at the moment, have I missed something? Using an sequence for each device, should I be using an init node instead?

flow

I've noticed the cookie directory I've specified 'C:\temp\node-red' is empty

Thanks

NovaGL commented 5 years ago

Your problem is file path is a file not a folder.

ThomasPoett commented 5 years ago

do you run node-red on windows? if not and its raspi, use the Linux notation. but I still have an issue with (cannot authenticate) with proxy. still figuring out whats going on

NovaGL commented 5 years ago

@ThomasPoett I'm using a Pi2. What happens when you try to authenticate, connect it to a debug node and does it have output

BassTeQ commented 5 years ago

@NovaGL Thanks, I've changed it to C:\temp\node-red\cookie.txt and its working now :) Is there any benefit to using an 'init' node? Do I also need to have a flow that does a cookie refresh? If so how would this be done?

@ThomasPoett , yes I'm running on windows.

NovaGL commented 5 years ago

Cookie refresh is done in the init node using a payload of refresh.

So I guess that answers both your questions :)

ThomasPoett commented 5 years ago

@ThomasPoett I'm using a Pi2. What happens when you try to authenticate, connect it to a debug node and does it have output

its the message of cookie file doesn't exitis, I guess this is a wrong path with my PI3

BassTeQ commented 5 years ago

Cookie refresh is done in the init node using a payload of refresh.

So I guess that answers both your questions :)

Thanks @NovaGL , are you able to share a screenshot? Does this look correct? How often does this node need to be invoked to refresh the cookie? Once per week?

flow
NovaGL commented 5 years ago

Looks right to me. I would try 48hrs not sure how long the cookie lasts

ThomasPoett commented 5 years ago

the cookie lasts approx. 8 days. but sure refresh every 24hrs and trace the response can be help full. I'll trace the response every 24 hrs and write it to dashboard

BassTeQ commented 5 years ago

Any idea why I'm getting this "no JSON" error appearing? The payload is coming from an MQTT Topic, I'm setting it to "this is a test" Thanks image

NovaGL commented 5 years ago

Has the cookie expired?

BassTeQ commented 5 years ago

No, if I re-deploy the flow, it goes to a "ready" state.

NovaGL commented 5 years ago

So other commands, like get devices work?

BassTeQ commented 5 years ago

I've not used that one before, will add it.

BassTeQ commented 5 years ago

Yes get devices works fine

image

BassTeQ commented 5 years ago

Things seem to be working ok for the time being, will monitor.

Do you know if its possible to get the current volume from a device? I'd like to set the volume, read the text to speech and set the volume back to its original value.

Cheers

NovaGL commented 5 years ago

Pretty sure you can set device actions not at a PC to check Just look at the various nodes.

BassTeQ commented 5 years ago

I cant find anything obvious to obtain the volume level within the "Alexa Get" node

NovaGL commented 5 years ago

The examples might help. https://github.com/586837r/node-red-contrib-alexa-remote2/blob/85ecb370e638f59678c3e7dc005a17ad2d48b8a7/examples.md

BassTeQ commented 5 years ago

Thanks, so I want to look at example 3, to see how it works. I have the dashboard installed, how do I create one using a json string? Eg; [{"id":"d88ff07e.1817a","type":"tab","label":"Alexa Music","disabled":false,"info":""},{"id":"85ce383c.682918","type":"ui_dropdown","z":"d88ff07e.1817a","name":"","label":"Provider","place":" SNIP

NovaGL commented 5 years ago

Just look at the nodes not the output. You might get overwhelmed otherwise

BassTeQ commented 5 years ago

Spoke too soon, now getting an error "no csrf" I've removed the cookie, re-authenticated, and still see this error.

image

NovaGL commented 5 years ago

Delete the cookie and re-authenticate should work.

Use "Alexa command" to set the volume. Get Media has the current volume

586837r commented 5 years ago

@BassTeQ

BassTeQ commented 5 years ago

Tried deleting the cookie, re-authenticated, but still seeing the error.

@586837r , I've tried using the content of the cookie with the "cookie" method, but it says authentication failed, should I be using the whole content of the cookie.txt or just part of it?

The code you pasted to set to the original volume, how would I use that? I currently have an "alexa sequence" where I set the volume, speak the text, then I'd like to reset the volume to the original value. image

Cheers

NovaGL commented 5 years ago

That looks correct assuming you stored the volume before in that payload (from get media)

BassTeQ commented 5 years ago

@NovaGL I'm actually passing a volume value in the json via mqtt in that screenshot, its not from the device.

How do I use the code below to create a node?

[{"id":"cbdf4c36.0296a","type":"alexa-remote-get","z":"c7058271.2790f","name":"","account":"","target_type":"select","target_value":"media","serialOrName_type":"str","serialOrName_value":"","options":{"devices":{},"cards":{"limit":{"type":"num","value":"10"},"beforeCreationTime":{"type":"str","value":"%t"}},"media":{},"playerInfo":{},"list":{"size":{"type":"num","value":"100"},"startTime":{"type":"str","value":""},"endTime":{"type":"str","value":""},"completed":{"type":"bool","value":"false"},"listType":{"type":"select","value":"TASK"}},"wakewords":{},"notifications":{"cached":{"type":"bool","value":"true"}},"doNotDisturb":{},"deviceNotificationState":{},"bluetooth":{"cached":{"type":"bool","value":"true"}},"activities":{"startTime":{"type":"str","value":""},"size":{"type":"num","value":"1"},"offset":{"type":"num","value":"1"}},"account":{},"conversations":{"latest":{"type":"bool","value":"true"},"includeHomegroup":{"type":"bool","value":"true"},"unread":{"type":"bool","value":"false"},"modifiedSinceDate":{"type":"str","value":"1970-01-01T00:00:00.000Z"},"includeUserName":{"type":"bool","value":"true"}},"automationRoutines":{"limit":{"type":"num","value":"2000"}},"musicProviders":{},"homeGroup":{},"devicePreferences":{},"smarthomeDevices":{},"smarthomeGroups":{},"smarthomeEntities":{},"smarthomeBehaviourActionDefinitions":{}},"x":330,"y":740,"wires":[["297f0996.343656"]]},{"id":"280eeef7.485c92","type":"inject","z":"c7058271.2790f","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":160,"y":740,"wires":[["cbdf4c36.0296a"]]},{"id":"297f0996.343656","type":"alexa-remote-sequence","z":"c7058271.2790f","name":"","account":"","serialOrName_type":"str","serialOrName_value":"","sequenceInputs":[{"command":"volume","value_type":"num","value_value":"50"},{"command":"speak","value_type":"str","value_value":"Hello World!"},{"command":"volume","value_type":"msg","value_value":"payload.volume"}],"x":520,"y":740,"wires":[[]]}]
NovaGL commented 5 years ago

By node I mean variable. You can use the change node to store the value or store in a global or flow variable.

586837r commented 5 years ago

@BassTeQ

BassTeQ commented 5 years ago

Thanks @NovaGL and @586837r , will try out your suggestions and see how it goes.

Any idea why the proxy method is no longer working? Not ideal to use the cookie due to the expiry,

586837r commented 5 years ago

Yeah, it seems something changed with amazon. Other users of the underlying library have reported the same error. https://github.com/Apollon77/alexa-remote/issues/44

BassTeQ commented 5 years ago

Thanks for confirming, I have the cookie working now, and I've included your example, just trying to get it working in my flow.

Cheers

BassTeQ commented 5 years ago

I've created this, now a little stuck.

image

In the inject node I pass a json string

{ "text": "this is some test", "volume_before" : "50" }

In the commands, the highlighted ones come from the JSON payload, and the 3rd comes from "get media kitchen". It appears the payload is missing the values from the JSON, how should these be injected?

Cheers

NovaGL commented 5 years ago

Volume before should be a number and doesn't need quotes.

You can use the change node. image

Then use this image

BassTeQ commented 5 years ago

Thanks @NovaGL will try out your suggestion.

BassTeQ commented 5 years ago

Yeah, it seems something changed with amazon. Other users of the underlying library have reported the same error. https://github.com/Apollon77/alexa-remote/issues/44

Reading that thread, it appears they've now fixed it, hope it gets included here soon!

586837r commented 5 years ago

You're right! It should work again in version 2.3.0

ThomasPoett commented 5 years ago

Mhhh, either I'm not clever enough or there is still an issue with Proxy Auth. Cookie works within the limitation to TTL, but Proxy has an issue with now Auth fail. image image it running on rapsmatic…

586837r commented 5 years ago

There is nothing wrong with your configuration. Some ideas if you haven't done that already:

ThomasPoett commented 5 years ago

it is a little wired, there was no file stored and uppon i used icognito mode I got this error from the node: "Error: EISDIR: illegal operation on a directory, read"

going to reboot the system and try it again


well, it came up with chapta Auth.. but same result, after typing in my credential massage : Authentication failed. Further, reentering the credentials again do not work,: the internal web proxy is not responding. waiting 5-10min let the proxy respond again, but same "Authentication failed"

586837r commented 5 years ago

The first error is because a path to a file is expected like /usr/test01/alexa-cookie.json, not a directory. But authentication should still work. Looks like there is something wrong with the proxy on your system. As a workaround I suppose you could generate the file on a different system and copy it over.

ThomasPoett commented 5 years ago

I think I know why… the RaspMatic is different from a "normal" Linux distribution. Therefore the main directories are not writable. So I can create a in e.g. tmp. I also was able to write a file with "vi". Could may post a json example of the cookie file. I'll will copy the actual cookie in and try. This seems also the problem with Authentication/Proxy, due to the RaspMatic seem to be a little to different. @hobbyquaker who ported Node-Red might be the right one helping out with this issue