diff --git a/fhem/FHEM/71_YAMAHA_AVR.pm b/fhem/FHEM/71_YAMAHA_AVR.pm
index 7c87ef82b..9efe6fd0f 100755
--- a/fhem/FHEM/71_YAMAHA_AVR.pm
+++ b/fhem/FHEM/71_YAMAHA_AVR.pm
@@ -68,7 +68,6 @@ YAMAHA_AVR_GetStatus($;$)
my $name = $hash->{NAME};
my $power;
-
$local = 0 unless(defined($local));
return "" if(!defined($hash->{helper}{ADDRESS}) or !defined($hash->{helper}{OFF_INTERVAL}) or !defined($hash->{helper}{ON_INTERVAL}));
@@ -238,6 +237,7 @@ YAMAHA_AVR_Set($@)
if($a[2] =~ /^($scenes_piped)$/)
{
my $command = YAMAHA_AVR_getParamName($hash, $a[2], $hash->{helper}{SCENES});
+
if(defined($command) and length($command) > 0)
{
YAMAHA_AVR_SendCommand($hash, "<$zone>".$command."$zone>", $what, $a[2]);
@@ -375,6 +375,7 @@ YAMAHA_AVR_Set($@)
if($a[2] =~ /^($dsp_modes_piped)$/)
{
my $command = YAMAHA_AVR_getParamName($hash, $a[2],$hash->{helper}{DSP_MODES});
+
if(defined($command) and length($command) > 0)
{
YAMAHA_AVR_SendCommand($hash, "<$zone>$command$zone>", $what, $a[2]);
@@ -514,7 +515,6 @@ YAMAHA_AVR_Set($@)
}
elsif($what eq "remoteControl")
{
-
# the RX-Vx75 series use a different tag name to access the remoteControl commands
my $control_tag = ($hash->{MODEL} =~ /RX-V\d75/ ? "Cursor_Control" : "List_Control");
@@ -578,7 +578,6 @@ YAMAHA_AVR_Set($@)
return undef;
}
-
#############################
sub
YAMAHA_AVR_Define($$)
@@ -589,17 +588,15 @@ YAMAHA_AVR_Define($$)
if(! @a >= 4)
{
- my $msg = "wrong syntax: define YAMAHA_AVR [] [] [] ";
- Log 2, $msg;
- return $msg;
+ my $msg = "wrong syntax: define YAMAHA_AVR [] [] [] ";
+ Log3 $name, 2, $msg;
+ return $msg;
}
-
my $address = $a[2];
$hash->{helper}{ADDRESS} = $address;
-
-
+
# if a zone was given, use it, otherwise use the mainzone
if(defined($a[3]))
{
@@ -619,8 +616,7 @@ YAMAHA_AVR_Define($$)
{
$hash->{helper}{OFF_INTERVAL} = 30;
}
-
-
+
if(defined($a[5]) and $a[5] > 0)
{
$hash->{helper}{ON_INTERVAL} = $a[5];
@@ -711,7 +707,7 @@ YAMAHA_AVR_Undefine($$)
}
-#############################################################################################################
+############################################################################################################
#
# Begin of helper functions
#
@@ -720,6 +716,7 @@ YAMAHA_AVR_Undefine($$)
#############################
+# sends a command to the receiver via HTTP
sub
YAMAHA_AVR_SendCommand($@)
{
@@ -742,13 +739,11 @@ YAMAHA_AVR_SendCommand($@)
arg => $arg,
callback => \&YAMAHA_AVR_ParseResponse
}
- );
-
-
-
+ );
}
-
+#############################
+# parses the receiver response
sub
YAMAHA_AVR_ParseResponse ($$$)
{
@@ -760,6 +755,8 @@ YAMAHA_AVR_ParseResponse ($$$)
my $cmd = $param->{cmd};
my $arg = $param->{arg};
+ $hash->{helper}{AVAILABLE} = ($err eq "" ? 1 : 0);
+
if($err ne "")
{
Log3 $name, 5, "YAMAHA_AVR ($name) - could not execute command \"$cmd".(defined($arg) ? " ".(split("\\|", $arg))[0] : "")."\": $err";
@@ -770,14 +767,11 @@ YAMAHA_AVR_ParseResponse ($$$)
readingsSingleUpdate($hash, "presence", "absent", 1);
readingsSingleUpdate($hash, "state", "absent", 1);
}
-
}
elsif($data ne "")
{
Log3 $name, 5, "YAMAHA_AVR ($name) - got response for \"$cmd".(defined($arg) ? " ".(split("\\|", $arg))[0] : "")."\": $data";
-
-
if (defined($hash->{helper}{AVAILABLE}) and $hash->{helper}{AVAILABLE} eq 0)
{
Log3 $name, 3, "YAMAHA_AVR ($name) - device $name reappeared";
@@ -787,14 +781,13 @@ YAMAHA_AVR_ParseResponse ($$$)
if(not $data =~ /RC="0"/)
{
# if the returncode isn't 0, than the command was not successful
- Log3 $name, 3, "YAMAHA_AVR ($name) - Could not execute \"$cmd".(defined($arg) ? " ".$arg : "")."\"";
+ Log3 $name, 3, "YAMAHA_AVR ($name) - Could not execute \"$cmd".(defined($arg) ? " ".(split("\\|", $arg))[0] : "")."\"";
}
readingsBeginUpdate($hash);
if($cmd eq "statusRequest")
{
-
if($arg eq "unitDescription")
{
if($data =~ /(.+?)<\/URL>/)
@@ -816,8 +809,7 @@ YAMAHA_AVR_ParseResponse ($$$)
hash => $hash,
callback => \&YAMAHA_AVR_ParseXML
}
- );
-
+ );
}
elsif($arg eq "systemConfig")
{
@@ -838,7 +830,6 @@ YAMAHA_AVR_ParseResponse ($$$)
}
elsif($arg eq "getInputs")
{
-
delete($hash->{helper}{INPUTS}) if(exists($hash->{helper}{INPUTS}));
while($data =~ /(.+?)<\/Param>/gc)
@@ -851,12 +842,10 @@ YAMAHA_AVR_ParseResponse ($$$)
$hash->{helper}{INPUTS} .= $1;
}
- $hash->{helper}{INPUTS} = join("|", sort split("\\|", $hash->{helper}{INPUTS}));
-
+ $hash->{helper}{INPUTS} = join("|", sort split("\\|", $hash->{helper}{INPUTS}));
}
elsif($arg eq "getScenes")
{
-
delete($hash->{helper}{SCENES}) if(exists($hash->{helper}{SCENES}));
# get all available scenes from response
@@ -872,11 +861,9 @@ YAMAHA_AVR_ParseResponse ($$$)
$hash->{helper}{SCENES} .= $1;
}
}
-
}
elsif($arg eq "basicStatus")
{
-
if($data =~ /(.+)<\/Power>/)
{
my $power = $1;
@@ -906,7 +893,6 @@ YAMAHA_AVR_ParseResponse ($$$)
$hash->{helper}{USE_SHORT_VOL_CMD} = "1";
}
-
# (only available in zones other than mainzone) absolute or relative volume change to the mainzone
if($data =~ /.*?