From 543dd7d83bfdb64509a487d374341b94f8c671be Mon Sep 17 00:00:00 2001 From: jpawlowski Date: Sun, 6 Jan 2019 17:51:21 +0000 Subject: [PATCH] 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 --- fhem/FHEM/70_ONKYO_AVR.pm | 41 +++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/fhem/FHEM/70_ONKYO_AVR.pm b/fhem/FHEM/70_ONKYO_AVR.pm index 570614987..88b5129a0 100644 --- a/fhem/FHEM/70_ONKYO_AVR.pm +++ b/fhem/FHEM/70_ONKYO_AVR.pm @@ -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 "" ) {