diff --git a/fhem/CHANGED b/fhem/CHANGED index 5c555327f..55d7e3870 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,6 @@ # Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Do not insert empty lines here, update check depends on it. + - feature: YAMAHA_AVR: new attribute volumeMax to limit the maximum volume - update: 70_WS3600.pm extension for UV and illuminance - bugfix: 38_CO20.pm: fixed Device::USB init errors - update: 93_DBLog: new Version 2.13.5, supports primary key now, diff --git a/fhem/FHEM/71_YAMAHA_AVR.pm b/fhem/FHEM/71_YAMAHA_AVR.pm index 0ca300635..809b72358 100755 --- a/fhem/FHEM/71_YAMAHA_AVR.pm +++ b/fhem/FHEM/71_YAMAHA_AVR.pm @@ -60,6 +60,7 @@ YAMAHA_AVR_Initialize($) "request-timeout:1,2,3,4,5 ". "model ". "volumeSteps:1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20 ". + "volumeMax ". "volume-smooth-change:0,1 ". "volume-smooth-steps:1,2,3,4,5,6,7,8,9,10 ". $readingFnAttributes; @@ -436,6 +437,11 @@ YAMAHA_AVR_Set($@) { return $usage; } + + if($target_volume > YAMAHA_AVR_volume_rel2abs(AttrVal($name, "volumeMax","100"))) + { + $target_volume = YAMAHA_AVR_volume_rel2abs(AttrVal($name, "volumeMax","100")); + } # if lower than minimum (-80.5) or higher than max (16.5) set target volume to the corresponding boundary $target_volume = -80.5 if(defined($target_volume) and $target_volume < -80.5); @@ -919,14 +925,39 @@ YAMAHA_AVR_Set($@) sub YAMAHA_AVR_Attr(@) { - my @a = @_; - my $hash = $defs{$a[1]}; + my ($cmd, $name, $attr, $val) = @_; + + my $hash = $defs{$name}; - if($a[2] eq "disable") + return unless($hash); + + if($attr eq "disable") { # Start/Stop Timer according to new disabled-Value YAMAHA_AVR_ResetTimer($hash, 1); } + + if($cmd eq "set") + { + if($attr =~ /^(?:volumeMax|volumeSteps)$/) + { + if($val !~ /^\d+$/) + { + return "invalid attribute value for attribute $attr: $val"; + } + + if($attr eq "volumeMax" and ($val < 0 or $val > 100)) + { + return "value is out of range (0-100) for attribute $attr: $val"; + } + + if($attr eq "volumeSteps" and ($val < 1)) + { + return "value is out of range (1-*) for attribute $attr: $val"; + } + } + } + return undef; } @@ -2395,28 +2426,36 @@ So here are some examples: Attributes Generated Readings/Events:
Generierte Readings/Events: