diff --git a/fhem/FHEM/71_YAMAHA_AVR.pm b/fhem/FHEM/71_YAMAHA_AVR.pm index fde783ec1..cfccac8e0 100755 --- a/fhem/FHEM/71_YAMAHA_AVR.pm +++ b/fhem/FHEM/71_YAMAHA_AVR.pm @@ -128,13 +128,25 @@ YAMAHA_AVR_GetStatus($;$) { readingsBulkUpdate($hash, "volume_level", ($1 / 10 ** $2)); readingsBulkUpdate($hash, "mute", lc($3)); + $hash->{helper}{USE_SHORT_VOL_CMD} = "0"; } + elsif($return =~ /(.+)<\/Val>(.+)<\/Exp>.+<\/Unit><\/Lvl>(.+)<\/Mute>.*<\/Vol>/) + { + readingsBulkUpdate($hash, "volume_level", ($1 / 10 ** $2)); + readingsBulkUpdate($hash, "mute", lc($3)); + $hash->{helper}{USE_SHORT_VOL_CMD} = "1"; + } + # (only available in zones other than mainzone) absolute or relative volume change to the mainzone if($return =~ /.*?(.+?)<\/Output>.*?<\/Volume>/) { readingsBulkUpdate($hash, "output", lc($1)); } + elsif($return =~ /.*?(.+?)<\/Output>.*?<\/Vol>/) + { + readingsBulkUpdate($hash, "output", lc($1)); + } else { # delete the reading if this information is not available @@ -188,7 +200,7 @@ YAMAHA_AVR_Get($@) } else { - return "Unknown argument $what, choose one of power input input_name volume_level mute".(exists($hash->{READINGS}{output})?" output":""); + return "Unknown argument $what, choose one of power:noArg input:noArg input_name:noArg volume_level:noArg mute:noArg".(exists($hash->{READINGS}{output})?" output:noArg":""); } } @@ -215,8 +227,11 @@ YAMAHA_AVR_Set($@) return "No Argument given" if(!defined($a[1])); my $what = $a[1]; - my $usage = "Unknown argument $what, choose one of on off volume:slider,-80,1,16 input:".$inputs_comma." mute:on,off remoteControl:setup,up,down,left,right,return,option,display,enter scene:".$scenes_comma." statusRequest"; + my $usage = "Unknown argument $what, choose one of on:noArg off:noArg volume:slider,-80,1,16 input:".$inputs_comma." mute:on,off remoteControl:setup,up,down,left,right,return,option,display,enter ".(defined($hash->{helper}{SCENES})?"scene:".$scenes_comma." ":"")."statusRequest:noArg"; + # Depending on the status response, use the short or long Volume command + + my $volume_cmd = (exists($hash->{helper}{USE_SHORT_VOL_CMD}) and $hash->{helper}{USE_SHORT_VOL_CMD} eq "1" ? "Vol" : "Volume"); if($what eq "on") { @@ -344,11 +359,11 @@ YAMAHA_AVR_Set($@) { if( $a[2] eq "on") { - $result = YAMAHA_AVR_SendCommand($hash, "<$zone>On"); + $result = YAMAHA_AVR_SendCommand($hash, "<$zone><$volume_cmd>On"); } elsif($a[2] eq "off") { - $result = YAMAHA_AVR_SendCommand($hash, "<$zone>Off"); + $result = YAMAHA_AVR_SendCommand($hash, "<$zone><$volume_cmd>Off"); } else { @@ -397,7 +412,8 @@ YAMAHA_AVR_Set($@) { Log GetLogLevel($name, 4), "YAMAHA_AVR: set volume to ".($current_volume + ($diff * $step))." dB"; - YAMAHA_AVR_SendCommand($hash, "<$zone>".(($current_volume + ($diff * $step))*10)."1dB"); + YAMAHA_AVR_SendCommand($hash, "<$zone><$volume_cmd>".(($current_volume + ($diff * +$step))*10)."1dB"); Log GetLogLevel($name, 4), "YAMAHA_AVR: sleeping for ".sprintf("%.3f", $sleep)." seconds" unless ($time == 0); sleep $sleep unless ($time == 0); @@ -407,7 +423,8 @@ YAMAHA_AVR_Set($@) # Set the desired volume Log GetLogLevel($name, 4), "YAMAHA_AVR: set volume to ".$a[2]." dB"; - $result = YAMAHA_AVR_SendCommand($hash, "<$zone>".($a[2]*10)."1dB"); + $result = YAMAHA_AVR_SendCommand($hash, "<$zone><$volume_cmd>".($a[2]*10)."1dB"); if(not $result =~ /RC="0"/) { # if the returncode isn't 0, than the command was not successful @@ -742,6 +759,12 @@ sub YAMAHA_AVR_getModel($) $hash->{SYSTEM_ID} = $2; $hash->{FIRMWARE} = $3; } + elsif(defined($response) and $response =~ /(.+?)<\/Model_Name>.*(.+?)<\/System_ID>.*.*
(.+?)<\/Main>.*(.+?)<\/Sub>.*<\/Version>/) + { + $hash->{MODEL} = $1; + $hash->{SYSTEM_ID} = $2; + $hash->{FIRMWARE} = $3." ".$4; + } else { return undef;