Version 44 (modified by lolodomo, 10 years ago) (diff)

--

The Sonos Wireless HiFi Music Systems plugin for Vera

This plugin permits control of your Sonos via Vera scenes and Vera UI.

As a bonus, a Text to Speech feature is included.

Installation

What you need

  • Vera with UI4, and UI5 has been tested.
  • At least one Sonos Zone
  • The UPnP event proxy plugin: http://code.mios.com/trac/mios_upnp-event-proxy# If this plugin is installed in parallel of the Sonos plugin, the Sonos plugin will work in a more efficient way (highly recommended)
  • The Sonos plugin

How To (MiOS Marketplace)

The plugin version available in the MiOS Marketplace is for UI5 only. For UI4, please read the chapter "How To (code.mios.com)".

  • Install the UPnP event proxy plugin from the MiOS Marketplace.
  • Install the Sonos plugin from the MiOS Marketplace.
  • When installation is done, refresh your Web browser cache (Ctrl+F5 in most of the browsers)

How To (code.mios.com)

  • Install the UPnP event proxy plugin from the MiOS Marketplace.
  • Upload the Sonos plugin files:
    • Unzip the ZIP archive
    • For UI4 users only: rename D_Sonos1_UI4.json into D_Sonos1.json
    • Use WinSCP ( http://winscp.net/eng/index.php ) to upload certain files:
      • the following PNG files go into /www/cmh/skins/default/icons/
        • Sonos.png
        • Sonos_0.png
        • Sonos_25.png
        • Sonos_50.png
        • Sonos_75.png
        • Sonos_100.png
        • Sonos_125.png
        • Sonos_150.png
      • All other files can be uploaded using the normal MiOS UI
    • In the Toolbox section (UI4) or APPS section (UI5), open MiOS Developers (UI4) or Develop Apps (UI5) >> Luup Files and upload the following files, uncheck the Restart Luup after upload checkbox and click GO
      • S_SonosAVTransport1.xml
      • S_SonosGroupRenderingControl1.xml
      • S_SonosRenderingControl1.xml
    • In the Toolbox section (UI4) or APPS section (UI5), open MiOS Developers (UI4) or Develop Apps (UI5) >> Luup Files and upload the following files, check the Restart Luup after upload checkbox and click GO
      • D_Sonos1.xml
      • D_Sonos1.json
      • I_Sonos1.xml
      • J_Sonos1.js
      • L_Sonos1.lua
      • L_SonosTTS.lua
      • S_Sonos1.xml

Create a Sonos device

If you installed the plugin from the MiOS Marketplace, one device is automatically created. But if you have several Sonos zones and you want to drive more than one Sonos zone with the Vera, you have to add additional devices in the Vera, one for each zone you want to control.

  • Open Toolbox section (UI4) or APPS section (UI5); open MiOS Developers (UI4) or Develop Apps (UI5) >> Create Device.
    • In the !Upnp Device Filename input box enter D_Sonos1.xml.
    • In the Description input box enter a name for the panel device, e.g. Sonos Living Room.
    • In the Ip Address input box enter the IP address of your Sonos zone (you can find this information opening About my Sonos system in your Sonos application) or leave it blank and run later the next step "Select your Sonos".
    • In the Parent device list box select No parent.
    • Click Create device.
  • (UI4) Close this window and Save.
  • (UI5) Close the popup window that informs you about the creation of a new device, then push the Reload button.
  • When reload is done, refresh your Web browser cache (Ctrl+F5 in most of the browsers)

Select your Sonos

This step will allow to link a Vera device to a physical Sonos unit. It is required for the device automatically created when installing the plugin from the Marketplace or for the additional devices you created without specifying a IP address. Note it can be used to assign the Vera device to a different Sonos. It can be useful in case your Sonos has been assigned a new IP address. Please note that you must avoid having several Vera devices linked to the same physical Sonos (same IP).

  • Find your new device in the UI,
  • Click on its wrench button,
  • Open the Settings tab,
  • Push the Discover button and wait for few seconds until the selection box is filled and the Select button is enabled again,
  • Select your Sonos in the selection box and then push the Select button,
  • If the automatic discovery is not working (the selection box remains empty), you can enter the IP address of your Sonos zone in the field New IPand then push the Select button,
  • Wait for few seconds for a complete initialiazation

Automatic discovery (UPnP discovery) could require an additional setup of your Vera Lite. Please read the explanations in this message if it does not work directly: http://forum.micasaverde.com/index.php/topic,16905.msg132502.html#msg132502

User Interface (outdated)

Scenes

Creating a Sonos scene under UI5 (outdated)

To use the Sonos device under UI5, follow the steps outlined below.

  • Create New Scene
  • Give the scene a name, such as Play Sonos
  • Select the [Advanced] option/tab
  • Select the Sonos device
  • Click (Add)
  • Then from the drop down options list created below, Choose SetFileToPlay and enter the full location of the NAS file
    e.g. 192.168.1.10/media/Music/Mp3s/Changes.mp3

Now you have selected the file, you need to tell the Sonos to play it

  • Select the Sonos device again
  • Click (Add)
  • Then from the drop down option list created below, Choose 'Play'
  • Confirm Changes & (Save)

Now you should have a scene that, once run, will play the track you've selected.

Notes:

  • The above bypasses the Sonos queue and will just play the selected track only.
  • If you know the length of the track being played you can set a delay to occur
    e.g 3.45mins and set another file to play.

Making a Sonos "Play" something

This functionality is exposed declaratively through the PlayURI action under Advanced Scenes. The functionality is also exposed programmatically via Lua code:

luup.call_action("urn:micasaverde-com:serviceId:Sonos1", "PlayURI",
                 {URIToPlay="x-file-cifs:...", Volume=50},
                 666)

This action will play what is defined by the URIToPlay parameter. To know how to set this parameter, you can open the Help tab of the Vera Sonos device, you will discover a list of example usages with your current own context. Here are examples:

  • x-file-cifs:path - Play the music file defined by "path"
  • x-rincon-mp3radio:url - Play the MP3 WEB radio defined by "url"
  • Q: - Play what is in the Sonos queue, starting at first item
  • Q:3 - Play what is in the Sonos queue, starting at third item
  • AI: - Play the local line-in audio input
  • AI:name - Play the line-in audio input of the Sonos unit with name "name"
  • TR:id - Play the tunein radio station having "id" (a number) as id
  • SR:id - Play the Sirius radio station having "id" as id
  • FR:radio - Play the favorite radio station having "radio" as name
  • SQ:name - Play the Sonos playlist having "name" as name
  • GZ:name - Group the Sonos to Sonos with name "name"

Notes:

  • Parameters not specified will default internally. (Volume=nil) By default, the volume is not set.

Making a Sonos "Say" something

The Sonos plugin exposes Text to Speech capability through Google's service. The functionality is exposed declaratively through the Say action under Advanced Scenes. The functionality is also exposed programmatically via Lua code.

Suppose you have 4 Sonos zones named Bedroom, Bathroom, Living-room and Kitchen. Your bedroom Sonos is linked to device 666 in your Vera.

To play a message only in the bedroom, use this lua code:

luup.call_action("urn:micasaverde-com:serviceId:Sonos1", "Say",
                 {Text="The sun shines outside", Language="en"},
                 666)

This action will pause the current playback, say the text, and then the playback will be resumed. Language is a string of 2 characters, like en, fr ...

To play a message in the bedroom setting the volume for the message at level 60:

luup.call_action("urn:micasaverde-com:serviceId:Sonos1", "Say",
                 {Text="The sun shines outside", Language="en", Volume=50},
                 666)

The volume will be adjusted to play the message, and finally restored to its previous level. When the Volume parameter is not used, the volume is not adjusted and the message is played with the current volume.

To play a synchronized message in the bedroom, the bathroom and the kitchen:

luup.call_action("urn:micasaverde-com:serviceId:Sonos1", "Say",
                 {Text="The sun shines outside", Language="en", GroupZones="Bathroom,Kitchen"},
                 666)

After the text is said, the playback will be resumed on the 3 zones.

To play a synchronized message in all rooms setting the volume for the message at level 60 in all rooms:

luup.call_action("urn:micasaverde-com:serviceId:Sonos1", "Say",
                 {Text="The sun shines outside", Language="en", GroupZones="ALL",
                  Volume=60, SameVolumeForAll="true"},
                 666)

When the parameter SameVolumeForAll is set to false or not set, the volume is adjusted only on the main zone, that is the bedroom in our example.

To play a message in the bedroom using your personal OSX TTS server rather than using Google Internet service:

luup.call_action("urn:micasaverde-com:serviceId:Sonos1", "Say",
                 {Text="The sun shines outside", Language="en", Engine="OSX_TTS_SERVER"},
                 666)

Two accepted values for the engine: "GOOGLE" for the Google Internet service and "OSX_TTS_SERVER" for a personal OSX TTS server.

In addition, the Text to Speech capability can be setup with the following variables (use the Advanced tab to adjust the values):

  • DefaultLanguageTTS - default language used when calling the Say action; must be a string of 2 characters
  • DefaultEngineTTS - default engine used when calling the Say action; must be either GOOGLE or OSX_TTS_SERVER
  • OSXTTSServerURL - defines the location of your OSX TTS server; something like http://www.mypersonaltts.org:80

Notes:

  • Google service may be removed at any time
  • Explanations on how to setup the OSX TTS server: http://wolfpaulus.com/jounal/mac/ttsserver/
  • For GroupZones, you have to use room names (zone names defined with your Sonos application), not the name of your Vera device
  • It is possible to use the parameter named GroupDevices in place of GroupZones. In this case, you must have a device in the Vera for all the Sonos zones you want to address. The value is a CSV list of device ids. For example, if your living-room and kitchen Sonos are linked respectively to devices 667 and 668 in your Vera, you will use GroupDevices="667,668". The GroupDevices has been kept for compatibility reasons with old versions but the use of GroupZones is now recommended.
  • Parameters not specified will default internally. (Language=en, Engine=GOOGLE, GroupDevices="", GroupZones="", Volume=nil, SameVolumeForAll=false)

Making a Sonos play an alert message (outdated)

This functionality is exposed declaratively through the Alert action under Advanced Scenes. The functionality is also exposed programmatically via Lua code:

luup.call_action("urn:micasaverde-com:serviceId:Sonos1", "Alert",
                 {URI="x-file-cifs:...", Volume=50, Duration=15, GroupDevices="667,668"},
                 666)

This action will pause the current playback, play the alert, and then the playback will be resumed.

By using the GroupDevices parameter, it is even possible to play the alert on several Sonos zones at the same time. This parameter represents a CSV list of deviceId's of other Sonos units that should be included during the save-play-restore model of the Alert command.

Notes:

  • Parameters not specified will default internally. (Duration=10, GroupDevices="", Volume=nil) By default, the volume is not set.

Service Variables (outdated)

urn:micasaverde-com:serviceId:Sonos1

  • CurrentService - name of the current service, for example "TuneIn"
  • GroupCoordinator - UUID of the group coordinator
  • ProxyUsed - "proxy is used" or "proxy is not used" to indicate if the UPnP event proxy is used
  • RouterIp - router/firewall IP when the Sonos unit can access the Vera only with a port forwarding rule
  • RouterPort - router/firewall port when the Sonos unit can access the Vera only with a port forwarding rule
  • SonosModelName - model of the Sonos unit, for example "Sonos PLAY:5" or "Sonos CONNECT:AMP"
  • SonosOnline - "1" when the Sonos is online or "0" when it is offline
  • SonosServicesKeys - for plugin internal usage

urn:upnp-org:serviceId:DeviceProperties

  • SonosID - UUID of the Sonos unit
  • ZoneName - name of the Sonos unit

urn:upnp-org:serviceId:AVTransport

  • AVTransportURI -
  • AVTransportURIMetaData -
  • CurrentAlbum -
  • CurrentAlbumArt -
  • CurrentArtist -
  • CurrentCrossfadeMode -
  • CurrentDetails -
  • CurrentMediaDuration -
  • CurrentPlayMode -
  • CurrentRadio -
  • CurrentStatus -
  • CurrentTitle -
  • CurrentTrack -
  • CurrentTrackDuration -
  • CurrentTrackMetaData -
  • CurrentTrackURI -
  • CurrentTransportActions -
  • NumberOfTracks -
  • RelativeTimePosition
  • TransportPlaySpeed - not updated when the UPnP event proxy is used
  • TransportState -
  • TransportStatus -

urn:upnp-org:serviceId:ContentDirectory

  • FavoritesRadios - XML data describing all the favorites radio stations
  • Queue - XML data describing the content of the Sonos queue
  • SavedQueues - XML data describing all the Sonos playlists

urn:upnp-org:serviceId:RenderingControl

  • Mute - "1" if volume muted or "0" if unmuted
  • Volume - general volume, value from 0 to 100

urn:upnp-org:serviceId:ZoneGroupTopology

  • ZonePlayerUUIDsInGroup - comma-separated list of UUIDs identifying the group members
  • ZoneGroupState - XML data describing the Sonos network and the current state of all groups

Obsolete

The following service variables have been obsoleted, and replaced with standard variables from the AV-UPnP set.

  • urn:schemas-micasaverde-com:device:avmisc:1, CurrentZoneName
  • urn:schemas-micasaverde-com:device:avmisc:1, CurrentTransportState
  • urn:schemas-micasaverde-com:device:avmisc:1, PlayMode
  • urn:schemas-micasaverde-com:device:avmisc:1, TrackURI
  • urn:schemas-micasaverde-com:device:avmisc:1, CurrentMute
  • urn:schemas-micasaverde-com:device:avmisc:1, CurrentVolume

If you see these in your system, they're from an older release and will no longer be updated.  Any scenes, or Lua code, that depends upon these variables will need to be manually changed.

Reference

Attachments