Logitech Media Server

From Domoticz
(Redirected from LMS)
Jump to: navigation, search

Documentation for Logitech Media Server


Logitech Media Server (formerly SlimServer, SqueezeCenter and Squeezebox Server) is a streaming audio server supported by Logitech (formerly Slim Devices), developed in particular to support their Squeezebox range of digital audio receivers. Logitech EOL'd the product line in 2012 but the open-source LMS software is still actively developed in a so-called community effort. The latest version can be downloaded here - http://downloads.slimdevices.com/nightly or for Synology NAS devices here - http://server.pinkdot.nl/dsm6/

Logitech Media Server in Domoticz

Logitech Media Server Settings

Your Logitech Media Server must be configured to allow Domoticz to control the attached players. Default port for Web Server connections is 9000 or 9002.

LMS Server.png

Adding Hardware

Add the Logitech Media Server via the Hardware page under Settings. Fill in the IP of your Logitech Media Server and the port you specified.

LMS Hardware.png

Domoticz Settings

Click 'Setup' to see the detected/connected players.

  • Poll interval controls how often Domoticz will attempt to reconnect to the Logitech Media Server to poll the player's status.
  • Ping timeout controls how long Domoticz will try to contact the Logitech Media Server.

LMS Settings.png

Detected Players

If you entered the correct IP & port of your Logitech Media Server, your players will be detected and displayed under Devices. It displays names and MAC-addresses.

Supported Models

The supported models are:

  • Squeezebox 1
  • Squeezebox 2
  • Squeezebox 3
  • Squeezebox Receiver
  • Squeezebox Boom
  • Squeezebox Controller
  • SqueezePlay
  • Squeezebox Radio
  • Squeezebox Touch
  • iPeng iOS App (iPhone & iPad)
  • Max2Play SqueezePlug


If your player model is not supported, it will be reported in the logfile. The logfile also reports detected players when starting the Logitech Media Server hardware.

Events and Notifications

Domoticz device events work for Logitech Media Players using both Blockly and LUA.

Events and notifications are triggered for:


The following actions can be performed by using 'Set' on a Logitech Media Player.

On or Group On Will turn the device on.
Off or Group Off Will turn the device off.
Play Will send a Play command.
Pause Will toggle between Play and Pause.
Stop Will send a Stop command.
Set Volume <0-100> Will set the volume of the player-output.
Play Playlist <name> Will play the playlist with name <name>.
Play Favorites Will play the favorites.

commandArray['SqueezeBox']='Set Volume 30'
commandArray['SqueezeBox']='Play Playlist WakeUpList1'
commandArray['SqueezeBox']='Play Favorites

On Screen Notifications

Domoticz can display notification messages on the screens of certain Logitech Media Players. This is configured via the Notifications tab on the Settings page as shown here:

LMS Notifications.png

Fill in the MAC-address (separated by a semicolon) and the duration that the message will be displayed on the screen (in seconds) The MAC-address of your player(s) can be found in the Hardware-settings of your Logitech Media Server hardware.

Known Issues

  • (Song-)Titles with special characters will show wrong symbols in the logfile.

Audio Alerts via Squeezebox Players

The Squeezebox radio and boom players can be used to play audio alerts from Domoticz via the following example perl script. It will work with any type of player but the radio and boom are well-suited as they have their own amplifier and can therefore act autonomously. The script needs to be configured with the MAC addresses of your players, the idx values of the switches corresponding to the players in Domoticz, the URL/port of your Domoticz instance, plus the URL/port where your Logitech Media Server resides.

The basic idea is to save several current parameters from the player (power state, repeat mode, now-playing playlist (if any), current time position within currently-playing song (if any), current volume setting), play the desired audio clip (turning on the player if needed or else just pausing the current song if currently playing something) at a defined volume with no-repeat, and then returning everything back the way it was. The $duration variable should be set to the length of the alert audio clip. The 'unlink' statement deletes the temporary playlist after use to prevent it being scanned on a library rescan so you should set the path correctly (I have /play defined in my fstab). Note you cannot use a path in the 'save playlist' call as the default playlists folder is hard-coded into LMS. Make sure the CPAN modules in the 'use' list are installed, and of course perl itself.

You can copy some of the audio clip files in your windows /media folder over to your LMS server as nice examples of short alert clips. These can be used to alert for all kinds of things in Domoticz like PIR motion detected or Garage door left open for more than 10 minutes, etc.

