rgraciano / echo-sonos

Amazon Echo integration with Sonos
Other
712 stars 235 forks source link

Adds support for Open Sonos command #176

Closed jplourde5 closed 7 years ago

jplourde5 commented 7 years ago

Saying "Alexa, open Sonos" or "Alexa, start Sonos", etc. invokes Sonos. The current room and service are indicated followed by a "What would you like to do next?". You can continue to perform multiple commands without having to repeat "Alexa, ask Sonos...". You can conclude at any point by answering "I'm finished", "Finished", "Done", etc.

jplourde5 commented 7 years ago

Fixed INTERACTIVEMODE typo and removed HELPMODE, which I believe would be too complex to implement, at least in a comprehensive fashion.

loftgren commented 7 years ago

Hello,

I apologize if this is not protocol.

My name is Chris Murray. I am writing you because I have gotten no reply to my post for help on GitHub, and I am desperately in need of help.

I manage a home on the coast of Maine, and though I'm certainly not an expert, I have managed to get all up and running. However, when I updated last week to the "Alexa, open Sonos..." , any time I request music from any music service, Alexa says "ok," but no music plays, and my terminal npm window says " invalid music service," with the Lambda logs stating a 500 error code.

My issue on Github is called "Music Service Trouble," or something like that. If you could offer any help I would truly be grateful.

Best,

Chris

christopherwintermurray@gmail.com Cell: (207)266-9522

On Jun 20, 2017, 11:33 AM -0400, Ryan Graciano notifications@github.com, wrote:

Merged #176. — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

jplourde5 commented 7 years ago

There was a typo in the code that was just corrected yesterday. That may be your problem. Do you get the room and service status when you say "Open Sonos" ?

Also, what music service are you using? If Spotify, you need to update your nod-sones-http-api to the latest version. Spotify recently added authentication to their music search api.

loftgren commented 7 years ago

Yes. I get current room and service. I can play/pause, add rooms to groups etc. all works except for any request involving a music service.

I believe I already corrected the typo from yesterday.

Thanks so much for the help!

Best,

Chris

christopherwintermurray@gmail.com Cell: (207)266-9522

On Jun 20, 2017, 5:42 PM -0400, jplourde5 notifications@github.com, wrote:

There was a typo in the code that was just corrected yesterday. That may be your problem. Do you get the room and service status when you say "Open Sonos" ? — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

loftgren commented 7 years ago

FYI... when I call http://xxxxx.ddns.net:5005/house/musicsearch/apple/song/artist:Paul%20McCartney I get the following: {"status":"error","error":"You are missing spotify clientId and secret in settings.json! Please read the README for instructions on how to generate and add them","stack":"Error: You are missing spotify clientId and secret in settings.json! Please read the README for instructions on how to generate and add them\n at getHeaders (/Users/christophermurray/node-sonos-http-api-master/lib/music_services/spotifyDef.js:66:11)\n at getOptions (/Users/christophermurray/node-sonos-http-api-master/lib/music_services/spotifyDef.js:78:14)\n at auth (/Users/christophermurray/node-sonos-http-api-master/lib/music_services/spotifyDef.js:88:19)\n at Promise (/Users/christophermurray/node-sonos-http-api-master/lib/music_services/spotifyDef.js:110:5)\n at authenticateService (/Users/christophermurray/node-sonos-http-api-master/lib/music_services/spotifyDef.js:109:10)\n at doSearch (/Users/christophermurray/node-sonos-http-api-master/lib/actions/musicSearch.js:133:12)\n at getAccountId.then (/Users/christophermurray/node-sonos-http-api-master/lib/actions/musicSearch.js:215:14)\n at tryCatcher (/Users/christophermurray/node-sonos-http-api-master/node_modules/bluebird/js/main/util.js:26:23)\n at Promise._settlePromiseFromHandler (/Users/christophermurray/node-sonos-http-api-master/node_modules/bluebird/js/main/promise.js:510:31)\n at Promise._settlePromiseAt (/Users/christophermurray/node-sonos-http-api-master/node_modules/bluebird/js/main/promise.js:584:18)\n at Async._drainQueue (/Users/christophermurray/node-sonos-http-api-master/node_modules/bluebird/js/main/async.js:128:12)\n at Async._drainQueues (/Users/christophermurray/node-sonos-http-api-master/node_modules/bluebird/js/main/async.js:133:10)\n at Immediate.Async.drainQueues (/Users/christophermurray/node-sonos-http-api-master/node_modules/bluebird/js/main/async.js:15:14)\n at runCallback (timers.js:651:20)\n at tryOnImmediate (timers.js:624:5)\n at processImmediate [as _immediateCallback] (timers.js:596:5)"}

Best,

Chris

christopherwintermurray@gmail.com Cell: (207)266-9522

On Jun 20, 2017, 5:42 PM -0400, jplourde5 notifications@github.com, wrote:

There was a typo in the code that was just corrected yesterday. That may be your problem. Do you get the room and service status when you say "Open Sonos" ? — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

loftgren commented 7 years ago

Oh, and yes, I do get the room and service. I can do everything... play/pause, add or remove players from group etc. All works except when I ask for Sonos to play something... "play Bruno Mars in the kitchen." Alexa say "ok" but nothing happens, and the terminal npm window says "Invalid music service."

Best,

Chris

christopherwintermurray@gmail.com Cell: (207)266-9522

On Jun 20, 2017, 5:42 PM -0400, jplourde5 notifications@github.com, wrote:

There was a typo in the code that was just corrected yesterday. That may be your problem. Do you get the room and service status when you say "Open Sonos" ? — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

jplourde5 commented 7 years ago

Ahhhh... Try reading the readme on entering the Spotify credentials and enter some dummy credentials in the settings.json file. Just enter some characters. I'm guessing that there is a bug requiring something to be there even if not used. Let me know what happens.

loftgren commented 7 years ago

Thanks. Any chance you can send me the link to that read me file... I have trouble finding my way around github 😊

Best,

Chris

