Compare commits
9 Commits
4c3f195a15
...
2bfdbd9c05
Author | SHA1 | Date | |
---|---|---|---|
|
2bfdbd9c05 | ||
|
2883b6de26 | ||
|
96a492a78f | ||
|
3acc0dc955 | ||
|
3a71f505f5 | ||
|
3c7aab77fb | ||
|
bce2a7a6ad | ||
|
7915a96de4 | ||
|
ce554402f6 |
@ -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}) ) {
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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/ ) {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user