From 48856f46b5886f9ca7c04aa000c962fd4c422a34 Mon Sep 17 00:00:00 2001
From: markusbloch <>
Date: Fri, 23 Nov 2012 22:39:00 +0000
Subject: [PATCH] added deeper log output, fixed documentation grammar
git-svn-id: https://svn.fhem.de/fhem/trunk@2172 2b470e98-0d58-463d-a4d8-8e2adae1ed80
---
fhem/FHEM/71_YAMAHA_AVR.pm | 59 ++++++++++++++++++++++++++------------
1 file changed, 41 insertions(+), 18 deletions(-)
diff --git a/fhem/FHEM/71_YAMAHA_AVR.pm b/fhem/FHEM/71_YAMAHA_AVR.pm
index 497375388..b8e2ed2d4 100755
--- a/fhem/FHEM/71_YAMAHA_AVR.pm
+++ b/fhem/FHEM/71_YAMAHA_AVR.pm
@@ -94,7 +94,7 @@ YAMAHA_AVR_GetStatus($;$)
return "No Zone available" if(not defined($zone));
- my $return = YAMAHA_AVR_SendCommand($device,"<$zone>GetParam$zone>");
+ my $return = YAMAHA_AVR_SendCommand($hash, $device,"<$zone>GetParam$zone>");
Log GetLogLevel($name, 4), "YANMAHA_AVR: GetStatus-Request returned:\n$return";
@@ -203,7 +203,7 @@ YAMAHA_AVR_Set($@)
if($what eq "on")
{
- $result = YAMAHA_AVR_SendCommand($address, "<$zone>On$zone>");
+ $result = YAMAHA_AVR_SendCommand($hash, $address, "<$zone>On$zone>");
if($result =~ /RC="0"/ and $result =~ /<\/Power>/)
{
@@ -220,7 +220,7 @@ YAMAHA_AVR_Set($@)
}
elsif($what eq "off")
{
- $result = YAMAHA_AVR_SendCommand($address, "<$zone>Standby$zone>");
+ $result = YAMAHA_AVR_SendCommand($hash, $address, "<$zone>Standby$zone>");
if(not $result =~ /RC="0"/)
{
@@ -243,7 +243,7 @@ YAMAHA_AVR_Set($@)
$command = YAMAHA_AVR_getCommandParam($hash, $a[2]);
if(defined($command) and length($command) > 0)
{
- $result = YAMAHA_AVR_SendCommand($address,"<$zone>".$command."$zone>");
+ $result = YAMAHA_AVR_SendCommand($hash, $address,"<$zone>".$command."$zone>");
}
else
{
@@ -286,11 +286,11 @@ YAMAHA_AVR_Set($@)
{
if( $a[2] eq "on")
{
- $result = YAMAHA_AVR_SendCommand($address, "<$zone>On$zone>");
+ $result = YAMAHA_AVR_SendCommand($hash, $address, "<$zone>On$zone>");
}
elsif($a[2] eq "off")
{
- $result = YAMAHA_AVR_SendCommand($address, "<$zone>Off$zone>");
+ $result = YAMAHA_AVR_SendCommand($hash, $address, "<$zone>Off$zone>");
}
else
{
@@ -339,7 +339,7 @@ YAMAHA_AVR_Set($@)
{
Log GetLogLevel($name, 4), "YAMAHA_AVR: set volume to ".($current_volume + ($diff * $step))." dB";
- YAMAHA_AVR_SendCommand($address,"<$zone>".(($current_volume + ($diff * $step))*10)."1dB$zone>");
+ YAMAHA_AVR_SendCommand($hash, $address,"<$zone>".(($current_volume + ($diff * $step))*10)."1dB$zone>");
sleep $sleep unless ($time == 0);
}
@@ -348,7 +348,7 @@ YAMAHA_AVR_Set($@)
# Set the desired volume
Log GetLogLevel($name, 4), "YAMAHA_AVR: set volume to ".$a[2]." dB";
- $result = YAMAHA_AVR_SendCommand($address,"<$zone>".($a[2]*10)."1dB$zone>");
+ $result = YAMAHA_AVR_SendCommand($hash, $address,"<$zone>".($a[2]*10)."1dB$zone>");
if(not $result =~ /RC="0"/)
{
# if the returncode isn't 0, than the command was not successful
@@ -450,12 +450,21 @@ YAMAHA_AVR_Define($$)
#############################
sub
-YAMAHA_AVR_SendCommand($$)
+YAMAHA_AVR_SendCommand($$$)
{
- my($address, $command) = @_;
+ my($hash, $address, $command) = @_;
+ my $name = $hash->{NAME};
+ my $response;
+
+ Log GetLogLevel($name, 5), "YAMAHA_AVR: execute on $name: $command";
+
# In case any URL changes must be made, this part is separated in this function".
- return GetFileFromURL("http://".$address."/YamahaRemoteControl/ctrl", 10, "".$command);
+ $response = GetFileFromURL("http://".$address."/YamahaRemoteControl/ctrl", 10, "".$command);
+ Log GetLogLevel($name, 3), "YAMAHA_AVR: could not execute command on device $name" unless (defined($response));
+
+ return $response;
+
}
#############################
@@ -554,7 +563,9 @@ sub YAMAHA_AVR_getModel($$)
my $response;
my $desc_url;
- $response = YAMAHA_AVR_SendCommand($address, "GetParam");
+ $response = YAMAHA_AVR_SendCommand($hash, $address, "GetParam");
+
+ Log GetLogLevel($name, 3), "YAMAHA_AVR: could not get unit description url from device $name" unless (defined($response));
if(defined($response) and $response =~ /(.+?)<\/URL>/)
@@ -566,7 +577,9 @@ sub YAMAHA_AVR_getModel($$)
$desc_url = "/YamahaRemoteControl/desc.xml";
}
- $response = YAMAHA_AVR_SendCommand($address, "GetParam");
+ $response = YAMAHA_AVR_SendCommand($hash, $address, "GetParam");
+
+ Log GetLogLevel($name, 3), "YAMAHA_AVR: could not get system configuration from device $name" unless (defined($response));
if(defined($response) and $response =~ /(.+?)<\/Model_Name>.*(.+?)<\/System_ID>.*(.+?)<\/Version>/)
{
@@ -580,6 +593,9 @@ sub YAMAHA_AVR_getModel($$)
}
$response = GetFileFromURL("http://".$address.$desc_url);
+
+ Log GetLogLevel($name, 3), "YAMAHA_AVR: could not get unit description from device $name" unless (defined($response));
+
return undef unless(defined($response));
while($response =~ /
- If your receiver supports Zone Selection (e.g. RX-V671, RX_V673,... and the AVANTAGE series)
- you can select the zone which should be controlled. The RX_4xx and RX_3xx series for example
+ If your receiver supports zone selection (e.g. RX-V671, RX-V673,... and the AVANTAGE series)
+ you can select the zone which should be controlled. The RX-V4xx and RX-V3xx series for example
just have a "Main Zone" (which is the whole receiver itself). In general you have the following
possibilities for the parameter <zone> (depending on your receiver model).
@@ -704,8 +727,8 @@ sub YAMAHA_AVR_getInputs($$)
define AV_Receiver_Zone2 YAMAHA_AVR 192.168.0.10 zone2
attr AV_Receiver_Zone2 room Bedroom
- Each Zone needs an own device and can be assigned to the different rooms, as each zone
- can be separatly controlled from the other zones.
+ For each Zone you will need an own YAMAHA_AVr device, which can be assigned to a different room.
+ Each zone can be controlled separatly from all other available zones.