Version 31 (modified by lolodomo, 11 years ago) (diff)

--

The Sonos Wireless HiFi Music Systems plugin for Vera

This plugin permits control of your Sonos via Vera scenes.

Development Status

Tested features:

  • Supported Models: ZP80, ZP100, Sonos3, Sonos5, Sonos Connect, Sonos Connect AMP tested
  • Functionality:
    • Sonos:
      • Mute
      • UnMute
      • SetVolume
      • PlayURI (Places chosen audio file into queue)
    • MediaNavigation:
      • ChapterDown(Not implemented)
      • ChapterUp (Not implemented)
      • DiskDown (Not implemented)
      • DiskUp (Not implemented)
      • FastForward (Not implemented yet)
      • Play, Pause, Seek
      • QuickSkip (Not implemented)
      • Rewind
      • SkipDown (implemented as 'Next' on Sonos)
      • SkipUp (implemented as 'Previous' on Sonos)
      • Slow (Not implemented)
      • Stop
    • Speech
      • Say (TTS by Google)
    • Playlists
      • PlayList Save & Restore
    • Advanced Dialog UI
    • Volume & Equalization
      • Volume:
        • Down (by 3 out of 100)
        • Mute (a toggle mute function - currently a poor mans version)
        • Up (by 3 out of 100)
      • Set Bass, Treble & Loudness Levels
    • Periodic Updates
      • Updates automatically, every 15s, from Sonos device
      • Manual Poll also available for scene scripting

To do list:

  • Autodiscovery of Zones
  • Autonaming of zone names

Installation

What you need

How To

  • Install the UPnP event proxy plugin from the APP store.
  • Upload the Sonos plugin files:
    • Unzip the ZIP archive
    • Use WinSCP ( http://winscp.net/eng/index.php ) to upload certain files:
      • the MP3 file goes into /etc/cmh-ludl/
      • the PNG files go into /www/cmh/skins/default/icons/
      • All other files can be uploaded using the normal MiOS UI
    • In the Toolbox section open MiOS Developers >> Luup Files and upload all the other (MP3 and PNG files excluded) files (except the file D_Sonos1_UI4.json and the services subdirectory), check the Restart Luup after upload checkbox and click GO.
  • Create the Sonos device:
    • Open Toolbox section open MiOS Developers >> Create Device.
    • In the UpnpDevFilename 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).
    • Click Create device.
  • Close this window and Save.

Configuration

  • In the Sonos device advanced control tab specify the IP Address of your Sonos Zone
  • Now actions are available in scenes

User Interface

Scenes

Creating a Sonos scene under UI5

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
  • 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:

luup.call_action("urn:micasaverde-com:serviceId:Sonos1", "Say",
                 {Text="Welcome Home", Language="en", Volume=50, GroupDevices="667,668"},
                 666)

This action will pause the current playback, say the text, and then the playback will be resumed.

By using the GroupDevices parameter, it is even possible to activate the Text To Speech 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-say-restore model of the Say command.

Notes:

  • This service may be removed at any time, as can happen with Google services.
  • Parameters not specified will default internally. (Language=en, GroupDevices="", Volume=nil) By default, the volume is not set.

Making a Sonos play an alert message

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

urn:micasaverde-com:serviceId:Sonos1

  • CurrentService - name of the current service, for example "TuneIn?"
  • 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
  • SonosDevices - XML data describing the Sonos network
  • SonosModel - a number used to display the right icon for the Vera device, depending on the Sonos model (for plugin internal usage)
  • 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

  • AbsoluteCounterPosition - not updated when the UPnP event proxy is used
  • AbsoluteTimePosition - not updated when the UPnP event proxy is used
  • AVTransportURI -
  • AVTransportURIMetaData -
  • CurrentAlbum -
  • CurrentAlbumArt -
  • CurrentArtist -
  • CurrentCrossfadeMode -
  • CurrentDetails -
  • CurrentMediaDuration -
  • CurrentPlayMode -
  • CurrentRadio -
  • CurrentStatus -
  • CurrentTitle -
  • CurrentTrack -
  • CurrentTrackDuration -
  • CurrentTrackMetaData -
  • CurrentTrackURI -
  • CurrentTransportActions -
  • NumberOfTracks -
  • RelativeCounterPosition - not updated when the UPnP event proxy is used
  • RelativeTimePosition - not updated when the UPnP event proxy is used
  • 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

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