ONKYO_AVR: implicit toggle for mute command + improved errorhandling
git-svn-id: https://svn.fhem.de/fhem/trunk@4453 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
@@ -210,14 +210,16 @@ sub ONKYO_AVR_GetStatus($;$) {
|
|||||||
if ( defined( $attr{$name}{inputs} ) ) {
|
if ( defined( $attr{$name}{inputs} ) ) {
|
||||||
my @inputs = split( ':', $attr{$name}{inputs} );
|
my @inputs = split( ':', $attr{$name}{inputs} );
|
||||||
|
|
||||||
|
if ( ref(@inputs) eq "ARRAY" ) {
|
||||||
foreach (@inputs) {
|
foreach (@inputs) {
|
||||||
if (m/[^,\s]+(,[^,\s]+)+/) {
|
if (m/[^,\s]+(,[^,\s]+)+/) {
|
||||||
my @input_names = split( ',', $_ );
|
my @input_names = split( ',', $_ );
|
||||||
$input_names[1] =~ s/\s/_/g;
|
$input_names[1] =~ s/\s/_/g;
|
||||||
$hash->{helper}{receiver}{input_aliases}{ $input_names[0] }
|
$hash->{helper}{receiver}{input_aliases}
|
||||||
= $input_names[1];
|
{ $input_names[0] } = $input_names[1];
|
||||||
$hash->{helper}{receiver}{input_names}{ $input_names[1] } =
|
$hash->{helper}{receiver}{input_names}
|
||||||
$input_names[0];
|
{ $input_names[1] } = $input_names[0];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -776,25 +778,25 @@ sub ONKYO_AVR_Set($@) {
|
|||||||
|
|
||||||
# mute
|
# mute
|
||||||
elsif ( $a[1] eq "mute" ) {
|
elsif ( $a[1] eq "mute" ) {
|
||||||
if ( !defined( $a[2] ) ) {
|
if ( defined( $a[2] ) ) {
|
||||||
$return = "No argument given, choose one of on off toggle";
|
Log3 $name, 2, "ONKYO_AVR set $name " . $a[1] . " " . $a[2];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Log3 $name, 2, "ONKYO_AVR set $name " . $a[1] . " " . $a[2];
|
Log3 $name, 2, "ONKYO_AVR set $name " . $a[1];
|
||||||
|
}
|
||||||
|
|
||||||
if ( $hash->{READINGS}{state}{VAL} eq "on" ) {
|
if ( $hash->{READINGS}{state}{VAL} eq "on" ) {
|
||||||
if ( $a[2] eq "off" ) {
|
if ( !defined( $a[2] ) || $a[2] eq "toggle" ) {
|
||||||
|
$result = ONKYO_AVR_SendCommand( $hash, "mute", "toggle" );
|
||||||
|
}
|
||||||
|
elsif ( $a[2] eq "off" ) {
|
||||||
$result = ONKYO_AVR_SendCommand( $hash, "mute", "off" );
|
$result = ONKYO_AVR_SendCommand( $hash, "mute", "off" );
|
||||||
}
|
}
|
||||||
elsif ( $a[2] eq "on" ) {
|
elsif ( $a[2] eq "on" ) {
|
||||||
$result = ONKYO_AVR_SendCommand( $hash, "mute", "on" );
|
$result = ONKYO_AVR_SendCommand( $hash, "mute", "on" );
|
||||||
}
|
}
|
||||||
elsif ( $a[2] eq "toggle" ) {
|
|
||||||
$result = ONKYO_AVR_SendCommand( $hash, "mute", "toggle" );
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
$return =
|
$return = "Argument does not seem to be one of on off toogle";
|
||||||
"Argument does not seem to be one of on off toogle";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( defined($result) ) {
|
if ( defined($result) ) {
|
||||||
@@ -809,7 +811,6 @@ sub ONKYO_AVR_Set($@) {
|
|||||||
$return = "Device needs to be ON to mute/unmute audio.";
|
$return = "Device needs to be ON to mute/unmute audio.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
# volume
|
# volume
|
||||||
elsif ( $a[1] eq "volume" ) {
|
elsif ( $a[1] eq "volume" ) {
|
||||||
@@ -832,6 +833,13 @@ sub ONKYO_AVR_Set($@) {
|
|||||||
{
|
{
|
||||||
readingsSingleUpdate( $hash, "volume", $result, 1 );
|
readingsSingleUpdate( $hash, "volume", $result, 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( !defined( $hash->{READINGS}{mute}{VAL} )
|
||||||
|
|| $hash->{READINGS}{mute}{VAL} eq "on" )
|
||||||
|
{
|
||||||
|
readingsSingleUpdate( $hash, "mute", "off", 1 )
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -911,7 +919,8 @@ sub ONKYO_AVR_Set($@) {
|
|||||||
if ( !defined( $a[2] ) || $a[2] eq "help" ) {
|
if ( !defined( $a[2] ) || $a[2] eq "help" ) {
|
||||||
|
|
||||||
# Get all commands for zone
|
# Get all commands for zone
|
||||||
my $commands_details = ONKYOdb::ONKYO_GetRemotecontrolCommandDetails($zone);
|
my $commands_details =
|
||||||
|
ONKYOdb::ONKYO_GetRemotecontrolCommandDetails($zone);
|
||||||
|
|
||||||
my $valid_commands =
|
my $valid_commands =
|
||||||
"Usage: <command> <value>\n\nValid commands in zone '$zone':\n\n\n"
|
"Usage: <command> <value>\n\nValid commands in zone '$zone':\n\n\n"
|
||||||
@@ -950,7 +959,8 @@ sub ONKYO_AVR_Set($@) {
|
|||||||
|
|
||||||
# Reading values for command from HASH table
|
# Reading values for command from HASH table
|
||||||
my $values =
|
my $values =
|
||||||
ONKYOdb::ONKYO_GetRemotecontrolValue( $zone, $commands->{ $a[2] } );
|
ONKYOdb::ONKYO_GetRemotecontrolValue( $zone,
|
||||||
|
$commands->{ $a[2] } );
|
||||||
|
|
||||||
# Output help for values
|
# Output help for values
|
||||||
if ( !defined( $a[3] ) || $a[3] eq "help" ) {
|
if ( !defined( $a[3] ) || $a[3] eq "help" ) {
|
||||||
@@ -1163,7 +1173,8 @@ sub ONKYO_AVR_SendCommand($$$) {
|
|||||||
|
|
||||||
# Resolve command and value to ISCP raw command
|
# Resolve command and value to ISCP raw command
|
||||||
my $cmd_raw = ONKYOdb::ONKYO_GetRemotecontrolCommand( $zone, $cmd );
|
my $cmd_raw = ONKYOdb::ONKYO_GetRemotecontrolCommand( $zone, $cmd );
|
||||||
my $value_raw = ONKYOdb::ONKYO_GetRemotecontrolValue( $zone, $cmd_raw, $value );
|
my $value_raw =
|
||||||
|
ONKYOdb::ONKYO_GetRemotecontrolValue( $zone, $cmd_raw, $value );
|
||||||
my $request_code = substr( $cmd_raw, 0, 3 );
|
my $request_code = substr( $cmd_raw, 0, 3 );
|
||||||
|
|
||||||
if ( !defined($cmd_raw) ) {
|
if ( !defined($cmd_raw) ) {
|
||||||
@@ -1212,7 +1223,9 @@ sub ONKYO_AVR_SendCommand($$$) {
|
|||||||
$line = ONKYO_AVR_read( $hash, \$buf );
|
$line = ONKYO_AVR_read( $hash, \$buf );
|
||||||
$response_code = substr( $line, 0, 3 ) if defined($line);
|
$response_code = substr( $line, 0, 3 ) if defined($line);
|
||||||
|
|
||||||
if ( defined($response_code) && $response_code eq $request_code ) {
|
if ( defined($response_code)
|
||||||
|
&& $response_code eq $request_code )
|
||||||
|
{
|
||||||
$response->{$response_code} = $line;
|
$response->{$response_code} = $line;
|
||||||
$readon = 0;
|
$readon = 0;
|
||||||
}
|
}
|
||||||
@@ -1254,7 +1267,8 @@ sub ONKYO_AVR_SendCommand($$$) {
|
|||||||
# Decode return value
|
# Decode return value
|
||||||
#
|
#
|
||||||
my $values =
|
my $values =
|
||||||
ONKYOdb::ONKYO_GetRemotecontrolCommandDetails( $zone, $request_code );
|
ONKYOdb::ONKYO_GetRemotecontrolCommandDetails( $zone,
|
||||||
|
$request_code );
|
||||||
|
|
||||||
# Decode through device information
|
# Decode through device information
|
||||||
if ( $cmd eq "input"
|
if ( $cmd eq "input"
|
||||||
|
|||||||
Reference in New Issue
Block a user