Code Monkey home page Code Monkey logo

node-sonos-http-api's Introduction

PayPal donate button Join the chat at gitter

⚠WARNING!⚠

The Sonos S2 update, released June 2020, still works with this API. However, it might break in the future if and when Sonos decide to drop UPnP as the control protocol.

Feel free to use it as you please. Consider donating if you want to support further development. Reach out on the gitter chat if you have issues getting it to run, instead of creating new issues, thank you!

If you are also looking for cloud control (ifttt, public webhooks etc), see the bronos-client project! That pi image also contains an installation of this http-api.

SONOS HTTP API

** Beta is no more, master is up to date with the beta now! **

This application requires node 4.0.0 or higher!

This should now work on Node 6+, please let me know if you have issues

A simple http based API for controlling your Sonos system.

There is a simple sandbox at /docs (incomplete atm)

USAGE

Start by fixing your dependencies. Invoke the following command:

npm install --production

This will download the necessary dependencies if possible.

start the server by running

npm start

Now you can control your system by invoking the following commands:

http://localhost:5005/zones
http://localhost:5005/lockvolumes
http://localhost:5005/unlockvolumes
http://localhost:5005/pauseall[/{timeout in minutes}]
http://localhost:5005/resumeall[/{timeout in minutes}]
http://localhost:5005/preset/{JSON preset}
http://localhost:5005/preset/{predefined preset name}
http://localhost:5005/reindex
http://localhost:5005/{room name}/sleep/{timeout in seconds or "off"}
http://localhost:5005/{room name}/sleep/{timeout in seconds or "off"}
http://localhost:5005/{room name}/{action}[/{parameter}]

Example:

http://localhost:5005/living room/volume/15 (will set volume for room Living Room to 15%)

http://localhost:5005/living room/volume/+1 (will increase volume by 1%)

http://localhost:5005/living room/next (will skip to the next track on living room, unless it's not a coordinator)

http://localhost:5005/living room/pause (will pause the living room)

http://localhost:5005/living room/favorite/mysuperplaylist (will replace queue with the favorite called "mysuperplaylist")

http://localhost:5005/living room/repeat/on (will turn on repeat mode for group)

The actions supported as of today:

  • play
  • pause
  • playpause (toggles playing state)
  • volume (parameter is absolute or relative volume. Prefix +/- indicates relative volume)
  • groupVolume (parameter is absolute or relative volume. Prefix +/- indicates relative volume)
  • mute / unmute
  • groupMute / groupUnmute
  • togglemute (toggles mute state)
  • trackseek (parameter is queue index)
  • timeseek (parameter is in seconds, 60 for 1:00, 120 for 2:00 etc)
  • next
  • previous
  • state (will return a json-representation of the current state of player)
  • favorite
  • favorites (with optional "detailed" parameter)
  • playlist
  • lockvolumes / unlockvolumes (experimental, will enforce the volume that was selected when locking!)
  • repeat (on(=all)/one/off(=none)/toggle)
  • shuffle (on/off/toggle)
  • crossfade (on/off/toggle)
  • pauseall (with optional timeout in minutes)
  • resumeall (will resume the ones that was pause on the pauseall call. Useful for doorbell, phone calls, etc. Optional timeout)
  • say
  • sayall
  • saypreset
  • queue
  • clearqueue
  • sleep (values in seconds)
  • linein (only analog linein, not PLAYBAR yet)
  • clip (announce custom mp3 clip)
  • clipall
  • clippreset
  • join / leave (Grouping actions)
  • sub (on/off/gain/crossover/polarity) See SUB section for more info
  • nightmode (on/off/toggle, PLAYBAR only)
  • speechenhancement (on/off/toggle, PLAYBAR only)
  • bass/treble (use -10 through to 10 as the value. 0 is neutral)

State

Example of a state json:

{
  "currentTrack":{
    "artist":"College",
    "title":"Teenage Color - Anoraak Remix",
    "album":"Nightdrive With You",
    "albumArtURI":"/getaa?s=1&u=x-sonos-spotify%3aspotify%253atrack%253a3DjBDQs8ebkxMBo2V8V3SH%3fsid%3d9%26flags%3d32",
    "duration":347,
    "uri":"x-sonos-spotify:spotify%3atrack%3a3DjBDQs8ebkxMBo2V8V3SH?sid=9&flags=32"
  },
  "nextTrack":{
    "artist":"Blacknuss",
    "title":"Thinking of You",
    "album":"3",
    "albumArtURI":"/getaa?s=1&u=x-sonos-spotify%3aspotify%253atrack%253a4U93TIa0X6jGQrTBGTkChH%3fsid%3d9%26flags%3d32",
    "duration":235,
    "uri":"x-sonos-spotify:spotify%3atrack%3a4U93TIa0X6jGQrTBGTkChH?sid=9&flags=32"
  },
  "volume":18,
  "mute":false,
  "trackNo":161,
  "elapsedTime":200,
  "elapsedTimeFormatted":"03:20",
  "zoneState":"PAUSED_PLAYBACK",
  "playerState":"PLAYING",
  "zonePlayMode":{
    "shuffle":true,
    "repeat":false,
    "crossfade":false
  },
  "equalizer": {
    "bass": 0,
    "treble": 0,
    "loudness": true
  }
}

Queue

Obtain the current queue list from a specified player. The request will accept:

  • limit (optional)

  • offset (optional, requires limit)

  • detailed flag (optional, include uri in response)

     http://localhost:5005/living room/queue
     http://localhost:5005/living room/queue/10 (only return top 10)
     http://localhost:5005/living room/queue/10/10 (return result 11-20)
     http://localhost:5005/living room/queue/detailed
     http://localhost:5005/living room/queue/10/detailed
    

Example queue response:

[
    {
      "albumArtURI": "/getaa?s=1&u=x-sonos-spotify%3aspotify%253atrack%253a0AvV49z4EPz5ocYN7eKGAK%3fsid%3d9%26flags%3d8224%26sn%3d3",
      "title": "No Diggity",
      "artist": "Blackstreet",
      "album": "Another Level"
    },
    {
      "albumArtURI": "/getaa?s=1&u=x-sonos-spotify%3aspotify%253atrack%253a5OQGeJ1ceykovrykZsGhqL%3fsid%3d9%26flags%3d8224%26sn%3d3",
      "title": "Breathless",
      "artist": "The Corrs",
      "album": "In Blue"
    }
]

Preset

A preset is a predefined grouping of players with predefined volumes, that will start playing whatever is in the coordinators queue.

Example preset (state and uri are optional):

{
  "players": [
    { "roomName": "room1", "volume": 15},
    {"roomName": "room2", "volume": 25}
  ],
  "state": "stopped",
  "favorite": "my favorite name",
  "uri": "x-rincon-stream:RINCON_0000000000001400",
  "playMode": {
    "shuffle": true
  },
  "pauseOthers": true
  "sleep": 600
}

The first player listed in the example, "room1", will become the coordinator. It will loose it's queue when ungrouped but eventually that will be fixed in the future. Playmode defines the three options "shuffle", "repeat", "crossfade" similar to the state Favorite will have precedence over a uri. pauseOthers will pause all zones before applying the preset, effectively muting your system. sleep is an optional value that enables the sleep timer and is defined in total seconds (600 = 10 minutes).

presets.json (deprecated, use preset files instead)

You can create a file with pre made presets, called presets.json. It will be loaded upon start, any changes requires a restart of the server.

Example content:

{
  "all": {
    "playMode": {
      "shuffle": true
    },
    "players": [
      {
        "roomName": "Bathroom",
        "volume": 10
      },
      {
        "roomName": "Kitchen",
        "volume": 10
      },
      {
        "roomName": "Office",
        "volume": 10
      },
      {
        "roomName": "Bedroom",
        "volume": 10
      },
      {
        "roomName": "TV Room",
        "volume": 15
      }
    ],
    "pauseOthers": true
  },
  "tv": {
    "players": [
      {
        "roomName": "TV Room",
        "volume": 20
      }
    ],
    "pauseOthers": true,
    "uri": "x-rincon-stream:RINCON_000XXXXXXXXXX01400"
  }
}

In the example, there is one preset called all, which you can apply by invoking:

http://localhost:5005/preset/all

presets folder

You can create a preset files in the presets folder with pre made presets. It will be loaded upon start, any changes made to files in this folder (addition, removal, modification) will trigger a reload of your presets. The name of the file (xxxxxx.json) will become the name of the preset. It will be parsed as JSON5, to be more forgiving of typos. See http://json5.org/ for more info.

Example content:

{
  "players": [
    {
      "roomName": "Bathroom",
      "volume": 10
    },
    {
      "roomName": "Kitchen",
      "volume": 10
    },
    {
      "roomName": "Office",
      "volume": 10
    },
    {
      "roomName": "Bedroom",
      "volume": 10
    },
    {
      "roomName": "TV Room",
      "volume": 15
    }
  ],
  "trackNo": 3,
  "elapsedTime": 42,
  "playMode": {
    "shuffle": true,
    "repeat": "all",
    "crossfade": false
  },
  "pauseOthers": false,
  "favorite": "My example favorite"
}

There is an example.json bundled with this repo. The name of the file will become the name of the preset.

settings.json

