-
Notifications
You must be signed in to change notification settings - Fork 130
Items SqueezeboxCLI
See original
The module enables control of a Squeezebox device through the CLI (command line interface) of the Squeezebox server (a.k.a. Logitech Media server).
This module connects to the Squeezebox server through the telnet interface. The following preparations need to be done to get the code up and running:
Create the Squeezebox devices in the mht file or in user code:
Note: [parameters] are optional.
CODE, require SqueezeboxCLI; #noloop
CODE, $squeezecenter = new SqueezeboxCLI_Interface('hostname'); #noloop
CODE, $sb_living = new SqueezeboxCLI_Player('living', $squeezecenter, [coupled_device], [auto_off_time]); #noloop
CODE, $sb_kitchen = new SqueezeboxCLI_Player('kitchen', $squeezecenter, [coupled_device], [auto_off_time]); #noloop
Optional parameters:
You can add a 'coupled device' to the Squeezebox. You would typically use this when you want to switch the amplifier together with the Squeezebox. Couple a device with: CODE, $sb_living->couple_device($amplifier_living);
you can set an 'auto-off' time in minutes. When the player gets paused, you can define after how many minutes is should be turned off completely. This is useful when you have defined a coupled device to avoid the amplifier to be on for too long after a playlist is paused.
To play a file or URL from your user code you can use this function call:
$sb_kitchen->play_notification('/Volumes/Media/speech/test1.wave');
For additional debugging, add the option squeezeboxcli:3 to the 'debug' entry to your mh.ini file.
This module allows to control and to monitor the state over a Squeezebox player through the telnet command line interface of the server. It also allows you to play notifications. Notifications can either be local files or URLs.
URI::Escape - The CLI interface uses an escaped format
Method | Description |
---|---|
new(name, interface, amplifier, auto_off_time) |
Creates a Squeezebox_Player object. The following parameter are required:name : the 'friendly' name of the squeezebox in squeezecenter. This parameter is used to link this object to the correct status messages in the CLI interface of squeezecenterinterface : the object that is the CLI interface to assign this player to.The following parameters are optional amplifier : the object that needs to be enabled and disabled together with the squeezeboxauto_off_time : the time (in minutes) the squeezebox and the optional attached amplifier should be turned off after a playlist has endedpreheat_time : the time (in seconds) the amplifier should be turned on before a notification is played if the amplifier is off. This enables the amplifier to turn on and enable the speakers before the notification is played. |
process_cli_response() |
Interpret the data that is received from the CLI interface. Called from the gateway module. |
default_setstate() |
Handle state changes of the Squeezeboxes |
addStates() |
Add states to the device |
couple_device(amplifier) |
Couple another MisterHouse object to the Squeezebox device so that this device follows the state of the Squeezebox. This can e.g. be used to switch an amplifier on when the Squeezebox starts playing. |
play_notification(notification, <optional_volume)> |
Play a notification on this squeezebox. The notification can either be a file or an URL. This function stops the current playback, plays the notification and then returns the Squeezebox to the previous state. Credits to @rudybrian for writing the first version of this code and his permission to re-use it! You can pass an extra parameter that is used for the notification. Note: currently this function does not support multiple notifications being pushed at the same time |
play(media, [volume]) |
Changes the playlist to a new media file Parameters are the media (a file or an URL) and optionally the volume at which to play the media. |
play_playlist(name, [volume]) |
Changes the playlist to a new playlist. Parameters are the playlist name and optionally the volume at which to play the media. |
save_sb_state |
Saves the current state of the Squeezebox so that it can be restored later |
restore_sb_state |
Resume the Squeezebox state from the previously saved state |
send_cmd(command) |
Helper function to send a command to the squeezebox over the CLI |