Skip to content

Items xPL_Squeezebox

ggodart edited this page Jan 6, 2021 · 1 revision

xPL_Squeezebox

See original

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.

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

Items.mht

Defined in items.mht as

#   XPL_SQUEEZEBOX, xpl_device_id, object_name, SBs
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();
   }

INI PARAMETERS

Turn on debug=xpl_squeezebox for diagnostic messages

METHODS

Method Description
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.

AUTHOR

Lieven Hollevoet [email protected]

CREDITS

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

Clone this wiki locally