From 0d3eb21c9e19235e1efe3120cf73bd28e6279dbc Mon Sep 17 00:00:00 2001 From: justme1968 Date: Sat, 25 Jun 2016 17:57:29 +0000 Subject: [PATCH] 37_plex.pm: more defaults for plex_publishToSonos() function git-svn-id: https://svn.fhem.de/fhem/trunk@11716 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/37_plex.pm | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/fhem/FHEM/37_plex.pm b/fhem/FHEM/37_plex.pm index f12b969ee..2af7d52de 100644 --- a/fhem/FHEM/37_plex.pm +++ b/fhem/FHEM/37_plex.pm @@ -890,12 +890,13 @@ plex_Set($$@) return undef; } elsif( $cmd eq 'smapiRegister' ) { - return "first use the httpPort to configure a fixed http port" if( !AttrVal($name, 'httpPort', 0) ); + return "first use the httpPort attribute to configure a fixed http port" if( !AttrVal($name, 'httpPort', 0) ); return plex_publishToSonos($name, 'PLEX', $params[0]); } $list .= 'playlistCreate playlistAdd playlistRemove '; + $list .= 'smapiRegister ' if( $hash->{helper}{timelineListener} ); $list .= 'unwatched watched '; } @@ -3937,13 +3938,18 @@ Log 1, "!!!!!!!!!!"; } sub -plex_publishToSonos($$;$) +plex_publishToSonos(;$$$) { my ($hash,$service,$player) = @_; + $hash = $modules{plex}{defptr}{MASTER} if( !$hash && defined($modules{plex}{defptr}{MASTER}) ); $hash = $defs{$hash} if( ref($hash) ne 'HASH' ); - return undef if( !$hash ); + return 'no plex device found' if( !$hash ); my $name = $hash->{NAME}; + return 'no timeline listener started' if( !$hash->{helper}{timelineListener} ); + + $service = 'PLEX' if( !$service ); + my $i = 0; foreach my $d (devspec2array("TYPE=SONOSPLAYER")) { next if( $player && $d !~ /$player/ );