# Plays an alert sound on a Squeezebox player and subsequently puts everything back the way it was before the sound played.
# Also logs a message to Domoticz. Any offline players are skipped. Author: philchillbill, 2017.
use LWP::UserAgent;
use JSON::RPC::Client;
use JSON::XS;
use URI::Escape;
no warnings 'uninitialized';
# ----------------------------------------------------------------------------------
# NOTE - edit this list to correspond to the MACs and Domoticz idx's of your players
# The hex values for the MAC are case-sensitive and should be lowercase
%players = (
 bathroom    => { mac => "00:04:20:xx:yy:zz", idx => 20 },
 bedroom     => { mac => "00:04:20:xx:yy:zz", idx => 18 },
 kitchen     => { mac => "00:04:20:xx:yy:zz", idx => 19 },
 livingroom  => { mac => "00:04:20:xx:yy:zz", idx => 21 },
 studio      => { mac => "00:04:20:xx:yy:zz", idx => 17 },
 garage      => { mac => "00:04:20:xx:yy:zz", idx => 142 },
# Change these 2 values to match your configuration for Domoticz and LMS
$domo_url = 	'';
$sq_uri = 	'';
# ----------------------------------------------------------------------------------
$client=new JSON::RPC::Client;
$ua=LWP::UserAgent->new; $ua->timeout(5);
sub logMessage {
 my $msg=shift; $urimsg=uri_escape($msg);
sub checkPlayerState {
 my $idx=shift;
 $data=decode_json $res;
 if ($state=~m/Disconnected/) { $status=0 } else { $status=1 };
 return $status;
sub squeezeAlert {
 ($player, $sound, $duration)=@_;
 $playerid=$players{$player}{mac}; $idx=$players{$player}{idx};
 $online=&checkPlayerState($idx); if (!$online) { return };
 &logMessage("SQUEEZEALERT: played alert '$sound' on player $player");
 # Get current player state so it can be restored after we play our alert
 $res = $client->call($sq_uri, { method  => 'slim.request', params  => [ $playerid, ['power', '?'] ] });
 $response=$res->jsontext; $data=decode_json $response; $power=$$data{result}{_power};
 $res = $client->call($sq_uri, { method  => 'slim.request', params  => [ $playerid, ['mode', '?'] ] });
 $response=$res->jsontext; $data=decode_json $response; $mode=$$data{result}{_mode};
 $res = $client->call($sq_uri, { method  => 'slim.request', params  => [ $playerid, ['mixer', 'volume', '?'] ] });
 $response=$res->jsontext; $data=decode_json $response; $volume=$$data{result}{_volume};
 $res = $client->call($sq_uri, { method  => 'slim.request', params  => [ $playerid, ['playlist', 'repeat', '?'] ] });
 $response=$res->jsontext; $data=decode_json $response; $repeat=$$data{result}{_repeat};
 $res = $client->call($sq_uri, { method  => 'slim.request', params  => [ $playerid, ['time', '?'] ] });
 $response=$res->jsontext; $data=decode_json $response; $time=$$data{result}{_time}; 
 if ($mode eq 'play') {
  $res = $client->call($sq_uri, { method  => 'slim.request', params  => [ $playerid, ['pause'] ] });
 } else { $noplay='noplay:1' };
 $res = $client->call($sq_uri, { method  => 'slim.request', params  => [ $playerid, ['playlist', 'save', 'curplayer', 'silent:1'] ] });
 # Now Play our alert sound
 $res = $client->call($sq_uri, { method  => 'slim.request', params  => [ $playerid, ['mixer', 'volume', '70'] ] });
 $res = $client->call($sq_uri, { method  => 'slim.request', params  => [ $playerid, ['playlist', 'repeat', '0'] ] });
 $res = $client->call($sq_uri, { method  => 'slim.request', params  => [ $playerid, ['playlist', 'play', $sound ] ] });
 sleep $duration;
 # Restore player to previous state from before the alert
 $res = $client->call($sq_uri, { method  => 'slim.request', params  => [ $playerid, ['mixer', 'volume', $volume] ] });
 $res = $client->call($sq_uri, { method  => 'slim.request', params  => [ $playerid, ['playlist', 'repeat', $repeat] ] });
 $res = $client->call($sq_uri, { method  => 'slim.request', params  => [ $playerid, ['playlist', 'resume', 'curplayer', $noplay ] ] });
 $res = $client->call($sq_uri, { method  => 'slim.request', params  => [ $playerid, ['time', $time ] ] });
 $res = $client->call($sq_uri, { method  => 'slim.request', params  => [ $playerid, ['power', $power] ] });
 unlink('/play/curplayer.m3u') or warn $!; # delete the temp playlist
# Now play the alert on the listed player(s).
foreach $sbox (qw/kitchen garage bathroom/) { 
 &squeezeAlert($sbox, 'file:///volume1/music/alerts/Ring10.wav', 5);

Work in Progress

  • Add support for Timers (schedule your player to play playlists)