mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 06:39:11 +00:00
YAMAHA_AVR: new commands play, pause, stop, skip, shuffle, repeat (Forum #33209)
git-svn-id: https://svn.fhem.de/fhem/trunk@7889 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
ab5bfdf751
commit
1529250062
@ -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!
|
||||
|
@ -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,"<YAMAHA_AV cmd=\"PUT\"><".$hash->{helper}{CURRENT_INPUT_TAG}."><Play_Control><Playback>Play</Playback></Play_Control></".$hash->{helper}{CURRENT_INPUT_TAG}."></YAMAHA_AV>", $what, $a[2]);
|
||||
}
|
||||
elsif($what eq "stop" and exists($hash->{helper}{CURRENT_INPUT_TAG}))
|
||||
{
|
||||
YAMAHA_AVR_SendCommand($hash,"<YAMAHA_AV cmd=\"PUT\"><".$hash->{helper}{CURRENT_INPUT_TAG}."><Play_Control><Playback>Stop</Playback></Play_Control></".$hash->{helper}{CURRENT_INPUT_TAG}."></YAMAHA_AV>", $what, $a[2]);
|
||||
}
|
||||
elsif($what eq "pause" and exists($hash->{helper}{CURRENT_INPUT_TAG}))
|
||||
{
|
||||
YAMAHA_AVR_SendCommand($hash,"<YAMAHA_AV cmd=\"PUT\"><".$hash->{helper}{CURRENT_INPUT_TAG}."><Play_Control><Playback>Pause</Playback></Play_Control></".$hash->{helper}{CURRENT_INPUT_TAG}."></YAMAHA_AV>", $what, $a[2]);
|
||||
}
|
||||
elsif($what eq "skip")
|
||||
{
|
||||
if($a[2] eq "forward")
|
||||
{
|
||||
YAMAHA_AVR_SendCommand($hash,"<YAMAHA_AV cmd=\"PUT\"><".$hash->{helper}{CURRENT_INPUT_TAG}."><Play_Control><Playback>Skip Fwd</Playback></Play_Control></".$hash->{helper}{CURRENT_INPUT_TAG}."></YAMAHA_AV>", $what, $a[2]);
|
||||
}
|
||||
elsif($a[2] eq "reverse")
|
||||
{
|
||||
YAMAHA_AVR_SendCommand($hash,"<YAMAHA_AV cmd=\"PUT\"><".$hash->{helper}{CURRENT_INPUT_TAG}."><Play_Control><Playback>Skip Rev</Playback></Play_Control></".$hash->{helper}{CURRENT_INPUT_TAG}."></YAMAHA_AV>", $what, $a[2]);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $usage;
|
||||
}
|
||||
}
|
||||
elsif($what eq "shuffle")
|
||||
{
|
||||
if($a[2] eq "on")
|
||||
{
|
||||
YAMAHA_AVR_SendCommand($hash,"<YAMAHA_AV cmd=\"PUT\"><".$hash->{helper}{CURRENT_INPUT_TAG}."><Play_Control><Play_Mode><Shuffle>On</Shuffle></Play_Mode></Play_Control></".$hash->{helper}{CURRENT_INPUT_TAG}."></YAMAHA_AV>", $what, $a[2]);
|
||||
}
|
||||
elsif($a[2] eq "off")
|
||||
{
|
||||
YAMAHA_AVR_SendCommand($hash,"<YAMAHA_AV cmd=\"PUT\"><".$hash->{helper}{CURRENT_INPUT_TAG}."><Play_Control><Play_Mode><Shuffle>Off</Shuffle></Play_Mode></Play_Control></".$hash->{helper}{CURRENT_INPUT_TAG}."></YAMAHA_AV>", $what, $a[2]);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $usage;
|
||||
}
|
||||
}
|
||||
elsif($what eq "repeat")
|
||||
{
|
||||
if($a[2] eq "one")
|
||||
{
|
||||
YAMAHA_AVR_SendCommand($hash,"<YAMAHA_AV cmd=\"PUT\"><".$hash->{helper}{CURRENT_INPUT_TAG}."><Play_Control><Play_Mode><Repeat>One</Repeat></Play_Mode></Play_Control></".$hash->{helper}{CURRENT_INPUT_TAG}."></YAMAHA_AV>", $what, $a[2]);
|
||||
}
|
||||
elsif($a[2] eq "off")
|
||||
{
|
||||
YAMAHA_AVR_SendCommand($hash,"<YAMAHA_AV cmd=\"PUT\"><".$hash->{helper}{CURRENT_INPUT_TAG}."><Play_Control><Play_Mode><Repeat>Off</Repeat></Play_Mode></Play_Control></".$hash->{helper}{CURRENT_INPUT_TAG}."></YAMAHA_AV>", $what, $a[2]);
|
||||
}
|
||||
elsif($a[2] eq "all")
|
||||
{
|
||||
YAMAHA_AVR_SendCommand($hash,"<YAMAHA_AV cmd=\"PUT\"><".$hash->{helper}{CURRENT_INPUT_TAG}."><Play_Control><Play_Mode><Repeat>All</Repeat></Play_Mode></Play_Control></".$hash->{helper}{CURRENT_INPUT_TAG}."></YAMAHA_AV>", $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>(.+?)<\/Input_Sel>/)
|
||||
{
|
||||
$hash->{helper}{CURRENT_INPUT_TAG} = $1;
|
||||
|
||||
readingsBulkUpdate($hash, "input", YAMAHA_AVR_Param2Fhem(lc($1), 0));
|
||||
|
||||
if($data =~ /<Src_Name>(.+?)<\/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, "<YAMAHA_AV cmd=\"GET\"><$1><Play_Info>GetParam</Play_Info></$1></YAMAHA_AV>", "statusRequest", "playInfo");
|
||||
YAMAHA_AVR_SendCommand($hash, "<YAMAHA_AV cmd=\"GET\"><$1><Play_Control><Play_Mode><Repeat>GetParam</Repeat></Play_Mode></Play_Control></$1></YAMAHA_AV>", "statusRequest", "playRepeat");
|
||||
YAMAHA_AVR_SendCommand($hash, "<YAMAHA_AV cmd=\"GET\"><$1><Play_Control><Play_Mode><Shuffle>GetParam</Shuffle></Play_Mode></Play_Control></$1></YAMAHA_AV>", "statusRequest", "playShuffle");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1043,7 +1126,7 @@ YAMAHA_AVR_ParseResponse ($$$)
|
||||
|
||||
if($data =~ /<Meta_Info>.*?<Channel>(.+?)<\/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>(.+?)<\/Shuffle>/)
|
||||
{
|
||||
$hash->{helper}{PLAY_CONTROL} = 1;
|
||||
readingsBulkUpdate($hash, "shuffle", lc($1));
|
||||
}
|
||||
}
|
||||
elsif($arg eq "playRepeat")
|
||||
{
|
||||
if($data =~ /<Repeat>(.+?)<\/Repeat>/)
|
||||
{
|
||||
$hash->{helper}{PLAY_CONTROL} = 1;
|
||||
readingsBulkUpdate($hash, "repeat", lc($1));
|
||||
}
|
||||
}
|
||||
}
|
||||
elsif($cmd eq "on")
|
||||
{
|
||||
@ -1476,6 +1575,12 @@ sub YAMAHA_AVR_html2txt($)
|
||||
<li><b>straight</b> on|off - bypasses the internal codec converter and plays the original sound codec</li>
|
||||
<li><b>direct</b> on|off - bypasses all internal sound enhancement features and plays the sound straight directly</li>
|
||||
<li><b>sleep</b> off,30min,60min,...,last - activates the internal sleep timer</li>
|
||||
<li><b>shuffle</b> on,off - activates the shuffle mode on the current input</li>
|
||||
<li><b>repeat</b> one,all,off - activates the repeat mode on the current input for one or all titles</li>
|
||||
<li><b>pause</b> - pause playback on current input</li>
|
||||
<li><b>play</b> - start playback on current input</li>
|
||||
<li><b>stop</b> - stop playback on current input</li>
|
||||
<li><b>skip</b> reverse,forward - skip track on current input</li>
|
||||
<li><b>statusRequest</b> - requests the current status of the device</li>
|
||||
<li><b>remoteControl</b> up,down,... - sends remote control commands as listed below</li>
|
||||
|
||||
@ -1517,20 +1622,22 @@ sub YAMAHA_AVR_html2txt($)
|
||||
# the initial definition.<br>
|
||||
define AV_receiver YAMAHA_AVR 192.168.0.3
|
||||
</code></ul><br><br>
|
||||
And in your 99_MyUtils.pm the following function:<br><br>
|
||||
And in your myUtils.pm (based on myUtilsTemplate.pm) the following function:<br><br>
|
||||
<ul><code>
|
||||
sub startNetRadio()<br>
|
||||
{<br>
|
||||
fhem "set AV_Receiver on";<br>
|
||||
sleep 5;<br>
|
||||
fhem "set AV_Receiver input netradio";<br>
|
||||
sleep 4;<br>
|
||||
fhem "set AV_Receiver remoteControl enter";<br>
|
||||
sleep 2;<br>
|
||||
fhem "set AV_Receiver remoteControl enter";<br>
|
||||
}
|
||||
sub startNetRadio()<br>
|
||||
{<br>
|
||||
fhem("set AV_Receiver on;<br>
|
||||
sleep 5;<br>
|
||||
set AV_Receiver input netradio;<br>
|
||||
sleep 4;<br>
|
||||
set AV_Receiver remoteControl enter;<br>
|
||||
sleep 2;<br>
|
||||
set AV_Receiver remoteControl enter;<br>
|
||||
sleep 2;<br>
|
||||
set AV_Receiver remoteControl enter");<br>
|
||||
}<br>
|
||||
</code></ul><br><br>
|
||||
The remote control commands must be separated with a sleep, because the receiver is loading meanwhile and don't accept commands.<br><br>
|
||||
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.<br><br>
|
||||
|
||||
Now you can use this function by typing the following line in your FHEM command line or in your notify-definitions:<br><br>
|
||||
<ul><code>
|
||||
@ -1598,6 +1705,8 @@ sub YAMAHA_AVR_html2txt($)
|
||||
<li><b>currentArtist</b> - Artist name of the current song</li>
|
||||
<li><b>currentTitle</b> - Title of the current song</li>
|
||||
<li><b>playStatus</b> - indicates if the input plays music or not</li>
|
||||
<li><b>shuffle</b> - indicates the shuffle status for the current input</li>
|
||||
<li><b>repeat</b> - indicates the repeat status for the current input</li>
|
||||
</ul>
|
||||
<br>
|
||||
<b>Implementator's note</b><br>
|
||||
@ -1703,6 +1812,12 @@ sub YAMAHA_AVR_html2txt($)
|
||||
<li><b>mute</b> on,off,toggle - Schaltet den Receiver stumm</li>
|
||||
<li><b>straight</b> on,off - Umgeht die interne Codec-Umwandlung und gibt den Original-Codec wieder.</li>
|
||||
<li><b>sleep</b> off,30min,60min,...,last - Aktiviert den internen Sleep-Timer zum automatischen Abschalten</li>
|
||||
<li><b>shuffle</b> on,off - Aktiviert die Zufallswiedergabe des aktuellen Eingangs (ist nur eingangsabhängig verfügbar)</li>
|
||||
<li><b>repeat</b> one,all,off - Wiederholt den aktuellen (one) oder alle (all) Titel des aktuellen Eingangs (ist nur eingangsabhängig verfügbar)</li>
|
||||
<li><b>pause</b> - Wiedergabe pausieren (ist nur eingangsabhängig verfügbar)</li>
|
||||
<li><b>play</b> - Wiedergabe starten (ist nur eingangsabhängig verfügbar)</li>
|
||||
<li><b>stop</b> - Wiedergabe stoppen (ist nur eingangsabhängig verfügbar)</li>
|
||||
<li><b>skip</b> reverse,forward - Aktuellen Titel überspringen (ist nur eingangsabhängig verfügbar)</li>
|
||||
<li><b>statusRequest</b> - Fragt den aktuell Status des Receivers ab</li>
|
||||
<li><b>remoteControl</b> up,down,... - Sendet Fernbedienungsbefehle wie im nächsten Abschnitt beschrieben</li>
|
||||
</ul>
|
||||
@ -1743,20 +1858,22 @@ sub YAMAHA_AVR_html2txt($)
|
||||
# Die Gerätedefinition<br><br>
|
||||
define AV_receiver YAMAHA_AVR 192.168.0.3
|
||||
</code></ul><br><br>
|
||||
Und in der 99_MyUtils.pm die folgende Funktion:<br><br>
|
||||
Und in der myUtils.pm (basierend auf der myUtilsTemplate.pm) die folgende Funktion:<br><br>
|
||||
<ul><code>
|
||||
sub startNetRadio<br>
|
||||
{<br>
|
||||
fhem "set AV_Receiver on";<br>
|
||||
sleep 5;<br>
|
||||
fhem "set AV_Receiver input netradio";<br>
|
||||
sleep 4;<br>
|
||||
fhem "set AV_Receiver remoteControl enter";<br>
|
||||
sleep 2;<br>
|
||||
fhem "set AV_Receiver remoteControl enter";<br>
|
||||
}
|
||||
sub startNetRadio()<br>
|
||||
{<br>
|
||||
fhem("set AV_Receiver on;<br>
|
||||
sleep 5;<br>
|
||||
set AV_Receiver input netradio;<br>
|
||||
sleep 4;<br>
|
||||
set AV_Receiver remoteControl enter;<br>
|
||||
sleep 2;<br>
|
||||
set AV_Receiver remoteControl enter;<br>
|
||||
sleep 2;<br>
|
||||
set AV_Receiver remoteControl enter");<br>
|
||||
}<br>
|
||||
</code></ul><br><br>
|
||||
Die Kommandos der Fernbedienung müssen mit einem sleep pausiert werden, da der Receiver in der Zwischenzeit arbeitet und keine Befehle annimmt..<br><br>
|
||||
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.<br><br>
|
||||
|
||||
Nun kann man diese Funktion in der FHEM Kommandozeile oder in notify-Definitionen wie folgt verwenden.:<br><br>
|
||||
<ul><code>
|
||||
@ -1821,6 +1938,8 @@ sub YAMAHA_AVR_html2txt($)
|
||||
<li><b>currentArtist</b> - Interpret des aktuell gespielten Titel</li>
|
||||
<li><b>currentTitle</b> - Name des aktuell gespielten Titel</li>
|
||||
<li><b>playStatus</b> - Wiedergabestatus des Eingangs</li>
|
||||
<li><b>shuffle</b> - Status der Zufallswiedergabe des aktuellen Eingangs</li>
|
||||
<li><b>repeat</b> - Status der Titelwiederholung des aktuellen Eingangs</li>
|
||||
</ul>
|
||||
<br>
|
||||
<b>Hinweise des Autors</b>
|
||||
|
Loading…
Reference in New Issue
Block a user