From 144c49063341ce4d7ab0ca9ba1d3293b153d91f1 Mon Sep 17 00:00:00 2001 From: markusbloch <> Date: Mon, 7 Jan 2013 18:14:50 +0000 Subject: [PATCH] don't log further error messages if device is still not reachable - part 1 of 2 git-svn-id: https://svn.fhem.de/fhem/trunk@2446 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/71_YAMAHA_AVR.pm | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/fhem/FHEM/71_YAMAHA_AVR.pm b/fhem/FHEM/71_YAMAHA_AVR.pm index 5a379b86f..73b91f974 100755 --- a/fhem/FHEM/71_YAMAHA_AVR.pm +++ b/fhem/FHEM/71_YAMAHA_AVR.pm @@ -118,7 +118,7 @@ YAMAHA_AVR_GetStatus($;$) $power = "Off"; } - readingsBulkUpdate($hash, "state", lc($power)); + $hash->{STATE} = lc($power); } @@ -451,6 +451,10 @@ YAMAHA_AVR_Define($$) # set the volume-smooth-change attribute only if it is not defined, so no user values will be overwritten $attr{$name}{"volume-smooth-change"} = "1" unless(defined($attr{$name}{"volume-smooth-change"})); + $hash->{helper}{AVAILABLE} = 1; + + + InternalTimer(gettimeofday()+2, "YAMAHA_AVR_GetStatus", $hash, 0); return undef; @@ -460,18 +464,28 @@ YAMAHA_AVR_Define($$) sub YAMAHA_AVR_SendCommand($$$) { - my($hash, $address, $command) = @_; - my $name = $hash->{NAME}; - my $response; + my($hash, $address, $command) = @_; + my $name = $hash->{NAME}; + my $response; - Log GetLogLevel($name, 5), "YAMAHA_AVR: execute on $name: $command"; + 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". - $response = GetFileFromURL("http://".$address."/YamahaRemoteControl/ctrl", 10, "".$command); - Log GetLogLevel($name, 3), "YAMAHA_AVR: could not execute command on device $name" unless (defined($response)); + # In case any URL changes must be made, this part is separated in this function". + $response = GetFileFromURL("http://".$address."/YamahaRemoteControl/ctrl", 10, "".$command); - return $response; + unless(defined($response)) + { + Log GetLogLevel($name, 3), "YAMAHA_AVR: could not execute command on device $name" if (defined($hash->{helper}{AVAILABLE}) and $hash->{helper}{AVAILABLE} eq 1); + } + else + { + Log GetLogLevel($name, 3), "YAMAHA_AVR: device $name reappeared" if (defined($hash->{helper}{AVAILABLE}) and $hash->{helper}{AVAILABLE} eq 0); + } + + $hash->{helper}{AVAILABLE} = (defined($response) ? 1 : 0); + + return $response; }