diff --git a/fhem/CHANGED b/fhem/CHANGED index 90b3978e3..d9aa143bf 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 commands play, pause, stop, skip, shuffle, repeat - feature: 71_YAMAHA_NP: New command set and readings for menu navigation - feature: 71_YAMAHA_NP: New command 'dimmer [1..3]' - bugfix: 31_MilightDevice: if we're already off don't turn on to set dim level! diff --git a/fhem/FHEM/71_YAMAHA_AVR.pm b/fhem/FHEM/71_YAMAHA_AVR.pm index 51581133e..50f9f0c43 100755 --- a/fhem/FHEM/71_YAMAHA_AVR.pm +++ b/fhem/FHEM/71_YAMAHA_AVR.pm @@ -173,8 +173,21 @@ YAMAHA_AVR_Set($@) return "No Argument given" if(!defined($a[1])); my $what = $a[1]; - my $usage = "Unknown argument $what, choose one of on:noArg off:noArg volumeStraight:slider,-80,1,16 volume:slider,0,1,100 volumeUp volumeDown ".(exists($hash->{helper}{INPUTS})?"input:".$inputs_comma." ":"")."mute:on,off,toggle remoteControl:setup,up,down,left,right,return,option,display,tunerPresetUp,tunerPresetDown,enter ".(exists($hash->{helper}{SCENES})?"scene:".$scenes_comma." ":"").(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 " : "")."sleep:off,30min,60min,90min,120min,last statusRequest:noArg"; - + my $usage = "Unknown argument $what, choose one of ". "on:noArg ". + "off:noArg ". + "volumeStraight:slider,-80,1,16 ". + "volume:slider,0,1,100 ". + "volumeUp ". + "volumeDown ". + (exists($hash->{helper}{INPUTS})?"input:".$inputs_comma." ":""). + "mute:on,off,toggle ". + "remoteControl:setup,up,down,left,right,return,option,display,tunerPresetUp,tunerPresetDown,enter ". + (exists($hash->{helper}{SCENES})?"scene:".$scenes_comma." ":""). + (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 ". + "statusRequest:noArg"; + Log3 $name, 5, "YAMAHA_AVR ($name) - set ".join(" ", @a); if($what eq "on") @@ -565,6 +578,67 @@ YAMAHA_AVR_Set($@) return $usage; } } + elsif($what eq "play" and exists($hash->{helper}{CURRENT_INPUT_TAG})) + { + YAMAHA_AVR_SendCommand($hash,"<".$hash->{helper}{CURRENT_INPUT_TAG}.">Play{helper}{CURRENT_INPUT_TAG}.">", $what, $a[2]); + } + elsif($what eq "stop" and exists($hash->{helper}{CURRENT_INPUT_TAG})) + { + YAMAHA_AVR_SendCommand($hash,"<".$hash->{helper}{CURRENT_INPUT_TAG}.">Stop{helper}{CURRENT_INPUT_TAG}.">", $what, $a[2]); + } + elsif($what eq "pause" and exists($hash->{helper}{CURRENT_INPUT_TAG})) + { + YAMAHA_AVR_SendCommand($hash,"<".$hash->{helper}{CURRENT_INPUT_TAG}.">Pause{helper}{CURRENT_INPUT_TAG}.">", $what, $a[2]); + } + elsif($what eq "skip") + { + if($a[2] eq "forward") + { + YAMAHA_AVR_SendCommand($hash,"<".$hash->{helper}{CURRENT_INPUT_TAG}.">Skip Fwd{helper}{CURRENT_INPUT_TAG}.">", $what, $a[2]); + } + elsif($a[2] eq "reverse") + { + YAMAHA_AVR_SendCommand($hash,"<".$hash->{helper}{CURRENT_INPUT_TAG}.">Skip Rev{helper}{CURRENT_INPUT_TAG}.">", $what, $a[2]); + } + else + { + return $usage; + } + } + elsif($what eq "shuffle") + { + if($a[2] eq "on") + { + YAMAHA_AVR_SendCommand($hash,"<".$hash->{helper}{CURRENT_INPUT_TAG}.">On{helper}{CURRENT_INPUT_TAG}.">", $what, $a[2]); + } + elsif($a[2] eq "off") + { + YAMAHA_AVR_SendCommand($hash,"<".$hash->{helper}{CURRENT_INPUT_TAG}.">Off{helper}{CURRENT_INPUT_TAG}.">", $what, $a[2]); + } + else + { + return $usage; + } + } + elsif($what eq "repeat") + { + if($a[2] eq "one") + { + YAMAHA_AVR_SendCommand($hash,"<".$hash->{helper}{CURRENT_INPUT_TAG}.">One{helper}{CURRENT_INPUT_TAG}.">", $what, $a[2]); + } + elsif($a[2] eq "off") + { + YAMAHA_AVR_SendCommand($hash,"<".$hash->{helper}{CURRENT_INPUT_TAG}.">Off{helper}{CURRENT_INPUT_TAG}.">", $what, $a[2]); + } + elsif($a[2] eq "all") + { + YAMAHA_AVR_SendCommand($hash,"<".$hash->{helper}{CURRENT_INPUT_TAG}.">All{helper}{CURRENT_INPUT_TAG}.">", $what, $a[2]); + } + else + { + return $usage; + } + } elsif($what eq "statusRequest") { YAMAHA_AVR_GetStatus($hash, 1); @@ -782,6 +856,11 @@ YAMAHA_AVR_ParseResponse ($$$) if(exists($param->{code})) { Log3 $name, 5, "YAMAHA_AVR ($name) - received HTTP code ".$param->{code}." for command \"$cmd".(defined($arg) ? " ".(split("\\|", $arg))[0] : "")."\""; + + if($cmd eq "statusRequest" and $arg eq "playShuffle" and $param->{code} ne "200") + { + delete($hash->{helper}{PLAY_CONTROL}) if(exists($hash->{helper}{PLAY_CONTROL})); + } } if($err ne "") @@ -944,13 +1023,17 @@ YAMAHA_AVR_ParseResponse ($$$) # current input same as the corresponding set command name if($data =~ /(.+?)<\/Input_Sel>/) { + $hash->{helper}{CURRENT_INPUT_TAG} = $1; + readingsBulkUpdate($hash, "input", YAMAHA_AVR_Param2Fhem(lc($1), 0)); if($data =~ /(.+?)<\/Src_Name>/) { - Log3 $name, 4, "YAMAHA_AVR ($name) - check for extended informations"; + Log3 $name, 4, "YAMAHA_AVR ($name) - check for extended input informations on <$1>"; YAMAHA_AVR_SendCommand($hash, "<$1>GetParam", "statusRequest", "playInfo"); + YAMAHA_AVR_SendCommand($hash, "<$1>GetParam", "statusRequest", "playRepeat"); + YAMAHA_AVR_SendCommand($hash, "<$1>GetParam", "statusRequest", "playShuffle"); } else { @@ -1043,7 +1126,7 @@ YAMAHA_AVR_ParseResponse ($$$) if($data =~ /.*?(.+?)<\/Channel>.*?<\/Meta_Info>/) { - readingsBulkUpdate($hash, "currentChannel", $1); + readingsBulkUpdate($hash, "currentChannel", YAMAHA_AVR_html2txt($1)); } else { @@ -1090,6 +1173,22 @@ YAMAHA_AVR_ParseResponse ($$$) readingsBulkUpdate($hash, "playStatus", lc($1)); } } + elsif($arg eq "playShuffle") + { + if($data =~ /(.+?)<\/Shuffle>/) + { + $hash->{helper}{PLAY_CONTROL} = 1; + readingsBulkUpdate($hash, "shuffle", lc($1)); + } + } + elsif($arg eq "playRepeat") + { + if($data =~ /(.+?)<\/Repeat>/) + { + $hash->{helper}{PLAY_CONTROL} = 1; + readingsBulkUpdate($hash, "repeat", lc($1)); + } + } } elsif($cmd eq "on") { @@ -1476,6 +1575,12 @@ sub YAMAHA_AVR_html2txt($)
  • straight on|off   -   bypasses the internal codec converter and plays the original sound codec
  • direct on|off   -   bypasses all internal sound enhancement features and plays the sound straight directly
  • sleep off,30min,60min,...,last   -   activates the internal sleep timer
  • +
  • shuffle on,off   -   activates the shuffle mode on the current input
  • +
  • repeat one,all,off   -   activates the repeat mode on the current input for one or all titles
  • +
  • pause   -   pause playback on current input
  • +
  • play   -   start playback on current input
  • +
  • stop   -   stop playback on current input
  • +
  • skip reverse,forward   -   skip track on current input
  • statusRequest   -   requests the current status of the device
  • remoteControl up,down,...   -   sends remote control commands as listed below
  • @@ -1517,20 +1622,22 @@ sub YAMAHA_AVR_html2txt($) # the initial definition.
    define AV_receiver YAMAHA_AVR 192.168.0.3

    - And in your 99_MyUtils.pm the following function:

    + And in your myUtils.pm (based on myUtilsTemplate.pm) the following function:

      - sub startNetRadio()
      - {
      -   fhem "set AV_Receiver on";
      -   sleep 5;
      -   fhem "set AV_Receiver input netradio";
      -   sleep 4;
      -   fhem "set AV_Receiver remoteControl enter";
      -   sleep 2;
      -   fhem "set AV_Receiver remoteControl enter";
      - } + sub startNetRadio()
      + {
      +   fhem("set AV_Receiver on;
      +         sleep 5;
      +         set AV_Receiver input netradio;
      +         sleep 4;
      +         set AV_Receiver remoteControl enter;
      +         sleep 2;
      +         set AV_Receiver remoteControl enter;
      +         sleep 2;
      +         set AV_Receiver remoteControl enter");
      + }


    - The remote control commands must be separated with a sleep, because the receiver is loading meanwhile and don't accept commands.

    + The remote control commands must be separated with a sleep, because the receiver is loading meanwhile and don't accept commands. These commands will be executed in background and does not harm the FHEM main process.

    Now you can use this function by typing the following line in your FHEM command line or in your notify-definitions:

      @@ -1598,6 +1705,8 @@ sub YAMAHA_AVR_html2txt($)
    • currentArtist - Artist name of the current song
    • currentTitle - Title of the current song
    • playStatus - indicates if the input plays music or not
    • +
    • shuffle - indicates the shuffle status for the current input
    • +
    • repeat - indicates the repeat status for the current input

    Implementator's note
    @@ -1703,6 +1812,12 @@ sub YAMAHA_AVR_html2txt($)
  • mute on,off,toggle   -   Schaltet den Receiver stumm
  • 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)
  • +
  • repeat one,all,off   -   Wiederholt den aktuellen (one) oder alle (all) Titel des aktuellen Eingangs (ist nur eingangsabhängig verfügbar)
  • +
  • pause   -   Wiedergabe pausieren (ist nur eingangsabhängig verfügbar)
  • +
  • play   -   Wiedergabe starten (ist nur eingangsabhängig verfügbar)
  • +
  • stop   -   Wiedergabe stoppen (ist nur eingangsabhängig verfügbar)
  • +
  • skip reverse,forward   -   Aktuellen Titel überspringen (ist nur eingangsabhängig verfügbar)
  • statusRequest   -   Fragt den aktuell Status des Receivers ab
  • remoteControl up,down,...   -   Sendet Fernbedienungsbefehle wie im nächsten Abschnitt beschrieben
  • @@ -1743,20 +1858,22 @@ sub YAMAHA_AVR_html2txt($) # Die Gerätedefinition

    define AV_receiver YAMAHA_AVR 192.168.0.3


    - Und in der 99_MyUtils.pm die folgende Funktion:

    + Und in der myUtils.pm (basierend auf der myUtilsTemplate.pm) die folgende Funktion:

      - sub startNetRadio
      - {
      -   fhem "set AV_Receiver on";
      -   sleep 5;
      -   fhem "set AV_Receiver input netradio";
      -   sleep 4;
      -   fhem "set AV_Receiver remoteControl enter";
      -   sleep 2;
      -   fhem "set AV_Receiver remoteControl enter";
      - } + sub startNetRadio()
      + {
      +   fhem("set AV_Receiver on;
      +         sleep 5;
      +         set AV_Receiver input netradio;
      +         sleep 4;
      +         set AV_Receiver remoteControl enter;
      +         sleep 2;
      +         set AV_Receiver remoteControl enter;
      +         sleep 2;
      +         set AV_Receiver remoteControl enter");
      + }


    - Die Kommandos der Fernbedienung müssen mit einem sleep pausiert werden, da der Receiver in der Zwischenzeit arbeitet und keine Befehle annimmt..

    + Die Kommandos der Fernbedienung müssen mit einem sleep pausiert werden, da der Receiver in der Zwischenzeit arbeitet und keine Befehle annimmt. Diese Befehle werden alle im Hintergrund ausgeführt, so dass für den FHEM Hauptprozess keine Verzögerung entsteht.

    Nun kann man diese Funktion in der FHEM Kommandozeile oder in notify-Definitionen wie folgt verwenden.:

      @@ -1821,6 +1938,8 @@ sub YAMAHA_AVR_html2txt($)
    • currentArtist - Interpret des aktuell gespielten Titel
    • currentTitle - Name des aktuell gespielten Titel
    • playStatus - Wiedergabestatus des Eingangs
    • +
    • shuffle - Status der Zufallswiedergabe des aktuellen Eingangs
    • +
    • repeat - Status der Titelwiederholung des aktuellen Eingangs

    Hinweise des Autors