diff --git a/fhem/CHANGED b/fhem/CHANGED index e5e167388..c2b78e5ae 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,7 @@ # 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: 71_YAMAHA_AVR: new set commands/readings for controlling + bass and treble (by dev0) - feature: 66_ECMD: requestSeparator can be turned off - feature: 02_RSS: viewport configurable by attribute - change: 93_DbLog: removed use of perl's 'switch' feature. diff --git a/fhem/FHEM/71_YAMAHA_AVR.pm b/fhem/FHEM/71_YAMAHA_AVR.pm index bf60d5db1..0f5f1bdd5 100755 --- a/fhem/FHEM/71_YAMAHA_AVR.pm +++ b/fhem/FHEM/71_YAMAHA_AVR.pm @@ -98,9 +98,32 @@ YAMAHA_AVR_GetStatus($;$) YAMAHA_AVR_SendCommand($hash, "<$zone>GetParam", "statusRequest", "basicStatus"); YAMAHA_AVR_SendCommand($hash, "GetParam", "statusRequest", "fwUpdate", 1); + + if (YAMAHA_AVR_isModel_DSP($hash)) + { + #Log3 $name, 5, "ZONE: " . $zone; + if ($zone eq "Main_Zone") + { + YAMAHA_AVR_SendCommand($hash, "<$zone>GetParam", "statusRequest", "toneStatus"); + YAMAHA_AVR_SendCommand($hash, "<$zone>GetParam", "statusRequest", "toneStatus"); + } + else + { + YAMAHA_AVR_SendCommand($hash, "<$zone>GetParam", "statusRequest", "toneStatus"); + YAMAHA_AVR_SendCommand($hash, "<$zone>GetParam", "statusRequest", "toneStatus"); + } + } + else + { + YAMAHA_AVR_SendCommand($hash, "<$zone>GetParam", "statusRequest", "toneStatus"); + YAMAHA_AVR_SendCommand($hash, "<$zone>GetParam", "statusRequest", "toneStatus"); + } + YAMAHA_AVR_SendCommand($hash, "GetParam", "statusRequest", "fwUpdate", 1); YAMAHA_AVR_ResetTimer($hash) unless($local == 1); + + return undef; } ################################### @@ -188,6 +211,9 @@ YAMAHA_AVR_Set($@) (exists($hash->{ACTIVE_ZONE}) and $hash->{ACTIVE_ZONE} eq "mainzone" ? "straight:on,off 3dCinemaDsp:off,auto adaptiveDrc:off,auto ".(exists($hash->{helper}{DIRECT_TAG}) ? "direct:on,off " : "").(exists($hash->{helper}{DSP_MODES}) ? "dsp:".$dsp_modes_comma." " : "")."enhancer:on,off " : ""). (exists($hash->{helper}{CURRENT_INPUT_TAG}) ? "play:noArg pause:noArg stop:noArg skip:reverse,forward ".(exists($hash->{helper}{PLAY_CONTROL}) ? "shuffle:on,off repeat:off,one,all " : "") : ""). "sleep:off,30min,60min,90min,120min,last ". + (exists($hash->{ACTIVE_ZONE}) and ($hash->{ACTIVE_ZONE} eq "mainzone") ? "bass:slider,-6,0.5,6 treble:slider,-6,0.5,6 " : ""). + (exists($hash->{ACTIVE_ZONE}) and ($hash->{ACTIVE_ZONE} ne "mainzone") and (YAMAHA_AVR_isModel_DSP($hash)) ? "bass:slider,-10,1,10 treble:slider,-10,1,10 " : ""). + (exists($hash->{ACTIVE_ZONE}) and ($hash->{ACTIVE_ZONE} ne "mainzone") and (not YAMAHA_AVR_isModel_DSP($hash)) ? "bass:slider,-10,2,10 treble:slider,-10,2,10 " : ""). "statusRequest:noArg"; Log3 $name, 5, "YAMAHA_AVR ($name) - set ".join(" ", @a); @@ -379,6 +405,94 @@ YAMAHA_AVR_Set($@) } } } + elsif($what eq "bass") + { + if(defined($a[2])) + { + if($hash->{READINGS}{power}{VAL} eq "on") + { + my $bassVal = $a[2]; + if ((exists($hash->{ACTIVE_ZONE})) && ($hash->{ACTIVE_ZONE} eq "mainzone")) + { + $bassVal = int($a[2]) if not (($a[2] =~ /^\d$/ ) || ($a[2] =~ /\.5/) || ($a[2] =~ /\.0/)); + $bassVal = -6 if($bassVal < -6); + $bassVal = 6 if($bassVal > 6); + if (YAMAHA_AVR_isModel_DSP($hash)) + { + YAMAHA_AVR_SendCommand($hash, "<$zone>" . ReadingsVal($name,".bass_crossover","125") . "0Hz" . $bassVal*10 . "1dB", $what, $bassVal); + } + else + { + YAMAHA_AVR_SendCommand($hash, "<$zone>" . $bassVal*10 . "1dB", $what, $bassVal); + } + } + else # !main_zone + { + $bassVal = int($a[2]); + $bassVal = -10 if($bassVal < -10); + $bassVal = 10 if($bassVal > 10); + if (YAMAHA_AVR_isModel_DSP($hash)) + { + YAMAHA_AVR_SendCommand($hash, "<$zone>" . $bassVal*10 . "1dB", $what, $bassVal); + } + else + { + $bassVal-- if (($bassVal % 2 != 0) && ($bassVal > 0)); + $bassVal++ if (($bassVal % 2 != 0) && ($bassVal < 0)); + YAMAHA_AVR_SendCommand($hash, "<$zone>" . $bassVal*10 . "1dB", $what, $bassVal); + } + } + } + else + { + return "bass can only used when device is powered on"; + } + } + } + elsif($what eq "treble") + { + if(defined($a[2])) + { + if($hash->{READINGS}{power}{VAL} eq "on") + { + my $trebleVal = $a[2]; + if ((exists($hash->{ACTIVE_ZONE})) && ($hash->{ACTIVE_ZONE} eq "mainzone")) + { + $trebleVal = int($a[2]) if not (($a[2] =~ /^\d$/ ) || ($a[2] =~ /\.5/) || ($a[2] =~ /\.0/)); + $trebleVal = -6 if($trebleVal < -6); + $trebleVal = 6 if($trebleVal > 6); + if (YAMAHA_AVR_isModel_DSP($hash)) + { + YAMAHA_AVR_SendCommand($hash, "<$zone>" . ReadingsVal($name,".treble_crossover","35") . "1kHz" . $trebleVal*10 . "1dB", $what, $trebleVal); + } + else + { + YAMAHA_AVR_SendCommand($hash, "<$zone>" . $trebleVal*10 . "1dB", $what, $trebleVal); + } + } + else # !main_zone + { + $trebleVal = int($trebleVal); + $trebleVal = -10 if($trebleVal < -10); + $trebleVal = 10 if($trebleVal > 10); + if (YAMAHA_AVR_isModel_DSP($hash)) + { + YAMAHA_AVR_SendCommand($hash, "<$zone>" . $trebleVal*10 . "1dB", $what, $trebleVal); + } + else + { + $trebleVal-- if (($trebleVal % 2 != 0) && ($trebleVal > 0)); + $trebleVal++ if (($trebleVal % 2 != 0) && ($trebleVal < 0)); + YAMAHA_AVR_SendCommand($hash, "<$zone>" . $trebleVal*10 . "1dB", $what, $trebleVal); + } + } + } + else + { + return "treble can only used when device is powered on"; + } + } + } elsif($what eq "dsp") { if(defined($a[2])) @@ -976,6 +1090,59 @@ YAMAHA_AVR_ParseResponse ($$$) } } } + elsif($arg eq "toneStatus") + { + # Response DSP-Z7: 1250Hz351dB + # Response DSP-Z7: 01dB + # Response other models ???: 01dB + if (($data =~ /(.+?)<\/Val>.*?<\/Exp>.*?<\/Unit><\/Cross_Over>(.+?)<\/Val>.*?<\/Lvl><\/Bass><\/Speaker><\/Tone>/) || + ($data =~ /(.+?)<\/Val>1<\/Exp>dB<\/Unit><\/Bass><\/Tone>/)) + { + Log3 $name, 5, "YAMAHA_AVR ($name) - toneStatus Bass: " . $data; + if ((exists($hash->{ACTIVE_ZONE})) && ($hash->{ACTIVE_ZONE} eq "mainzone")) + { + + if($2) + { + readingsBulkUpdate($hash, "bass", int($2)/10); + readingsBulkUpdate($hash, "bassCrossover", lc($1)); + } + else + { + readingsBulkUpdate($hash, "bass", int($1)/10); + } + } + else #!main_zone + { + readingsBulkUpdate($hash, "bass", int($1)/10); + } + } + + # Response DSP-Z7: 351kHz101dB + # Response DSP-Z7: 01dB + # Response other models ???: 01dB + elsif (($data =~ /(.+?)<\/Val>.*?<\/Exp>.*?<\/Unit><\/Cross_Over>(.+?)<\/Val>.*?<\/Lvl><\/Treble><\/Speaker><\/Tone>/) || + ($data =~ /(.+?)<\/Val>1<\/Exp>dB<\/Unit><\/Treble><\/Tone>/)) + { + Log3 $name, 5, "YAMAHA_AVR ($name) - toneStatus Treble: " . $data; + if ((exists($hash->{ACTIVE_ZONE})) && ($hash->{ACTIVE_ZONE} eq "mainzone")) + { + if($2) + { + readingsBulkUpdate($hash, "treble", int($2)/10); + readingsBulkUpdate($hash, "trebleCrossover", lc($1)); + } + else + { + readingsBulkUpdate($hash, "treble", int($1)/10); + } + } + else #!main_zone + { + readingsBulkUpdate($hash, "treble", int($1)/10); + } + } + } elsif($arg eq "basicStatus") { if($data =~ /(.+?)<\/Power>/) @@ -1484,6 +1651,27 @@ sub YAMAHA_AVR_html2txt($) return $string; } + + +# ######################################################################################## +# ### DSP-Z7 / 3900 specific functions ################################################### +# ######################################################################################## + + +############################# +# Check if amp is one of these models: DSP-Z7, DSP-Z9, DSP-Z11, RX-Z7, RX-Z9, RX-Z11, RX-V3900, DSP-AX3900 +# Tested models: DSP-Z7 +sub +YAMAHA_AVR_isModel_DSP($) +{ + my($hash) = @_; + if (exists($hash->{MODEL}) && (($hash->{MODEL} =~ /DSP-Z/) || ($hash->{MODEL} =~ /RX-Z/) || ($hash->{MODEL} =~ /RX-V3900/) || ($hash->{MODEL} =~ /DSP-AX3900/))) + { + return 1; + } + return 0; +} + 1; =pod @@ -1579,6 +1767,8 @@ sub YAMAHA_AVR_html2txt($)
  • volumeUp [0-100] [direct]   -   increases the volume level by 5% or the value of attribute volumeSteps (optional the increasing level can be given as argument, which will be used instead). If you use "direct" as second argument, no volume smoothing is used (if activated) for this volume change. In this case, the volume will be set immediatly.
  • volumeDown [0-100] [direct]   -   decreases the volume level by 5% or the value of attribute volumeSteps (optional the decreasing level can be given as argument, which will be used instead). If you use "direct" as second argument, no volume smoothing is used (if activated) for this volume change. In this case, the volume will be set immediatly.
  • mute on|off|toggle   -   activates volume mute
  • +
  • bass [-6...6] step 0.5 (main zone), [-10...10] step 2 (other zones), [-10...10] step 1 (other zones, DSP models)   -   set bass tone level in decibel
  • +
  • treble [-6...6] step 0.5 (main zone), [-10...10] step 2 (other zones), [-10...10] step 1 (other zones, DSP models)   -   set treble tone level in decibel
  • dsp hallinmunich,hallinvienna,...   -   sets the DSP mode to the given preset
  • enhancer on|off   -   controls the internal sound enhancer
  • 3dCinemaDsp auto|off   -   controls the CINEMA DSP 3D mode
  • @@ -1696,6 +1886,7 @@ sub YAMAHA_AVR_html2txt($)
    • 3dCinemaDsp - The status of the CINEMA DSP 3D mode (can be "auto" or "off")
    • adaptiveDrc - The status of the Adaptive DRC (can be "auto" or "off")
    • +
    • bass Reports the current bass tone level of the receiver or zone in decibel values (between -6 and 6 dB (mainzone) and -10 and 10 dB (other zones)
    • dsp - The current selected DSP mode for sound output
    • direct - indicates if all sound enhancement features are bypassed or not ("on" => all features are bypassed, "off" => sound enhancement features are used).
    • enhancer - The status of the internal sound enhancer (can be "on" or "off")
    • @@ -1710,6 +1901,7 @@ sub YAMAHA_AVR_html2txt($)
    • sleep - indicates if the internal sleep timer is activated or not.
    • straight - indicates if the internal sound codec converter is bypassed or not (can be "on" or "off")
    • state - Reports the current power state and an absence of the device (can be "on", "off" or "absent")
    • +
    • treble Reports the current treble tone level of the receiver or zone in decibel values (between -6 and 6 dB (mainzone) and -10 and 10 dB (other zones)


    • Input dependent Readings/Events:
    • currentChannel - Number of the input channel (SIRIUS only)
    • currentStation - Station name of the current radio station (available on NET RADIO, PANDORA
    • @@ -1822,6 +2014,8 @@ sub YAMAHA_AVR_html2txt($)
    • volumeUp [0...100] [direct]   -   Erhöht die Lautstärke um 5% oder entsprechend dem Attribut volumeSteps (optional kann der Wert auch als Argument angehangen werden, dieser hat dann Vorang). Wenn als zweites Argument "direct" gesetzt ist, wird keine weiche Lautstärkenanpassung durchgeführt (sofern aktiviert). Die Lautstärke wird in diesem Fall sofort gesetzt.
    • volumeDown [0...100] [direct]   -   Veringert die Lautstärke um 5% oder entsprechend dem Attribut volumeSteps (optional kann der Wert auch als Argument angehangen werden, dieser hat dann Vorang). Wenn als zweites Argument "direct" gesetzt ist, wird keine weiche Lautstärkenanpassung durchgeführt (sofern aktiviert). Die Lautstärke wird in diesem Fall sofort gesetzt.
    • mute on,off,toggle   -   Schaltet den Receiver stumm
    • +
    • bass [-6...6] Schrittweite 0.5 (main zone), [-10...10] Schrittweite 2 (andere Zonen), [-10...10] Schrittweite 1 (andere Zonen, DSP Modelle)   -   Stellt die Tiefen in decibel ein
    • +
    • treble [-6...6] Schrittweite 0.5 (main zone), [-10...10] Schrittweite 2 (andere Zonen), [-10...10] Schrittweite 1 (andere Zonen, DSP Modelle)   -   Stellt die Höhen in decibel ein
    • straight on,off   -   Umgeht die interne Codec-Umwandlung und gibt den Original-Codec wieder.
    • sleep off,30min,60min,...,last   -   Aktiviert den internen Sleep-Timer zum automatischen Abschalten
    • shuffle on,off   -   Aktiviert die Zufallswiedergabe des aktuellen Eingangs (ist nur eingangsabhängig verfügbar)
    • @@ -1930,6 +2124,7 @@ sub YAMAHA_AVR_html2txt($)
      • 3dCinemaDsp - Der Status des CINEMA DSP 3D-Modus ("auto" => an, "off" => aus)
      • adaptiveDrc - Der Status des Adaptive DRC ("auto" => an, "off" => aus)
      • +
      • bass Der aktuelle Basspegel, zwischen -6 and 6 dB (main zone) and -10 and 10 dB (andere Zonen)
      • dsp - Das aktuell aktive DSP Preset
      • enhancer - Der Status des Enhancers ("on" => an, "off" => aus)
      • input - Der ausgewählte Eingang entsprechend dem FHEM-Kommando
      • @@ -1944,6 +2139,7 @@ sub YAMAHA_AVR_html2txt($)
      • straight - Zeigt an, ob die interne Codec Umwandlung umgangen wird oder nicht ("on" => Codec Umwandlung wird umgangen, "off" => Codec Umwandlung wird benutzt)
      • sleep - Zeigt den Status des internen Sleep-Timers an
      • state - Der aktuelle Schaltzustand (power-Reading) oder die Abwesenheit des Gerätes (mögliche Werte: "on", "off" oder "absent")
      • +
      • treble Der aktuelle Höhenpegel, zwischen -6 and 6 dB (main zone) and -10 and 10 dB (andere Zonen)


      • Eingangsabhängige Readings/Events:
      • currentChannel - Nummer des Eingangskanals (nur bei SIRIUS)
      • currentStation - Name des Radiosenders (nur bei TUNER, NET RADIO und PANDORA)