christopherwintermurray@gmail.com Cell: (207)266-9522

On Jun 21, 2017, 3:32 PM -0400, jplourde5 notifications@github.com, wrote:

Ahhhh... Try reading the readme on entering the Spotify credentials and enter some dummy credentials in the settings.json file. Just enter some characters. I'm guessing that there is a bug requiring something to be there even if not used. Let me know what happens. — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

jplourde5 commented 7 years ago

https://github.com/jishi/node-sonos-http-api

loftgren commented 7 years ago

I would actually pay to have someone remote to my machine and solve this. It's making me a little crazy.

Best,

Chris

christopherwintermurray@gmail.com Cell: (207)266-9522

On Jun 21, 2017, 3:42 PM -0400, jplourde5 notifications@github.com, wrote:

https://github.com/rgraciano/echo-sonos — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

jplourde5 commented 7 years ago

:) Look in your node-sones-http-api-master directory. Edit (or create) the settings.json file with the following entry at the end. Include the , if the file already exists:

      ,
  "spotify": {
    "clientId": "dummy",
    "clientSecret": "dummy"
  }
loftgren commented 7 years ago

Says it can't read the file. I'm clearly not a code guy... this is what i did...

{ "region": "YOUR_REGION_CODE", "accessKeyId": "YOUR_ACCESS_KEY_ID", "secretAccessKey": "YOUR_SECRET_ACCESS_KEY", "host": "localhost", "port": "5005”, , “spotify:{ “clientId”:”dummy”, “clientSecret”:”dummy” }

On Wed, Jun 21, 2017 at 4:13 PM, jplourde5 notifications@github.com wrote:

:) Look in your node-sones-http-api-master directory. Edit (or create) the settings.json file with the following entry at the end. Include the , if the file already exists:

  ,

"spotify": { "clientId": "dummy", "clientSecret": "dummy" }

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/rgraciano/echo-sonos/pull/176#issuecomment-310191620, or mute the thread https://github.com/notifications/unsubscribe-auth/AZk7d3e4GOGE5SOZBWZyTQ6TNAjyD2Tlks5sGXlSgaJpZM4Nvjvw .

jplourde5 commented 7 years ago

It looks like the exception may just be noise. The above will get rid of it and I just submitted a fix for node-sones-http-api. BTW, get rid of the extra , before "Spotify". You do have an Apple Music account and can play Apple Music through your Sonos apps, correct?

Remove the extra comma, issue the command, and see if you are getting an exception.

loftgren commented 7 years ago

no, i have no apple music account set up with Alexa. Before this big update I was simply able to tell Alexa to ask sonos to change the music service (only really used Pandora and Spotify) and it worked like a charm. Will this process make Pandora come back?

On Wed, Jun 21, 2017 at 4:29 PM, jplourde5 notifications@github.com wrote:

It looks like the exception may just be noise. The above will get rid of it and I just submitted a fix for node-sones-http-api. BTW, get rid of the extra , before "Spotify". You do have an Apple Music account and can play Apple Music through your Sonos apps, correct?

Remove the extra comma, issue the command, and see if you are getting an exception.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/rgraciano/echo-sonos/pull/176#issuecomment-310195672, or mute the thread https://github.com/notifications/unsubscribe-auth/AZk7d40W_3sj8JnU6at808kB-Bajg5zDks5sGX0YgaJpZM4Nvjvw .

jplourde5 commented 7 years ago

You would need an Apple Music account setup on your Sonos for the apple service to work.

loftgren commented 7 years ago

This is what I get when I start npm. Then, at the end, when I ask Alexa to ask sonos to play songs my Bruno Mars in the Kitchen

Christophers-Mac-mini:node-sonos-http-api-master christophermurray$ npm start

sonos-http-api@1.4.1 start /Users/christophermurray/node-sonos-http-api-master

node server.js

2017-06-21T20:33:38.337Z WARN Could not read file /Users/christophermurray/node-sonos-http-api-master/settings.json, ignoring.

SyntaxError: Bad string at line 7 column 0 of the JSON5 data. Still to read: "\n \n “spotify:{\n "

at error

(/Users/christophermurray/node-sonos-http-api-master/node_modules/json5/lib/json5.js:56:25)

at string

(/Users/christophermurray/node-sonos-http-api-master/node_modules/json5/lib/json5.js:268:13)

at value

(/Users/christophermurray/node-sonos-http-api-master/node_modules/json5/lib/json5.js:487:20)

at object

(/Users/christophermurray/node-sonos-http-api-master/node_modules/json5/lib/json5.js:459:35)

at value

(/Users/christophermurray/node-sonos-http-api-master/node_modules/json5/lib/json5.js:482:20)

at Object.parse

(/Users/christophermurray/node-sonos-http-api-master/node_modules/json5/lib/json5.js:508:18)

at tryLoadJson

(/Users/christophermurray/node-sonos-http-api-master/lib/helpers/try-load-json.js:8:33)

at Object.<anonymous>

(/Users/christophermurray/node-sonos-http-api-master/settings.js:28:22)

at Module._compile (module.js:570:32)

at Object.Module._extensions..js (module.js:579:10)