If you want to change default settings, you can create a settings.json file and put in the root folder. This will be parsed as JSON5, to be more forgiving. See http://json5.org/ for more info.

Available options are:

  • port: change the listening port
  • ip: change the listening IP
  • https: use https which requires a key and certificate or pfx file
  • auth: require basic auth credentials which requires a username and password
  • announceVolume: the percentual volume use when invoking say/sayall without any volume parameter
  • presetDir: absolute path to look for presets (folder must exist!)
  • household: when theres multiple sonos accounts on one network (example: Sonos_ab7d67898dcc5a6d, find it in [Your sonos IP]:1400/status/zp). Note that the value after the '.' should not be removed. See more info here: #783

Example:

	{
	  "voicerss": "Your api key for TTS with voicerss",
	  "microsoft": {
	    "key": "Your api for Bing speech API",
	    "name": "ZiraRUS"
	  },
	  "port": 5005,
	  "ip": "0.0.0.0",
	  "securePort": 5006,
	  "https": {
	    "key": "/path/to/key.pem",
	    "cert" : "/path/to/cert.pem"

	    //... for pfx (alternative configuration)
	    "pfx": "/path/to/pfx.pfx",
	    "passphrase": "your-passphrase-if-applicable"
	  },
	  "auth": {
	    "username": "admin",
	    "password": "password"
	  },
	  "announceVolume": 40,
	  "pandora": {
	    "username": "your-pandora-account-email-address",
	    "password": "your-pandora-password"
	  },
	  "spotify": {
	    "clientId": "your-spotify-application-clientId",
	    "clientSecret": "your-spotify-application-clientSecret"
	  },
	  "library": {
	    "randomQueueLimit": 50
	  }
	}

Override as it suits you.

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.

Favorites

It now has support for starting favorites. Simply invoke:

http://localhost:5005/living room/favorite/[favorite name]

and it will replace the queue with that favorite. Bear in mind that favorites may share name, which might give unpredictable behavior at the moment.

Playlist

Playing a Sonos playlist is now supported. Invoke the following:

http://localhost:5005/living room/playlist/[playlist name]

and it will replace the queue with the playlist and starts playing.

Say (TTS support)

Experimental support for TTS. Today the following providers are available:

  • voicerss
  • Microsoft Cognitive Services (Bing Text to Speech API)
  • AWS Polly
  • Google (default)
  • macOS say command
  • Elevenlabs

It will use the one you configure in settings.json. If you define settings for multiple TTS services, it will not be guaranteed which one it will choose!

VoiceRSS

This REQUIRES a registered API key from voiceRSS! See http://www.voicerss.org/ for info.

