contrib/97_SB_SERVER.pm: changed reconnect after modify, fixed rescan, cliraw and scan_last
git-svn-id: https://svn.fhem.de/fhem/trunk@9811 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
@@ -38,9 +38,8 @@
|
|||||||
# CLIPORT the port for the CLI interface of the server
|
# CLIPORT the port for the CLI interface of the server
|
||||||
#
|
#
|
||||||
# ############################################################################
|
# ############################################################################
|
||||||
# based on 97_SB_SERVER.pm beta 20141120 bugster_de, Update 0014 CD
|
# based on 97_SB_SERVER.pm 8246 beta 0016 CD
|
||||||
# ############################################################################
|
# ############################################################################
|
||||||
|
|
||||||
package main;
|
package main;
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
@@ -314,6 +313,13 @@ sub SB_SERVER_Define( $$ ) {
|
|||||||
# CD wait for init_done
|
# CD wait for init_done
|
||||||
if ($init_done>0){
|
if ($init_done>0){
|
||||||
delete($hash->{NEXT_OPEN}) if($hash->{NEXT_OPEN}); # CD 0007 reconnect immediately after modify
|
delete($hash->{NEXT_OPEN}) if($hash->{NEXT_OPEN}); # CD 0007 reconnect immediately after modify
|
||||||
|
# CD 0016 start
|
||||||
|
if( $hash->{STATE} eq "opened" ) {
|
||||||
|
DevIo_CloseDev( $hash );
|
||||||
|
readingsSingleUpdate( $hash, "power", "?", 0 );
|
||||||
|
$hash->{STATE}="disconnected";
|
||||||
|
}
|
||||||
|
# CD 0016 end
|
||||||
$ret= DevIo_OpenDev($hash, 0, "SB_SERVER_DoInit" );
|
$ret= DevIo_OpenDev($hash, 0, "SB_SERVER_DoInit" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -452,10 +458,8 @@ sub SB_SERVER_Ready( $ ) {
|
|||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# ----------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------
|
||||||
# Get functions
|
# Get functions
|
||||||
# ----------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------
|
||||||
@@ -479,14 +483,21 @@ sub SB_SERVER_Get( $@ ) {
|
|||||||
sub SB_SERVER_Attr( @ ) {
|
sub SB_SERVER_Attr( @ ) {
|
||||||
my $cmd = shift( @_ );
|
my $cmd = shift( @_ );
|
||||||
my $name = shift( @_ );
|
my $name = shift( @_ );
|
||||||
|
my $hash = $defs{$name};
|
||||||
my @args = @_;
|
my @args = @_;
|
||||||
|
|
||||||
Log( 4, "SB_SERVER_Attr($name): called with @args" );
|
Log( 4, "SB_SERVER_Attr($name): called with @args" );
|
||||||
|
|
||||||
if( $cmd eq "set" ) {
|
if( $cmd eq "set" ) {
|
||||||
if( $args[ 0 ] eq "alivetimer" ) {
|
if( $args[ 0 ] eq "alivetimer" ) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
# CD 0015 bei Änderung des Ports diesen an Clients schicken
|
||||||
|
if( $args[ 0 ] eq "httpport" ) {
|
||||||
|
SB_SERVER_Broadcast( $hash, "SERVER",
|
||||||
|
"IP " . $hash->{IP} . ":" .
|
||||||
|
$args[ 1 ] );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -547,15 +558,13 @@ sub SB_SERVER_Set( $@ ) {
|
|||||||
DevIo_SimpleWrite( $hash, "alarm playlists 0 300\n", 0 ); # CD 0011
|
DevIo_SimpleWrite( $hash, "alarm playlists 0 300\n", 0 ); # CD 0011
|
||||||
|
|
||||||
} elsif( $cmd eq "cliraw" ) {
|
} elsif( $cmd eq "cliraw" ) {
|
||||||
# write raw messages to the CLI interface per player
|
# write raw messages to the CLI interface per player
|
||||||
my $v = join( " ", @a );
|
my $v = join( " ", @a );
|
||||||
$v .= "\n";
|
$v .= "\n";
|
||||||
Log3( $hash, 5, "SB_SERVER_Set: cliraw: $v " );
|
Log3( $hash, 5, "SB_SERVER_Set: cliraw: $v " );
|
||||||
IOWrite( $hash, $v );
|
DevIo_SimpleWrite( $hash, $v, 0 ); # CD 0016 IOWrite in DevIo_SimpleWrite geändert
|
||||||
|
|
||||||
} elsif( $cmd eq "rescan" ) {
|
} elsif( $cmd eq "rescan" ) {
|
||||||
IOWrite( $hash, $cmd . " " . $a[ 0 ] . "\n" );
|
DevIo_SimpleWrite( $hash, $cmd . " " . $a[ 0 ] . "\n", 0 ); # CD 0016 IOWrite in DevIo_SimpleWrite geändert
|
||||||
|
|
||||||
# CD 0013/14 start
|
# CD 0013/14 start
|
||||||
} elsif( $cmd eq "updateModules" ) {
|
} elsif( $cmd eq "updateModules" ) {
|
||||||
if(defined($a[0])) {
|
if(defined($a[0])) {
|
||||||
@@ -952,6 +961,12 @@ sub SB_SERVER_ParseCmds( $$ ) {
|
|||||||
SB_SERVER_ParseServerAlarmPlaylists( $hash, \@args );
|
SB_SERVER_ParseServerAlarmPlaylists( $hash, \@args );
|
||||||
}
|
}
|
||||||
# CD 0011 end
|
# CD 0011 end
|
||||||
|
# CD 0016 start
|
||||||
|
} elsif( $cmd eq "rescan" ) {
|
||||||
|
if( $args[0] eq "done" ) {
|
||||||
|
DevIo_SimpleWrite( $hash, "serverstatus 0 200\n", 0 );
|
||||||
|
}
|
||||||
|
# CD 0016 end
|
||||||
} else {
|
} else {
|
||||||
# unkown
|
# unkown
|
||||||
}
|
}
|
||||||
@@ -1247,7 +1262,7 @@ sub SB_SERVER_ParseServerStatus( $$ ) {
|
|||||||
my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
|
my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
|
||||||
localtime( $2 );
|
localtime( $2 );
|
||||||
$year = $year + 1900;
|
$year = $year + 1900;
|
||||||
readingsBulkUpdate( $hash, "scan_last", "$mday-$mon-$year " .
|
readingsBulkUpdate( $hash, "scan_last", "$mday-".($mon+1)."-$year " . # CD 0016 Monat korrigiert
|
||||||
"$hour:$min:$sec" );
|
"$hour:$min:$sec" );
|
||||||
next;
|
next;
|
||||||
} elsif( $_ =~ /^(scanning:)([0-9]*)/ ) {
|
} elsif( $_ =~ /^(scanning:)([0-9]*)/ ) {
|
||||||
@@ -1996,7 +2011,7 @@ sub SB_SERVER_setStates($$)
|
|||||||
<a name="SBserverdefine"></a>
|
<a name="SBserverdefine"></a>
|
||||||
<b>Define</b>
|
<b>Define</b>
|
||||||
<ul>
|
<ul>
|
||||||
<code>define <name> SB_SERVER <ip[:cliserverport]> [RCC:<RCC>] [WOL:<WOL>] [PRSENCE:<PRSENCE>] [USER:<username>] [PASSWORD:<password>]</code>
|
<code>define <name> SB_SERVER <ip[:cliserverport]> [RCC:<RCC>] [WOL:<WOL>] [PRESENCE:<PRESENCE>] [USER:<username>] [PASSWORD:<password>]</code>
|
||||||
<br><br>
|
<br><br>
|
||||||
|
|
||||||
This module allows you to control Logitech Media Server and connected Squeezebox Media Players.<br><br>
|
This module allows you to control Logitech Media Server and connected Squeezebox Media Players.<br><br>
|
||||||
|
|||||||
Reference in New Issue
Block a user