2017-06-21T20:33:39.718Z INFO Presets loaded: { presets:

{ test:

  { players: [ { roomName: 'Master Bedroom', volume: 30 } ],

    state: 'PLAYING',

    favorite: 'Rock',

    uri: 'x-rincon-stream:RINCON_0000000000001500',

    playMode: 'SHUFFLE',

    pauseOthers: true },

 rap:

  { players:

     [ { roomName: 'Dining Room', volume: 30 },

       { roomName: 'Living Room', volume: 30 },

       { roomName: 'Master Bedroom', volume: 30 },

       { roomName: 'Kitchen5', volume: 40 },

       { roomName: 'KitchenWall', volume: 50 } ],

    state: 'PLAYING',

    favorite: 'Rap',

    uri: 'x-rincon-stream:RINCON_0000000000001500',

    playMode: 'SHUFFLE',

    pauseOthers: true },

 'pop rap':

  { players:

     [ { roomName: 'Dining Room', volume: 30 },

       { roomName: 'Living Room', volume: 30 },

       { roomName: 'Master Bedroom', volume: 30 },

       { roomName: 'Kitchen5', volume: 40 },

       { roomName: 'KitchenWall', volume: 50 } ],

    state: 'PLAYING',

    favorite: 'Rap (Pop)',

    uri: 'x-rincon-stream:RINCON_0000000000001500',

    playMode: 'SHUFFLE',

    pauseOthers: true },

 rock:

  { players:

     [ { roomName: 'Dining Room', volume: 30 },

       { roomName: 'Living Room', volume: 30 },

       { roomName: 'Kitchen5', volume: 40 },

       { roomName: 'Master Bedroom', volume: 30 },

       { roomName: 'KitchenWall', volume: 50 } ],

    state: 'PLAYING',

    favorite: 'Rock',

    uri: 'x-rincon-stream:RINCON_0000000000001500',

    playMode: 'SHUFFLE',

    pauseOthers: true } } }

2017-06-21T20:33:41.770Z INFO http server listening on port 5005

(node:23090) Warning: Possible EventEmitter memory leak detected. 11 group-mute listeners added. Use emitter.setMaxListeners() to increase limit

(node:23090) Warning: Possible EventEmitter memory leak detected. 11 last-change listeners added. Use emitter.setMaxListeners() to increase limit

2017-06-21T20:34:10.699Z ERROR Invalid music service

On Wed, Jun 21, 2017 at 4:29 PM, jplourde5 notifications@github.com wrote:

It looks like the exception may just be noise. The above will get rid of it and I just submitted a fix for node-sones-http-api. BTW, get rid of the extra , before "Spotify". You do have an Apple Music account and can play Apple Music through your Sonos apps, correct?

Remove the extra comma, issue the command, and see if you are getting an exception.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/rgraciano/echo-sonos/pull/176#issuecomment-310195672, or mute the thread https://github.com/notifications/unsubscribe-auth/AZk7d40W_3sj8JnU6at808kB-Bajg5zDks5sGX0YgaJpZM4Nvjvw .

jplourde5 commented 7 years ago

You have an extra , before "Spotify: in your settings.json file that is causing the initial exception.

jplourde5 commented 7 years ago

You are also missing a bracket. Replace everything with the following:

