Compare commits

...

9 Commits

Author SHA1 Message Date
Marko Oldenburg
2bfdbd9c05 merge from master 2020-02-27 13:59:50 +01:00
Marko Oldenburg
2883b6de26 fix Use of uninitialized value {repeat} in substitution (s///) 2018-03-13 20:14:29 +01:00
Marko Oldenburg
96a492a78f fix Use of uninitialized value {repeat} in substitution (s///) 2018-03-08 10:41:46 +01:00
Marko Oldenburg
3acc0dc955 change Master play_previous, change all Modules decode_json in a eval 2018-02-28 10:08:41 +01:00
Marko Oldenburg
3a71f505f5 add input URL 2017-12-13 10:04:13 +01:00
Marko Oldenburg
3c7aab77fb fix typo in define Fn 2017-10-17 11:03:00 +02:00
Marko Oldenburg
bce2a7a6ad bugfix missing curl 2017-08-25 21:34:27 +02:00
Marko Oldenburg
7915a96de4 little bugfixes 2017-08-24 06:37:47 +02:00
Marko Oldenburg
ce554402f6 diverse kleinere Anpassungen und fixes 2017-08-22 12:13:40 +02:00
3 changed files with 48 additions and 66 deletions

View File

@ -2,7 +2,7 @@
#
# Developed with Kate
#
# (c) 2017 Copyright: Marko Oldenburg (leongaultier at gmail dot com)
# (c) 2017-2018 Copyright: Marko Oldenburg (leongaultier at gmail dot com)
# All rights reserved
#
# Special thanks goes to comitters:
@ -38,7 +38,7 @@ use JSON qw(decode_json);
use Encode qw(encode_utf8);
my $version = "0.2.0";
my $version = "1.0.3";
@ -433,8 +433,13 @@ sub HEOSGroup_Parse($$) {
my $decode_json;
my $code;
$decode_json = eval{decode_json(encode_utf8($json))};
if($@){
Log3 $name, 3, "HEOSGroup ($name) - JSON error while request: $@";
return;
}
$decode_json = decode_json(encode_utf8($json));
Log3 $name, 4, "HEOSGroup ($name) - ParseFn wurde aufgerufen";
if( defined($decode_json->{gid}) ) {

View File

@ -2,7 +2,7 @@
#
# Developed with Kate
#
# (c) 2017 Copyright: Marko Oldenburg (leongaultier at gmail dot com)
# (c) 2017-2018 Copyright: Marko Oldenburg (leongaultier at gmail dot com)
# All rights reserved
#
# Special thanks goes to comitters:
@ -61,12 +61,12 @@ my $missingModul = "";
eval "use Net::Telnet;1" or $missingModul .= "Net::Telnet ";
eval "use JSON;1" or $missingModul .= "JSON ";
eval "use Encode;1" or $missingModul .= "Encode ";
eval "use IO::Socket::Multicast;1" or $missingModul .= "IO::Socket::Multicast ";
my $version = "1.0.0";
my $version = "1.0.3";
my %heosCmds = (
'enableChangeEvents' => 'system/register_for_change_events?enable=',
@ -95,7 +95,7 @@ my %heosCmds = (
'setMute' => 'player/set_mute?',
'setGroupMute' => 'group/set_mute?',
'playNext' => 'player/play_next?',
'playPrev' => 'player/play_prev?',
'playPrev' => 'player/play_previous?',
'playPresetStation' => 'browse/play_preset?',
'playInput' => 'browse/play_input?',
'playStream' => 'browse/play_stream?',
@ -216,7 +216,7 @@ sub HEOSMaster_Define($$) {
InternalTimer( gettimeofday()+15, 'HEOSMaster_FirstRun', $hash, 0 ) if( ($hash->{HOST}) );
}
$modules{HEOSPlayer}{defptr}{$host} = $hash;
$modules{HEOSMaster}{defptr}{$host} = $hash;
return undef;
}
@ -230,7 +230,7 @@ sub HEOSMaster_Undef($$) {
HEOSMaster_Close($hash);
delete $modules{HEOSMaster}{defptr}{$hash->{HOST}};
Log3 $name, 3, "HEOSPlayer ($name) - device $name deleted";
Log3 $name, 3, "HEOSMaster ($name) - device $name deleted";
return undef;
}
@ -366,7 +366,7 @@ sub HEOSMaster_Open($) {
my $password = HEOSMaster_ReadPassword($hash,$name);
Log3 $name, 4, "HEOSMaster ($name) - Baue Socket Verbindung auf";
Log3 $name, 4, "HEOSMaster ($name) - Build socket connection";
my $socket = new Net::Telnet ( Host=>$host,
Port => $port,
@ -464,7 +464,7 @@ sub HEOSMaster_Read($) {
Log3 $name, 4, "HEOSMaster ($name) - ReadFn gestartet";
$len = sysread($hash->{CD},$buf,1024); # die genaue Puffergröße wird noch ermittelt
$len = sysread($hash->{CD},$buf,1024);
if( !defined($len) || !$len ) {
@ -475,7 +475,7 @@ sub HEOSMaster_Read($) {
unless( defined $buf) {
Log3 $name, 3, "HEOSMaster ($name) - Keine Daten empfangen";
Log3 $name, 3, "HEOSMaster ($name) - no data received";
return;
}
@ -516,8 +516,12 @@ sub HEOSMaster_ProcessRead($$) {
$hash->{LAST_RECV} = time();
Log3 $name, 5, "HEOSMaster ($name) - Decoding JSON message. Length: " . length($json) . " Content: " . $json;
#my $obj = JSON->new->utf8(0)->decode($json); Änderung unter großem Vorbehalt wegen Sorge was Umlaute an geht!!!
my $obj = decode_json($json);
my $obj = eval{decode_json($json)};
if($@){
Log3 $name, 3, "HEOSMaster ($name) - JSON error while request: $@";
return;
}
if(defined($obj->{heos})) {
@ -551,7 +555,11 @@ sub HEOSMaster_ResponseProcessing($$) {
unless( defined($json));
Log3 $name, 4, "HEOSMaster ($name) - JSON detected!";
$decode_json = decode_json(encode_utf8($json));
$decode_json = eval{decode_json(encode_utf8($json))};
if($@){
Log3 $name, 3, "HEOSMaster ($name) - JSON error while request: $@";
return;
}
return Log3 $name, 3, "HEOSMaster ($name) - decode_json has no Hash"
unless(ref($decode_json) eq "HASH");
@ -829,17 +837,6 @@ sub HEOSMaster_ResponseProcessing($$) {
$ret =~ s/\n/<br>/g;
$ret = "<pre>$ret</pre>" if( $ret =~ m/ / );
$ret = "<html>$ret</html>";
} else {
#$ret =~ s/<a[^>]*>//g;
#$ret =~ s/<\/a>//g;
#$ret =~ s/<img[^>]*>\n//g;
#$ret =~ s/<div[^>]*>//g;
#$ret =~ s/<\/div>//g;
#$ret =~ s/<h2[^>]*>//g;
#$ret =~ s/<\/h2>//g;
#$ret .= "\n";
}
asyncOutput( $hash->{helper}{blocking}{$idx}{cl}, $ret );
@ -887,10 +884,6 @@ sub HEOSMaster_ResponseProcessing($$) {
my $ret = '';
$ret .= sprintf( "%-35s %-10s %s\n", 'Fav', 'type', 'title' );
#foreach my $item (@{ $hash->{helper}{searchresult}}) {
# $ret .= HEOSMaster_MakePlayLink($hash->{helper}{blocking}{name}, 'input', $message{sid}, $item, sprintf( "%-35s %-10s %s\n", "x", $item->{type}, $item->{name} ) );
#}
$ret .= "\n\n";
@ -1080,7 +1073,6 @@ sub HEOSMaster_ParseMsg($$) {
foreach my $c (split //, $buffer) {
if($open == $close && $open > 0) {
$tail .= $c;
#Log3 $name, 5, "HEOSMaster ($name) - $open == $close && $open > 0";
} elsif(($open == $close) && ($c ne '{')) {
@ -1107,8 +1099,7 @@ sub HEOSMaster_ParseMsg($$) {
$msg = '';
}
}
#Log3 $name, 5, "HEOSMaster ($name) - return msg: $msg and tail: $tail";
return ($msg,$tail);
}

View File

@ -2,7 +2,7 @@
#
# Developed with Kate
#
# (c) 2017 Copyright: Marko Oldenburg (leongaultier at gmail dot com)
# (c) 2017-2018 Copyright: Marko Oldenburg (leongaultier at gmail dot com)
# All rights reserved
#
# Special thanks goes to comitters:
@ -39,7 +39,7 @@ use Encode qw(encode_utf8);
use URI::Escape;
#use Data::Dumper;
my $version = "0.2.0";
my $version = "1.0.4";
@ -246,7 +246,6 @@ sub HEOSPlayer_Get($$@) {
my $param = shift( @args );
$param = '' if( !$param );
#$param = substr($param,1) if( $param && $param =~ '^|' );
if ( $param eq '' ) {
@ -277,7 +276,6 @@ sub HEOSPlayer_Get($$@) {
$ret .= HEOSPlayer_MakePlayLink($me->{cl}->{TYPE}, $hash->{NAME}, "1029", "heos_service", "Warteschlange", "https://production.ws.skyegloup.com:443/media/images/service/logos/musicsource_logo_playlists.png", 128, 32);
#$ret .= "\n\n";
if( $me->{cl}->{TYPE} eq 'FHEMWEB' ) {
@ -287,21 +285,6 @@ sub HEOSPlayer_Get($$@) {
$ret =~ s/\n/<br>/g;
$ret = "<pre>$ret</pre>" if( $ret =~ m/ / );
$ret = "<html>$ret</html>";
} else {
#$ret =~ s/<h3[^>]*>//g;
#$ret =~ s/<\/h3>/\n\n/g;
#$ret =~ s/<h5[^>]*>//g;
#$ret =~ s/<\/h5>/\n/g;
#$ret =~ s/<hr>//g;
#$ret =~ s/<a[^>]*>//g;
#$ret =~ s/<\/a>//g;
#$ret =~ s/<img[^>]*>//g;
#$ret =~ s/<div[^>]*>//g;
#$ret =~ s/<\/div>//g;
#$ret .= "\n";
}
return $ret;
@ -309,7 +292,6 @@ sub HEOSPlayer_Get($$@) {
} else {
my ($sid,$cid) = split /,/,$param;
#$param=~/^(-?\d+),?(.*)$/;
if ( $sid eq "1025" ) {
@ -404,15 +386,6 @@ sub HEOSPlayer_Get($$@) {
$ret =~ s/\n/<br>/g;
$ret = "<pre>$ret</pre>" if( $ret =~ m/ / );
$ret = "<html>$ret</html>";
} else {
#$ret =~ s/<a[^>]*>//g;
#$ret =~ s/<\/a>//g;
#$ret =~ s/<img[^>]*>\n//g;
#$ret =~ s/<div[^>]*>//g;
#$ret =~ s/<\/div>//g;
#$ret .= "\n";
}
asyncOutput( $me->{cl}, $ret );
@ -739,6 +712,15 @@ sub HEOSPlayer_Set($$@) {
$heosCmd = 'playQueueItem';
$action = "qid=$cid";
} elsif ( $sid eq "url" ) {
#URL abspielen
$heosCmd = 'playStream';
#$action = "url=".substr($param,4);
$action = "url=$cid";
#getestet mit "set HEOSPlayer_Name input url,http://sender.eldoradio.de:8000/128.mp3" ich wollte [cid] nicht nutzen da in einer url ja durchaus mehrere Kommata vorkommen können ob das mit dem substr() so toll ich kann ich leider nicht beurteilen. Auch würde ich bei der $sid ein lc($sid) drum machen aber da es nirgendwo ist :-)
} else {
if ( $sid > 0 && $sid < 1024 ) {
return "usage: $cmd sid,cid,mid" unless( defined($cid) && defined($mid) );
@ -789,7 +771,7 @@ sub HEOSPlayer_Set($$@) {
$list .= " playPlaylist:".join(",",@playlists) if( scalar @playlists > 0 );
$list .= " deletePlaylist:".join(",",@playlists) if( scalar @playlists > 0 );
}
#print "List#########################################################\n".Dumper($list);
$list .= " aux:noArg" if ( exists $hash->{helper}{aux} );
return "Unknown argument $cmd, choose one of $list";
}
@ -808,8 +790,13 @@ sub HEOSPlayer_Parse($$) {
my $decode_json;
my $code;
$decode_json = eval{decode_json(encode_utf8($json))};
if($@){
Log3 $name, 3, "HEOSPlayer ($name) - JSON error while request: $@";
return;
}
$decode_json = decode_json(encode_utf8($json));
Log3 $name, 4, "HEOSPlayer - ParseFn wurde aufgerufen";
if( defined($decode_json->{pid}) ) {
@ -913,7 +900,6 @@ sub HEOSPlayer_WriteReadings($$) {
my( @index )= grep { $presets[$_] eq $search } 0..$#presets if ( defined $search );
readingsBulkUpdate( $hash, 'channel', $index[0]+1 ) if ( scalar @index > 0 );
#readingsBulkUpdate( $hash, 'state', 'on' );
readingsEndUpdate( $hash, 1 );
Log3 $name, 5, "HEOSPlayer ($name) - readings set for $name";
return undef;
@ -952,7 +938,7 @@ sub HEOSPlayer_PreProcessingReadings($$) {
$buffer{'shuffle'} = $message{shuffle};
$buffer{'repeat'} = $message{repeat};
$buffer{'repeat'} =~ s/.*\_(.*)/$1/g;
$buffer{'repeat'} =~ s/.*\_(.*)/$1/g if( defined($buffer{'repeat'}) );
} elsif ( $decode_json->{heos}{command} =~ /get_mute/ ) {