2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-07 19:04:20 +00:00

70_ONKYO_AVR.pm: improve album art support, forum #msg882019

git-svn-id: https://svn.fhem.de/fhem/trunk@18164 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
jpawlowski 2019-01-06 17:51:21 +00:00
parent cc75e524e1
commit 543dd7d83b

View File

@ -1387,9 +1387,6 @@ sub ONKYO_AVR_Get($$$) {
sub ONKYO_AVR_Read($) {
my ($hash) = @_;
my $name = $hash->{NAME};
my $state = ReadingsVal( $name, "power", "off" );
my $zone = 0;
my $definedZones = scalar keys %{ $modules{ONKYO_AVR_ZONE}{defptr}{$name} };
# read from serial device
my $buf = DevIo_SimpleRead($hash);
@ -1418,6 +1415,24 @@ sub ONKYO_AVR_Read($) {
$hash->{PARTIAL} = "";
}
my @cmds = split( 'ISCP', $buf );
for my $el (@cmds) {
if ( $el ne '' ) {
ONKYO_AVR_Read2( $hash, $name, "ISCP$el" );
}
}
return;
}
sub ONKYO_AVR_Read2($$$) {
my ( $hash, $name, $buf ) = @_;
my $state = ReadingsVal( $name, "power", "off" );
my $zone = 0;
my $definedZones = scalar keys %{ $modules{ONKYO_AVR_ZONE}{defptr}{$name} };
my $length = length $buf;
return unless ( $length >= 16 );
@ -1945,22 +1960,28 @@ sub ONKYO_AVR_Read($) {
&& $value ne "on"
&& $value ne "off" )
{
if ( $value =~ /^([012])([012])(.*)$/ ) {
if ( $value =~ /^([012])([012\-])(.*)$/ ) {
my $type = "bmp";
$type = "jpg" if ( $1 eq "1" );
$type = "link" if ( $1 eq "2" );
$hash->{helper}{cover}{$type}{parts} = "1" if ( "$2" eq "0" );
$hash->{helper}{cover}{$type}{parts}++ if ( "$2" ne "0" );
$hash->{helper}{cover}{$type}{data} = "" if ( "$2" eq "0" );
$hash->{helper}{cover}{$type}{data} .= "$3"
if ( "$2" eq "0" || $hash->{helper}{cover}{$type}{data} ne "" );
if ( $2 eq "-" ) {
$hash->{helper}{cover}{$type}{data} = "$3";
}
else {
$hash->{helper}{cover}{$type}{parts} = "1" if ( "$2" eq "0" );
$hash->{helper}{cover}{$type}{parts}++ if ( "$2" ne "0" );
$hash->{helper}{cover}{$type}{data} = "" if ( "$2" eq "0" );
$hash->{helper}{cover}{$type}{data} .= "$3"
if ( "$2" eq "0"
|| $hash->{helper}{cover}{$type}{data} ne "" );
}
Log3 $name, 4, "ONKYO_AVR $name: rcv $cmd($type) in progress, part "
. $hash->{helper}{cover}{$type}{parts};
# complete album art received
if ( $2 eq "2"
if ( ( $2 eq "2" || $2 eq "-" )
&& $type eq "link"
&& $hash->{helper}{cover}{$type}{data} ne "" )
{