mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 18:59:33 +00:00
70_PIONEERAVR: minor fixes
git-svn-id: https://svn.fhem.de/fhem/trunk@14580 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
ea3f29d85a
commit
abb5d42713
@ -178,8 +178,6 @@ sub PIONEERAVR_Define($$) {
|
||||
DevIo_CloseDev( $hash);
|
||||
delete $hash->{NEXT_OPEN} if ( defined( $hash->{NEXT_OPEN} ) );
|
||||
|
||||
$hash->{TIMEOUT} = AttrVal( $name, "timeout", "3" );
|
||||
|
||||
# set default attributes
|
||||
if ( $init_done && !defined( $hash->{OLDDEF} ) ) {
|
||||
fhem 'attr ' . $name . ' stateFormat stateAV';
|
||||
@ -1259,7 +1257,7 @@ sub PIONEERAVR_Define($$) {
|
||||
"17"=>"screenLineHasFocus",
|
||||
"18"=>"screenLineNumberFirst",
|
||||
"19"=>"screenLineNumberLast",
|
||||
"20"=>"screenLineNumberTotal",
|
||||
"20"=>"screenLineNumbersTotal",
|
||||
"21"=>"screenLineNumbers",
|
||||
"22"=>"screenType",
|
||||
"23"=>"screenName",
|
||||
@ -1314,7 +1312,7 @@ PIONEERAVR_Ready($)
|
||||
my ( $hash) = @_;
|
||||
my $name = $hash->{NAME};
|
||||
|
||||
Log3 $name, 5, "PIONEERAVR $name: PIONEERAVR_Ready() called at state: ".$hash->{STATE};
|
||||
Log3 $name, 5, "PIONEERAVR $name: PIONEERAVR_Ready() called at state: ".$hash->{STATE}." reading state:".ReadingsVal( $name, "state", "disconnected" );
|
||||
|
||||
if ( ReadingsVal( $name, "state", "disconnected" ) eq "disconnected" ) {
|
||||
|
||||
@ -1373,7 +1371,6 @@ sub PIONEERAVR_Notify($$) {
|
||||
DoTrigger( $name, "DISCONNECTED" );
|
||||
}
|
||||
}
|
||||
|
||||
# unknown event
|
||||
else {
|
||||
Log3 $hash, 5,
|
||||
@ -1495,16 +1492,50 @@ PIONEERAVR_Clear($)
|
||||
sub
|
||||
PIONEERAVR_Set($@)
|
||||
{
|
||||
my ( $hash, $a, $h) = @_;
|
||||
my ($hash, $a, $h) = @_;
|
||||
my $name = $hash->{NAME};
|
||||
my $cmd = @$a[1];
|
||||
my $arg = (@$a[2] ? @$a[2] : "");
|
||||
my $presence = ReadingsVal( $name, "presence", "absent" );
|
||||
my @args = @$a; shift @args; shift @args;
|
||||
my @setsPlayer = ("play","pause","stop","repeat","shuffle","prev","next","rev","fwd","up","down","right","left","enter","return","menu"); # available commands for certain inputs (@playerInputNr)
|
||||
my @setsPlayer = ("play",
|
||||
"pause",
|
||||
"stop",
|
||||
"repeat",
|
||||
"shuffle",
|
||||
"prev",
|
||||
"next",
|
||||
"rev",
|
||||
"fwd",
|
||||
"up",
|
||||
"down",
|
||||
"right",
|
||||
"left",
|
||||
"enter",
|
||||
"return",
|
||||
"menu"); # available commands for certain inputs (@playerInputNr)
|
||||
my @playerInputNr = ("13","17","18","26","27","33","38","41","44","45","48","53"); # Input number for usbDac, ipodUsb, xmRadio, homeMediaGallery, sirius, adapterPort, internetRadio, pandora, mediaServer, Favorites, mhl, spotify
|
||||
my @setsTuner = ("channelUp","channelDown","channelStraight","channel"); # available commands for input tuner
|
||||
my @setsWithoutArg = ("off","toggle","volumeUp","volumeDown","muteOn","muteOff","muteToggle","inputUp","inputDown","selectLine01","selectLine02","selectLine03","selectLine04","selectLine05","selectLine06","selectLine07","selectLine08" ); # set commands without arguments
|
||||
my @setsTuner = ("channelUp",
|
||||
"channelDown",
|
||||
"channelStraight",
|
||||
"channel"); # available commands for input tuner
|
||||
my @setsWithoutArg = ("off",
|
||||
"toggle",
|
||||
"volumeUp",
|
||||
"volumeDown",
|
||||
"muteOn",
|
||||
"muteOff",
|
||||
"muteToggle",
|
||||
"inputUp",
|
||||
"inputDown",
|
||||
"selectLine01",
|
||||
"selectLine02",
|
||||
"selectLine03",
|
||||
"selectLine04",
|
||||
"selectLine05",
|
||||
"selectLine06",
|
||||
"selectLine07",
|
||||
"selectLine08" ); # set commands without arguments
|
||||
my $playerCmd = "";
|
||||
my $inputNr = "";
|
||||
|
||||
@ -1516,6 +1547,7 @@ PIONEERAVR_Set($@)
|
||||
if ( $presence eq "absent"
|
||||
&& lc( $cmd ) ne "on"
|
||||
&& lc( $cmd ) ne "?"
|
||||
&& lc( $cmd ) ne "reopen"
|
||||
&& lc( $cmd ) ne "help" );
|
||||
|
||||
# get all input names (preferable the aliasName) of the enabled inputs for the drop down list of "set <device> input xxx"
|
||||
@ -1531,15 +1563,17 @@ PIONEERAVR_Set($@)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
my $inputsList=join(':', sort @listInputNames);
|
||||
readingsSingleUpdate( $hash, "inputsList", $inputsList, 0 );
|
||||
|
||||
my $list = "reopen:noArg on:noArg off:noArg toggle:noArg input:"
|
||||
. join(',', sort @listInputNames)
|
||||
. " hdmiOut:"
|
||||
. join(',', sort values (%{$hash->{helper}{HDMIOUT}}))
|
||||
. " inputUp:noArg inputDown:noArg"
|
||||
. " channelUp:noArg channelDown:noArg channelStraight"
|
||||
# . join(',', sort values ( $hash->{helper}{TUNERCHANNELNAMES}))
|
||||
# . join(',', sort values ( $hash->{helper}{TUNERCHANNELNAMES}))
|
||||
. " channel:1,2,3,4,5,6,7,8,9"
|
||||
. " listeningMode:"
|
||||
. join(',', sort values (%{$hash->{helper}{LISTENINGMODES}}))
|
||||
@ -1565,7 +1599,9 @@ PIONEERAVR_Set($@)
|
||||
$list .= " right:noArg left:noArg enter:noArg return:noArg menu:noArg";
|
||||
$list .= " selectLine01:noArg selectLine02:noArg selectLine03:noArg selectLine04:noArg selectLine05:noArg selectLine06:noArg selectLine07:noArg selectLine08:noArg";
|
||||
}
|
||||
|
||||
$list .= " networkStandby:on,off";
|
||||
|
||||
if ( $cmd eq "?" ) {
|
||||
return SetExtensions( $hash, $list, $name, $cmd, @args);
|
||||
|
||||
@ -1596,8 +1632,9 @@ PIONEERAVR_Set($@)
|
||||
PIONEERAVR_Write( $hash, $setCmd);
|
||||
select(undef, undef, undef, 0.2);
|
||||
PIONEERAVR_Write( $hash, $setCmd);
|
||||
|
||||
if (ReadingsVal($name,"networkStandby","") eq "off") {
|
||||
return "NetworkStandby for the Pioneer AV receiver is off. If Fhem should be able to turn the AV Receiver on from standby enable networkStandby on the Pioneer AV Receiver!";
|
||||
return "NetworkStandby for the Pioneer AV receiver is off. If Fhem should be able to turn the AV Receiver on from standby enable networkStandby on the Pioneer AV Receiver (e.g. set $name networkStandby on )!";
|
||||
} else {
|
||||
return undef;
|
||||
}
|
||||
@ -1615,6 +1652,7 @@ PIONEERAVR_Set($@)
|
||||
Log3 $name, 5, "PIONEERAVR $name: Set $cmd ";
|
||||
PIONEERAVR_statusUpdate( $hash);
|
||||
return undef;
|
||||
|
||||
#### play, pause, stop, random, repeat,prev,next,rev,fwd,up,down,right,left,enter,return,menu
|
||||
#### Only available if the input is one of:
|
||||
#### ipod, internetRadio, mediaServer, favorites, adapterPort, mhl
|
||||
@ -1671,9 +1709,9 @@ PIONEERAVR_Set($@)
|
||||
Log3 $name, 5, "PIONEERAVR $name: set $cmd ".dq($arg);
|
||||
foreach my $key ( keys %{$hash->{helper}{INPUTNAMES}} ) {
|
||||
if ( $hash->{helper}{INPUTNAMES}->{$key}{aliasName} eq $arg ) {
|
||||
PIONEERAVR_Write( $hash, sprintf "%02dFN", $key);
|
||||
PIONEERAVR_Write( $hash, sprintf "%02dFN", $key );
|
||||
} elsif ( $hash->{helper}{INPUTNAMES}->{$key}{name} eq $arg ) {
|
||||
PIONEERAVR_Write( $hash, sprintf "%02dFN", $key);
|
||||
PIONEERAVR_Write( $hash, sprintf "%02dFN", $key );
|
||||
}
|
||||
}
|
||||
return undef;
|
||||
@ -1858,23 +1896,21 @@ PIONEERAVR_Set($@)
|
||||
} elsif ( $cmd eq "eq" ) {
|
||||
if ($arg eq "on") {
|
||||
PIONEERAVR_Write( $hash, "1ATC");
|
||||
# readingsSingleUpdate( $hash, "eq", "on", 1 );
|
||||
}
|
||||
elsif ($arg eq "off") {
|
||||
PIONEERAVR_Write( $hash, "0ATC");
|
||||
# readingsSingleUpdate( $hash, "eq", "off", 1 );
|
||||
} else {
|
||||
my $err= "PIONEERAVR $name: Error: unknown set ... eq argument: $arg !";
|
||||
Log3 $name, 3, $err;
|
||||
return $err;
|
||||
}
|
||||
|
||||
# standingWave on/off/toggle
|
||||
} elsif ( $cmd eq "standingWave" ) {
|
||||
if ($arg eq "on") {
|
||||
PIONEERAVR_Write( $hash, "1ATD");
|
||||
}
|
||||
elsif ($arg eq "off") {
|
||||
PIONEERAVR_Write( $hash, "0ATD");
|
||||
if ( $arg eq "on" ) {
|
||||
PIONEERAVR_Write( $hash, "1ATD" );
|
||||
} elsif ( $arg eq "off" ) {
|
||||
PIONEERAVR_Write( $hash, "0ATD" );
|
||||
} else {
|
||||
my $err= "PIONEERAVR $name: Error: unknown set ... standingWave argument: $arg !";
|
||||
Log3 $name, 3, $err;
|
||||
@ -1884,11 +1920,11 @@ PIONEERAVR_Set($@)
|
||||
# Network standby (on|off)
|
||||
# needs to be "on" to turn on the Pioneer AVR via this module
|
||||
} elsif ( $cmd eq "networkStandby" ) {
|
||||
if ($arg eq "on") {
|
||||
if ( $arg eq "on" ) {
|
||||
PIONEERAVR_Write( $hash, "1STJ");
|
||||
}
|
||||
elsif ($arg eq "off") {
|
||||
PIONEERAVR_Write( $hash, "0STJ");
|
||||
elsif ( $arg eq "off" ) {
|
||||
PIONEERAVR_Write( $hash, "0STJ" );
|
||||
} else {
|
||||
my $err= "PIONEERAVR $name: Error: unknown set ... networkStandby argument: $arg !";
|
||||
Log3 $name, 3, $err;
|
||||
@ -1922,7 +1958,7 @@ sub PIONEERAVR_Get($$$) {
|
||||
my $cmd = @$a[1];
|
||||
my $presence = ReadingsVal( $name, "presence", "absent" );
|
||||
|
||||
Log3 $name, 5, "ONKYO_AVR $name: called function PIONEERAVR_AVR_Get()";
|
||||
Log3 $name, 5, "PIONEERAVR $name: called function PIONEERAVR_AVR_Get()";
|
||||
|
||||
return "get $name needs at least one parameter" if ( int(@$a) < 1 );
|
||||
|
||||
@ -2946,7 +2982,7 @@ sub PIONEERAVR_Reopen($) {
|
||||
}
|
||||
#####################################
|
||||
# writing to the Pioneer AV receiver
|
||||
# connection check 13s after writing
|
||||
# connection check 3s (or attr timout seconds) after writing
|
||||
sub PIONEERAVR_Write($$) {
|
||||
my ( $hash, $msg ) = @_;
|
||||
my $name = $hash->{NAME};
|
||||
@ -2958,7 +2994,7 @@ sub PIONEERAVR_Write($$) {
|
||||
DevIo_SimpleWrite( $hash, $msg, 0 );
|
||||
|
||||
# do connection check latest after TIMEOUT
|
||||
my $next = gettimeofday() + $hash->{TIMEOUT};
|
||||
my $next = gettimeofday() + AttrVal( $name, "timeout", "3" );
|
||||
if ( !defined( $hash->{helper}{nextConnectionCheck} )
|
||||
|| $hash->{helper}{nextConnectionCheck} > $next )
|
||||
{
|
||||
@ -2995,7 +3031,7 @@ sub PIONEERAVR_connectionCheck ($) {
|
||||
my $connState =
|
||||
DevIo_Expect( $hash,
|
||||
"\r\n",
|
||||
$hash->{TIMEOUT} );
|
||||
AttrVal( $name, "timeout", "3" ) );
|
||||
|
||||
# successful connection
|
||||
if ( defined($connState) ) {
|
||||
@ -3007,14 +3043,14 @@ sub PIONEERAVR_connectionCheck ($) {
|
||||
$hash->{helper}{nextConnectionCheck} = $next;
|
||||
InternalTimer( $next, "PIONEERAVR_connectionCheck", $hash, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
if ($connState =~ m/^R\r?\n?$/) {
|
||||
Log3 $name, 5, "PIONEERAVR $name: PIONEERAVR_checkConnection() --- connstate=R -> do nothing: ".dq($connState)." PARTIAL: ".dq( $hash->{PARTIAL});
|
||||
} else {
|
||||
$hash->{PARTIAL} .= $connState;
|
||||
Log3 $name, 5, "PIONEERAVR $name: PIONEERAVR_checkConnection() --- connstate<>R -> do nothing: ".dq($connState)." PARTIAL: ".dq( $hash->{PARTIAL});
|
||||
}
|
||||
|
||||
}
|
||||
$attr{$name}{verbose} = $verbose if ( $verbose ne "" );
|
||||
delete $attr{$name}{verbose} if ( $verbose eq "" );
|
||||
}
|
||||
@ -3041,33 +3077,40 @@ sub PIONEERAVR_askForInputNames($$) {
|
||||
my $name = $hash->{NAME};
|
||||
my $comstr = '';
|
||||
my $now120 = gettimeofday()+120;
|
||||
my $delay = 0.1;
|
||||
|
||||
RemoveInternalTimer( $hash);
|
||||
InternalTimer($now120, "PIONEERAVR_checkConnection", $hash, 0);
|
||||
|
||||
# we ask for the inputs 1 to 59 if an input name exists (command: ?RGB00 ... ?RGB59)
|
||||
# and if the input is disabled (command: ?SSC0003 ... ?SSC5903)
|
||||
# at least the model VSX-923 needs a break of 0.1s between each command, otherwise it closes the tcp port
|
||||
for ( my $i=0; $i<60; $i++ ) {
|
||||
select( undef, undef, undef, 0.1 );
|
||||
#select( undef, undef, undef, 0.1 );
|
||||
$comstr = sprintf '?RGB%02d', $i;
|
||||
PIONEERAVR_Write( $hash,$comstr );
|
||||
select( undef, undef, undef, 0.1 );
|
||||
select( undef, undef, undef, $delay );
|
||||
|
||||
#digital(audio) input terminal (coax, optical, analog)
|
||||
$comstr = sprintf '?SSC%02d00',$i;
|
||||
PIONEERAVR_Write( $hash,$comstr );
|
||||
select( undef, undef, undef, 0.1 );
|
||||
select( undef, undef, undef, $delay );
|
||||
|
||||
#hdmi input terminal?
|
||||
$comstr = sprintf '?SSC%02d01',$i;
|
||||
PIONEERAVR_Write( $hash,$comstr );
|
||||
select( undef, undef, undef, 0.1 );
|
||||
select( undef, undef, undef, $delay );
|
||||
|
||||
#component video input terminal ?
|
||||
$comstr = sprintf '?SSC%02d02',$i;
|
||||
PIONEERAVR_Write( $hash,$comstr );
|
||||
select( undef, undef, undef, 0.1 );
|
||||
select( undef, undef, undef, $delay );
|
||||
|
||||
#input enabled/disabled?
|
||||
$comstr = sprintf '?SSC%02d03',$i;
|
||||
PIONEERAVR_Write( $hash,$comstr );
|
||||
select( undef, undef, undef, 0.1 );
|
||||
select( undef, undef, undef, $delay );
|
||||
|
||||
#inputLevelAdjust (-12dB ... +12dB)
|
||||
$comstr = sprintf '?ILA%02d',$i;
|
||||
PIONEERAVR_Write( $hash,$comstr );
|
||||
@ -3077,6 +3120,7 @@ sub PIONEERAVR_askForInputNames($$) {
|
||||
sub PIONEERAVR_GetStateAV($) {
|
||||
my ($hash) = @_;
|
||||
my $name = $hash->{NAME};
|
||||
my $iNr = ReadingsVal( $name, "inputNr", "1" );
|
||||
|
||||
if ( ReadingsVal( $name, "presence", "absent" ) eq "absent" ) {
|
||||
return "absent";
|
||||
@ -3084,7 +3128,7 @@ sub PIONEERAVR_GetStateAV($) {
|
||||
return "off";
|
||||
} elsif ( ReadingsVal( $name, "mute", "off" ) eq "on" ) {
|
||||
return "muted";
|
||||
} elsif ( $hash->{helper}{INPUTNAMES}{ReadingsVal( $name, "inputNr", "1" )}{playerCommands} eq "1"
|
||||
} elsif ( $hash->{helper}{INPUTNAMES}->{$iNr}{playerCommands} eq "1"
|
||||
&& ReadingsVal( $name, "playStatus", "stopped" ) ne "stopped" )
|
||||
{
|
||||
return ReadingsVal( $name, "playStatus", "stopped" );
|
||||
@ -3369,7 +3413,7 @@ sub RC_layout_PioneerAVR() {
|
||||
<li><b>screenLineHasFocus</b> - Which line of the OSD has the focus?</li>
|
||||
<li><b>screenLineNumberFirst</b> - Long lists are shown in the OSD in smaller pages with 8 lines. This shows which elemnt of the lang list is the currently shown first line.</li>
|
||||
<li><b>screenLineNumberLast</b> - Long lists are shown in the OSD in smaller pages with 8 lines. This shows which elemnt of the lang list is the currently shown last line.</li>
|
||||
<li><b>screenLineNumberTotal</b> - How many lines has the full list</li>
|
||||
<li><b>screenLineNumbersTotal</b> - How many lines has the full list</li>
|
||||
<li><b>screenLineNumbers</b> - How many lines has the OSD</li>
|
||||
<li><b>screenLineType01...08</b> - Which type has line 01...08? E.g. "directory", "Now playing", "current Artist",...</li>
|
||||
<li><b>screenName</b> - Name of the OSD</li>
|
||||
@ -3379,7 +3423,12 @@ sub RC_layout_PioneerAVR() {
|
||||
<li><b>speakerSystem</b> - Shows how the rear surround speaker connectors and the B-speaker connectors are used</li>
|
||||
<li><b>speakers</b> - Which speaker output connectors are active?</li>
|
||||
<li><b>standingWave</b> - Standing wave</li>
|
||||
<li><b>state</b> - Is set while connecting from fhem to the Pioneer AV Receiver (disconnected|innitialized|off|on|opened)</li>
|
||||
<li>
|
||||
<b>state</b> - Is set while connecting from fhem to the Pioneer AV Receiver (disconnected|innitialized|off|on|opened)
|
||||
</li>
|
||||
<li>
|
||||
<b>stateAV</b> - Status from user perspective combining readings presence, power, mute and playStatus to a useful overall status (on|off|absent|stopped|playing|paused|fast-forward|fast-rewind).
|
||||
</li>
|
||||
<li><b>tone</b> - Is the tone control turned on?</li>
|
||||
<li><b>treble</b> - Current value of treble</li>
|
||||
<li><b>tunerFrequency</b> - Tuner frequency</li>
|
||||
@ -3642,7 +3691,7 @@ sub RC_layout_PioneerAVR() {
|
||||
<li><b>screenLineHasFocus</b> - Welche Zeile des OSD hat den Fokus?</li>
|
||||
<li><b>screenLineNumberFirst</b> - Lange Listen werden im OSD zu einzelnen Seiten mit je 8 Zeilen angezeigt. Die oberste Zeile im OSD repräsentiert welche Zeile in der gesamten Liste?</li>
|
||||
<li><b>screenLineNumberLast</b> - Lange Listen werden im OSD zu einzelnen Seiten mit je 8 Zeilen angezeigt. Die unterste Zeile im OSD repräsentiert welche Zeile in der gesamten Liste?</li>
|
||||
<li><b>screenLineNumberTotal</b> - Wie viele Zeilen hat die im OSD anzuzeigende Liste insgesamt?</li>
|
||||
<li><b>screenLineNumbersTotal</b> - Wie viele Zeilen hat die im OSD anzuzeigende Liste insgesamt?</li>
|
||||
<li><b>screenLineNumbers</b> - Wie viele Zeilen hat das OSD</li>
|
||||
<li><b>screenLineType01...08</b> - Welchen Typs ist die Zeile 01...08? Z.B. "directory", "Now playing", "current Artist",...</li>
|
||||
<li><b>screenName</b> - Name des OSD</li>
|
||||
@ -3652,7 +3701,12 @@ sub RC_layout_PioneerAVR() {
|
||||
<li><b>speakerSystem</b> - Zeigt, wie die hinteren Surround-Lautsprecheranschlüsse und die B-Lautsprecheranschlüsse verwendet werden</li>
|
||||
<li><b>speakers</b> - Welche Lautsprecheranschlüsse sind aktiviert?</li>
|
||||
<li><b>standingWave</b> - Einstellung der Steuerung stark resonanter tiefer Frequenzen im Hörraum</li>
|
||||
<li><b>state</b> - Wird beim Verbindungsaufbau von Fhem mit dem Pioneer AV Receiver gesetzt. Mögliche Werte sind disconnected, innitialized, off, on, opened</li>
|
||||
<li>
|
||||
<b>state</b> - Wird beim Verbindungsaufbau von Fhem mit dem Pioneer AV Receiver gesetzt. Mögliche Werte sind disconnected, innitialized, off, on, opened
|
||||
</li>
|
||||
<li>
|
||||
<b>stateAV</b> - Status aus der Sicht des USers: Kombiniert die readings presence, power, mute und playStatus zu einem Status (on|off|absent|stopped|playing|paused|fast-forward|fast-rewind).
|
||||
</li>
|
||||
<li><b>tone</b> - Ist die Klangsteuerung eingeschalten?</li>
|
||||
<li><b>treble</b> - Einstellung des Höhenreglers</li>
|
||||
<li><b>tunerFrequency</b> - Tunerfrequenz</li>
|
||||
|
Loading…
Reference in New Issue
Block a user