xPL_Squeezebox.pm

xPL_Squeezebox

DESCRIPTION

xPL_Squeezebox.pm - xPL support for the former SlimDevices (now Logitech) Squeezebox devices

This module allows to easily integrate Squeezebox devices in your MH setup by using the xPL interface to the devices.

It supports device monitoring (check the heartbeat), keeps the state of the squeezebox (playing/stopped/power_off), and allows to play a file/URL.

Usage:

 In your items.mht, add the squeezebox devices like this:
 
   XPL_SQUEEZEBOX, xpl_device_id, object_name, SBs
 
 e.g. assuming the xpl name of your SB is 'slimdev-slimserv.kitchen'
 
   XPL_SQUEEZEBOX, kitchen, sb_kitchen, Squeezeboxes
   
 Then in your code do something like:
   
   $sb_status_req_timer = new Timer; # noloop
   set $sb_status_req_timer 10;      # noloop

   $sb_kitchen->manage_heartbeat_timeout(360, "speak 'Squeezebox kitchen is offline'", 1); #noloop

   if ($state = state_now $sb_kitchen){
         print_log "+++ State event on sb_kitchen, state is " . $state;
   }
   
   if (expired $sb_status_req_timer) {
        set $sb_status_req_timer 60;
        xPL_Squeezebox::request_all_stat();
   }

Turn on debug=xpl_squeezebox for diagnostic messages

Currently supports: * Turning the SB on/off (play/stop command) * Keeping track of the status of the SB when it is controlled by the remote/web interface * Playing a file or an URL on a Squeezebox

METHODS

new()

Creates a new object

request_all_stat()

Requests the state of all squeezebox devices

We need to do this through this rather elaborate code that keeps a list of all objects that have been created and that goes over this list one by one. This is because SqueezeCenter currently does not respond to an audio.request that is directed to slimdev-slimserv.* If it would we could here simply use &xPL::sendXpl('slimdev-slimserv.*', 'cmnd', 'audio.request' => { 'cmd' => 'status' });

request_stat()

Request the status of a single Squeezebox

id()

Returns the ID of the Squeezebox

addStates()

Add states to the device

ignore_message()

Determine what xPL messages will be interpreted

default_setstate()

Handle state changes of the Squeezeboxes

play(file/URL)

Accepts a file (a full paths on the machine that is running the Squeezebox server application) or an URL that should be played on the device.

LICENSE

This free software is licensed under the terms of the GNU public license.

AUTHOR

Lieven Hollevoet lieven@lika.be

CREDITS Gregg Liming for the idea that we should not rely on the heartbeat messages to get the status of the Squeezebox.

 xPL_Squeezebox.pm