Hier das Script und die Variablen:
<?
include "59739.ips.php"; // Squeezefunktions-Sammlung und Variablendefinitionen
$antwort = $IPS_VALUE;
$array = explode ( ' ', $antwort ); // Antwortstring in Array umwandeln
$array[0] = urldecode ( $array[0] ); // MAC in lesbares Format umwandeln
// Variablen aus der RegVar in die entsprechenden Variablen von IPS eintragen
// =============================
// SqueezeBox Classic Wohnzimmer
// =============================
if($array[0] == Wohnzimmer) { // Wohnzimmer
// Powertaste bei Änderung aktualisieren
if($array[1] == 'power') {
if ($array[2] == 1) {
SetValue(48681 /*[Sqeezebox\Power]*/, true);
} else {
SetValue(48681 /*[Sqeezebox\Power]*/, false);
}
SetValue(37372 /*[Sqeezebox\MAC]*/, $array[0]); //MAC in Variable
}
//Lautstärke bei Änderung aktualisieren
if($array[1]=='prefset' and $array[3]=='volume') {
SetValue(54790 /*[Sqeezebox\Volumen]*/, urldecode($array[4]));
SetValue(37372 /*[Sqeezebox\MAC]*/, $array[0]); //MAC in Variable
}
// Repeat bei Änderung aktualisieren
if($array[1]=='prefset' and $array[3]=='repeat') {
SetValue(54155 /*[Sqeezebox\Wiederholung]*/, $array[4]);
}
// Shuffle bei Änderung aktualisieren
if($array[1]=='prefset' and $array[3]=='shuffle') {
SetValue(14620 /*[Sqeezebox\Zufallwiedergabe]*/, $array[4]);
}
//Titel-Tag aktualisieren
if($array[1]=='playlist' and $array[2]=='newsong') {
SetValue(54731 /*[Sqeezebox\Aktueller Titel]*/ , utf8_decode(urldecode($array[3])));
SetValue(37372 /*[Sqeezebox\MAC]*/ , $array[0]); //MAC in Variable
SetValue(59750 /*[Sqeezebox\Steuerung]*/, 2); // Button auf play
cover(Wohnzimmer, 16410 /*[Sqeezebox\Cover]*/); // Cover anzeigen
// Subscripe auf entsprechende Box für Anzeige des Laufzeitbalkens
$box = Wohnzimmer;
$cmd = "status - 1 subscribe:2";
CSCK_SendText(SqueezeServer, $box." ".$cmd.chr(13));
}
// Steuerungstasten im Webfront aktualisieren
if($array[1]=='play') {
SetValue(59750 /*[Sqeezebox\Steuerung]*/, 2);
}
if($array[1]=='stop') {
SetValue(59750 /*[Sqeezebox\Steuerung]*/, 0);
// Subscribe ausschalten
$box = Wohnzimmer;
$cmd = "status - 1 subscribe:0";
CSCK_SendText(SqueezeServer, $box." ".$cmd.chr(13));
}
if($array[1]=='pause' and $array[2]==1) {
SetValue(59750 /*[Sqeezebox\Steuerung]*/, 1);
// Subscribe ausschalten
$box = Wohnzimmer;
$cmd = "status - 1 subscribe:0";
CSCK_SendText(SqueezeServer, $box." ".$cmd.chr(13));
}
if($array[1]=='pause' and $array[2]==0) {
SetValue(59750 /*[Sqeezebox\Steuerung]*/, 2);
$box = Wohnzimmer;
$cmd = "status - 1 subscribe:2";
CSCK_SendText(SqueezeServer, $box." ".$cmd.chr(13));
}
if($array[1]=='button' and $array[2]=='jump_rew') {
SetValue(59750 /*[Sqeezebox\Steuerung]*/, 4);
}
if($array[1]=='button' and $array[2]=='jump_fwd') {
SetValue(59750 /*[Sqeezebox\Steuerung]*/, 3);
}
if($array[1]=='status' and $array[4]=='subscribe%3A2') {
foreach($array as $item)
{
$item = utf8_decode(urldecode($item));
$chunks = explode(":", $item);
if($chunks[0] == "time")
{
SetValue(32602 /*[Sqeezebox\akt. Position]*/, date('i:s', $chunks[1]));
SetValue(15960 /*[Sqeezebox\akt. Position]*/, sprintf('%01.0f', $chunks[1]));
}
if($chunks[0] == "duration")
{
SetValue(15356 /*[Sqeezebox\Länge]*/, date('i:s', $chunks[1]));
SetValue(32289 /*[Sqeezebox\Länge]*/, sprintf('%01.0f', $chunks[1]));
}
if(GetValue(15356 /*[Sqeezebox\Länge]*/) !== "00:00") {
//slider(34996 /*[Objekt #34996 existiert nicht]*/, 100/GetValue(12610 /*[Objekt #12610 existiert nicht]*/)*GetValue(37989 /*[Objekt #37989 existiert nicht]*/), GetValue(40778 /*[Objekt #40778 existiert nicht]*/), GetValue(30117 /*[Objekt #30117 existiert nicht]*/));
slider2(31940 /*[Sqeezebox\Position Neu]*/, 100/GetValue(32289 /*[Sqeezebox\Länge]*/)*GetValue(15960 /*[Sqeezebox\akt. Position]*/));
}
}
}
}
//==============================================================
// Wiedergabelisten aus Squeezeserver nach IPS-Variable
//==============================================================
if($array[0] == 'playlists') {
if($array[1] == '0') {
// Associations löschen
$Playlists = IPS_GetVariableProfile(".SQ_Playlist") ; // Variablenprofil in Array schreiben
$CountPlaylists = count ($Playlists['Associations']); // Anzahl Assoziationen auslesen
for($del = 1; $del < $CountPlaylists + 1; $del++) {
IPS_SetVariableProfileAssociation(".SQ_Playlist", $del, "", "", -1); // Rekursiv überschreiben
}
IPS_Sleep(500); // IPS zeit geben die Ass. zu löschen
// Associations mit Wiedergabelisten aus Squeezeserver füllen
// array besteht aus "playlist / startwert / endwert / playlistname / playlist_id / ..... / chr(13)
// die ersten 3 Werte und das chr(13) wird entfernt
// durch 2 geteilt und 1 dazu da array bei 1 beginnt, ergibt anzahl der Playlisten ((count($array)-4)/2)+1
for($x=1; $x < ((count($array)-4)/2)+1; $x++ ) {
$y = ($x*2)+2;
$playlist = urldecode ( substr ($array[$y], 11) );
$playlist_id = urldecode ( substr ($array[$y-1], 5 ) );
IPS_SetVariableProfileAssociation(".SQ_Playlist", $x, $playlist, $playlist_id, -1);
}
}
}
//======================================================================
// Wiedergabelistenverarbeitung anstossen wenn eine neue Wiedergabeliste
// angelegt und benannte wurde
//======================================================================
if($array[0] == 'playlists') {
if($array[1] == 'rename') {
$cmd = "playlists 0 20";
CSCK_SendText(SqueezeServer, $cmd.chr(13)); // Playlists abrufen
}
}
//===========================================================================
// Wiedergabelistenprofil aktualisieren wenn im Squeezeserver gelöscht wurde
//===========================================================================
if($array[0] == 'playlists') {
if($array[1] == 'delete') {
// alle Associations löschen da sonst die letzte stehen bleibt
$Playlists = IPS_GetVariableProfile(".SQ_Playlist") ; // Profil in Array schreiben
$CountPlaylists = count ($Playlists['Associations']); // Anzahl Associations
for($del = 1; $del < $CountPlaylists + 1; $del++) {
IPS_SetVariableProfileAssociation(".SQ_Playlist", $del, "", ""); // entsprechend Anzahl löschen / überschreiben
}
IPS_Sleep(1000);
$cmd = "playlists 0 20";
CSCK_SendText(SqueezeServer, $cmd.chr(13)); // Playlists abrufen
IPS_Sleep(1000);
// Associations mit Wiedergabelisten aus Squeezeserver füllen
// array besteht aus "playlist / startwert / endwert / playlistname / playlist_id / ..... / chr(13)
// die ersten 3 Werte und das chr(13) wird entfernt
// durch 2 geteilt und 1 dazu da array bei 1 gebinnt, ergibt anzahl der Playlisten ((count($array)-4)/2)+1
for($x=1; $x < ((count($array)-4)/2)+1; $x++ ) {
$y = ($x*2)+2;
$playlist = urldecode ( substr ($array[$y], 11) );
$playlist_id = urldecode ( substr ($array[$y-1], 5 ) );
IPS_SetVariableProfileAssociation(".SQ_Playlist", $x, $playlist, $playlist_id);
}
}
}
//===========================================================================
// Antwort aus Playlistenausleseskript (33443 /*[Objekt #33443 existiert nicht]*/) nach IPS schreiben
//===========================================================================
if($array[0] == 'playlists' and $array[1] == 'tracks' and $array[2] == 0) {
SetValue(43991 /*[Objekt #43991 existiert nicht]*/, $antwort);
}
?>