71_PIONEERAVRZONE.pm: code cleanup inspired by perlcritic
git-svn-id: https://svn.fhem.de/fhem/trunk@22797 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
@@ -27,16 +27,16 @@ use warnings;
|
|||||||
use Time::HiRes qw(gettimeofday);
|
use Time::HiRes qw(gettimeofday);
|
||||||
use SetExtensions qw/ :all /;
|
use SetExtensions qw/ :all /;
|
||||||
|
|
||||||
sub PIONEERAVRZONE_Get($@);
|
sub PIONEERAVRZONE_Get;
|
||||||
sub PIONEERAVRZONE_Set($@);
|
sub PIONEERAVRZONE_Set;
|
||||||
sub PIONEERAVRZONE_Attr($@);
|
sub PIONEERAVRZONE_Attr;
|
||||||
sub PIONEERAVRZONE_Define($$);
|
sub PIONEERAVRZONE_Define;
|
||||||
|
|
||||||
no if $] >= 5.017011, warnings => 'experimental::smartmatch';
|
no if $] >= 5.017011, warnings => 'experimental::smartmatch';
|
||||||
|
|
||||||
###################################
|
###################################
|
||||||
sub
|
sub
|
||||||
PIONEERAVRZONE_Initialize($)
|
PIONEERAVRZONE_Initialize
|
||||||
{
|
{
|
||||||
my ($hash) = @_;
|
my ($hash) = @_;
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ PIONEERAVRZONE_Initialize($)
|
|||||||
|
|
||||||
###################################
|
###################################
|
||||||
sub
|
sub
|
||||||
PIONEERAVRZONE_Changed($$$)
|
PIONEERAVRZONE_Changed
|
||||||
{
|
{
|
||||||
my ($hash, $cmd, $value)= @_;
|
my ($hash, $cmd, $value)= @_;
|
||||||
|
|
||||||
@@ -76,7 +76,7 @@ PIONEERAVRZONE_Changed($$$)
|
|||||||
###################################
|
###################################
|
||||||
|
|
||||||
sub
|
sub
|
||||||
PIONEERAVRZONE_Get($@)
|
PIONEERAVRZONE_Get
|
||||||
{
|
{
|
||||||
my ($hash, @a)= @_;
|
my ($hash, @a)= @_;
|
||||||
|
|
||||||
@@ -98,14 +98,12 @@ PIONEERAVRZONE_Get($@)
|
|||||||
|
|
||||||
my $v= IOWrite($hash, $cmd);
|
my $v= IOWrite($hash, $cmd);
|
||||||
|
|
||||||
# return PIONEERAVRZONE_Changed($hash, $cmdname, $v);;
|
return;
|
||||||
return undef;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#############################
|
#############################
|
||||||
sub
|
sub
|
||||||
PIONEERAVRZONE_Set($@)
|
PIONEERAVRZONE_Set
|
||||||
{
|
{
|
||||||
my ($hash, @a)= @_;
|
my ($hash, @a)= @_;
|
||||||
my @args= @a; shift @args; shift @args;
|
my @args= @a; shift @args; shift @args;
|
||||||
@@ -170,7 +168,7 @@ PIONEERAVRZONE_Set($@)
|
|||||||
my $setCmd= $IOhash->{helper}{SETS}{$zone}{$cmd};
|
my $setCmd= $IOhash->{helper}{SETS}{$zone}{$cmd};
|
||||||
my $v= IOWrite($hash, $setCmd);
|
my $v= IOWrite($hash, $setCmd);
|
||||||
Log3 $hash, 5, "PIONEERAVR $name: Set_IOwrite($zone ... $cmd ): $setCmd";
|
Log3 $hash, 5, "PIONEERAVR $name: Set_IOwrite($zone ... $cmd ): $setCmd";
|
||||||
return undef;
|
return;
|
||||||
|
|
||||||
### Power on
|
### Power on
|
||||||
### Command: PO
|
### Command: PO
|
||||||
@@ -180,7 +178,7 @@ PIONEERAVRZONE_Set($@)
|
|||||||
Log3 $name, 5, "PIONEERAVR $name: Set $cmd ";
|
Log3 $name, 5, "PIONEERAVR $name: Set $cmd ";
|
||||||
my $setCmd= "";
|
my $setCmd= "";
|
||||||
IOWrite($hash, $setCmd);
|
IOWrite($hash, $setCmd);
|
||||||
select(undef, undef, undef, 0.1);
|
sleep(0.1);
|
||||||
|
|
||||||
if ( $zone eq "zone2" ) {
|
if ( $zone eq "zone2" ) {
|
||||||
$setCmd = "APO";
|
$setCmd = "APO";
|
||||||
@@ -190,9 +188,9 @@ PIONEERAVRZONE_Set($@)
|
|||||||
$setCmd = "ZEO";
|
$setCmd = "ZEO";
|
||||||
}
|
}
|
||||||
IOWrite($hash, $setCmd);
|
IOWrite($hash, $setCmd);
|
||||||
select(undef, undef, undef, 0.1);
|
sleep(0.1);
|
||||||
Log3 $hash, 5, "PIONEERAVR $name: Set_IOwrite: $setCmd";
|
Log3 $hash, 5, "PIONEERAVR $name: Set_IOwrite: $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") {
|
||||||
@@ -200,7 +198,7 @@ PIONEERAVRZONE_Set($@)
|
|||||||
foreach my $key ( keys %{$IOhash->{helper}{GETS}{$zone}} ) {
|
foreach my $key ( keys %{$IOhash->{helper}{GETS}{$zone}} ) {
|
||||||
IOWrite($hash, $IOhash->{helper}{GETS}->{$zone}->{$key});
|
IOWrite($hash, $IOhash->{helper}{GETS}->{$zone}->{$key});
|
||||||
}
|
}
|
||||||
return undef;
|
return;
|
||||||
}
|
}
|
||||||
#### commands with argument(s)
|
#### commands with argument(s)
|
||||||
} elsif(@a > 2) {
|
} elsif(@a > 2) {
|
||||||
@@ -230,7 +228,7 @@ PIONEERAVRZONE_Set($@)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return undef;
|
return;
|
||||||
#####VolumeStraight (-80.5 - 12) in dB
|
#####VolumeStraight (-80.5 - 12) in dB
|
||||||
####according to http://www.fhemwiki.de/wiki/DevelopmentGuidelinesAV
|
####according to http://www.fhemwiki.de/wiki/DevelopmentGuidelinesAV
|
||||||
} elsif ( $cmd eq "volumeStraight" ) {
|
} elsif ( $cmd eq "volumeStraight" ) {
|
||||||
@@ -244,7 +242,7 @@ PIONEERAVRZONE_Set($@)
|
|||||||
readingsBulkUpdate($hash, "volumeStraight", $arg );
|
readingsBulkUpdate($hash, "volumeStraight", $arg );
|
||||||
readingsBulkUpdate($hash, "volume", sprintf "%d", ($a[2]+80)/0.8 );
|
readingsBulkUpdate($hash, "volume", sprintf "%d", ($a[2]+80)/0.8 );
|
||||||
readingsEndUpdate($hash, 1);
|
readingsEndUpdate($hash, 1);
|
||||||
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
|
||||||
} elsif ( $cmd eq "volume" ) {
|
} elsif ( $cmd eq "volume" ) {
|
||||||
@@ -258,7 +256,7 @@ PIONEERAVRZONE_Set($@)
|
|||||||
readingsBulkUpdate($hash, "volumeStraight", $zahl - 80 );
|
readingsBulkUpdate($hash, "volumeStraight", $zahl - 80 );
|
||||||
readingsBulkUpdate($hash, "volume", sprintf "%d", $a[2] );
|
readingsBulkUpdate($hash, "volume", sprintf "%d", $a[2] );
|
||||||
readingsEndUpdate($hash, 1);
|
readingsEndUpdate($hash, 1);
|
||||||
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" ) {
|
||||||
@@ -273,20 +271,19 @@ PIONEERAVRZONE_Set($@)
|
|||||||
elsif ($arg eq "toggle") {
|
elsif ($arg eq "toggle") {
|
||||||
IOWrite($hash, $IOhash->{helper}{SETS}{$zone}{muteToggle});
|
IOWrite($hash, $IOhash->{helper}{SETS}{$zone}{muteToggle});
|
||||||
}
|
}
|
||||||
return undef;
|
return;
|
||||||
} else {
|
} else {
|
||||||
return SetExtensions($hash, $list, $name, $cmd, @args);
|
return SetExtensions($hash, $list, $name, $cmd, @args);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return SetExtensions($hash, $list, $name, $cmd, @args);
|
return SetExtensions($hash, $list, $name, $cmd, @args);
|
||||||
}
|
}
|
||||||
return undef;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#############################
|
#############################
|
||||||
sub
|
sub
|
||||||
PIONEERAVRZONE_Parse($$)
|
PIONEERAVRZONE_Parse
|
||||||
{
|
{
|
||||||
# we are called from dispatch() from the PIONEERAVR device
|
# we are called from dispatch() from the PIONEERAVR device
|
||||||
# we never come here if $msg does not match $hash->{MATCH} in the first place
|
# we never come here if $msg does not match $hash->{MATCH} in the first place
|
||||||
@@ -478,23 +475,22 @@ PIONEERAVRZONE_Parse($$)
|
|||||||
}
|
}
|
||||||
return @matches if(@matches);
|
return @matches if(@matches);
|
||||||
return "UNDEFINED PIONEERAVRZONE message1 $msg";
|
return "UNDEFINED PIONEERAVRZONE message1 $msg";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#####################################
|
#####################################
|
||||||
sub
|
sub
|
||||||
PIONEERAVRZONE_Attr($@)
|
PIONEERAVRZONE_Attr
|
||||||
{
|
{
|
||||||
|
|
||||||
my @a = @_;
|
my @a = @_;
|
||||||
my $hash= $defs{$a[1]};
|
my $hash= $defs{$a[1]};
|
||||||
|
|
||||||
return undef;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#############################
|
#############################
|
||||||
sub
|
sub
|
||||||
PIONEERAVRZONE_Define($$)
|
PIONEERAVRZONE_Define
|
||||||
{
|
{
|
||||||
my ($hash, $def) = @_;
|
my ($hash, $def) = @_;
|
||||||
my @a = split("[ \t]+", $def);
|
my @a = split("[ \t]+", $def);
|
||||||
@@ -543,8 +539,7 @@ PIONEERAVRZONE_Define($$)
|
|||||||
$attr{$name}{devStateIcon} =
|
$attr{$name}{devStateIcon} =
|
||||||
'on:rc_GREEN:off off:rc_STOP:on absent:rc_RED';
|
'on:rc_GREEN:off off:rc_STOP:on absent:rc_RED';
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
return undef;
|
|
||||||
}
|
}
|
||||||
#####################################
|
#####################################
|
||||||
#Function to show special chars (e.g. \n\r) in logs
|
#Function to show special chars (e.g. \n\r) in logs
|
||||||
|
|||||||
Reference in New Issue
Block a user