2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-21 20:06:18 +00:00

70_PIONEERAVR.pm: code cleanup inspired by perlcritic

git-svn-id: https://svn.fhem.de/fhem/trunk@22796 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
50watt 2020-09-19 20:59:41 +00:00
parent 8291e8d0ce
commit 9d5991bc26

View File

@ -54,15 +54,15 @@ no if $] >= 5.017011, warnings => 'experimental::smartmatch';
######################### #########################
# Forward declaration # Forward declaration
sub PIONEERAVR_Set($@); sub PIONEERAVR_Set;
sub PIONEERAVR_Get($$$); sub PIONEERAVR_Get;
sub PIONEERAVR_Define($$); sub PIONEERAVR_Define;
sub PIONEERAVR_Undef($$); sub PIONEERAVR_Undef;
sub PIONEERAVR_Read($); sub PIONEERAVR_Read;
sub PIONEERAVR_Write($$); sub PIONEERAVR_Write;
sub PIONEERAVR_Parse($$$); sub PIONEERAVR_Parse;
sub RC_layout_PioneerAVR(); sub RC_layout_PioneerAVR;
sub PIONEERAVR_RCmakenotify($$); sub PIONEERAVR_RCmakenotify;
##################################### #####################################
#Die Funktion wird von Fhem.pl nach dem Laden des Moduls aufgerufen #Die Funktion wird von Fhem.pl nach dem Laden des Moduls aufgerufen
@ -83,7 +83,7 @@ sub PIONEERAVR_RCmakenotify($$);
# readingsBeginUpdate, readingsBulkUpdate, readingsEndUpdate oder readingsSingleUpdate verwendet. # readingsBeginUpdate, readingsBulkUpdate, readingsEndUpdate oder readingsSingleUpdate verwendet.
# In diesen Funktionen werden Attribute wie event-min-interval oder auch event-on-change-reading ausgewertet # In diesen Funktionen werden Attribute wie event-min-interval oder auch event-on-change-reading ausgewertet
sub PIONEERAVR_Initialize($) { sub PIONEERAVR_Initialize {
my ( $hash) = @_; my ( $hash) = @_;
Log3 $hash, 5, "PIONEERAVR_Initialize: Entering"; Log3 $hash, 5, "PIONEERAVR_Initialize: Entering";
@ -152,7 +152,7 @@ sub PIONEERAVR_Initialize($) {
# Damit die übergebenen Werte auch anderen Funktionen zur Verfügung stehen und an die jeweilige Geräteinstanz gebunden sind, # Damit die übergebenen Werte auch anderen Funktionen zur Verfügung stehen und an die jeweilige Geräteinstanz gebunden sind,
# werden die Werte typischerweise als Internals im Hash der Geräteinstanz gespeichert # werden die Werte typischerweise als Internals im Hash der Geräteinstanz gespeichert
sub PIONEERAVR_Define($$) { sub PIONEERAVR_Define {
my ( $hash, $a, $h ) = @_; my ( $hash, $a, $h ) = @_;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
my $protocol = @$a[2]; my $protocol = @$a[2];
@ -1300,7 +1300,7 @@ sub PIONEERAVR_Define($$) {
### initialize timer ### initialize timer
$hash->{helper}{nextConnectionCheck} = gettimeofday()+120; $hash->{helper}{nextConnectionCheck} = gettimeofday()+120;
return undef; return;
} }
##################################### #####################################
@ -1312,7 +1312,7 @@ sub PIONEERAVR_Define($$) {
#Zugewiesene Variablen im Hash der Geräteinstanz, Internals oder Readings müssen hier nicht gelöscht werden. #Zugewiesene Variablen im Hash der Geräteinstanz, Internals oder Readings müssen hier nicht gelöscht werden.
# In fhem.pl werden die entsprechenden Strukturen beim Löschen der Geräteinstanz ohnehin vollständig gelöscht. # In fhem.pl werden die entsprechenden Strukturen beim Löschen der Geräteinstanz ohnehin vollständig gelöscht.
sub sub
PIONEERAVR_Undef($$) PIONEERAVR_Undef
{ {
my ( $hash, $arg) = @_; my ( $hash, $arg) = @_;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
@ -1332,12 +1332,12 @@ PIONEERAVR_Undef($$)
} }
} }
DevIo_CloseDev( $hash); DevIo_CloseDev( $hash);
return undef; return;
} }
##################################### #####################################
sub sub
PIONEERAVR_Ready($) PIONEERAVR_Ready
{ {
my ( $hash) = @_; my ( $hash) = @_;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
@ -1367,7 +1367,7 @@ PIONEERAVR_Ready($)
} }
sub PIONEERAVR_Notify($$) { sub PIONEERAVR_Notify {
my ( $hash, $dev ) = @_; my ( $hash, $dev ) = @_;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
my $devName = $dev->{NAME}; my $devName = $dev->{NAME};
@ -1493,7 +1493,7 @@ sub PIONEERAVR_Notify($$) {
##################################### #####################################
sub sub
PIONEERAVR_DoInit($) PIONEERAVR_DoInit
{ {
my $hash = shift; my $hash = shift;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
@ -1503,12 +1503,12 @@ PIONEERAVR_DoInit($)
$hash->{STATE} = "Initialized" if(!$hash->{STATE}); $hash->{STATE} = "Initialized" if(!$hash->{STATE});
return undef; return;
} }
##################################### #####################################
sub sub
PIONEERAVR_Clear($) PIONEERAVR_Clear
{ {
my $hash = shift; my $hash = shift;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
@ -1520,7 +1520,7 @@ PIONEERAVR_Clear($)
#################################### ####################################
sub sub
PIONEERAVR_Set($@) PIONEERAVR_Set
{ {
my ($hash, $a, $h) = @_; my ($hash, $a, $h) = @_;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
@ -1660,18 +1660,18 @@ PIONEERAVR_Set($@)
Log3 $name, 5, "PIONEERAVR $name: Set $cmd -> 2x newline + 2x PO with 100ms break in between"; Log3 $name, 5, "PIONEERAVR $name: Set $cmd -> 2x newline + 2x PO with 100ms break in between";
my $setCmd= ""; my $setCmd= "";
PIONEERAVR_Write( $hash, $setCmd); PIONEERAVR_Write( $hash, $setCmd);
select(undef, undef, undef, 0.1); sleep(0.1);
PIONEERAVR_Write( $hash, $setCmd); PIONEERAVR_Write( $hash, $setCmd);
select(undef, undef, undef, 0.1); sleep(0.1);
$setCmd= "\n\rPO"; $setCmd= "\n\rPO";
PIONEERAVR_Write( $hash, $setCmd); PIONEERAVR_Write( $hash, $setCmd);
select(undef, undef, undef, 0.2); sleep(0.2);
PIONEERAVR_Write( $hash, $setCmd); PIONEERAVR_Write( $hash, $setCmd);
if (ReadingsVal($name,"networkStandby","") eq "off") { if (ReadingsVal($name,"networkStandby","") eq "off") {
return "NetworkStandby for the Pioneer AV receiver is off. If Fhem should be able to turn the AV Receiver on from standby enable networkStandby on the Pioneer AV Receiver (e.g. set $name networkStandby on )!"; return "NetworkStandby for the Pioneer AV receiver is off. If Fhem should be able to turn the AV Receiver on from standby enable networkStandby on the Pioneer AV Receiver (e.g. set $name networkStandby on )!";
} else { } else {
return undef; return;
} }
#### simple set commands without attributes #### simple set commands without attributes
#### we just "translate" the human readable command to the PioneerAvr command #### we just "translate" the human readable command to the PioneerAvr command
@ -1680,13 +1680,13 @@ PIONEERAVR_Set($@)
my $setCmd= $hash->{helper}{SETS}{main}{$cmd}; my $setCmd= $hash->{helper}{SETS}{main}{$cmd};
my $v= PIONEERAVR_Write( $hash, $setCmd); my $v= PIONEERAVR_Write( $hash, $setCmd);
Log3 $name, 5, "PIONEERAVR $name: Set $cmd (setsWithoutArg): ". $cmd ." -> $setCmd"; Log3 $name, 5, "PIONEERAVR $name: Set $cmd (setsWithoutArg): ". $cmd ." -> $setCmd";
return undef; return;
# statusRequest: execute all "get" commands to update the readings # statusRequest: execute all "get" commands to update the readings
} elsif ( $cmd eq "statusRequest") { } elsif ( $cmd eq "statusRequest") {
Log3 $name, 5, "PIONEERAVR $name: Set $cmd "; Log3 $name, 5, "PIONEERAVR $name: Set $cmd ";
PIONEERAVR_statusUpdate( $hash); PIONEERAVR_statusUpdate( $hash);
return undef; return;
#### play, pause, stop, random, repeat,prev,next,rev,fwd,up,down,right,left,enter,return,menu #### play, pause, stop, random, repeat,prev,next,rev,fwd,up,down,right,left,enter,return,menu
#### Only available if the input is one of: #### Only available if the input is one of:
@ -1735,7 +1735,7 @@ PIONEERAVR_Set($@)
} }
my $setCmd= $hash->{helper}{SETS}{main}{$playerCmd}; my $setCmd= $hash->{helper}{SETS}{main}{$playerCmd};
PIONEERAVR_Write( $hash, $setCmd); PIONEERAVR_Write( $hash, $setCmd);
return undef; return;
#### channelUp, channelDown #### channelUp, channelDown
#### Only available if the input is 02 (tuner) #### Only available if the input is 02 (tuner)
} elsif ($cmd ~~ @setsTuner) { } elsif ($cmd ~~ @setsTuner) {
@ -1748,7 +1748,7 @@ PIONEERAVR_Set($@)
Log3 $name, 3, $err; Log3 $name, 3, $err;
return $err; return $err;
} }
return undef; return;
} }
#### commands with argument(s) #### commands with argument(s)
} elsif(@$a > 2) { } elsif(@$a > 2) {
@ -1758,7 +1758,7 @@ PIONEERAVR_Set($@)
my $allArgs= join " ", @args; my $allArgs= join " ", @args;
Log3 $name, 5, "PIONEERAVR $name: sending raw command ".dq($allArgs); Log3 $name, 5, "PIONEERAVR $name: sending raw command ".dq($allArgs);
PIONEERAVR_Write( $hash, $allArgs); PIONEERAVR_Write( $hash, $allArgs);
return undef; return;
####Input (all available Inputs of the Pioneer AV receiver -> see 'get $name loadInputNames') ####Input (all available Inputs of the Pioneer AV receiver -> see 'get $name loadInputNames')
#### according to http://www.fhemwiki.de/wiki/DevelopmentGuidelinesAV #### according to http://www.fhemwiki.de/wiki/DevelopmentGuidelinesAV
@ -1774,7 +1774,7 @@ PIONEERAVR_Set($@)
} }
} }
} }
return undef; return;
####hdmiOut ####hdmiOut
} elsif ( $cmd eq "hdmiOut" ) { } elsif ( $cmd eq "hdmiOut" ) {
@ -1783,7 +1783,7 @@ PIONEERAVR_Set($@)
if ( $hash->{helper}{LISTENINGMODES}->{$key} eq $arg ) { if ( $hash->{helper}{LISTENINGMODES}->{$key} eq $arg ) {
Log3 $name, 5, "PIONEERAVR $name: set $cmd ".dq($arg)." -> found nr: ".$key." for HDMIOut ".dq($arg); Log3 $name, 5, "PIONEERAVR $name: set $cmd ".dq($arg)." -> found nr: ".$key." for HDMIOut ".dq($arg);
PIONEERAVR_Write( $hash, sprintf "%dHO", $key); PIONEERAVR_Write( $hash, sprintf "%dHO", $key);
return undef; return;
} }
} }
my $err= "PIONEERAVR $name: Error: unknown HDMI Out $cmd --- $arg !"; my $err= "PIONEERAVR $name: Error: unknown HDMI Out $cmd --- $arg !";
@ -1797,7 +1797,7 @@ PIONEERAVR_Set($@)
if ( $hash->{helper}{LISTENINGMODES}->{$key} eq $arg ) { if ( $hash->{helper}{LISTENINGMODES}->{$key} eq $arg ) {
Log3 $name, 5, "PIONEERAVR $name: set $cmd ".dq($arg)." -> found nr: ".$key." for listeningMode ".dq($arg); Log3 $name, 5, "PIONEERAVR $name: set $cmd ".dq($arg)." -> found nr: ".$key." for listeningMode ".dq($arg);
PIONEERAVR_Write( $hash, sprintf "%04dSR", $key); PIONEERAVR_Write( $hash, sprintf "%04dSR", $key);
return undef; return;
} }
} }
my $err= "PIONEERAVR $name: Error: unknown listeningMode $cmd --- $arg !"; my $err= "PIONEERAVR $name: Error: unknown listeningMode $cmd --- $arg !";
@ -1829,7 +1829,7 @@ PIONEERAVR_Set($@)
}else{ }else{
PIONEERAVR_Write( $hash, sprintf "%03dVL", $pioneerVol); PIONEERAVR_Write( $hash, sprintf "%03dVL", $pioneerVol);
} }
return undef; return;
####Volume (0 - 100) in % ####Volume (0 - 100) in %
####according to http://www.fhemwiki.de/wiki/DevelopmentGuidelinesAV ####according to http://www.fhemwiki.de/wiki/DevelopmentGuidelinesAV
# PioneerAVR expects values between 000 - 185 # PioneerAVR expects values between 000 - 185
@ -1854,7 +1854,7 @@ PIONEERAVR_Set($@)
}else{ }else{
PIONEERAVR_Write( $hash, sprintf "%03dVL", $pioneerVol); PIONEERAVR_Write( $hash, sprintf "%03dVL", $pioneerVol);
} }
return undef; return;
####tone (on|bypass) ####tone (on|bypass)
} elsif ( $cmd eq "tone" ) { } elsif ( $cmd eq "tone" ) {
if ($arg eq "on") { if ($arg eq "on") {
@ -1867,19 +1867,19 @@ PIONEERAVR_Set($@)
Log3 $name, 3, $err; Log3 $name, 3, $err;
return $err; return $err;
} }
return undef; return;
####bass (-6 - 6) in dB ####bass (-6 - 6) in dB
} elsif ( $cmd eq "bass" ) { } elsif ( $cmd eq "bass" ) {
Log3 $name, 5, "PIONEERAVR $name: set $cmd ".dq($arg); Log3 $name, 5, "PIONEERAVR $name: set $cmd ".dq($arg);
my $zahl = sprintf "%d", ($arg * (-1)) + 6; my $zahl = sprintf "%d", ($arg * (-1)) + 6;
PIONEERAVR_Write( $hash, sprintf "%02dBA", $zahl); PIONEERAVR_Write( $hash, sprintf "%02dBA", $zahl);
return undef; return;
####treble (-6 - 6) in dB ####treble (-6 - 6) in dB
} elsif ( $cmd eq "treble" ) { } elsif ( $cmd eq "treble" ) {
Log3 $name, 5, "PIONEERAVR $name: set $cmd ".dq($arg); Log3 $name, 5, "PIONEERAVR $name: set $cmd ".dq($arg);
my $zahl = sprintf "%d", ($arg * (-1)) + 6; my $zahl = sprintf "%d", ($arg * (-1)) + 6;
PIONEERAVR_Write( $hash, sprintf "%02dTR", $zahl); PIONEERAVR_Write( $hash, sprintf "%02dTR", $zahl);
return undef; return;
####Mute (on|off|toggle) ####Mute (on|off|toggle)
####according to http://www.fhemwiki.de/wiki/DevelopmentGuidelinesAV ####according to http://www.fhemwiki.de/wiki/DevelopmentGuidelinesAV
} elsif ( $cmd eq "mute" ) { } elsif ( $cmd eq "mute" ) {
@ -1898,7 +1898,7 @@ PIONEERAVR_Set($@)
Log3 $name, 3, $err; Log3 $name, 3, $err;
return $err; return $err;
} }
return undef; return;
#### channelStraight #### channelStraight
#### set tuner preset in Pioneer preset format (A1...G9) #### set tuner preset in Pioneer preset format (A1...G9)
#### Only available if the input is 02 (tuner) #### Only available if the input is 02 (tuner)
@ -1913,7 +1913,7 @@ PIONEERAVR_Set($@)
Log3 $name, 3, $err; Log3 $name, 3, $err;
return $err; return $err;
} }
return undef; return;
#### channel #### channel
####according to http://www.fhemwiki.de/wiki/DevelopmentGuidelinesAV ####according to http://www.fhemwiki.de/wiki/DevelopmentGuidelinesAV
#### set tuner preset numeric (1...9) #### set tuner preset numeric (1...9)
@ -1929,7 +1929,7 @@ PIONEERAVR_Set($@)
Log3 $name, 3, $err; Log3 $name, 3, $err;
return $err; return $err;
} }
return undef; return;
####Speakers (off|A|B|A+B) ####Speakers (off|A|B|A+B)
} elsif ( $cmd eq "speakers" ) { } elsif ( $cmd eq "speakers" ) {
Log3 $name, 5, "PIONEERAVR $name: set $cmd $arg"; Log3 $name, 5, "PIONEERAVR $name: set $cmd $arg";
@ -1946,7 +1946,7 @@ PIONEERAVR_Set($@)
Log3 $name, 5, $err; Log3 $name, 5, $err;
return $err; return $err;
} }
return undef; return;
####Signal select (auto|analog|digital|hdmi|cycle) ####Signal select (auto|analog|digital|hdmi|cycle)
} elsif ( $cmd eq "signalSelect" ) { } elsif ( $cmd eq "signalSelect" ) {
@ -1966,7 +1966,7 @@ PIONEERAVR_Set($@)
Log3 $name, 5, $err; Log3 $name, 5, $err;
return $err; return $err;
} }
return undef; return;
#mcacc memory #mcacc memory
} elsif ($cmd eq "mcaccMemory") { } elsif ($cmd eq "mcaccMemory") {
@ -1974,7 +1974,7 @@ PIONEERAVR_Set($@)
my $setCmd = $arg."MC"; my $setCmd = $arg."MC";
Log3 $name, 5, "PIONEERAVR $name: setting MCACC memory to ".dq($arg); Log3 $name, 5, "PIONEERAVR $name: setting MCACC memory to ".dq($arg);
PIONEERAVR_Write( $hash, $setCmd); PIONEERAVR_Write( $hash, $setCmd);
return undef; return;
} else { } else {
my $err= "PIONEERAVR $name: Error: unknown argument $arg in set ... mcaccMemory!"; my $err= "PIONEERAVR $name: Error: unknown argument $arg in set ... mcaccMemory!";
Log3 $name, 5, $err; Log3 $name, 5, $err;
@ -2019,7 +2019,7 @@ PIONEERAVR_Set($@)
Log3 $name, 3, $err; Log3 $name, 3, $err;
return $err; return $err;
} }
return undef; return;
# Rename InputAlias (up to 14 chars) # Rename InputAlias (up to 14 chars)
} elsif ( $cmd eq "renameInputAlias" ) { } elsif ( $cmd eq "renameInputAlias" ) {
@ -2038,7 +2038,7 @@ PIONEERAVR_Set($@)
return $err; return $err;
}; };
Log3 $name, 3, "PIONEERAVR $name: set $cmd for inputName: $arg new name: $arg2 ! write $arg2 1RGB $inputToChange "; Log3 $name, 3, "PIONEERAVR $name: set $cmd for inputName: $arg new name: $arg2 ! write $arg2 1RGB $inputToChange ";
return undef; return;
# Change "skip input" # Change "skip input"
} elsif ( $cmd eq "inputSkip" ) { } elsif ( $cmd eq "inputSkip" ) {
@ -2057,7 +2057,7 @@ PIONEERAVR_Set($@)
return $err; return $err;
}; };
Log3 $name, 3, "PIONEERAVR $name: set $cmd for inputName: $arg skip: $arg2 !"; Log3 $name, 3, "PIONEERAVR $name: set $cmd for inputName: $arg skip: $arg2 !";
return undef; return;
# selectScreenPage (player command) # selectScreenPage (player command)
} elsif ($cmd eq "selectScreenPage") { } elsif ($cmd eq "selectScreenPage") {
@ -2065,7 +2065,7 @@ PIONEERAVR_Set($@)
if ($inputNr eq "17") { if ($inputNr eq "17") {
my $setCmd = sprintf "%05dGGI", $arg; my $setCmd = sprintf "%05dGGI", $arg;
PIONEERAVR_Write( $hash, $setCmd); PIONEERAVR_Write( $hash, $setCmd);
return undef; return;
#### homeMediaGallery, sirius, internetRadio, pandora, mediaServer, favorites, spotify #### homeMediaGallery, sirius, internetRadio, pandora, mediaServer, favorites, spotify
} elsif ( ( $inputNr eq "26") } elsif ( ( $inputNr eq "26")
@ -2078,7 +2078,7 @@ PIONEERAVR_Set($@)
{ {
my $setCmd = sprintf "%05dGGH", $arg; my $setCmd = sprintf "%05dGGH", $arg;
PIONEERAVR_Write( $hash, $setCmd); PIONEERAVR_Write( $hash, $setCmd);
return undef; return;
} }
####remoteControl ####remoteControl
@ -2092,7 +2092,7 @@ PIONEERAVR_Set($@)
Log3 $name, 5, $err; Log3 $name, 5, $err;
return $err; return $err;
} }
return undef; return;
} else { } else {
return SetExtensions( $hash, $list, $name, $cmd, @args); return SetExtensions( $hash, $list, $name, $cmd, @args);
} }
@ -2101,7 +2101,7 @@ PIONEERAVR_Set($@)
} }
} }
##################################### #####################################
sub PIONEERAVR_Get($$$) { sub PIONEERAVR_Get {
my ( $hash, $a, $h ) = @_; my ( $hash, $a, $h ) = @_;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
my $cmd = @$a[1]; my $cmd = @$a[1];
@ -2144,7 +2144,7 @@ sub PIONEERAVR_Get($$$) {
# PIONEERAVR_Read() makes sure, that a message is complete and correct, # PIONEERAVR_Read() makes sure, that a message is complete and correct,
# and calls the global Dispatch() with one message if this message is not for the main zone # and calls the global Dispatch() with one message if this message is not for the main zone
# as the main zone is handled here # as the main zone is handled here
sub PIONEERAVR_Read($) sub PIONEERAVR_Read
{ {
my ( $hash) = @_; my ( $hash) = @_;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
@ -2414,21 +2414,21 @@ sub PIONEERAVR_Read($)
# response: E06: inappropriate parameter (input function nr not available on that device) # response: E06: inappropriate parameter (input function nr not available on that device)
# we can not trust "E06" as it is not sure that it is the reply for the current input nr # we can not trust "E06" as it is not sure that it is the reply for the current input nr
if ( $2 == 00) { if ( $2 eq '00') {
$hash->{helper}{INPUTNAMES}->{$1}{audioTerminal} = "No Assign"; $hash->{helper}{INPUTNAMES}->{$1}{audioTerminal} = "No Assign";
} elsif ( $2 == 01) { } elsif ( $2 eq '01') {
$hash->{helper}{INPUTNAMES}->{$1}{audioTerminal} = "COAX 1"; $hash->{helper}{INPUTNAMES}->{$1}{audioTerminal} = "COAX 1";
} elsif ( $2 == 02) { } elsif ( $2 eq '02') {
$hash->{helper}{INPUTNAMES}->{$1}{audioTerminal} = "COAX 2"; $hash->{helper}{INPUTNAMES}->{$1}{audioTerminal} = "COAX 2";
} elsif ( $2 == 03) { } elsif ( $2 eq '03') {
$hash->{helper}{INPUTNAMES}->{$1}{audioTerminal} = "COAX 3"; $hash->{helper}{INPUTNAMES}->{$1}{audioTerminal} = "COAX 3";
} elsif ( $2 == 04) { } elsif ( $2 eq '04') {
$hash->{helper}{INPUTNAMES}->{$1}{audioTerminal} = "OPT 1"; $hash->{helper}{INPUTNAMES}->{$1}{audioTerminal} = "OPT 1";
} elsif ( $2 == 05) { } elsif ( $2 eq '05') {
$hash->{helper}{INPUTNAMES}->{$1}{audioTerminal} = "OPT 2"; $hash->{helper}{INPUTNAMES}->{$1}{audioTerminal} = "OPT 2";
} elsif ( $2 == 06) { } elsif ( $2 eq '06') {
$hash->{helper}{INPUTNAMES}->{$1}{audioTerminal} = "OPT 3"; $hash->{helper}{INPUTNAMES}->{$1}{audioTerminal} = "OPT 3";
} elsif ( $2 == 10) { } elsif ( $2 eq '10') {
$hash->{helper}{INPUTNAMES}->{$1}{audioTerminal} = "ANALOG"; $hash->{helper}{INPUTNAMES}->{$1}{audioTerminal} = "ANALOG";
} }
@ -3162,25 +3162,25 @@ sub PIONEERAVR_Read($)
##################################### #####################################
sub sub
PIONEERAVR_Attr($@) PIONEERAVR_Attr
{ {
my @a = @_; my @a = @_;
my $hash= $defs{$a[1]}; my $hash= $defs{$a[1]};
return undef; return;
} }
##################################### #####################################
# helper functions # helper functions
##################################### #####################################
#Function to show special chars (e.g. \n\r) in logs #Function to show special chars (e.g. \n\r) in logs
sub dq($) { sub dq {
my ( $s )= @_; my ( $s )= @_;
$s = "<nothing>" unless( defined( $s ) ); $s = "<nothing>" unless( defined( $s ) );
return "\"" . escapeLogLine( $s ) . "\""; return "\"" . escapeLogLine( $s ) . "\"";
} }
##################################### #####################################
#PIONEERAVR_Log() is used to show the data sent and received from/to PIONEERAVR if attr logTraffic is set #PIONEERAVR_Log() is used to show the data sent and received from/to PIONEERAVR if attr logTraffic is set
sub PIONEERAVR_Log($$$) { sub PIONEERAVR_Log {
my ( $hash, $loglevel, $logmsg ) = @_; my ( $hash, $loglevel, $logmsg ) = @_;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
@ -3190,7 +3190,7 @@ sub PIONEERAVR_Log($$$) {
} }
##################################### #####################################
sub PIONEERAVR_DevInit($) { sub PIONEERAVR_DevInit {
my ( $hash ) = @_; my ( $hash ) = @_;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
@ -3203,7 +3203,7 @@ sub PIONEERAVR_DevInit($) {
} }
##################################### #####################################
sub PIONEERAVR_Reopen($) { sub PIONEERAVR_Reopen {
my ( $hash ) = @_; my ( $hash ) = @_;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
@ -3227,7 +3227,7 @@ sub PIONEERAVR_Reopen($) {
##################################### #####################################
# writing to the Pioneer AV receiver # writing to the Pioneer AV receiver
# connection check 3s (or attr timout seconds) after writing # connection check 3s (or attr timout seconds) after writing
sub PIONEERAVR_Write($$) { sub PIONEERAVR_Write {
my ( $hash, $msg ) = @_; my ( $hash, $msg ) = @_;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
@ -3262,7 +3262,7 @@ sub PIONEERAVR_Write($$) {
# - if there is no reply the state is set to "disconnected" # - if there is no reply the state is set to "disconnected"
# #
sub PIONEERAVR_connectionCheck ($) { sub PIONEERAVR_connectionCheck {
my ( $hash ) = @_; my ( $hash ) = @_;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
my $verbose = AttrVal( $name, "verbose", "" ); my $verbose = AttrVal( $name, "verbose", "" );
@ -3299,7 +3299,7 @@ sub PIONEERAVR_connectionCheck ($) {
delete $attr{$name}{verbose} if ( $verbose eq "" ); delete $attr{$name}{verbose} if ( $verbose eq "" );
} }
sub PIONEERAVR_screenUpdate($) { sub PIONEERAVR_screenUpdate {
my ($hash) = @_; my ($hash) = @_;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
my $cmd = "updateScreen"; my $cmd = "updateScreen";
@ -3328,7 +3328,7 @@ sub PIONEERAVR_screenUpdate($) {
} }
######################################################### #########################################################
sub PIONEERAVR_statusUpdate($) { sub PIONEERAVR_statusUpdate {
my ($hash) = @_; my ($hash) = @_;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
@ -3337,13 +3337,13 @@ sub PIONEERAVR_statusUpdate($) {
foreach my $zone ( keys %{$hash->{helper}{GETS}} ) { foreach my $zone ( keys %{$hash->{helper}{GETS}} ) {
foreach my $key ( keys %{$hash->{helper}{GETS}{$zone}} ) { foreach my $key ( keys %{$hash->{helper}{GETS}{$zone}} ) {
PIONEERAVR_Write( $hash, $hash->{helper}{GETS}->{$zone}->{$key}); PIONEERAVR_Write( $hash, $hash->{helper}{GETS}->{$zone}->{$key});
select(undef, undef, undef, 0.1); sleep(0.1);
} }
} }
PIONEERAVR_askForInputNames( $hash,5); PIONEERAVR_askForInputNames( $hash,5);
} }
######################################################### #########################################################
sub PIONEERAVR_askForInputNames($$) { sub PIONEERAVR_askForInputNames {
my ($hash, $loglevel) = @_; my ($hash, $loglevel) = @_;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
my $comstr = ''; my $comstr = '';
@ -3360,27 +3360,27 @@ sub PIONEERAVR_askForInputNames($$) {
#select( undef, undef, undef, 0.1 ); #select( undef, undef, undef, 0.1 );
$comstr = sprintf '?RGB%02d', $i; $comstr = sprintf '?RGB%02d', $i;
PIONEERAVR_Write( $hash,$comstr ); PIONEERAVR_Write( $hash,$comstr );
select( undef, undef, undef, $delay ); sleep($delay);
#digital(audio) input terminal (coax, optical, analog) #digital(audio) input terminal (coax, optical, analog)
$comstr = sprintf '?SSC%02d00',$i; $comstr = sprintf '?SSC%02d00',$i;
PIONEERAVR_Write( $hash,$comstr ); PIONEERAVR_Write( $hash,$comstr );
select( undef, undef, undef, $delay ); sleep($delay);
#hdmi input terminal? #hdmi input terminal?
$comstr = sprintf '?SSC%02d01',$i; $comstr = sprintf '?SSC%02d01',$i;
PIONEERAVR_Write( $hash,$comstr ); PIONEERAVR_Write( $hash,$comstr );
select( undef, undef, undef, $delay ); sleep($delay);
#component video input terminal ? #component video input terminal ?
$comstr = sprintf '?SSC%02d02',$i; $comstr = sprintf '?SSC%02d02',$i;
PIONEERAVR_Write( $hash,$comstr ); PIONEERAVR_Write( $hash,$comstr );
select( undef, undef, undef, $delay ); sleep($delay);
#input enabled/disabled? #input enabled/disabled?
$comstr = sprintf '?SSC%02d03',$i; $comstr = sprintf '?SSC%02d03',$i;
PIONEERAVR_Write( $hash,$comstr ); PIONEERAVR_Write( $hash,$comstr );
select( undef, undef, undef, $delay ); sleep($delay);
#inputLevelAdjust (-12dB ... +12dB) #inputLevelAdjust (-12dB ... +12dB)
$comstr = sprintf '?ILA%02d',$i; $comstr = sprintf '?ILA%02d',$i;
@ -3388,7 +3388,7 @@ sub PIONEERAVR_askForInputNames($$) {
} }
} }
sub PIONEERAVR_GetStateAV($) { sub PIONEERAVR_GetStateAV {
my ($hash) = @_; my ($hash) = @_;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
@ -3419,7 +3419,7 @@ sub PIONEERAVR_GetStateAV($) {
##################################### #####################################
# Callback from 95_remotecontrol for command makenotify. # Callback from 95_remotecontrol for command makenotify.
sub PIONEERAVR_RCmakenotify($$) { sub PIONEERAVR_RCmakenotify {
my ($nam, $ndev) = @_; my ($nam, $ndev) = @_;
my $nname = "notify_$nam"; my $nname = "notify_$nam";