{ "region": "YOUR_REGION_CODE", "accessKeyId": "YOUR_ACCESS_KEY_ID", "secretAccessKey": "YOUR_SECRET_ACCESS_KEY", "host": "localhost", "port": "5005”, “spotify:{ “clientId”:”dummy”, “clientSecret”:”dummy” } }

loftgren commented 7 years ago

ok... i literally did a cut and paste:

this is my settings.json file now: { "region": "YOUR_REGION_CODE", "accessKeyId": "YOUR_ACCESS_KEY_ID", "secretAccessKey": "YOUR_SECRET_ACCESS_KEY", "host": "localhost", "port": "5005”, “spotify:{ “clientId”:”dummy”, “clientSecret”:”dummy” } } same errors though: npm start

sonos-http-api@1.4.1 start /Users/christophermurray/node-sonos-http-api-master node server.js

2017-06-21T20:48:01.608Z WARN Could not read file /Users/christophermurray/node-sonos-http-api-master/settings.json, ignoring. SyntaxError: Bad string at line 7 column 0 of the JSON5 data. Still to read: "\n“spotify:{\n“clientI" at error (/Users/christophermurray/node-sonos-http-api-master/node_modules/json5/lib/json5.js:56:25) at string (/Users/christophermurray/node-sonos-http-api-master/node_modules/json5/lib/json5.js:268:13) at value (/Users/christophermurray/node-sonos-http-api-master/node_modules/json5/lib/json5.js:487:20) at object (/Users/christophermurray/node-sonos-http-api-master/node_modules/json5/lib/json5.js:459:35) at value (/Users/christophermurray/node-sonos-http-api-master/node_modules/json5/lib/json5.js:482:20) at Object.parse (/Users/christophermurray/node-sonos-http-api-master/node_modules/json5/lib/json5.js:508:18) at tryLoadJson (/Users/christophermurray/node-sonos-http-api-master/lib/helpers/try-load-json.js:8:33) at Object. (/Users/christophermurray/node-sonos-http-api-master/settings.js:28:22) at Module._compile (module.js:570:32) at Object.Module._extensions..js (module.js:579:10) 2017-06-21T20:48:03.167Z INFO Presets loaded: { presets: { test: { players: [ { roomName: 'Master Bedroom', volume: 30 } ], state: 'PLAYING', favorite: 'Rock', uri: 'x-rincon-stream:RINCON_0000000000001500', playMode: 'SHUFFLE', pauseOthers: true }, rap: { players: [ { roomName: 'Dining Room', volume: 30 }, { roomName: 'Living Room', volume: 30 }, { roomName: 'Master Bedroom', volume: 30 }, { roomName: 'Kitchen5', volume: 40 }, { roomName: 'KitchenWall', volume: 50 } ], state: 'PLAYING', favorite: 'Rap', uri: 'x-rincon-stream:RINCON_0000000000001500', playMode: 'SHUFFLE', pauseOthers: true }, 'pop rap': { players: [ { roomName: 'Dining Room', volume: 30 }, { roomName: 'Living Room', volume: 30 }, { roomName: 'Master Bedroom', volume: 30 }, { roomName: 'Kitchen5', volume: 40 }, { roomName: 'KitchenWall', volume: 50 } ], state: 'PLAYING', favorite: 'Rap (Pop)', uri: 'x-rincon-stream:RINCON_0000000000001500', playMode: 'SHUFFLE', pauseOthers: true }, rock: { players: [ { roomName: 'Dining Room', volume: 30 }, { roomName: 'Living Room', volume: 30 }, { roomName: 'Kitchen5', volume: 40 }, { roomName: 'Master Bedroom', volume: 30 }, { roomName: 'KitchenWall', volume: 50 } ], state: 'PLAYING', favorite: 'Rock', uri: 'x-rincon-stream:RINCON_0000000000001500', playMode: 'SHUFFLE', pauseOthers: true } } } 2017-06-21T20:48:05.876Z INFO http server listening on port 5005 (node:23293) Warning: Possible EventEmitter memory leak detected. 11 group-mute listeners added. Use emitter.setMaxListeners() to increase limit (node:23293) Warning: Possible EventEmitter memory leak detected. 11 last-change listeners added. Use emitter.setMaxListeners() to increase limit 2017-06-21T20:49:54.530Z ERROR Invalid music service

jplourde5 commented 7 years ago

You have some things that you don't need because you are not specifying anything. Try this:

{ "host": "localhost", "port": "5005”, “spotify:{ “clientId”:”dummy”, “clientSecret”:”dummy” } }

loftgren commented 7 years ago

Same thing: npm start

sonos-http-api@1.4.1 start /Users/christophermurray/node-sonos-http-api-master node server.js

2017-06-21T20:59:00.607Z WARN Could not read file /Users/christophermurray/node-sonos-http-api-master/settings.json, ignoring. SyntaxError: Bad string at line 4 column 0 of the JSON5 data. Still to read: "\n“spotify:{\n“clientI" at error (/Users/christophermurray/node-sonos-http-api-master/node_modules/json5/lib/json5.js:56:25) at string (/Users/christophermurray/node-sonos-http-api-master/node_modules/json5/lib/json5.js:268:13) at value (/Users/christophermurray/node-sonos-http-api-master/node_modules/json5/lib/json5.js:487:20) at object (/Users/christophermurray/node-sonos-http-api-master/node_modules/json5/lib/json5.js:459:35) at value (/Users/christophermurray/node-sonos-http-api-master/node_modules/json5/lib/json5.js:482:20) at Object.parse (/Users/christophermurray/node-sonos-http-api-master/node_modules/json5/lib/json5.js:508:18) at tryLoadJson (/Users/christophermurray/node-sonos-http-api-master/lib/helpers/try-load-json.js:8:33) at Object. (/Users/christophermurray/node-sonos-http-api-master/settings.js:28:22) at Module._compile (module.js:570:32) at Object.Module._extensions..js (module.js:579:10) 2017-06-21T20:59:02.323Z INFO Presets loaded: { presets: { test: { players: [ { roomName: 'Master Bedroom', volume: 30 } ], state: 'PLAYING', favorite: 'Rock', uri: 'x-rincon-stream:RINCON_0000000000001500', playMode: 'SHUFFLE', pauseOthers: true }, rap: { players: [ { roomName: 'Dining Room', volume: 30 }, { roomName: 'Living Room', volume: 30 }, { roomName: 'Master Bedroom', volume: 30 }, { roomName: 'Kitchen5', volume: 40 }, { roomName: 'KitchenWall', volume: 50 } ], state: 'PLAYING', favorite: 'Rap', uri: 'x-rincon-stream:RINCON_0000000000001500', playMode: 'SHUFFLE', pauseOthers: true }, 'pop rap': { players: [ { roomName: 'Dining Room', volume: 30 }, { roomName: 'Living Room', volume: 30 }, { roomName: 'Master Bedroom', volume: 30 }, { roomName: 'Kitchen5', volume: 40 }, { roomName: 'KitchenWall', volume: 50 } ], state: 'PLAYING', favorite: 'Rap (Pop)', uri: 'x-rincon-stream:RINCON_0000000000001500', playMode: 'SHUFFLE', pauseOthers: true }, rock: { players: [ { roomName: 'Dining Room', volume: 30 }, { roomName: 'Living Room', volume: 30 }, { roomName: 'Kitchen5', volume: 40 }, { roomName: 'Master Bedroom', volume: 30 }, { roomName: 'KitchenWall', volume: 50 } ], state: 'PLAYING', favorite: 'Rock', uri: 'x-rincon-stream:RINCON_0000000000001500', playMode: 'SHUFFLE', pauseOthers: true } } } 2017-06-21T20:59:04.240Z INFO http server listening on port 5005 (node:23452) Warning: Possible EventEmitter memory leak detected. 11 group-mute listeners added. Use emitter.setMaxListeners() to increase limit (node:23452) Warning: Possible EventEmitter memory leak detected. 11 last-change listeners added. Use emitter.setMaxListeners() to increase limit 2017-06-21T20:59:14.659Z ERROR Invalid music service

jplourde5 commented 7 years ago

Let's start over. Delete the settings.json file and ignore the Spotify exception.

Can you play Apple Music on your Sonos?

loftgren commented 7 years ago

ok... deleted. Now it says it can't find file. then the same Invalid Music Service message. I can play Spotify and Pandora... do I need to play Apple specifically?

jplourde5 commented 7 years ago

What music service do you have on Sonos?

BTW... You were missing a ". You can put this in your settings.json file to get rid of the error message.

{ "host": "localhost", "port": "5005”, “spotify":{ “clientId”:”dummy”, “clientSecret”:”dummy” } }

loftgren commented 7 years ago

I have Spotify and Pandora on Sonos.

Changed settings.json, but same thing: npm start

sonos-http-api@1.4.1 start /Users/christophermurray/node-sonos-http-api-master node server.js

2017-06-21T21:15:17.804Z WARN Could not read file /Users/christophermurray/node-sonos-http-api-master/settings.json, ignoring. SyntaxError: Bad string at line 4 column 0 of the JSON5 data. Still to read: "\n“spotify\":{\n“client" at error (/Users/christophermurray/node-sonos-http-api-master/node_modules/json5/lib/json5.js:56:25) at string (/Users/christophermurray/node-sonos-http-api-master/node_modules/json5/lib/json5.js:268:13) at value (/Users/christophermurray/node-sonos-http-api-master/node_modules/json5/lib/json5.js:487:20) at object (/Users/christophermurray/node-sonos-http-api-master/node_modules/json5/lib/json5.js:459:35) at value (/Users/christophermurray/node-sonos-http-api-master/node_modules/json5/lib/json5.js:482:20) at Object.parse (/Users/christophermurray/node-sonos-http-api-master/node_modules/json5/lib/json5.js:508:18) at tryLoadJson (/Users/christophermurray/node-sonos-http-api-master/lib/helpers/try-load-json.js:8:33) at Object. (/Users/christophermurray/node-sonos-http-api-master/settings.js:28:22) at Module._compile (module.js:570:32) at Object.Module._extensions..js (module.js:579:10) 2017-06-21T21:15:19.163Z INFO Presets loaded: { presets: { test: { players: [ { roomName: 'Master Bedroom', volume: 30 } ], state: 'PLAYING', favorite: 'Rock', uri: 'x-rincon-stream:RINCON_0000000000001500', playMode: 'SHUFFLE', pauseOthers: true }, rap: { players: [ { roomName: 'Dining Room', volume: 30 }, { roomName: 'Living Room', volume: 30 }, { roomName: 'Master Bedroom', volume: 30 }, { roomName: 'Kitchen5', volume: 40 }, { roomName: 'KitchenWall', volume: 50 } ], state: 'PLAYING', favorite: 'Rap', uri: 'x-rincon-stream:RINCON_0000000000001500', playMode: 'SHUFFLE', pauseOthers: true }, 'pop rap': { players: [ { roomName: 'Dining Room', volume: 30 }, { roomName: 'Living Room', volume: 30 }, { roomName: 'Master Bedroom', volume: 30 }, { roomName: 'Kitchen5', volume: 40 }, { roomName: 'KitchenWall', volume: 50 } ], state: 'PLAYING', favorite: 'Rap (Pop)', uri: 'x-rincon-stream:RINCON_0000000000001500', playMode: 'SHUFFLE', pauseOthers: true }, rock: { players: [ { roomName: 'Dining Room', volume: 30 }, { roomName: 'Living Room', volume: 30 }, { roomName: 'Kitchen5', volume: 40 }, { roomName: 'Master Bedroom', volume: 30 }, { roomName: 'KitchenWall', volume: 50 } ], state: 'PLAYING', favorite: 'Rock', uri: 'x-rincon-stream:RINCON_0000000000001500', playMode: 'SHUFFLE', pauseOthers: true } } } 2017-06-21T21:15:21.115Z INFO http server listening on port 5005 (node:23692) Warning: Possible EventEmitter memory leak detected. 11 group-mute listeners added. Use emitter.setMaxListeners() to increase limit (node:23692) Warning: Possible EventEmitter memory leak detected. 11 last-change listeners added. Use emitter.setMaxListeners() to increase limit

jplourde5 commented 7 years ago

Okay, now we are getting somewhere. You need to follow the readme instructions (copied below) on getting Spotify credentials and enter actual credentials instead of dummy/dummy. You will also want to enter your Pandora credentials if you want to use Pandora. Your settings.json file would then have the below with valid values filled in. Once you have this in place, you will issue the following command to Alexa "Ask Sonos to change music service to Spotify"

{ "pandora": { "username": "your-pandora-account-email-address", "password": "your-pandora-password" }, "spotify": { "clientId": "your-spotify-application-clientId", "clientSecret": "your-spotify-application-clientSecret" } }

Spotify Instructions Note for Spotify users!

To use Spotify, go to https://developer.spotify.com/my-applications/#!/applications/create and create a Spotify application to get your client keys. You can name it Sonos or anything else and you don't have to change any values. Use the Client ID and the Client Secret values in the settings.json file as indicated above.

loftgren commented 7 years ago

I am not at work now, so I will try this first thing tomorrow.

I can't thank you enough for you help and patience!

Best,

Chris

christopherwintermurray@gmail.com Cell: (207)266-9522

On Jun 21, 2017, 6:13 PM -0400, jplourde5 notifications@github.com, wrote:

Okay, now we are getting somewhere. You need to follow the readme instructions (copied below) on getting Spotify credentials and enter actual credentials instead of dummy/dummy. You will also want to enter your Pandora credentials if you want to use Pandora. Your settings.json file would then have the below with valid values filled in. Once you have this in place, you will issue the following command to Alexa "Ask Sonos to change music service to Spotify" { "pandora": { "username": "your-pandora-account-email-address", "password": "your-pandora-password" }, "spotify": { "clientId": "your-spotify-application-clientId", "clientSecret": "your-spotify-application-clientSecret" } } Spotify Instructions Note for Spotify users! To use Spotify, go to https://developer.spotify.com/my-applications/#!/applications/create and create a Spotify application to get your client keys. You can name it Sonos or anything else and you don't have to change any values. Use the Client ID and the Client Secret values in the settings.json file as indicated above. — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

loftgren commented 7 years ago

my settings.json now looks like this: { "pandora": { "username": “kmahaney@thelolympiacompanies.com”, "password": "Km9427235" }, "spotify": { "clientId": "c7ce9c57029f42aaa463197ffab054c7", "clientSecret": "57ac79a6c78c45b39eb0327610c57835" } }

loftgren commented 7 years ago

When I restarted in terminal this is the message: npm start

sonos-http-api@1.4.1 start /Users/christophermurray/node-sonos-http-api-master node server.js

2017-06-22T13:29:05.488Z WARN Could not read file /Users/christophermurray/node-sonos-http-api-master/settings.json, ignoring. SyntaxError: Unexpected '“' at line 3 column 13 of the JSON5 data. Still to read: "“kmahaney@thelolympi" at error (/Users/christophermurray/node-sonos-http-api-master/node_modules/json5/lib/json5.js:56:25) at word (/Users/christophermurray/node-sonos-http-api-master/node_modules/json5/lib/json5.js:393:13) at value (/Users/christophermurray/node-sonos-http-api-master/node_modules/json5/lib/json5.js:493:56) at object (/Users/christophermurray/node-sonos-http-api-master/node_modules/json5/lib/json5.js:459:35) at value (/Users/christophermurray/node-sonos-http-api-master/node_modules/json5/lib/json5.js:482:20) at object (/Users/christophermurray/node-sonos-http-api-master/node_modules/json5/lib/json5.js:459:35) at value (/Users/christophermurray/node-sonos-http-api-master/node_modules/json5/lib/json5.js:482:20) at Object.parse (/Users/christophermurray/node-sonos-http-api-master/node_modules/json5/lib/json5.js:508:18) at tryLoadJson (/Users/christophermurray/node-sonos-http-api-master/lib/helpers/try-load-json.js:8:33) at Object. (/Users/christophermurray/node-sonos-http-api-master/settings.js:28:22) 2017-06-22T13:29:07.258Z INFO Presets loaded: { presets: { test: { players: [ { roomName: 'Master Bedroom', volume: 30 } ], state: 'PLAYING', favorite: 'Rock', uri: 'x-rincon-stream:RINCON_0000000000001500', playMode: 'SHUFFLE', pauseOthers: true }, rap: { players: [ { roomName: 'Dining Room', volume: 30 }, { roomName: 'Living Room', volume: 30 }, { roomName: 'Master Bedroom', volume: 30 }, { roomName: 'Kitchen5', volume: 40 }, { roomName: 'KitchenWall', volume: 50 } ], state: 'PLAYING', favorite: 'Rap', uri: 'x-rincon-stream:RINCON_0000000000001500', playMode: 'SHUFFLE', pauseOthers: true }, 'pop rap': { players: [ { roomName: 'Dining Room', volume: 30 }, { roomName: 'Living Room', volume: 30 }, { roomName: 'Master Bedroom', volume: 30 }, { roomName: 'Kitchen5', volume: 40 }, { roomName: 'KitchenWall', volume: 50 } ], state: 'PLAYING', favorite: 'Rap (Pop)', uri: 'x-rincon-stream:RINCON_0000000000001500', playMode: 'SHUFFLE', pauseOthers: true }, rock: { players: [ { roomName: 'Dining Room', volume: 30 }, { roomName: 'Living Room', volume: 30 }, { roomName: 'Kitchen5', volume: 40 }, { roomName: 'Master Bedroom', volume: 30 }, { roomName: 'KitchenWall', volume: 50 } ], state: 'PLAYING', favorite: 'Rock', uri: 'x-rincon-stream:RINCON_0000000000001500', playMode: 'SHUFFLE', pauseOthers: true } } } 2017-06-22T13:29:09.240Z INFO http server listening on port 5005 (node:35687) Warning: Possible EventEmitter memory leak detected. 11 group-mute listeners added. Use emitter.setMaxListeners() to increase limit (node:35687) Warning: Possible EventEmitter memory leak detected. 11 last-change listeners added. Use emitter.setMaxListeners() to increase limit 2017-06-22T13:31:20.498Z ERROR Invalid music service

loftgren commented 7 years ago

This is the Lambda cloud watch log: 13:23:39 END RequestId: 00bf934d-574e-11e7-947b-7de7509aebab  13:23:39 REPORT RequestId: 00bf934d-574e-11e7-947b-7de7509aebab Duration: 697.21 ms Billed Duration: 700 ms Memory Size: 128 MB Max Memory Used: 41 MB  13:31:19 START RequestId: 1332846e-574f-11e7-8aad-078eb9dd2fcc Version: $LATEST  13:31:19 2017-06-22T13:31:19.525Z 1332846e-574f-11e7-8aad-078eb9dd2fcc session applicationId: amzn1.ask.skill.9c9e8114-79c1-46e9-b129-50f68b17f692  13:31:19 2017-06-22T13:31:19.525Z 1332846e-574f-11e7-8aad-078eb9dd2fcc dispatch intent = MusicRadioIntent  13:31:19 2017-06-22T13:31:19.525Z 1332846e-574f-11e7-8aad-078eb9dd2fcc MusicRadioIntent received  13:31:19 2017-06-22T13:31:19.525Z 1332846e-574f-11e7-8aad-078eb9dd2fcc Advanced Mode = true  13:31:20 2017-06-22T13:31:20.005Z 1332846e-574f-11e7-8aad-078eb9dd2fcc Reading current settings  13:31:20 2017-06-22T13:31:20.164Z 1332846e-574f-11e7-8aad-078eb9dd2fcc room=kitchen newRoom= service=pandora newService=  13:31:20 2017-06-22T13:31:20.165Z 1332846e-574f-11e7-8aad-078eb9dd2fcc Getting coordinator for room: kitchen  13:31:20 2017-06-22T13:31:20.165Z 1332846e-574f-11e7-8aad-078eb9dd2fcc Calling '/zones'  13:31:20 2017-06-22T13:31:20.415Z 1332846e-574f-11e7-8aad-078eb9dd2fcc Call to 'http://74.75.123.155:5005/zones' suceeded  13:31:20 2017-06-22T13:31:20.416Z 1332846e-574f-11e7-8aad-078eb9dd2fcc Coordinator for kitchen : Kitchen  13:31:20 2017-06-22T13:31:20.416Z 1332846e-574f-11e7-8aad-078eb9dd2fcc Calling '/kitchen/musicsearch/pandora/station/jazz%20anova'  13:31:20 2017-06-22T13:31:20.522Z 1332846e-574f-11e7-8aad-078eb9dd2fcc Call to 'http://74.75.123.155:5005/kitchen/musicsearch/pandora/station/jazz%20anova' failed 2017-06-22T13:31:20.522Z 1332846e-574f-11e7-8aad-078eb9dd2fcc Call to 'http://74.75.123.155:5005/kitchen/musicsearch/pandora/station/jazz%20anova' failed  13:31:20 2017-06-22T13:31:20.524Z 1332846e-574f-11e7-8aad-078eb9dd2fcc Error: Failed to retrieve data, status code: 500 at ClientRequest.lib.get (/var/task/sonosProxy/httpClient.js:13:17) at ClientRequest.g (events.js:291:16) at emitOne (events.js:96:13) at ClientRequest.emit (events.js:188:7) at HTTPParser.parserOnIncomingClient (_http_client.js:473:21) at HTTPParser.parserOnHeader 2017-06-22T13:31:20.524Z 1332846e-574f-11e7-8aad-078eb9dd2fcc Error: Failed to retrieve data, status code: 500 at ClientRequest.lib.get (/var/task/sonosProxy/httpClient.js:13:17) at ClientRequest.g (events.js:291:16) at emitOne (events.js:96:13) at ClientRequest.emit (events.js:188:7) at HTTPParser.parserOnIncomingClient (_http_client.js:473:21) at HTTPParser.parserOnHeadersComplete (_http_common.js:99:23) at Socket.socketOnData (_http_client.js:362:20) at emitOne (events.js:96:13) at Socket.emit (events.js:188:7) at readableAddChunk (_stream_readable.js:176:18)  13:31:20 END RequestId: 1332846e-574f-11e7-8aad-078eb9dd2fcc  13:31:20 REPORT RequestId: 1332846e-574f-11e7-8aad-078eb9dd2fcc Duration: 1068.77 ms Billed Duration: 1100 ms Memory Size: 128 MB Max Memory Used: 41 MB  13:40:23 START RequestId: 5769c89e-5750-11e7-852d-f59fa8dfff86 Version: $LATEST  13:40:23 2017-06-22T13:40:23.525Z 5769c89e-5750-11e7-852d-f59fa8dfff86 session applicationId: amzn1.ask.skill.9c9e8114-79c1-46e9-b129-50f68b17f692  13:40:23 2017-06-22T13:40:23.526Z 5769c89e-5750-11e7-852d-f59fa8dfff86 dispatch intent = PlayPresetIntent  13:40:23 2017-06-22T13:40:23.526Z 5769c89e-5750-11e7-852d-f59fa8dfff86 PlayPresetIntent received  13:40:23 2017-06-22T13:40:23.526Z 5769c89e-5750-11e7-852d-f59fa8dfff86 Calling '/preset/test'  13:40:23 2017-06-22T13:40:23.685Z 5769c89e-5750-11e7-852d-f59fa8dfff86 Call to 'http://74.75.123.155:5005/preset/test' suceeded  13:40:23 END RequestId: 5769c89e-5750-11e7-852d-f59fa8dfff86  13:40:23 REPORT RequestId: 5769c89e-5750-11e7-852d-f59fa8dfff86 Duration: 287.28 ms Billed Duration: 300 ms Memory Size: 128 MB Max Memory Used: 41 MB

l0cutis commented 7 years ago

Just to chip in,

Copying and pasting from the web has left you with smartquotes in your settings file, which can be hard to spot…

“ ” and " are three different characters, and the system can’t properly parse the first two.

It’s a bit of a chore, but if you could open your settings.json file in notepad, then go through and manually replace each of the quote marks, so they are the correct type (the one at the end ").

That should help :)

Cheers!

Nat

From: loftgren [mailto:notifications@github.com] Sent: 22 June 2017 14:37 To: rgraciano/echo-sonos echo-sonos@noreply.github.com Cc: Subscribed subscribed@noreply.github.com Subject: Re: [rgraciano/echo-sonos] Adds support for Open Sonos command (#176)

When I restarted in terminal this is the message: npm start

sonos-http-api@1.4.1 mailto:sonos-http-api@1.4.1 start /Users/christophermurray/node-sonos-http-api-master node server.js

2017-06-22T13:29:05.488Z WARN Could not read file /Users/christophermurray/node-sonos-http-api-master/settings.json, ignoring. SyntaxError: Unexpected '“' at line 3 column 13 of the JSON5 data. Still to read: "“kmahaney@thelolympi" at error (/Users/christophermurray/node-sonos-http-api-master/node_modules/json5/lib/json5.js:56:25) at word (/Users/christophermurray/node-sonos-http-api-master/node_modules/json5/lib/json5.js:393:13) at value (/Users/christophermurray/node-sonos-http-api-master/node_modules/json5/lib/json5.js:493:56) at object (/Users/christophermurray/node-sonos-http-api-master/node_modules/json5/lib/json5.js:459:35) at value (/Users/christophermurray/node-sonos-http-api-master/node_modules/json5/lib/json5.js:482:20) at object (/Users/christophermurray/node-sonos-http-api-master/node_modules/json5/lib/json5.js:459:35) at value (/Users/christophermurray/node-sonos-http-api-master/node_modules/json5/lib/json5.js:482:20) at Object.parse (/Users/christophermurray/node-sonos-http-api-master/node_modules/json5/lib/json5.js:508:18) at tryLoadJson (/Users/christophermurray/node-sonos-http-api-master/lib/helpers/try-load-json.js:8:33) at Object. (/Users/christophermurray/node-sonos-http-api-master/settings.js:28:22) 2017-06-22T13:29:07.258Z INFO Presets loaded: { presets: { test: { players: [ { roomName: 'Master Bedroom', volume: 30 } ], state: 'PLAYING', favorite: 'Rock', uri: 'x-rincon-stream:RINCON_0000000000001500', playMode: 'SHUFFLE', pauseOthers: true }, rap: { players: [ { roomName: 'Dining Room', volume: 30 }, { roomName: 'Living Room', volume: 30 }, { roomName: 'Master Bedroom', volume: 30 }, { roomName: 'Kitchen5', volume: 40 }, { roomName: 'KitchenWall', volume: 50 } ], state: 'PLAYING', favorite: 'Rap', uri: 'x-rincon-stream:RINCON_0000000000001500', playMode: 'SHUFFLE', pauseOthers: true }, 'pop rap': { players: [ { roomName: 'Dining Room', volume: 30 }, { roomName: 'Living Room', volume: 30 }, { roomName: 'Master Bedroom', volume: 30 }, { roomName: 'Kitchen5', volume: 40 }, { roomName: 'KitchenWall', volume: 50 } ], state: 'PLAYING', favorite: 'Rap (Pop)', uri: 'x-rincon-stream:RINCON_0000000000001500', playMode: 'SHUFFLE', pauseOthers: true }, rock: { players: [ { roomName: 'Dining Room', volume: 30 }, { roomName: 'Living Room', volume: 30 }, { roomName: 'Kitchen5', volume: 40 }, { roomName: 'Master Bedroom', volume: 30 }, { roomName: 'KitchenWall', volume: 50 } ], state: 'PLAYING', favorite: 'Rock', uri: 'x-rincon-stream:RINCON_0000000000001500', playMode: 'SHUFFLE', pauseOthers: true } } } 2017-06-22T13:29:09.240Z INFO http server listening on port 5005 (node:35687) Warning: Possible EventEmitter memory leak detected. 11 group-mute listeners added. Use emitter.setMaxListeners() to increase limit (node:35687) Warning: Possible EventEmitter memory leak detected. 11 last-change listeners added. Use emitter.setMaxListeners() to increase limit 2017-06-22T13:31:20.498Z ERROR Invalid music service

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/rgraciano/echo-sonos/pull/176#issuecomment-310382345 , or mute the thread https://github.com/notifications/unsubscribe-auth/AQ4mKP5sTCrmcVGO1JL64hq8wigO6XyPks5sGm4LgaJpZM4Nvjvw . https://github.com/notifications/beacon/AQ4mKE3jcG3Rnx10u6u9JIIPyr1kIwaZks5sGm4LgaJpZM4Nvjvw.gif

loftgren commented 7 years ago

Thanks very much. I did what you suggested and that fixed the error when I started npm. My problem still exists though... Invalid Music Service

loftgren commented 7 years ago

just noticed that when I use USE_SQS in Lambda, I get a token T error, and no error in my terminal window. When I delete it I get the invalid music service.

loftgren commented 7 years ago

Ok... i can type in "http://74.75.123.155:5005/kitchen/musicsearch/spotify/song/artist:Bruno%20Mars" and it works. But when I ask Alexa to do it I get the Invalid Music Service error in my npm terminal window. Progress?

loftgren commented 7 years ago

Though it does not work if I replace "spotify" with "pandora"

jplourde5 commented 7 years ago

Issue "Alexa, ask sons to change music service to Spotify"

Then try asking for an artist or track. Pandora is not currently part of musicSearch since it was radio-only. The command is "http://74.75.123.155:5005/kitchen/musicsearch/pandora/play/{station name}". The invocation is "tune to pandora {Name} in the {Room}".

You need to follow the readme instructions in echo-sql-proxy to get that to work. Works great btw.

loftgren commented 7 years ago

Im following the Read Me now... it says I need to add to the settings.json, but I already have my spotify and pandora info there?

jplourde5 commented 7 years ago

Different settings. Follow the instructions very carefully, line by line.

loftgren commented 7 years ago

The Lambda service encountered an error...unexpected token T in position 0

loftgren commented 7 years ago

unexpected token T in json at position 0

loftgren commented 7 years ago

18:16:15 2017-06-22T18:16:15.513Z d4fb5d51-5776-11e7-8d1f-4170dd3a7f79 SQS '/zones' failed 2017-06-22T18:16:15.513Z d4fb5d51-5776-11e7-8d1f-4170dd3a7f79 SQS '/zones' failed  18:16:15 2017-06-22T18:16:15.514Z d4fb5d51-5776-11e7-8d1f-4170dd3a7f79 TypeError: Cannot read property '0' of undefined at purgeQueue.then.then.then (/var/task/sonosProxy/sqsClient.js:20:44) at process._tickDomainCallback (internal/process/next_tick.js:135:7) 2017-06-22T18:16:15.514Z d4fb5d51-5776-11e7-8d1f-4170dd3a7f79 TypeError: Cannot read property '0' of undefined at purgeQueue.then.then.then (/var/task/sonosProxy/sqsClient.js:20:44) at process._tickDomainCallback (internal/process/next_tick.js:135:7)

loftgren commented 7 years ago

Could this be my issue?

elmedico27 commented 17 days ago Found my issue -- my echo-sqs-proxy was erroring out because it didn't have async installed. Didn't realize it at first because I was running the script in PM2, which I eventually noticed had a high number of restarts. Ran it on the command line with npm start and saw the error right away. As soon as I installed async, all of my SQS messages from my tests came pouring through.

I submitted pull request #178 which adds async as a dependency for echo-sqs-proxy.

jplourde5 commented 7 years ago

Did you follow the instructions closely and issue npm install --production ? If so, it should be there.

Are you still getting errors with the settings.json file. You have to use a plain text editor when editing the JSON files. Other editors use the wrong " character. You should not be getting any errors when you startup.

Also, by default, you need to be running the proxy solution on the same server that you are running node-sones-http-api on, or you have to specify the IP that n-s-h-a is running on in the settings file instead of using localhost.

loftgren commented 7 years ago

I have done all of that. Errors are fixed in the JSON files. When I include the variable USE_SQS 'true' in Lambda, it passes the test, but the test takes much longer than without it. Is that normal?

loftgren commented 7 years ago

And the lag time is almost 20 seconds when I ask Alexa to do anything with sonos... and i get the unexpected token T in position 0 error.

lemketron commented 7 years ago

@loftgren Probably should change your pandora password, btw... 😉

loftgren commented 7 years ago

Yes. Thank you😊

jplourde5 commented 7 years ago

:) lol I was going to say the same.

It is a bit slower, but shouldn't be that noticeable and should not be anywhere near 20 seconds. Where are you located and what region are you in? Keep in mind that it is totally optional. It simply keeps you from having to create any pinholes in your firewall.

loftgren commented 7 years ago

hi... back at it with no luck so far!

loftgren commented 7 years ago

I just don't get it... before this big update Spotify and Pandora worked without any additional setup... no key codes etc.. now nothing... what changed?