You need to add this to a file called settings.json (create if it doesn't exist), like this:

{
  "voicerss": "f5e77e1d42063175b9219866129189a3"
}

Replace the code above (it is just made up) with the api-key you've got after registering.

Action is:

/[Room name]/say/[phrase][/[language_code]][/[announce volume]]
/sayall/[phrase][/[language_code]][/[announce volume]]

Example:

/Office/say/Hello, dinner is ready
/Office/say/Hej, maten är klar/sv-se
/sayall/Hello, dinner is ready
/Office/say/Hello, dinner is ready/90
/Office/say/Hej, maten är klar/sv-se/90

language code needs to be before volume if specified.

Sayall will group all players, set 40% volume (by default) and then try and restore everything as the way it where. Please try it out, it will probably contain glitches but please report detailed descriptions on what the problem is (starting state, error that occurs, and the final state of your system).

The supported language codes are:

Language code Language
ca-es Catalan
zh-cn Chinese (China)
zh-hk Chinese (Hong Kong)
zh-tw Chinese (Taiwan)
da-dk Danish
nl-nl Dutch
en-au English (Australia)
en-ca English (Canada)
en-gb English (Great Britain)
en-in English (India)
en-us English (United States)
fi-fi Finnish
fr-ca French (Canada)
fr-fr French (France)
de-de German
it-it Italian
ja-jp Japanese
ko-kr Korean
nb-no Norwegian
pl-pl Polish
pt-br Portuguese (Brazil)
pt-pt Portuguese (Portugal)
ru-ru Russian
es-mx Spanish (Mexico)
es-es Spanish (Spain)
sv-se Swedish (Sweden)

Microsoft

This one also requires a registered api key. You can sign up for free here: https://www.microsoft.com/cognitive-services/en-US/subscriptions?mode=NewTrials and select "Bing Speech - Preview".

The following configuration is available (the entered values except key are default, and may be omitted):

	{
	  "microsoft": {
	    "key": "Your api for Bing speech API",
	    "name": "ZiraRUS"
	  }
	}

You change language by specifying a voice name correlating to the desired language. Name should be specified according to this list: https://www.microsoft.com/cognitive-services/en-us/speech-api/documentation/API-Reference-REST/BingVoiceOutput#SupLocales where name is the right most part of the voice font name (without optional Apollo suffix). Example:

Microsoft Server Speech Text to Speech Voice (ar-EG, Hoda) name should be specified as Hoda

Microsoft Server Speech Text to Speech Voice (de-DE, Stefan, Apollo) name should be specified as Stefan

Microsoft Server Speech Text to Speech Voice (en-US, BenjaminRUS) name should be specified as BenjaminRUS

Action is:

/[Room name]/say/[phrase][/[name]][/[announce volume]]
/sayall/[phrase][/[name]][/[announce volume]]

Example:

/Office/say/Hello, dinner is ready
/Office/say/Hello, dinner is ready/BenjaminRUS
/Office/say/Guten morgen/Stefan
/sayall/Hello, dinner is ready
/Office/say/Hello, dinner is ready/90
/Office/say/Guten morgen/Stefan/90

Supported voices are:

Hoda, Naayf, Ivan, HerenaRUS, Jakub, Vit, HelleRUS, Michael, Karsten, Hedda, Stefan, Catherine, Linda, Susan, George, Ravi, ZiraRUS, BenjaminRUS, Laura, Pablo, Raul, Caroline, Julie, Paul, Cosimo, Ayumi, Ichiro, Daniel, Irina, Pavel, HuihuiRUS, Yaoyao, Kangkang, Tracy, Danny, Yating, Zhiwei

See https://www.microsoft.com/cognitive-services/en-us/speech-api/documentation/API-Reference-REST/BingVoiceOutput#SupLocales to identify which language and gender it maps against. If your desired voice is not in the list of supported one, raise an issue about adding it or send me a PR.

AWS Polly

Requires AWS access tokens, which you generate for your user. Since this uses the AWS SDK, it will look for settings in either Environment variables, the ~/.aws/credentials or ~/.aws/config.

You can also specify it for this application only, using:

	{
	  "aws": {
	    "credentials": {
	      "region": "eu-west-1",
	      "accessKeyId": "Your access key id",
	      "secretAccessKey": "Your secret"
	    },
	    "name": "Joanna"
	  }
	}

To select the neural engine, append Neural to the name, e.g. DanielNeural.

Choose the region where you registered your account, or the one closest to you.

If you have your credentials elsewhere and want to stick with the default voice, you still need to make sure that the aws config option is set to trigger AWS TTS:

	{
	  "aws": {}
	}

Action is:

/[Room name]/say/[phrase][/[name]][/[announce volume]]
/sayall/[phrase][/[name]][/[announce volume]]

Example:

/Office/say/Hello, dinner is ready
/Office/say/Hello, dinner is ready/Nicole
/Office/say/Hej, maten är klar/Astrid
/sayall/Hello, dinner is ready
/Office/say/Hello, dinner is ready/90
/Office/say/Hej, maten är klar/Astrid/90

This is the current list of voice names and their corresponding language and accent (as of Dec 2016). To get a current list of voices, you would need to use the AWS CLI and invoke the describe-voices command.

Language Code Gender Name
Australian English en-AU Female Nicole
Australian English en-AU Male Russell
Brazilian Portuguese pt-BR Female Vitoria
Brazilian Portuguese pt-BR Male Ricardo
British English en-GB Male Brian
British English en-GB Female Emma
British English en-GB Female Amy
Canadian French fr-CA Female Chantal
Castilian Spanish es-ES Female Conchita
Castilian Spanish es-ES Male Enrique
Danish da-DK Female Naja
Danish da-DK Male Mads
Dutch nl-NL Male Ruben
Dutch nl-NL Female Lotte
French fr-FR Male Mathieu
French fr-FR Female Celine
German de-DE Female Marlene
German de-DE Male Hans
Icelandic is-IS Male Karl
Icelandic is-IS Female Dora
Indian English en-IN Female Raveena
Italian it-IT Female Carla
Italian it-IT Male Giorgio
Japanese ja-JP Female Mizuki
Norwegian nb-NO Female Liv
Polish pl-PL Female Maja
Polish pl-PL Male Jacek
Polish pl-PL Male Jan
Polish pl-PL Female Ewa
Portuguese pt-PT Female Ines
Portuguese pt-PT Male Cristiano
Romanian ro-RO Female Carmen
Russian ru-RU Female Tatyana
Russian ru-RU Male Maxim
Swedish sv-SE Female Astrid
Turkish tr-TR Female Filiz
US English en-US Male Justin
US English en-US Female Joanna
US English en-US Male Joey
US English en-US Female Ivy
US English en-US Female Salli
US English en-US Female Kendra
US English en-US Female Kimberly
US Spanish es-US Female Penelope
US Spanish es-US Male Miguel
Welsh cy-GB Female Gwyneth
Welsh English en-GB-WLS Male Geraint

Elevenlabs

Elevenlabs is a TTS service enabling generatiung TTS audio files using AI generated voices.

Requires API Key and optionally default voiceId.

Since Elevenlabs AI models are multilingual by default, there is no need (nor place) for language parameter in Elevenlabs API. Because of this, language parameter in URL is used to inject custom voiceId on per-request basis. You will need to either configure default voiceId in settings.json or provide voiceId with every HTTP request.

Config

Minimal:

	{
	  "elevenlabs": {
		"auth": {
		  "apiKey": ""
		}
	  }
	}

Full:

	{
	  "elevenlabs": {
		"auth": {
		  "apiKey": ""
		},
		"config": {
		  "voiceId": "",
		  "stability": 0.5,
		  "similarityBoost": 0.5,
		  "speakerBoost": true,
		  "style": 1,
		  "modelId": "eleven_multilingual_v2"
		}
	  }
	}

Google (default if no other has been configured)

Does not require any API keys. Please note that Google has been known in the past to change the requirements for its Text-to-Speech API, and this may stop working in the future. There is also limiations to how many requests one is allowed to do in a specific time period.

The following language codes are supported

Language code Language
af Afrikaans
sq Albanian
ar Arabic
hy Armenian
bn Bengali
ca Catalan
zh Chinese
zh-cn Chinese (Mandarin/China)
zh-tw Chinese (Mandarin/Taiwan)
zh-yue Chinese (Cantonese)
hr Croatian
cs Czech
da Danish
nl Dutch
en English
en-au English (Australia)
en-gb English (Great Britain)
en-us English (United States)
eo Esperanto
fi Finnish
fr Franch
de German
el Greek
hi Hindi
hu Hungarian
is Icelandic
id Indonesian
it Italian
ja Japanese
ko Korean
la Latin
lv Latvian
mk Macedonian
no Norwegian
pl Polish
pt Portuguese
pt-br Portuguese (Brazil)
ro Romanian
ru Russian
sr Serbian
sk Slovak
es Spanish
es-es Spanish (Spain)
es-us Spanish (United States)
sw Swahili
sv Swedish
ta Tamil
th Thai
tr Turkish
vi Vietnamese
cy Welsh

Action is:

/[Room name]/say/[phrase][/[language_code]][/[announce volume]]
/sayall/[phrase][/[language_code]][/[announce volume]]

macOS say command

On macOS the "say" command can be used for text to speech. If your installation runs on macOS you can activate the system TTS by giving an empty configuration:

{
  "macSay": {}
}

Or you can provide a default voice and a speech rate:

{
  "macSay": {
  	"voice" : "Alex",
  	"rate": 90
  }
}

Action is:

/[Room name]/say/[phrase][/[voice]][/[announce volume]]
/sayall/[phrase][/[voice]][/[announce volume]]

Example:

/Office/say/Hello, dinner is ready
/Office/say/Hello, dinner is ready/Agnes
/Office/say/Guten morgen/Anna
/sayall/Hello, dinner is ready
/Office/say/Hello, dinner is ready/90
/Office/say/Guten morgen/Anna/90

Supported voices are:

Alex, Alice, Alva, Amelie, Anna, Carmit, Damayanti, Daniel, Diego, Ellen, Fiona, Fred, Ioana, Joana, Jorge, Juan, Kanya, Karen, Kyoko, Laura, Lekha, Luca, Luciana, Maged, Mariska, Mei-Jia, Melina, Milena, Moira, Monica, Nora, Paulina, Samantha, Sara, Satu, Sin-ji, Tessa, Thomas, Ting-Ting, Veena, Victoria, Xander, Yelda, Yuna, Yuri, Zosia, Zuzana

A list of available voices can be printed by this command:

   say -v '?'

See also https://gist.github.com/mculp/4b95752e25c456d425c6 and https://stackoverflow.com/questions/1489800/getting-list-of-mac-text-to-speech-voices-programmatically

To download more voices go to: System Preferences -> Accessibility -> Speech -> System Voice

Line-in

Convenience method for selecting line in. Will select linein for zone-group, not detach it for line-in. Optional parameter is line-in from another player. Examples:

/Office/linein Selects line-in on zone Office belongs to, with source Office.

/Office/linein/TV%20Room Selects line-in for zone Office belongs to, with source TV Room.

If you want to to isolate a player and then select line-in, use the /Office/leave first.

Clip

Like "Say" but instead of a phrase, reference a custom track from the static/clips folder. There is a sample file available (courtesy of https://www.sound-ideas.com/).

/{Room name}/clip/{filename}[/{announce volume}]
/clipall/{filename}[/{announce volume}]

Examples:

/clipall/sample_clip.mp3
/clipall/sample_clip.mp3/80
/Office/clip/sample_clip.mp3
/Office/clip/sample_clip.mp3/30

Pro-tip: announce your arrival with an epic theme song!

Grouping

You have basic grouping capabilities. join will join the selected player to the specified group (specify group by addressing any of the players in that group):

/Kitchen/join/Office This will join the Kitchen player to the group that Office currently belong to.

/Kitchen/leave Kitchen will leave any group it was part of and become a standalone player.

You don't have to ungroup a player in order to join it to another group, just join it to the new group and it will jump accordingly.

SUB

SUB actions include the following: /TV%20Room/sub/off Turn off sub

/TV%20Room/sub/on Turn on sub

/TV%20Room/sub/gain/3 Adjust gain, -15 to 15. You can make bigger adjustments, but I'm limiting it for now because it might damage the SUB.

/TV%20Room/sub/crossover/90 adjust crossover frequency in hz. Official values are 50 through 110 in increments of 10. Use other values at your own risk! My SUB gave a loud bang and shut down when setting this to high, and I thought I broke it. However, a restart woke it up again.

/TV%20Room/sub/polarity/1 Switch "placement adjustment" or more commonly known as phase. 0 = 0°, 1 = 180°

Spotify, Apple Music and Amazon Music (Experimental)

Allows you to perform your own external searches for Spotify, Apple Music or Amazon Music songs or albums and play a specified song or track ID. The Music Search funtionality outlined further below performs a search of its own and plays the specified music.

Ensure you have added and registered the respective service with your Sonos account, before trying to control your speakers with node-sonos-http-api. Instructions on how to do this can be found here: https://support.sonos.com/s/article/2757?language=en_US

The following endpoints are available:

# Spotify
/RoomName/spotify/now/spotify:track:4LI1ykYGFCcXPWkrpcU7hn
/RoomName/spotify/next/spotify:track:4LI1ykYGFCcXPWkrpcU7hn
/RoomName/spotify/queue/spotify:track:4LI1ykYGFCcXPWkrpcU7hn

# Apple Music
/RoomName/applemusic/{now,next,queue}/song:{songID}
/RoomName/applemusic/{now,next,queue}/album:{albumID}

# Amazon Music
/RoomName/amazonmusic/{now,next,queue}/song:{songID}
/RoomName/amazonmusic/{now,next,queue}/album:{albumID}

Spotify

You can find the Spotify track and album IDs as the last part of the URL.

How to find the URL?

  • Web player: the address bar URL for albums and playlist; select Copy Song Link from the dot menu.
  • Desktop client: via Share > Copy {Album,Playlist,Song} Link
  • Mobile client: via Share > Copy Link

For Spotify playlists, you'll need this format: spotify:user:spotify:playlist:{playlistid}. Even if it's a public playlist, you always need to prefix with spotify:user:. An example of a great playlist: /kitchen/spotify/now/spotify:user:spotify:playlist:32O0SSXDNWDrMievPkV0Im.

To get more technical, you actually use the Spotify URI (not URL) for the endpoint, like so: {room}/spotify/{now,next,queue}/{spotifyuri}.

It only handles a single spotify account currently. It will probably use the first account added on your system.

Apple Music

You can find Apple Music song and album IDs via the iTunes Search API.

You can also use iTunes to figure out song and album IDs. Right click on a song or album and select "Share" -> "Copy Link". You can do this when you searched within Apple Music or from your media library as long as the song is available in Apple Music.

Have a look at the link you just copied.

If you shared the link to a song: The format is: https://itunes.apple.com/de/album/{songName}/{albumID}?i={songID}

eg: https://itunes.apple.com/de/album/blood-of-my-enemies/355363490?i=355364259

If you shared the link to an album: The format is: https://itunes.apple.com/de/album/{albumName}/{albumID}

eg: https://itunes.apple.com/de/album/f-g-restless/355363490

Amazon Music

To find Amazon Music song and album IDs you can use the Amazon Music App, search for a song or an album and share a link.

Look at the link you just shared. This works with Amazon Music Prime as well as with Amazon Music Prime which is included in your Amazon Prime membership.

If you shared the link to a song: The format is: https://music.amazon.de/albums/{albumID}?trackAsin={songID}&ref=dm_sh_d74d-4daa-dmcp-63cb-e8747&musicTerritory=DE&marketplaceId=A1PA6795UKMFR9

eg: https://music.amazon.de/albums/B0727SH7LW?trackAsin=B071918VCR&ref=dm_sh_d74d-4daa-dmcp-63cb-e8747&musicTerritory=DE&marketplaceId=A1PA6795UKMFR9

If you shared the link to an album: The format is: https://music.amazon.de/albums/{albumID}?ref=dm_sh_97aa-255b-dmcp-c6ba-4ff00&musicTerritory=DE&marketplaceId=A1PA6795UKMFR9

eg: https://music.amazon.de/albums/B0727SH7LW?ref=dm_sh_97aa-255b-dmcp-c6ba-4ff00&musicTerritory=DE&marketplaceId=A1PA6795UKMFR9

BBC Sounds (as of 2022 only available in the UK)

Ensure you have added and registered the BBC Sounds service with your Sonos account, before trying to control your speakers with node-sonos-http-api. Instructions on how to do this can be found here: https://www.bbc.co.uk/sounds/help/questions/listening-on-a-smart-speaker/sonos or here: https://support.sonos.com/s/article/2757?language=en_US

You can specify a BBC station and the station will be played or set depending on the command used.

To play immediately:

/RoomName/bbcsounds/play/{stream code}

To set the station without playing:

/RoomName/bbcsounds/set/{stream code}

Refer to the table below for available codes for BBC Radio Stations

BBC Radio Station Name Stream Code
BBC Radio 1 bbc_radio_one
BBC 1Xtra bbc_1xtra
BBC 1Dance bbc_radio_one_dance
BBC 1Relax bbc_radio_one_relax
BBC Radio 2 bbc_radio_two
BBC Radio 3 bbc_radio_three
BBC Radio 4 FM bbc_radio_fourfm
BBC Radio 4 LW bbc_radio_fourlw
BBC Radio 4 Extra bbc_radio_four_extra
BBC Radio 5 Live bbc_radio_five_live
BBC Radio 5 Live Sports Extra bbc_five_live_sports_extra
BBC Radio 6 Music bbc_6music
BBC Asian Network bbc_asian_network
BBC Radio Berkshire bbc_radio_berkshire
BBC Radio Bristol bbc_radio_bristol
BBC Radio Cambridge bbc_radio_cambridge
BBC Radio Cornwall bbc_radio_cornwall
BBC Radio Cumbria bbc_radio_cumbria
BBC Radio Cymru bbc_radio_cymru
BBC Radio Cymru 2 bbc_radio_cymru_2
BBC Radio CWR bbc_radio_coventry_warwickshire
BBC Radio Derby bbc_radio_derby
BBC Radio Devon bbc_radio_devon
BBC Radio Essex bbc_radio_essex
BBC Radio Foyle bbc_radio_foyle
BBC Radio Gloucestershire bbc_radio_gloucestershire
BBC Radio Guernsey bbc_radio_guernsey
BBC Radio Hereford Worcester bbc_radio_hereford_worcester
BBC Radio Humberside bbc_radio_humberside
BBC Radio Jersey bbc_radio_jersey
BBC Radio Kent bbc_radio_kent
BBC Radio Lancashire bbc_radio_lancashire
BBC Radio Leeds bbc_radio_leeds
BBC Radio Leicester bbc_radio_leicester
BBC Radio Lincolnshire bbc_radio_lincolnshire
BBC Radio London bbc_london
BBC Radio Manchester bbc_radio_manchester
BBC Radio Merseyside bbc_radio_merseyside
BBC Radio nan Gaidheal bbc_radio_nan_gaidheal
BBC Radio Newcastle bbc_radio_newcastle
BBC Radio Norfolk bc_radio_norfolk
BBC Radio Northampton bbc_radio_northampton
BBC Radio Nottingham bbc_radio_nottingham
BBC Radio Oxford bbc_radio_oxford
BBC Radio Scotland FM bbc_radio_scotland_fm
BBC Radio Scotland Extra bbc_radio_scotland_mw
BBC Radio Sheffield bbc_radio_sheffield
BBC Radio Shropshire bbc_radio_shropshire
BBC Radio Solent bbc_radio_solent
BBC Radio Somerset bbc_radio_somerset_sound
BBC Radio Stoke bbc_radio_stoke
BBC Radio Suffolk bbc_radio_suffolk
BBC Radio Surrey bbc_radio_surrey
BBC Radio Sussex bbc_radio_sussex
BBC Radio Tees bbc_tees
BBC Radio Three Counties Radio bbc_three_counties_radio
BBC Radio Ulster bbc_radio_ulster
BBC Radio Wales bbc_radio_wales_fm
BBC Radio Wales Extra bbc_radio_wales_am
BBC Radio Wiltshire bbc_radio_wiltshire
BBC Radio WM bbc_wm
BBC Radio York bbc_radio_york
BBC World_Service bbc_world_service
Cbeebies Radio cbeebies_radio

SiriusXM

You can specify a SiriusXM channel number or station name and the station will be played.

/RoomName/siriusXM/{channel number,station name}

Pandora

Perform a search for one of your Pandora stations and begin playing. Give the currently playing song a thumbs up or thumbs down. Requires a valid Pandora account and credentials.

The following endpoints are available:

/RoomName/pandora/play/{station name}     Plays the closest match to the specified station name in your list of Pandora stations
/RoomName/pandora/thumbsup                Gives the current playing Pandora song a thumbs up
/RoomName/pandora/thumbsdown              Gives the current playing Pandora song a thumbs down

Your Pandora credentials need to be added to the settings.json file

       ,
       "pandora": {
         "username": "your-pandora-account-email-address",
         "password": "your-pandora-password"
       }

Tunein

Given a station id this will play or set the streaming broadcast via the tunein service. You can find tunein station ids via services like radiotime

The following endpoint is available:

/RoomName/tunein/play/{station id}
Will set and start playing given Station id

/RoomName/tunein/set/{station id}
Will set without start playing given Station id

For example to play Radio 6 Music - tunein.com/radio/s44491

/RoomName/tunein/play/44491
note the droping of the 's' in 's44491'

Music Search and Play

Perform a search for a song, artist, album or station and begin playing. Supports Apple Music, Spotify, Deezer, Deezer Elite, and your local Music Library.

The following endpoint is available:

/RoomName/musicsearch/{service}/{type}/{search term}

Service options: apple, spotify, deezer, elite, library

Type options for apple, spotify, deezer, and elite: album, song, station, playlist
Station plays a Pandora like artist radio station for a specified artist name.
Apple Music also supports song titles and artist name + song title.

Type options for library: album, song, load
Load performs an initial load or relaod of the local Sonos music library.
The music library will also get loaded the first time that the library service is
used if the load command has not been issued before.

Search terms for song for all services: artist name, song title, artist name + song title
Search terms for album for all services: artist name, album title, artist name + album title

Search terms for station for apple: artist name, song title, artist name + song title
Search terms for station for spotify and deezer: artist name
Search terms for station for library: not supported

Specifying just an artist name will load the queue with up to 50 of the artist's most popular songs
Specifying a song title or artist + song title will insert the closest match to the song into
the queue and start playing it. More than 50 tracks can be loaded from the local library by using
library.randomQueueLimit in the settings.json file to set the maximum to a higher value.

Examples:
/Den/musicsearch/spotify/song/red+hot+chili+peppers
/Kitchen/musicsearch/apple/song/dark+necessities
/Playroom/musicsearch/library/song/red+hot+chili+peppers+dark+necessities

/Den/musicsearch/spotify/album/abbey+road
/Playroom/musicsearch/library/album/red+hot+chili+peppers+the+getaway
/Kitchen/musicsearch/spotify/album/dark+necessities

/Kitchen/musicsearch/spotify/playlist/morning+acoustic
/Kitchen/musicsearch/spotify/playlist/dinner+with+friends

/Den/musicsearch/spotify/station/red+hot+chili+peppers
/Kitchen/musicsearch/apple/station/dark+necessities  (Only Apple Music supports song titles)
/Playroom/musicsearch/apple/station/red+hot+chili+peppers+dark+necessities  (Only Apple Music supports song titles)

/Kitchen/musicsearch/library/load  (Loads or reloads the music library from Sonos)

Experiment with these and leave feedback!

Webhook

NOTE! This is experimental and might change in the future! Please leave your feedback as github issues if you feel like it doesn't suit your need, since I don't know what kind of restrictions you will be facing.

Since 0.17.x there is now support for a web hook. If you add a setting in settings.json like this:

{
  "webhook": "http://localhost:5007/"
}

Every state change and topology change will be posted (method POST) to that URL, as JSON. The following data structure will be sent:

{
  "type": "transport-state",
  "data": { (snapshot of player) }
}

or

{
  "type": "topology-change",
  "data": { (snapshot of zones) }
}
{
  "type": "volume-change",
  "data": {
    "uuid": "RINCON_000000000000001400",
    "previousVolume": 14,
    "newVolume": 16,
    "roomName": "Office"
  }
}
{
  "type": "mute-change",
  "data": {
    "uuid": "RINCON_000000000000001400",
    "previousMute": true,
    "previousMute": false,
    "roomName": "Office"
  }
}

"data" property will be equal to the same data as you would get from /RoomName/state or /zones. There is an example endpoint in the root if this project called test_endpoint.js which you may fire up to get an understanding of what is posted, just invoke it with "node test_endpoint.js" in a terminal, and then start the http-api in another terminal.

Server Sent Events

As an alternative to the web hook you can also call the /events endpoint to receive every state change and topology change as Server Sent Event. Compared to the web hook there is no configuration required on the server, and you can listen for events from multiple clients.

Because it is a long-polling connection, you must take care of errors in your client code and re-connect if necessary.

The server sends events formatted as single-line JSON in the format of Server Sent Events: every event starts with the string data: , followed by the single-line JSON formatted event, and is terminated by two new line characters.

There are several client libraries available to listen for Server Sent Events. Using curl yields the following output for some volume changes:

host:~ user$ curl localhost:5005/events
data: {"type":"volume-change","data":{"uuid":"RINCON_E2832F58D9074C45B","previousVolume":13,"newVolume":19,"roomName":"Office"}}

data: {"type":"volume-change","data":{"uuid":"RINCON_E2832F58D9074C45B","previousVolume":19,"newVolume":25,"roomName":"Office"}}

data: {"type":"volume-change","data":{"uuid":"RINCON_E2832F58D9074C45B","previousVolume":25,"newVolume":24,"roomName":"Office"}}

data: {"type":"volume-change","data":{"uuid":"RINCON_E2832F58D9074C45B","previousVolume":23,"newVolume":23,"roomName":"Office"}}

DOCKER

Docker usage is maintained by Chris Nesbitt-Smith at chrisns/docker-node-sonos-http-api

FIREWALL

If you are running this in an environment where you manually have to unblock traffic to and from the machine, the following traffic needs to be allowed:

Incoming

TCP, port 3500 (Sonos events)
UDP, port 1905 (Sonos initial discovery)
TCP, port 5005 (if using the default api port)
TCP, port 5006 (if using https support, optional)

Outgoing

TCP, port 1400 (Sonos control commands)
UDP, port 1900 (Sonos initial discovery)
TCP, whatever port used for webhooks (optional)
TCP, port 80/443 (for looking up hig res cover arts on various music services)

The UDP traffic is a mixture of multicast (outgoing), broadcast (outgoing) and unicast (incoming). The multicast address is 239.255.255.250, the broadcast is 255.255.255.255 and the unicast is from the Sonos players.

If port 3500 is occupied while trying to bind it, it will try using 3501, 3502, 3503 etc. You would need to adjust your firewall rules accordingly, if running multiple instances of this software, or any other software utilizing these ports.

Projects built with this API

Alexa For Sonos (Alexa Skills)

Amazon Alexa voice layer on top of the amazing NodeJS component https://github.com/hypermoose/AlexaForSonos

Echo Sonos (Alexa Skills)

Amazon Echo integration with Sonos https://github.com/rgraciano/echo-sonos

JukeBot (Ruby)

A Slack bot that can control a Sonos instance. Custom spotify integration to find music. https://github.com/estiens/jukebot

Sonos Controller (JS / Electron)

A Sonos controller, built with the Electron framework. https://github.com/anton-christensen/sonos-controller

Sonos Cron (PHP)

Service for retrieving commands from an AWS SQS queue and passing them to an instance of the Sonos HTTP API https://github.com/cjrpaterson/sonos-cron

Sonos Push Server (JS)

A Node server to receive notifications from node-sonos-http-api and push them via socket.io to the clients. https://github.com/TimoKorinth/sonos-push-server

SonoBoss (Siri Shortcut)

A ChatGPT-assisted Siri Shortcut that acts as a virtual assistant to let you find music and control Sonos through voice and chat. https://github.com/Barloew/SonoBoss

node-sonos-http-api's People

Contributors

ashenshugarret avatar brase avatar brjpeters avatar connor-knabe avatar crissmil avatar dohall avatar fehguy avatar garycaldwell avatar goran58 avatar jishi avatar jplourde5 avatar jsiegenthaler avatar kienz avatar klaas avatar lukekarrys avatar maddox avatar markdstjohn avatar matiasgarciaisaia avatar maxrei-dev avatar mgorsk1 avatar michaelcampbell avatar mjbnz avatar pettersamuelsen avatar philhawthorne avatar riemers avatar rkokie avatar smurthas avatar sseiber avatar timotto avatar xfjx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-sonos-http-api's Issues

won't start on my newl installed raspi

I'm not sure what I'm doing wrong but I've installed to a new raspi (using "npm install") but when I try and run "node server.js" I get the following error. Any help appreciated.

no settings file found, will only use default settings
http server listening on port 5005
no preset file, ignoring...

==== Stack trace ============================================
Security context: 0x4fd34659 <JS Object>#0#
1: parse(aka parse) [/home/pi/node-sonos-http-api/node_modules/sonos-discovery/node_modules/easysax/easysax.js:~403](this=0x4fd08091 <undefined>,xml=0x306c0bd1 <Very long string[1100]>#1#)
2: parse [/home/pi/node-sonos-http-api/node_modules/sonos-discovery/node_modules/easysax/easysax.js:142](this=0x306c1891 <an EasySAXParser>#2#,xml=0x306c0bd1 <Very long string[1100]>#1#)
3: /\* anonymous _/ [/home/pi/node-sonos-http-api/node_modules/sonos-discovery/lib/sonos.js:271](this=0x306c0325 <an IncomingMessage>#3#)
4: emit [events.js:92](this=0x306c0325 <an IncomingMessage>#3#,type=0x3910f03d <String[3]: end)
5: /_ anonymous */ [_stream_readable.js:944](this=0x4fd34701 <JS Global Object>#4#)
6: _tickCallback [node.js:442](this=0x2d87d921 <a process>#5#)
==== Details ================================================
[1]: parse(aka parse) [/home/pi/node-sonos-http-api/node_modules/sonos-discovery/node_modules/easysax/easysax.js:~403](this=0x4fd08091 <undefined>,xml=0x306c0bd1 <Very long string[1100]>#1#)...

There is more to the error if needed.

TTS doesn't resume TV on Playbar

Hi,
When using TTS 'say' with Playbar while watching/listening to TV it fails to resume afterwards, and needs to be manually set back to TV.

Thanks,
Tom

cannot communicate to dev

hi, after running node server.js I am getting the following:

no settings file found, will only use default settings binding SSDP to port 2319 discovering all IPs from lo0 discovering all IPs from en0 discovering all IPs from awdl0 relevant IPs { '192.168.1.79': null } notification server listening on port 3500 http server listening on port 5005 no preset file, ignoring... scanning for players in ip 192.168.1.79

and then when trying to make a GET on localhost:5005 with /zones,
I am getting this:

node-sonos-http-api/lib/actions/zones.js:2 callback(player.discovery.getZones()); ^ TypeError: Cannot read property 'discovery' of null

any ideas?

crossfade, shuffle, and repeat state

I noticed that you added crossfade, shuffle, and repeat triggering support in the last version. Are you planning on adding the corresponding "state" for those also. Openremote wont let you create a switch without being able obtain the status/state for the attribute associated with the switch.

restore state after say / sayAll

It would be very nice, when the music will continue to play after the announcement. As a alternative it should be possible to restart music with the play/pause- button / http-call. Currently only the say-command is repeated after pressing the button. Skipping the TTS-Track is also not possible.
In addition with sayAll it happens that the playlist after the merge and split is not the same like before the say-command. One playlist wins and is copied to all devices.

Error when trying to set volume: forGroup is not defined

TransportState
{ room: 'BasementOffice', action: 'volume', value: '1' }
current volume 39

/Volumes/Data/Scripts/node-sonos-http-api-master/node_modules/sonos-discovery/lib/sonos.js:620
console.log('setting volume', volumeLevel, 'for Group', forGroup);
^
ReferenceError: forGroup is not defined

server not starting

I followed the two steps from the readme.md with npm install and node server.js. npm install seems to do everything as expected. executing node server.js throws no error, but afterwards no server is running. it is just coming back to command line input. any idea?

cross domain error

I have install your nice api to sonos on a raspberry, it is working well calling it from a browser in my network with 192.168.0.32:5005/xxx/play.
when I try to call from another web frontend, also running on the rasp, using a small javascript xmlhttprequest get http://192.168.0.32:5005/xxx/play, I get into cross domain trouble: Origin http://192.168.0.32:3000 is not allowed by Access-Control-Allow-Origin.
So I'm trying to find the place in your code to put in the allow-...
I'm very new to rasp, web, html,.. so maybe this is all wrong, but it seems so close to be solved

No command line after running node server.js

Should I see a command prompt to test the server after running node server.js? Seems to just lock up.

pi@raspberrypi ~ $ npm install
npm WARN package.json [email protected] No license field.
pi@raspberrypi ~ $ node server.js
no settings file found, will only use default settings
http server listening on port 5005
loaded presets { test:
{ players: [ [Object] ],
state: 'PLAYING',
favorite: 'Rock',
uri: 'x-rincon-stream:RINCON_0000000000001500',
playMode: 'SHUFFLE',
pauseOthers: true },
rap:
{ players: [ [Object], [Object], [Object], [Object], [Object] ],
state: 'PLAYING',
favorite: 'Rap',
uri: 'x-rincon-stream:RINCON_0000000000001500',
playMode: 'SHUFFLE',
pauseOthers: true },
'pop rap':
{ players: [ [Object], [Object], [Object], [Object], [Object] ],
state: 'PLAYING',
favorite: 'Rap (Pop)',
uri: 'x-rincon-stream:RINCON_0000000000001500',
playMode: 'SHUFFLE',
pauseOthers: true },
rock:
{ players: [ [Object], [Object], [Object], [Object], [Object] ],
state: 'PLAYING',
favorite: 'Rock',
uri: 'x-rincon-stream:RINCON_0000000000001500',
playMode: 'SHUFFLE',
pauseOthers: true } }

How to send status update to other devices?

Hi!

First I want to tell you that your work is really impressive! Great job there!!

I haves more a question than an issue. Could you point me on how to add notification to other devices? What I'm trying to do is to send an http request to update the status in real time.

For example, I have an amp that I can control through a box that send IR codes and that I can trigger through http request. My goal would be that if I start/stop the Sonos player that is hooked to that amp, to send an http request to turn the amp on/off.
How could I add this to your existing code? I've tried to looked into it, but I don't know enough about node to figure it out?
Many thanks for any help!

David

no connection after power failure

If a Sonos participant was unplugged and then reconnected, you can not access to this participant via the API until the node-http-api-sonos server has been restarted. Via the Sonos app it is possible to access this participant. To all other Sonos participants that were not dis- and reconnected, can still be accessed without any problems.

Is it possible to introduce a UPnP reconnect?

I have often the problem that a Sonos participant restarts (empty playlist) and it thus behaves like after a power failure.

Server Hangs On Start

Hi there, I just grabbed the latest version and ran npm install and the server is hanging on start after checking the presets. I tried starting without the preset file but it does the same thing, any thoughts?

Thanks for the help!

Multiple NIC support

Hi there,

Due to the protocols used by Sonos all devices need to be in the same network subnet.

When there are multiple NICs in a system, "server.js" always uses the first NIC, which is not always the NIC where the Sonos devices are located.

Would it be possible to allow specifying a bind address for server.js in order to make sure it is using the right network?

incorrect mute state

The following chain of commands gives an incorrect mute status on my system:

1st command:
http://localhost:5005/kitchen/mute
=> http://localhost:5005/kitchen/state gives "mute":true

2nd command:
http://localhost:5005/kitchen/volume/15
=> http://localhost:5005/kitchen/state gives "mute":false, when the sonos controller app correctly shows the room as still muted

I tried with solo room and grouped rooms, same result: changing the volume on a muted room keeps it muted for real but the state method returns 'mute:false'

Any clue? Is it just on my system?

Add url hook configuration

Add an optional configuration parameter that would receive a JSON state object for common changes.

Maybe additionally have global and optional room filtered url hooks.

Please subscribe and comment if you are interested in this, and describe your use case if possible.

setavtransporturi example

Hi all

Does anyone have an example of the SetAVTransportURI REST request working? I'm trying to load a particular mp3 file from a location on the server, but its just not happening. Suspect my URL structure is wrong, but I'm pulling my hair out.

Many thanks.

Rob

wrong player/zone states

Since the latest version the player / zone states are not set correctly. They are always in STOPPED.
"zoneState": "STOPPED",
"playerState": "STOPPED",

Also the times do not seem to be set correctly.
"elapsedTime": 0,
"elapsedTimeFormatted": "00:00",

I'm using node v0.10.26.

Album Art URL gets repeatedly appended to

There's some kind of a bug in lib/action/state.js which means that if you keep requesting the state of a zone which is playing a stream of some kind, the Album Art URL gets repeatedly (erroneously) appended to itself, so after a while it can look like this:

May% curl boris.tlyk.eu:5005/kitchen/state
{"currentTrack":{"artist":"","title":"x-sonosapi-stream:s44491?sid=254&flags=32","album":"","albumArtURI":"http://10.100.100.99:1400http://10.100.100.99:1400http://10.100.100.99:1400http://10.100.100.99:1400http://10.100.100.99:1400http://10.100.100.99:1400http://10.100.100.99:1400http://10.100.100.99:1400http://10.100.100.99:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400/getaa?s=1&u=x-sonosapi-stream%3as44491%3fsid%3d254%26flags%3d32","duration":0,"uri":"x-rincon-mp3radio://bbcmedia.ic.llnwd.net/stream/bbcmedia_6music_mf_p?s=1429005507&e=1429019907&h=f4f73492b70c9b0668151a62f347c0da"},"nextTrack":{"artist":"","title":"bbcmedia_6music_mf_q?s=1429005507&e=1429019907&h=a604344f65e40f553630f83b8564d426","album":"","albumArtURI":"http://10.100.100.99:1400http://10.100.100.99:1400http://10.100.100.99:1400http://10.100.100.99:1400http://10.100.100.99:1400http://10.100.100.99:1400http://10.100.100.99:1400http://10.100.100.99:1400http://10.100.100.99:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400http://10.100.100.71:1400","duration":"0","uri":"x-rincon-mp3radio://bbcmedia.ic.llnwd.net/stream/bbcmedia_6music_mf_q?s=1429005507&e=1429019907&h=a604344f65e40f553630f83b8564d426"},"volume":8,"mute":false,"trackNo":1,"elapsedTime":1895,"elapsedTimeFormatted":"31:35","zoneState":"PLAYING","playerState":"PLAYING","zonePlayMode":{"shuffle":false,"repeat":false,"crossfade":false}}%

Will try and write a fix for this at some point if I get round to it.

Sayall and resume playing - not working with tuneln

Hi,
When using the sayall function while playing a spotify playlist or any other playlist the music stoppes, says what it is supposed to say, and then it resumes playing the playlist. However, when playing a radio channel with tuneln and execute the sayall command the music/radio stoppes and says what it was supposed to say but when done it does not go back to play the radio station that was playing before.... Is this possible to fix?

Autostart Sonos Api in a Raspberry Pi

Hi

First of all I thank you for your effort.

I'm trying to autostart this API on a Raspberry Pi, but have not been successful. I can start it manually
Could you tell me how?

Best regards

error - failed: Address family not supported by protocol.

After installing node I was able to run the server.js file but have yet to successfully test the system. Each time I try to run a test I get the connection error below

pi@raspberrypi ~ $ wget http://localhost:5005/resumeall
--2015-07-29 03:04:03-- http://localhost:5005/resumeall
Resolving localhost (localhost)... 127.0.0.1, ::1
Connecting to localhost (localhost)|127.0.0.1|:5005... failed: Connection refused.
Connecting to localhost (localhost)|::1|:5005... failed: Address family not supported by protocol.

any thoughts?

Presets.json does not accept more than one preset

Hi,

i tried to add more than one preset to presets.json, but if i do so, the program throws an error on start:
2013-12-29T11:30:20.878692+01:00 myserver sonos[22510]: module.js:485
2013-12-29T11:30:20.879028+01:00 myserver sonos[22510]: throw err;
2013-12-29T11:30:20.879292+01:00 myserver sonos[22510]: ^
2013-12-29T11:30:20.880081+01:00 myserver sonos[22510]: SyntaxError: /data/Install/sonos-http/node-sonos-http-api-master/presets.json: Unexpected token :
2013-12-29T11:30:20.880591+01:00 myserver sonos[22510]: at Object.parse (native)
2013-12-29T11:30:20.881154+01:00 myserver sonos[22510]: at Object.Module._extensions..json (module.js:482:27)
2013-12-29T11:30:20.881682+01:00 myserver sonos[22510]: at Module.load (module.js:356:32)
2013-12-29T11:30:20.882226+01:00 myserver sonos[22510]: at Function.Module._load (module.js:312:12)
2013-12-29T11:30:20.882560+01:00 myserver sonos[22510]: at Module.require (module.js:364:17)
2013-12-29T11:30:20.882972+01:00 myserver sonos[22510]: at require (module.js:380:17)
2013-12-29T11:30:20.883292+01:00 myserver sonos[22510]: at http.createServer.res.writeHead.Content-Type (/data/Install/sonos-http/node-sonos-http-api-master/server.js:10:13)
2013-12-29T11:30:20.883660+01:00 myserver sonos[22510]: at Object.cb as oncomplete

My Json:
{
"FFHBad":{
"players": [
{"roomName": "Bad", "volume": 37}
],
"state": "play",
"favorite": "Bayern 3",
"uri": "x-rincon-stream:RINCON_000E58C271D801400",
"playMode": "NORMAL"
}
"Bayern3Kitchen":{
"players": [
{"roomName": "Küche", "volume": 25}
],
"state": "play",
"favorite": "Bayern 3",
"uri": "x-rincon-stream:RINCON_000E58C9DAB601400",
"playMode": "NORMAL"
}
"FFHKitchen":{
"players": [
{"roomName": "Küche", "volume": 25}
],
"state": "play",
"favorite": "Bayern 3",
"uri": "x-rincon-stream:RINCON_000E58C271D801400",
"playMode": "NORMAL"
}
}

Alarm integration?

I have this working nicely with Openremote for home automation. One nice feature for me would be to make use of the alarm feature of sonos to kick off events. For example in the morning turn on the lights when the alarm goes off. Is this feasible? I guess you would need the json STATE to include a field with the Alarm status.

Error when trying to node server.js - Synology

When trying to node server.js i get det following error
Synology> node server.js
no settings file found, will only use default settings
module.js:338
throw err;
^
Error: Cannot find module '/volume1/Multimedia/Sonos/lib/actions/'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at requirePath (/volume1/Multimedia/Sonos/node_modules/require-fu/lib/index.js:14:22)
at /volume1/Multimedia/Sonos/node_modules/require-fu/lib/index.js:21:9
at Array.forEach (native)
at fuDirectory (/volume1/Multimedia/Sonos/node_modules/require-fu/lib/index.js:20:34)
at /volume1/Multimedia/Sonos/node_modules/require-fu/lib/index.js:25:5
at new HttpAPI (/volume1/Multimedia/Sonos/lib/sonos-http-api.js:28:24)

The folder actions does exist in the place mentioned, and it is containing several files with commands XXXXX.js.

The Node version that is running is as follows 0.12.0-0009.
I downloaded the node-sones-http-api as zip file, transferred from my mac to synology and unpacked before running npm install (works fine) and then typing node server.js in the correct directory. This was all done while being connected to the synology via terminal ssh on my mac.

Adding a "music service"

This is great! I am also looking for a way to create and add a music service to sonos. This music service would be a server running on my computer to which I can stream sound (any sound!) and to which Sonos would be listening.

Any idea if this could be done? (Not the server part, the tweak Sonos to listen to it!)

Crossfade proper use?

Thank you for the fantastic HTTP API! It works really well.

Is there info anywhere about how the crossfade option is supposed to work? If I set it to "on" for the group controller and then I call "favorite" on that controller to switch the currently playing song to a favorite it stops the currently playing song completely before starting the new favorite.

One complicating factor is that I'm trying to do this with a song playing but then switching to a streaming radio station. Maybe that's not supported?

Because the Sonos alarm doesn't let you adjust the fade up time I hacked a fade-up function today using the http API you created that works very well, but I have no idea how to manually hack a crossfade or if it's possible.

Installation Question

Hi

I hade server.js running fine on my raspberry pi 2. After about one day it stopt and i couldn't run it again.

I thougt it would be best to install everything new. So i reinstalled the raspbian noob pack.

After installation of node / npm i installed node server.js again.

This time it wouldn't run at all. (no settings found)

What do i need for a stable run?

Can someone tell me all the tasks i have to do?

What is the recommended node version? link?

I hope you can help me.

Greetings from Switzerland

Crash when (un)muted

When a (group)zone is (un)muted either through Sonos app or through node-sonos-http-api it throws below exception:

/home/pi/node-sonos-http-api-master/node_modules/sonos-discovery/lib/player.js:157
updateMute(event.data);
^
ReferenceError: updateMute is not defined
at Discovery.handleNotification (/home/pi/node-sonos-http-api-master/node_modules/sonos-discovery/lib/player.js:157:9)
at Discovery.EventEmitter.emit (events.js:117:20)
at IncomingMessage. (/home/pi/node-sonos-http-api-master/node_modules/sonos-discovery/lib/sonos.js:282:15)
at IncomingMessage.EventEmitter.emit (events.js:92:17)
at _stream_readable.js:920:16
at process._tickCallback (node.js:415:13)

installed on new raspi but wont startup

npm install seemed to have completed with no errors, but when I node server.js this is the response I receive:

pi@raspberrypi ~/node-sonos-http-api $ node server.js
no settings file found, will only use default settings
http server listening on port 5005

module.js:340
    throw err;
          ^
Error: Cannot find module '/home/pi/node-sonos-http-api/lib/actions/'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at requirePath (/home/pi/node-sonos-http-api/node_modules/require-fu/lib/index.js:14:22)
    at /home/pi/node-sonos-http-api/node_modules/require-fu/lib/index.js:21:9
    at Array.forEach (native)
    at fuDirectory (/home/pi/node-sonos-http-api/node_modules/require-fu/lib/index.js:20:34)
    at /home/pi/node-sonos-http-api/node_modules/require-fu/lib/index.js:25:5
    at Object.<anonymous> (/home/pi/node-sonos-http-api/server.js:30:38)

Any ideas?

Infinite errors logged on network loss

Whenever I move away from the network in where Sonos is, the http-api server starts eternally logging this error messages, making high (~25% just for this process) CPU usage:

{ [Error: bind EADDRNOTAVAIL]
  code: 'EADDRNOTAVAIL',
  errno: 'EADDRNOTAVAIL',
  syscall: 'bind' } 'uuid:RINCON_000E58C0565401400_sub0000000411' '/MediaRenderer/AVTransport/Event'
{ [Error: bind EADDRNOTAVAIL]
  code: 'EADDRNOTAVAIL',
  errno: 'EADDRNOTAVAIL',
  syscall: 'bind' } 'uuid:RINCON_000E58C0565401400_sub0000000414' '/MediaRenderer/RenderingControl/Event'
{ [Error: bind EADDRNOTAVAIL]
  code: 'EADDRNOTAVAIL',
  errno: 'EADDRNOTAVAIL',
  syscall: 'bind' } 'uuid:RINCON_000E58C0565401400_sub0000000413' '/MediaRenderer/GroupRenderingControl/Event'
{ [Error: bind EADDRNOTAVAIL]
  code: 'EADDRNOTAVAIL',
  errno: 'EADDRNOTAVAIL',
  syscall: 'bind' } 'uuid:RINCON_000E58C0565401400_sub0000000412' '/MediaServer/ContentDirectory/Event'

If I start the server in a LAN without any Sonos component, the server would constantly log scanning for players in ip xxx.xxx.xxx.xxx, but without hogging CPU (0% usage).

I've tried replacing the console.log function with a custom one that appends the line in which the message is generated, but couldn't find anything useful. I think I've stashed it, I could try to search for it and update the report, but I'm pretty much sure it didn't say anything useful - or that seemed to me, at least.

Do you have any idea?

unable to get "say" command to work

I know the say function "says" experimental, but I just wanted to give my feedback regarding my results when attempting to utilize that function. I am unable to get the "say" function to work, although the command seems to be properly recognized by the server as seen here:
{ room: 'Living%20Room', action: 'say', value: 'Hello%20Sean' }

Any ideas on how to get this function to work properly? Running Mavericks 10.9.4 on a MacBook Pro Retina here.

Upgrade to latest build but wont startup

Hi,

My raspi was working well with sonos till now.

Today I upgraded the node and node-sonos-http-api and I have the following errors:

1.-The server doesn´t autostart. I followed this steps in issue #20 and #44, without success
2.- If I run node server.js I have "no settings file found, will only use default settings"

This is my node -v: v0.12.1

Could you help me?

Best regards

Problems with absolute URL for albumArtURI

I have problems with absolute URL for albumArtURI. Since this is implemented, the API does not work anymore. Each time the URL ist called the IP address and the port is rewritten in the URL.

1st call - result:

"currentTrack": {
"artist": "",
"title": "x-sonosapi-stream:s14991?sid=254&flags=32",
"album": "",
"albumArtURI": "http://192.168.86.101:1400/getaa?s=1&u=x-sonosapi-stream%3as14991%3fsid%3d254%26flags%3d32",
"duration": 0,
"uri": "x-rincon-mp3radio://br_mp3-bayern3_m.akacast.akamaistream.net/7/442/142692/v1/gnl.akacast.akamaistream.net/br_mp3_bayern3_m"
}

2nd call - result:

"currentTrack": {
"artist": "",
"title": "x-sonosapi-stream:s14991?sid=254&flags=32",
"album": "",
"albumArtURI": "http://192.168.86.101:1400http://192.168.86.101:1400/getaa?s=1&u=x-sonosapi-stream%3as14991%3fsid%3d254%26flags%3d32",
"duration": 0,
"uri": "x-rincon-mp3radio://br_mp3-bayern3_m.akacast.akamaistream.net/7/442/142692/v1/gnl.akacast.akamaistream.net/br_mp3_bayern3_m"
}

3rd call:
"albumArtURI": "http://192.168.86.101:1400http://192.168.86.101:1400http://192.168.86.101:1400/getaa?s=1&u=x-sonosapi-stream%3as14991%3fsid%3d254%26flags%3d32",

And so on.

This happens especially when the URL is called within short intervals.

Group Speakers

Hi,

Would it be possible to add a way to group 2 or more speakers together and play simultaneously?

Something like
/[controller]/add/[additional_node]
/controller/remove/[additional_node]

Or is there another easy way to do it?

playpause not working?

Hi I can't seem to get the playpause toggle to work - is there a problem with this command?
Thanks a brilliant tool for home automation well done.

current track duration is always 0

After installing the latest version (following issues #43) there seems to have an issue with the value of the current track duration: it is always 0
I remember that this duration was 0 when playing a radio stream (tunein) but was correctly set when playing local files or from spotify. Now it's 0 whatever I'm playing.
(note: next track duration value is fine)
Thanks

XML encode for OpenRemote

Is it possible to insert a XML-encoding like this:
xmlEntities.encode(nodeValue)

I want to use "absoluteAlbumArtURI" as an OpenRemote-sensor. But the OpenRemote data is stored as XML file. Thus, there are problems with the XML file, if the "&" and other characters are not stored encoded.

TypeError: Cannot call method 'indexOf' of undefined

I'm almost certain this is going to be something simple I've missed. The server is running great on my laptop from when I installed just to try it out. I'm attempting to run it on another machine and can't get past an error on start. Thanks in advance.

Also, awesome work!

Here is the output of the error:
'''
/Users/ronny/sonos-http/node_modules/sonos-discovery/lib/sonos.js:338
if (attributes.IsZoneBridge || attributes.ChannelMapSet.indexOf('SW,SW
^
TypeError: Cannot call method 'indexOf' of undefined
at /Users/ronny/sonos-http/node_modules/sonos-discovery/lib/sonos.js:338:65
at parse (/Users/ronny/sonos-http/node_modules/sonos-discovery/node_modules/easysax/easysax.js:671:10)
at EasySAXParser.parse (/Users/ronny/sonos-http/node_modules/sonos-discovery/node_modules/easysax/easysax.js:142:4)
at updateZoneState (/Users/ronny/sonos-http/node_modules/sonos-discovery/lib/sonos.js:388:15)
at /Users/ronny/sonos-http/node_modules/sonos-discovery/lib/sonos.js:231:11
at parse (/Users/ronny/sonos-http/node_modules/sonos-discovery/node_modules/easysax/easysax.js:683:10)
at EasySAXParser.parse (/Users/ronny/sonos-http/node_modules/sonos-discovery/node_modules/easysax/easysax.js:142:4)
at IncomingMessage. (/Users/ronny/sonos-http/node_modules/sonos-discovery/lib/sonos.js:286:17)
at IncomingMessage.EventEmitter.emit (events.js:92:17)
at _stream_readable.js:919:16
'''

sayAll not reversing to initial grouping state

Started out with all units as individuals (no groups) with 3 of them playing different spotify tracks (Bathroom, Kitchen, Gym)

After the sayall command was played, this was what the system returned to.
https://www.dropbox.com/s/hkz76zo1s00qid0/Screenshot%202015-01-10%2018.21.29.png?dl=0

Output from console:
pi@raspberrypi ~/node-sonos-http-api $ node server.js
no settings file found, will only use default settings
http server listening on port 5005
no preset file, ignoring...
Downloading new tts message file: /home/pi/node-sonos-http-api/static/tts/31247917743076daa139d8c8007a2e8705c12b97-en.mp3

Then with a delay this came up:

error in async series when applying backup error on play [ [ 'ungrouping',
'set volume, coordinator',
'setting uri',
'set playmode' ],
[ 'ungrouping',
'set volume, coordinator',
'setting uri',
'set playmode',
'seek',
'trackSeek' ],
[ 'ungrouping',
'set volume, coordinator',
'setting uri',
'set playmode',
'seek',
'trackSeek' ],
[ 'ungrouping',
'set volume, coordinator',
'setting uri',
'set playmode',
'seek' ],
[ 'ungrouping',
'set volume, coordinator',
'setting uri',
'set playmode' ],
[ 'ungrouping',
'set volume, coordinator',
'setting uri',
'set playmode',
'seek',
'trackSeek' ] ]

Say command not working

Hello Jishi, Thank you for the hard work on the node js http api.
I use it with openhab for my home automation because the standard songs binding is giving me less functionality so really great !

But i am facing the problem that the say functionality is not working because each time i get prompted for a captcha when i am going to the translate.google.com site.

This because of the many requests my home automation server does to the website.

do you know a workaround for this issue ?

Thank you for the hard work sofar !!!
roy hofman
[email protected]

Cannot bind SSDP port on OS X (UDP 1901) when occupied by Sonos Controller

After running npm install and node server.js I see the following:

no settings file found, will only use default settings
error:  code=EADDRINUSE, errno=EADDRINUSE, syscall=bind
http server listening on port 5005
no preset file, ignoring...

I switch to my browser and enter in http://localhost:5005/state to get the state of the player, and then terminal outputs what you see here:

sonos-http-error

I guess this has something to do with how my SONOS player is configured. There are multiple players on the same network; I can access the web interface for my network at http://10.0.1.51:1400/status. I don't see anything in the docs on how to interface with my existing system, and I am pretty sure this is the missing link.

I am running node.js 0.12.2 on Max OS X Yosemite.

Error on http://www.localhost.com:5005/zones

Clean install, fails on both Windows and Linux

/home/niels/sonos/node-sonos-http-api/lib/actions/zones.js:2
callback(player.discovery.getZones());
^
TypeError: Cannot read property 'discovery' of null
at Object.zones (/home/niels/sonos/node-sonos-http-api/lib/actions/zones.js:2:18)
at handleAction (/home/niels/sonos/node-sonos-http-api/lib/sonos-http-api.js:65:28)
at HttpAPI.requestHandler (/home/niels/sonos/node-sonos-http-api/lib/sonos-http-api.js:47:5)
at /home/niels/sonos/node-sonos-http-api/server.js:51:13
at Server.finish (/home/niels/sonos/node-sonos-http-api/node_modules/node-static/lib/node-static.js:109:13)
at finish (/home/niels/sonos/node-sonos-http-api/node_modules/node-static/lib/node-static.js:168:14)
at /home/niels/sonos/node-sonos-http-api/node_modules/node-static/lib/node-static.js:142:17
at Object.oncomplete (fs.js:107:15)

play mp3 files and radio streams

Hi,
This is more a feature request or general question than an issue.
Is it technically possible to play a mp3 file located on the harddisk or a mp3 radio stream based on the url. The files are not known in the sonos library.
Reason: I try to implement the http api to my home automation control system.
There, I already have a media manager knowing all the local mp3 files and radio stations. Now I would like to play these files or playlists or stations by sending an http API command.

Something like: play uri:
"x-file-cifs%3a2f%2fMEDIASERVER%2fiTunes%2520Music%2fMarc%2520Seales.mp3"
or
"x-rincon-mp3radio://players.creacast.com/creacast/klassik/playlist.pls"

or to put the files directly to the queue and play it by playing the queue.
I appreciate any hint or tipp and thanks a lot for your sonos github projects here.
Regards
Kenny

calling the say function?

Hi Jimmy we're loving the TTS function - especially the kids making announcements around the house!

I managed to set up a webform with java script with the following command

window.open("http://192.168.0.3:5005/Living%20Room/say/" + jSay);

This works fine but clearly means it keeps opening brower windows. I also want to try and embed this in openremote. Is there a way to do this is in the background? I am a novice with javascript - I am guessing I need a post or get command??

Presets

Hi.

I'm about to test the api, but have no knowlegde about sonos atm. So, what I was wondering is if there's somewhere to read up on preset options? I'm not familiar with the x-rincon-stream uri type etc.

Nice work.

Raspberry Pi issue

When attempting to run on the Raspberry Pi under the latest Raspbian, the following error is encountered:

pi@raspi-sonos ~/node-sonos-http-api $ node server.js
binding SSDP to port 2339
discovering all IPs from lo
discovering all IPs from wlan0
relevant IPs { '192.168.1.137': null }
notification server listening on port 3500
no preset file, ignoring...
http server listening on port 5005
scanning for players in ip 192.168.1.137
subscribing to topology 192.168.1.130
using local endpoint 192.168.1.137

/home/pi/node-sonos-http-api/node_modules/sonos-discovery/lib/player.js:215
_this.state.nextTrack.duration = attr().duration.parseTime();
^
TypeError: Cannot call method 'parseTime' of undefined
at /home/pi/node-sonos-http-api/node_modules/sonos-discovery/lib/player.js:215:58
at parse (/home/pi/node-sonos-http-api/node_modules/sonos-discovery/node_modules/easysax/easysax.js:671:10)
at EasySAXParser.parse (/home/pi/node-sonos-http-api/node_modules/sonos-discovery/node_modules/easysax/easysax.js:142:4)
at updateTransportState (/home/pi/node-sonos-http-api/node_modules/sonos-discovery/lib/player.js:238:17)
at Discovery.handleNotification (/home/pi/node-sonos-http-api/node_modules/sonos-discovery/lib/player.js:151:9)
at Discovery.EventEmitter.emit (events.js:117:20)
at IncomingMessage. (/home/pi/node-sonos-http-api/node_modules/sonos-discovery/lib/sonos.js:282:15)
at IncomingMessage.EventEmitter.emit (events.js:92:17)
at _stream_readable.js:883:14
at process._tickCallback (node.js:415:13)

albumArtURI Format

Is it possible for the "state" response to include the entire "albumArtURI"?

I'm assuming sonos-discovery already acquires this information anyways. And even if I created a script to format the current output of the "state" response to prepend the "albumArtURI" with the "http://:1400" that would not work as I have noticed that the ZP IP address changes occassionally. Not sure why yet as I have not looked into the pattern but regardless the "Associated ZP IP Address" would need to be updated to reflect the current IP address

example"

##Format Example##
http://<Associated ZP IP Address>:1400/getaa?s=1&u=x-sonos-http%3atrack%253a168274267.mp3%3fsid%3d160%26flags%3d32
##Exact Example##
http://10.0.0.105:1400/getaa?s=1&u=x-sonos-http%3atrack%253a168274267.mp3%3fsid%3d160%26flags%3d32

Once again this is meet the requirements for the openremote sensor to display the Album Art Image.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.