• You've been granted Beta access to this site, allowing you to explore some of the new features while they're still under construction. More information can be found in the Beta forum.

Squeezebox / Logitech Media Center and HaikuHelper


Active Member
I thought I would share the bit of code I wrote to control a Logitech Media Server (also called a Squeezecenter, Squeezebox Center and Squeezebox Media Server) from HaikuHelper.  Hopefully this can be of some use by someone else.
This lets you translate actions or triggers on a Lumina or Omni into actions on the squeezeboxes in your house.  Turning off all of the players when you arm the alarm for example... or actions in response to button presses.
I only have coded the basic transport commands, the way playlists and what not work are more complicated and I am not sure how much use I would have for that right now as I would change the actual music via the iPeng app.
Everything starts off at the top declaring the variables for the LMS.  You need to supply the IP and Port (9000 is the default) of the server, and then the MAC Addresses of each player in an array:

// Variables for Logitech Media Center

var lmsIP = "";
var lmsPort = "9000";
var lmsPlayer = ["00:04:20:1e:18:0a", "00:04:20:1f:49:2d"]; // Master Bedroom, Master Bathroom

The first player listed will be Player 0, the next is Player 1, and so on.
Then you need the code that will actually build and submit the HTTP requests to the LMS:

// Functions to support HTTP requests to devices

function httpGet(theURL)
var xmlHttp = null;
xmlHttp = new XMLHttpRequest();
return xmlHttp.responseText;

// Logitech Media Center actions

function lmsSendCommand(thePlayer,p0,p1,p2,p3)
var lmsURL = null;
// Generate the base of the URL
lmsURL = "http://" + lmsIP + ":"+lmsPort+"/status.txt?p0="+p0
// Check and see if Parameter 1 is passed
if (p1 != null) {
lmsURL = lmsURL +"&p1="+p1;
// Check and see if Parameter 2 is passed
if (p2 != null) {
lmsURL = lmsURL +"&p2="+p2;
// Check and see if Parameter 3 is passed
if (p3 != null) {
lmsURL = lmsURL +"&p3="+p3;
// Add the player MAC at the end
lmsURL = lmsURL+"&player=" + lmsPlayer[thePlayer];
// helper.log(controller,"The URL will be "+lmsURL);

I have disabled the logging of the actual URL just to clean up the controller log, but if you want to see how the URL looks just uncomment that second to last line.  These two scripts work together to build the HTTP request, including any required parameters.  The httpGet function is generic and can be used for any HTTP request, not just for the LMS.
Finally, we have all of the individual functions to perform remote control actions.  Most commands only need the Player Number, as determined by the order you placed them in the array.
For example, to start playing on Player 0, you would execute:


But some commands need extra parameters, the Volume command for example needs the player ID and the new volume from 0 to 100.  This would be how to set the volume of player 0 to the volume level 50:


Finally, here is the dump of all of the functions that I have coded so far:
// LMS Action - Player Play
function lmsPlay(thePlayer) 
	helper.log(controller,"LMS Action - Play Player "+thePlayer);

// LMS Action - Player Stop
function lmsStop(thePlayer) 
	helper.log(controller,"LMS Action - Stop Player "+thePlayer);

// LMS Action - Player Sleep
function lmsSleep(thePlayer,seconds) 
	helper.log(controller,"LMS Action - Sleep Player "+thePlayer+" for "+seconds+" seconds");

// LMS Action - Player Pause
function lmsPause(thePlayer) 
	helper.log(controller,"LMS Action - Pause Player "+thePlayer);

// LMS Action - Player Unpause
function lmsUnpause(thePlayer) 
	helper.log(controller,"LMS Action - Unpause Player "+thePlayer);

// LMS Action - Player Pause Toggle
function lmsPauseToggle(thePlayer) 
	helper.log(controller,"LMS Action - Pause Toggle Player "+thePlayer);

// LMS Action - Player Volume
function lmsVolume(thePlayer,volume) 
	helper.log(controller,"LMS Action - Change Player "+thePlayer+" volume to "+volume);

// LMS Action - Player Mute On
function lmsMuteOn(thePlayer) 
	helper.log(controller,"LMS Action - Mute On Player "+thePlayer);

// LMS Action - Player Mute Off
function lmsMuteOff(thePlayer) 
	helper.log(controller,"LMS Action - Mute Off Player "+thePlayer);

// LMS Action - Player Mute Toggle
function lmsMuteToggle(thePlayer) 
	helper.log(controller,"LMS Action - Mute Toggle Player "+thePlayer);

// LMS Action - Player Display Change
function lmsPlayerDisplay(thePlayer,line1,line2,seconds) 
	helper.log(controller,"LMS Action - Display "+line1+" and "+line2+" on player "+thePlayer+" for "+seconds+" seconds");

// LMS Action - Press remote button
function lmsPressButton(thePlayer,code) 
	helper.log(controller,"LMS Action - Pressing Button Code "+code+" on player "+thePlayer);

// LMS Action - Player Power On
function lmsPowerOn(thePlayer) 
	helper.log(controller,"LMS Action - Power On Player "+thePlayer);

// LMS Action - Player Power Off
function lmsPowerOff(thePlayer) 
	helper.log(controller,"LMS Action - Power Off Player "+thePlayer);

// LMS Action - Player Power Toggle
function lmsPowerOn(thePlayer) 
	helper.log(controller,"LMS Action - Toggle Power Player "+thePlayer);

// LMS Action - Synchronize Player
function lmsSyncPlayer(thePlayer,syncPlayer) 
	helper.log(controller,"LMS Action - Synchronize Player "+thePlayer+" tp player "+syncPlayer);

// LMS Action - Un-Synchronize Player
function lmsUnSyncPlayer(thePlayer) 
	helper.log(controller,"LMS Action - Remove Sync on Player "+thePlayer);