diff --git a/fhem/contrib/97_SB_SERVER.pm b/fhem/contrib/97_SB_SERVER.pm index f71c9dc82..0afe85b66 100644 --- a/fhem/contrib/97_SB_SERVER.pm +++ b/fhem/contrib/97_SB_SERVER.pm @@ -1,5 +1,5 @@ # ############################################################################ -# $Id$ +# $Id$ # # FHEM Module for Squeezebox Servers # @@ -38,9 +38,8 @@ # 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; use strict; use warnings; @@ -314,6 +313,13 @@ sub SB_SERVER_Define( $$ ) { # CD wait for init_done if ($init_done>0){ 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" ); } @@ -452,10 +458,8 @@ sub SB_SERVER_Ready( $ ) { return undef; } } - } - # ---------------------------------------------------------------------------- # Get functions # ---------------------------------------------------------------------------- @@ -479,14 +483,21 @@ sub SB_SERVER_Get( $@ ) { sub SB_SERVER_Attr( @ ) { my $cmd = shift( @_ ); my $name = shift( @_ ); + my $hash = $defs{$name}; my @args = @_; Log( 4, "SB_SERVER_Attr($name): called with @args" ); 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 } elsif( $cmd eq "cliraw" ) { - # write raw messages to the CLI interface per player - my $v = join( " ", @a ); - $v .= "\n"; - Log3( $hash, 5, "SB_SERVER_Set: cliraw: $v " ); - IOWrite( $hash, $v ); - + # write raw messages to the CLI interface per player + my $v = join( " ", @a ); + $v .= "\n"; + Log3( $hash, 5, "SB_SERVER_Set: cliraw: $v " ); + DevIo_SimpleWrite( $hash, $v, 0 ); # CD 0016 IOWrite in DevIo_SimpleWrite geändert } 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 } elsif( $cmd eq "updateModules" ) { if(defined($a[0])) { @@ -952,6 +961,12 @@ sub SB_SERVER_ParseCmds( $$ ) { SB_SERVER_ParseServerAlarmPlaylists( $hash, \@args ); } # 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 { # unkown } @@ -1247,7 +1262,7 @@ sub SB_SERVER_ParseServerStatus( $$ ) { my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime( $2 ); $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" ); next; } elsif( $_ =~ /^(scanning:)([0-9]*)/ ) { @@ -1996,7 +2011,7 @@ sub SB_SERVER_setStates($$) Define
define <name> SB_SERVER <ip[:cliserverport]> [RCC:<RCC>] [WOL:<WOL>] [PRSENCE:<PRSENCE>] [USER:<username>] [PASSWORD:<password>]
+ define <name> SB_SERVER <ip[:cliserverport]> [RCC:<RCC>] [WOL:<WOL>] [PRESENCE:<PRESENCE>] [USER:<username>] [PASSWORD:<password>]