2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-19 00:26:03 +00:00

70_ONKYO_AVR,71_ONKYO_AVR_ZONE,ONKYOdb: fix wrong hash<>IOhash assignment

git-svn-id: https://svn.fhem.de/fhem/trunk@11629 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
jpawlowski 2016-06-07 12:25:04 +00:00
parent 095c25bbac
commit 828ba4a87a
3 changed files with 123 additions and 170 deletions

View File

@ -1952,18 +1952,16 @@ sub ONKYO_AVR_Set($$$) {
# channel # channel
if ( lc( @$a[1] ) eq "channel" ) { if ( lc( @$a[1] ) eq "channel" ) {
Log3 $name, 3, "ONKYO_AVR set $name " . @$a[1] . " " . @$a[2];
if ( !defined( @$a[2] ) ) { if ( !defined( @$a[2] ) ) {
$return = "Syntax: CHANNELNAME [USERNAME PASSWORD]"; $return = "Syntax: CHANNELNAME [USERNAME PASSWORD]";
} }
else { else {
if ( $state eq "off" ) { if ( $state eq "off" ) {
$return = fhem "get $name remoteControl power on quiet"; $return = ONKYO_AVR_SendCommand( $hash, "power", "on" );
$return .= fhem "sleep 5;set $name channel " . @$a[2]; $return .= fhem "sleep 5;set $name channel " . @$a[2];
} }
elsif ( $hash->{INPUT} ne "2B" ) { elsif ( $hash->{INPUT} ne "2B" ) {
$return = fhem "get $name remoteControl input 2B quiet"; $return = ONKYO_AVR_SendCommand( $hash, "input", "2B" );
$return .= fhem "sleep 1;set $name channel " . @$a[2]; $return .= fhem "sleep 1;set $name channel " . @$a[2];
} }
elsif ( elsif (
@ -2006,46 +2004,46 @@ sub ONKYO_AVR_Set($$$) {
} }
} }
$return = "Unknown network service name " . @$a[2]
if ( $servicename eq "" );
Log3 $name, 3, "ONKYO_AVR set $name " . @$a[1] . " " . @$a[2];
$return = $return =
ONKYO_AVR_SendCommand( $hash, "net-service", $servicename ) ONKYO_AVR_SendCommand( $hash, "net-service", $servicename )
if ( $servicename ne "" ); if ( $servicename ne "" );
$return = "Unknown network service name " . @$a[2]
if ( $servicename eq "" );
} }
} }
} }
# channelDown # channelDown
elsif ( lc( @$a[1] ) eq "channeldown" ) { elsif ( lc( @$a[1] ) eq "channeldown" ) {
Log3 $name, 3, "ONKYO_AVR set $name " . @$a[1];
if ( $state eq "off" ) { if ( $state eq "off" ) {
$return = fhem "get $name remoteControl power on quiet"; $return = ONKYO_AVR_SendCommand( $hash, "power", "on" );
$return .= fhem "sleep 5;set $name channelDown"; $return .= fhem "sleep 5;set $name channelDown";
} }
elsif ( $hash->{INPUT} ne "2B" ) { elsif ( $hash->{INPUT} ne "2B" ) {
$return = fhem "get $name remoteControl input 2B quiet"; $return = ONKYO_AVR_SendCommand( $hash, "input", "2B" );
$return .= fhem "sleep 1;set $name channelDown"; $return .= fhem "sleep 1;set $name channelDown";
} }
else { else {
Log3 $name, 3, "ONKYO_AVR set $name " . @$a[1];
$return = ONKYO_AVR_SendCommand( $hash, "net-usb", "chdn" ); $return = ONKYO_AVR_SendCommand( $hash, "net-usb", "chdn" );
} }
} }
# channelUp # channelUp
elsif ( lc( @$a[1] ) eq "channelup" ) { elsif ( lc( @$a[1] ) eq "channelup" ) {
Log3 $name, 3, "ONKYO_AVR set $name " . @$a[1];
if ( $state eq "off" ) { if ( $state eq "off" ) {
$return = fhem "get $name remoteControl power on quiet"; $return = ONKYO_AVR_SendCommand( $hash, "power", "on" );
$return .= fhem "sleep 5;set $name channelUp"; $return .= fhem "sleep 5;set $name channelUp";
} }
elsif ( $hash->{INPUT} ne "2B" ) { elsif ( $hash->{INPUT} ne "2B" ) {
$return = fhem "get $name remoteControl input 2B quiet"; $return = ONKYO_AVR_SendCommand( $hash, "input", "2B" );
$return .= fhem "sleep 1;set $name channelUp"; $return .= fhem "sleep 1;set $name channelUp";
} }
else { else {
Log3 $name, 3, "ONKYO_AVR set $name " . @$a[1];
$return = ONKYO_AVR_SendCommand( $hash, "net-usb", "chup" ); $return = ONKYO_AVR_SendCommand( $hash, "net-usb", "chup" );
} }
} }
@ -2072,27 +2070,28 @@ sub ONKYO_AVR_Set($$$) {
# preset # preset
elsif ( lc( @$a[1] ) eq "preset" ) { elsif ( lc( @$a[1] ) eq "preset" ) {
Log3 $name, 3, "ONKYO_AVR set $name " . @$a[1] . " " . @$a[2];
if ( !defined( @$a[2] ) ) { if ( !defined( @$a[2] ) ) {
$return = "No argument given"; $return = "No argument given";
} }
else { else {
if ( $state eq "off" ) { if ( $state eq "off" ) {
$return = fhem "get $name remoteControl power on quiet quiet"; $return = ONKYO_AVR_SendCommand( $hash, "power", "on" );
$return .= fhem "sleep 5;set $name preset " . @$a[2]; $return .= fhem "sleep 5;set $name preset " . @$a[2];
} }
elsif ( $hash->{INPUT} ne "24" && $hash->{INPUT} ne "25" ) { elsif ( $hash->{INPUT} ne "24" && $hash->{INPUT} ne "25" ) {
$return = fhem "get $name remoteControl input 24 quiet"; $return = ONKYO_AVR_SendCommand( $hash, "input", "24" );
$return .= fhem "sleep 1;set $name preset " . @$a[2]; $return .= fhem "sleep 1;set $name preset " . @$a[2];
} }
elsif ( lc( @$a[2] ) eq "up" ) { elsif ( lc( @$a[2] ) eq "up" ) {
Log3 $name, 3, "ONKYO_AVR set $name " . @$a[1] . " " . @$a[2];
$return = ONKYO_AVR_SendCommand( $hash, lc( @$a[1] ), "UP" ); $return = ONKYO_AVR_SendCommand( $hash, lc( @$a[1] ), "UP" );
} }
elsif ( lc( @$a[2] ) eq "down" ) { elsif ( lc( @$a[2] ) eq "down" ) {
Log3 $name, 3, "ONKYO_AVR set $name " . @$a[1] . " " . @$a[2];
$return = ONKYO_AVR_SendCommand( $hash, lc( @$a[1] ), "DOWN" ); $return = ONKYO_AVR_SendCommand( $hash, lc( @$a[1] ), "DOWN" );
} }
elsif ( @$a[2] =~ /^\d*$/ ) { elsif ( @$a[2] =~ /^\d*$/ ) {
Log3 $name, 3, "ONKYO_AVR set $name " . @$a[1] . " " . @$a[2];
$return = ONKYO_AVR_SendCommand( $return = ONKYO_AVR_SendCommand(
$hash, $hash,
lc( @$a[1] ), lc( @$a[1] ),
@ -2111,6 +2110,9 @@ sub ONKYO_AVR_Set($$$) {
$presetName =~ s/\s/_/g; $presetName =~ s/\s/_/g;
if ( $presetName eq @$a[2] ) { if ( $presetName eq @$a[2] ) {
Log3 $name, 3,
"ONKYO_AVR set $name " . @$a[1] . " " . @$a[2];
$return = $return =
ONKYO_AVR_SendCommand( $hash, lc( @$a[1] ), uc($id) ); ONKYO_AVR_SendCommand( $hash, lc( @$a[1] ), uc($id) );
@ -2123,34 +2125,32 @@ sub ONKYO_AVR_Set($$$) {
# presetDown # presetDown
elsif ( lc( @$a[1] ) eq "presetdown" ) { elsif ( lc( @$a[1] ) eq "presetdown" ) {
Log3 $name, 3, "ONKYO_AVR set $name " . @$a[1];
if ( $state eq "off" ) { if ( $state eq "off" ) {
$return = fhem "get $name remoteControl power on quiet"; $return = ONKYO_AVR_SendCommand( $hash, "power", "on" );
$return .= fhem "sleep 5;set $name presetDown"; $return .= fhem "sleep 5;set $name presetDown";
} }
elsif ( $hash->{INPUT} ne "24" && $hash->{INPUT} ne "25" ) { elsif ( $hash->{INPUT} ne "24" && $hash->{INPUT} ne "25" ) {
$return = fhem "get $name remoteControl input 24 quiet"; $return = ONKYO_AVR_SendCommand( $hash, "input", "24" );
$return .= fhem "sleep 1;set $name presetDown"; $return .= fhem "sleep 1;set $name presetDown";
} }
else { else {
Log3 $name, 3, "ONKYO_AVR set $name " . @$a[1];
$return = ONKYO_AVR_SendCommand( $hash, "preset", "down" ); $return = ONKYO_AVR_SendCommand( $hash, "preset", "down" );
} }
} }
# presetUp # presetUp
elsif ( lc( @$a[1] ) eq "presetup" ) { elsif ( lc( @$a[1] ) eq "presetup" ) {
Log3 $name, 3, "ONKYO_AVR set $name " . @$a[1];
if ( $state eq "off" ) { if ( $state eq "off" ) {
$return = fhem "get $name remoteControl power on quiet"; $return = ONKYO_AVR_SendCommand( $hash, "power", "on" );
$return .= fhem "sleep 5;set $name presetUp"; $return .= fhem "sleep 5;set $name presetUp";
} }
elsif ( $hash->{INPUT} ne "24" && $hash->{INPUT} ne "25" ) { elsif ( $hash->{INPUT} ne "24" && $hash->{INPUT} ne "25" ) {
$return = fhem "get $name remoteControl input 24 quiet"; $return = ONKYO_AVR_SendCommand( $hash, "input", "24" );
$return .= fhem "sleep 1;set $name presetUp"; $return .= fhem "sleep 1;set $name presetUp";
} }
else { else {
Log3 $name, 3, "ONKYO_AVR set $name " . @$a[1];
$return = ONKYO_AVR_SendCommand( $hash, "preset", "up" ); $return = ONKYO_AVR_SendCommand( $hash, "preset", "up" );
} }
} }
@ -2241,8 +2241,6 @@ sub ONKYO_AVR_Set($$$) {
# toggle # toggle
elsif ( lc( @$a[1] ) eq "toggle" ) { elsif ( lc( @$a[1] ) eq "toggle" ) {
Log3 $name, 3, "ONKYO_AVR set $name " . @$a[1];
if ( $state eq "off" ) { if ( $state eq "off" ) {
$return = fhem "set $name on"; $return = fhem "set $name on";
} }
@ -2558,13 +2556,12 @@ sub ONKYO_AVR_Set($$$) {
$return = "No input given"; $return = "No input given";
} }
else { else {
Log3 $name, 3, "ONKYO_AVR set $name " . @$a[1] . " " . @$a[2];
if ( $state eq "off" ) { if ( $state eq "off" ) {
$return = fhem "set $name on"; $return = ONKYO_AVR_SendCommand( $hash, "power", "on" );
$return = ONKYO_AVR_SendCommand( $hash, "input", @$a[2] ); $return .= fhem "sleep 2;set $name input " . @$a[2];
} }
else { else {
Log3 $name, 3, "ONKYO_AVR set $name " . @$a[1] . " " . @$a[2];
$return = ONKYO_AVR_SendCommand( $hash, "input", @$a[2] ); $return = ONKYO_AVR_SendCommand( $hash, "input", @$a[2] );
} }
} }
@ -2572,26 +2569,24 @@ sub ONKYO_AVR_Set($$$) {
# inputUp # inputUp
elsif ( lc( @$a[1] ) eq "inputup" ) { elsif ( lc( @$a[1] ) eq "inputup" ) {
Log3 $name, 3, "ONKYO_AVR set $name " . @$a[1];
if ( $state eq "off" ) { if ( $state eq "off" ) {
$return = fhem "set $name on"; $return = ONKYO_AVR_SendCommand( $hash, "power", "on" );
$return = ONKYO_AVR_SendCommand( $hash, "input", "up" ); $return .= fhem "sleep 2;set $name inputUp";
} }
else { else {
Log3 $name, 3, "ONKYO_AVR set $name " . @$a[1];
$return = ONKYO_AVR_SendCommand( $hash, "input", "up" ); $return = ONKYO_AVR_SendCommand( $hash, "input", "up" );
} }
} }
# inputDown # inputDown
elsif ( lc( @$a[1] ) eq "inputdown" ) { elsif ( lc( @$a[1] ) eq "inputdown" ) {
Log3 $name, 3, "ONKYO_AVR set $name " . @$a[1];
if ( $state eq "off" ) { if ( $state eq "off" ) {
$return = fhem "set $name on"; $return = ONKYO_AVR_SendCommand( $hash, "power", "on" );
$return = ONKYO_AVR_SendCommand( $hash, "input", "down" ); $return .= fhem "sleep 2;set $name inputDown";
} }
else { else {
Log3 $name, 3, "ONKYO_AVR set $name " . @$a[1];
$return = ONKYO_AVR_SendCommand( $hash, "input", "down" ); $return = ONKYO_AVR_SendCommand( $hash, "input", "down" );
} }
} }

View File

@ -506,10 +506,10 @@ sub ONKYO_AVR_ZONE_Set($$$) {
my @input_names = split( ',', $_ ); my @input_names = split( ',', $_ );
$inputs_txt .= $input_names[1] . ","; $inputs_txt .= $input_names[1] . ",";
$input_names[1] =~ s/\s/_/g; $input_names[1] =~ s/\s/_/g;
$hash->{helper}{receiver}{input_aliases}{ $input_names[0] } $IOhash->{helper}{receiver}{input_aliases}
= $input_names[1]; { $input_names[0] } = $input_names[1];
$hash->{helper}{receiver}{input_names}{ $input_names[1] } = $IOhash->{helper}{receiver}{input_names}{ $input_names[1] }
$input_names[0]; = $input_names[0];
} }
else { else {
$inputs_txt .= $_ . ","; $inputs_txt .= $_ . ",";
@ -708,18 +708,16 @@ sub ONKYO_AVR_ZONE_Set($$$) {
# channel # channel
if ( lc( @$a[1] ) eq "channel" ) { if ( lc( @$a[1] ) eq "channel" ) {
Log3 $name, 3, "ONKYO_AVR_ZONE set $name " . @$a[1] . " " . @$a[2];
if ( !defined( @$a[2] ) ) { if ( !defined( @$a[2] ) ) {
$return = "Syntax: CHANNELNAME [USERNAME PASSWORD]"; $return = "Syntax: CHANNELNAME [USERNAME PASSWORD]";
} }
else { else {
if ( $state eq "off" ) { if ( $state eq "off" ) {
$return = fhem "get $name remoteControl power on quiet"; $return = ONKYO_AVR_ZONE_SendCommand( $hash, "power", "on" );
$return .= fhem "sleep 5;set $name channel " . @$a[2]; $return .= fhem "sleep 5;set $name channel " . @$a[2];
} }
elsif ( $hash->{INPUT} ne "2B" ) { elsif ( $hash->{INPUT} ne "2B" ) {
$return = fhem "get $name remoteControl input 2B quiet"; $return = ONKYO_AVR_ZONE_SendCommand( $hash, "input", "2B" );
$return .= fhem "sleep 1;set $name channel " . @$a[2]; $return .= fhem "sleep 1;set $name channel " . @$a[2];
} }
elsif ( elsif (
@ -762,48 +760,48 @@ sub ONKYO_AVR_ZONE_Set($$$) {
} }
} }
$return =
ONKYO_AVR_ZONE_SendCommand( $IOhash, "net-service",
$servicename )
if ( $servicename ne "" );
$return = "Unknown network service name " . @$a[2] $return = "Unknown network service name " . @$a[2]
if ( $servicename eq "" ); if ( $servicename eq "" );
Log3 $name, 3,
"ONKYO_AVR_ZONE set $name " . @$a[1] . " " . @$a[2];
$return =
ONKYO_AVR_SendCommand( $IOhash, "net-service", $servicename )
if ( $servicename ne "" );
} }
} }
} }
# channelDown # channelDown
elsif ( lc( @$a[1] ) eq "channeldown" ) { elsif ( lc( @$a[1] ) eq "channeldown" ) {
Log3 $name, 3, "ONKYO_AVR_ZONE set $name " . @$a[1];
if ( $state eq "off" ) { if ( $state eq "off" ) {
$return = fhem "get $name remoteControl power on quiet"; $return = ONKYO_AVR_ZONE_SendCommand( $hash, "power", "on" );
$return .= fhem "sleep 5;set $name channelDown"; $return .= fhem "sleep 5;set $name channelDown";
} }
elsif ( $hash->{INPUT} ne "2B" ) { elsif ( $hash->{INPUT} ne "2B" ) {
$return = fhem "get $name remoteControl input 2B quiet"; $return = ONKYO_AVR_ZONE_SendCommand( $hash, "input", "2B" );
$return .= fhem "sleep 1;set $name channelDown"; $return .= fhem "sleep 1;set $name channelDown";
} }
else { else {
$return = ONKYO_AVR_ZONE_SendCommand( $IOhash, "net-usb", "chdn" ); Log3 $name, 3, "ONKYO_AVR_ZONE set $name " . @$a[1];
$return = ONKYO_AVR_ZONE_SendCommand( $hash, "net-usb-z", "chdn" );
} }
} }
# channelUp # channelUp
elsif ( lc( @$a[1] ) eq "channelup" ) { elsif ( lc( @$a[1] ) eq "channelup" ) {
Log3 $name, 3, "ONKYO_AVR_ZONE set $name " . @$a[1];
if ( $state eq "off" ) { if ( $state eq "off" ) {
$return = fhem "get $name remoteControl power on quiet"; $return = ONKYO_AVR_ZONE_SendCommand( $hash, "power", "on" );
$return .= fhem "sleep 5;set $name channelUp"; $return .= fhem "sleep 5;set $name channelUp";
} }
elsif ( $hash->{INPUT} ne "2B" ) { elsif ( $hash->{INPUT} ne "2B" ) {
$return = fhem "get $name remoteControl input 2B quiet"; $return = ONKYO_AVR_ZONE_SendCommand( $hash, "input", "2B" );
$return .= fhem "sleep 1;set $name channelUp"; $return .= fhem "sleep 1;set $name channelUp";
} }
else { else {
$return = ONKYO_AVR_ZONE_SendCommand( $IOhash, "net-usb", "chup" ); Log3 $name, 3, "ONKYO_AVR_ZONE set $name " . @$a[1];
$return = ONKYO_AVR_ZONE_SendCommand( $hash, "net-usb-z", "chup" );
} }
} }
@ -822,39 +820,42 @@ sub ONKYO_AVR_ZONE_Set($$$) {
} }
else { else {
$return = $return =
ONKYO_AVR_ZONE_SendCommand( $hash, "net-usb-time-seek", ONKYO_AVR_SendCommand( $IOhash, "net-usb-time-seek", @$a[2] );
@$a[2] );
} }
} }
} }
# preset # preset
elsif ( lc( @$a[1] ) eq "preset" ) { elsif ( lc( @$a[1] ) eq "preset" ) {
Log3 $name, 3, "ONKYO_AVR_ZONE set $name " . @$a[1] . " " . @$a[2];
if ( !defined( @$a[2] ) ) { if ( !defined( @$a[2] ) ) {
$return = "No argument given"; $return = "No argument given";
} }
else { else {
if ( $state eq "off" ) { if ( $state eq "off" ) {
$return = fhem "get $name remoteControl power on quiet"; $return = ONKYO_AVR_ZONE_SendCommand( $hash, "power", "on" );
$return .= fhem "sleep 5;set $name preset " . @$a[2]; $return .= fhem "sleep 5;set $name preset " . @$a[2];
} }
elsif ( $hash->{INPUT} ne "24" && $hash->{INPUT} ne "25" ) { elsif ( $hash->{INPUT} ne "24" && $hash->{INPUT} ne "25" ) {
$return = fhem "get $name remoteControl input 24 quiet"; $return = ONKYO_AVR_ZONE_SendCommand( $hash, "input", "24" );
$return .= fhem "sleep 1;set $name preset " . @$a[2]; $return .= fhem "sleep 1;set $name preset " . @$a[2];
} }
elsif ( lc( @$a[2] ) eq "up" ) { elsif ( lc( @$a[2] ) eq "up" ) {
Log3 $name, 3,
"ONKYO_AVR_ZONE set $name " . @$a[1] . " " . @$a[2];
$return = $return =
ONKYO_AVR_ZONE_SendCommand( $IOhash, lc( @$a[1] ), "UP" ); ONKYO_AVR_ZONE_SendCommand( $hash, lc( @$a[1] ), "UP" );
} }
elsif ( lc( @$a[2] ) eq "down" ) { elsif ( lc( @$a[2] ) eq "down" ) {
Log3 $name, 3,
"ONKYO_AVR_ZONE set $name " . @$a[1] . " " . @$a[2];
$return = $return =
ONKYO_AVR_ZONE_SendCommand( $IOhash, lc( @$a[1] ), "DOWN" ); ONKYO_AVR_ZONE_SendCommand( $hash, lc( @$a[1] ), "DOWN" );
} }
elsif ( @$a[2] =~ /^\d*$/ ) { elsif ( @$a[2] =~ /^\d*$/ ) {
Log3 $name, 3,
"ONKYO_AVR_ZONE set $name " . @$a[1] . " " . @$a[2];
$return = ONKYO_AVR_ZONE_SendCommand( $return = ONKYO_AVR_ZONE_SendCommand(
$IOhash, $hash,
lc( @$a[1] ), lc( @$a[1] ),
ONKYO_AVR_dec2hex( @$a[2] ) ONKYO_AVR_dec2hex( @$a[2] )
); );
@ -871,8 +872,11 @@ sub ONKYO_AVR_ZONE_Set($$$) {
$presetName =~ s/\s/_/g; $presetName =~ s/\s/_/g;
if ( $presetName eq @$a[2] ) { if ( $presetName eq @$a[2] ) {
Log3 $name, 3,
"ONKYO_AVR_ZONE set $name " . @$a[1] . " " . @$a[2];
$return = $return =
ONKYO_AVR_ZONE_SendCommand( $IOhash, lc( @$a[1] ), ONKYO_AVR_ZONE_SendCommand( $hash, lc( @$a[1] ),
uc($id) ); uc($id) );
last; last;
@ -884,35 +888,33 @@ sub ONKYO_AVR_ZONE_Set($$$) {
# presetDown # presetDown
elsif ( lc( @$a[1] ) eq "presetdown" ) { elsif ( lc( @$a[1] ) eq "presetdown" ) {
Log3 $name, 3, "ONKYO_AVR_ZONE set $name " . @$a[1];
if ( $state eq "off" ) { if ( $state eq "off" ) {
$return = fhem "get $name remoteControl power on quiet"; $return = ONKYO_AVR_ZONE_SendCommand( $hash, "power", "on" );
$return .= fhem "sleep 5;set $name presetDown"; $return .= fhem "sleep 5;set $name presetDown";
} }
elsif ( $hash->{INPUT} ne "24" && $hash->{INPUT} ne "25" ) { elsif ( $hash->{INPUT} ne "24" && $hash->{INPUT} ne "25" ) {
$return = fhem "get $name remoteControl input 24 quiet"; $return = ONKYO_AVR_ZONE_SendCommand( $hash, "input", "24" );
$return .= fhem "sleep 1;set $name presetDown"; $return .= fhem "sleep 1;set $name presetDown";
} }
else { else {
$return = ONKYO_AVR_ZONE_SendCommand( $IOhash, "preset", "down" ); Log3 $name, 3, "ONKYO_AVR_ZONE set $name " . @$a[1];
$return = ONKYO_AVR_ZONE_SendCommand( $hash, "preset", "down" );
} }
} }
# presetUp # presetUp
elsif ( lc( @$a[1] ) eq "presetup" ) { elsif ( lc( @$a[1] ) eq "presetup" ) {
Log3 $name, 3, "ONKYO_AVR_ZONE set $name " . @$a[1];
if ( $state eq "off" ) { if ( $state eq "off" ) {
$return = fhem "get $name remoteControl power on quiet"; $return = ONKYO_AVR_ZONE_SendCommand( $hash, "power", "on" );
$return .= fhem "sleep 5;set $name presetUp"; $return .= fhem "sleep 5;set $name presetUp";
} }
elsif ( $hash->{INPUT} ne "24" && $hash->{INPUT} ne "25" ) { elsif ( $hash->{INPUT} ne "24" && $hash->{INPUT} ne "25" ) {
$return = fhem "get $name remoteControl input 24 quiet"; $return = ONKYO_AVR_ZONE_SendCommand( $hash, "input", "24" );
$return .= fhem "sleep 1;set $name presetUp"; $return .= fhem "sleep 1;set $name presetUp";
} }
else { else {
$return = ONKYO_AVR_ZONE_SendCommand( $IOhash, "preset", "up" ); Log3 $name, 3, "ONKYO_AVR_ZONE set $name " . @$a[1];
$return = ONKYO_AVR_ZONE_SendCommand( $hash, "preset", "up" );
} }
} }
@ -933,15 +935,14 @@ sub ONKYO_AVR_ZONE_Set($$$) {
$setVal = "B" if ( $2 eq "bass" ); $setVal = "B" if ( $2 eq "bass" );
$setVal = "T" if ( $2 eq "treble" ); $setVal = "T" if ( $2 eq "treble" );
$return = $return =
ONKYO_AVR_ZONE_SendCommand( $IOhash, lc($1), $setVal . "UP" ); ONKYO_AVR_ZONE_SendCommand( $hash, lc($1), $setVal . "UP" );
} }
elsif ( lc( @$a[2] ) eq "down" ) { elsif ( lc( @$a[2] ) eq "down" ) {
my $setVal = ""; my $setVal = "";
$setVal = "B" if ( $2 eq "bass" ); $setVal = "B" if ( $2 eq "bass" );
$setVal = "T" if ( $2 eq "treble" ); $setVal = "T" if ( $2 eq "treble" );
$return = $return =
ONKYO_AVR_ZONE_SendCommand( $IOhash, lc($1), ONKYO_AVR_ZONE_SendCommand( $hash, lc($1), $setVal . "DOWN" );
$setVal . "DOWN" );
} }
elsif ( @$a[2] =~ /^-*\d+$/ ) { elsif ( @$a[2] =~ /^-*\d+$/ ) {
my $setVal = ""; my $setVal = "";
@ -956,7 +957,7 @@ sub ONKYO_AVR_ZONE_Set($$$) {
$setVal2 = substr( $setVal2, 1 ) if ( $setVal2 ne "00" ); $setVal2 = substr( $setVal2, 1 ) if ( $setVal2 ne "00" );
$return = $return =
ONKYO_AVR_ZONE_SendCommand( $IOhash, lc($1), ONKYO_AVR_ZONE_SendCommand( $hash, lc($1),
$setVal . $setVal2 ); $setVal . $setVal2 );
} }
} }
@ -964,8 +965,6 @@ sub ONKYO_AVR_ZONE_Set($$$) {
# toggle # toggle
elsif ( lc( @$a[1] ) eq "toggle" ) { elsif ( lc( @$a[1] ) eq "toggle" ) {
Log3 $name, 3, "ONKYO_AVR_ZONE set $name " . @$a[1];
if ( $state eq "off" ) { if ( $state eq "off" ) {
$return = fhem "set $name on"; $return = fhem "set $name on";
} }
@ -1004,30 +1003,30 @@ sub ONKYO_AVR_ZONE_Set($$$) {
} }
else { else {
Log3 $name, 3, "ONKYO_AVR_ZONE set $name " . @$a[1]; Log3 $name, 3, "ONKYO_AVR_ZONE set $name " . @$a[1];
$return = ONKYO_AVR_ZONE_SendCommand( $IOhash, "power", "on" ); $return = ONKYO_AVR_ZONE_SendCommand( $hash, "power", "on" );
# don't wait for receiver to confirm power on # don't wait for receiver to confirm power on
# #
readingsBeginUpdate($IOhash); readingsBeginUpdate($hash);
# power # power
readingsBulkUpdate( $IOhash, "power", "on" ) readingsBulkUpdate( $hash, "power", "on" )
if ( ReadingsVal( $name, "power", "-" ) ne "on" ); if ( ReadingsVal( $name, "power", "-" ) ne "on" );
# stateAV # stateAV
my $stateAV = ONKYO_AVR_ZONE_GetStateAV($IOhash); my $stateAV = ONKYO_AVR_ZONE_GetStateAV($hash);
readingsBulkUpdate( $IOhash, "stateAV", $stateAV ) readingsBulkUpdate( $hash, "stateAV", $stateAV )
if ( ReadingsVal( $name, "stateAV", "-" ) ne $stateAV ); if ( ReadingsVal( $name, "stateAV", "-" ) ne $stateAV );
readingsEndUpdate( $IOhash, 1 ); readingsEndUpdate( $hash, 1 );
} }
} }
# off # off
elsif ( lc( @$a[1] ) eq "off" ) { elsif ( lc( @$a[1] ) eq "off" ) {
Log3 $name, 3, "ONKYO_AVR_ZONE set $name " . @$a[1]; Log3 $name, 3, "ONKYO_AVR_ZONE set $name " . @$a[1];
$return = ONKYO_AVR_ZONE_SendCommand( $IOhash, "power", "off" ); $return = ONKYO_AVR_ZONE_SendCommand( $hash, "power", "off" );
} }
# remoteControl # remoteControl
@ -1067,24 +1066,24 @@ sub ONKYO_AVR_ZONE_Set($$$) {
|| lc( @$a[2] ) eq "9" ) || lc( @$a[2] ) eq "9" )
{ {
$return = $return =
ONKYO_AVR_ZONE_SendCommand( $IOhash, "net-usb", ONKYO_AVR_ZONE_SendCommand( $hash, "net-usb-z",
lc( @$a[2] ) ); lc( @$a[2] ) );
} }
elsif ( lc( @$a[2] ) eq "prev" ) { elsif ( lc( @$a[2] ) eq "prev" ) {
$return = $return =
ONKYO_AVR_ZONE_SendCommand( $IOhash, "net-usb", "trdown" ); ONKYO_AVR_ZONE_SendCommand( $hash, "net-usb-z", "trdown" );
} }
elsif ( lc( @$a[2] ) eq "next" ) { elsif ( lc( @$a[2] ) eq "next" ) {
$return = $return =
ONKYO_AVR_ZONE_SendCommand( $IOhash, "net-usb", "trup" ); ONKYO_AVR_ZONE_SendCommand( $hash, "net-usb-z", "trup" );
} }
elsif ( lc( @$a[2] ) eq "shuffle" ) { elsif ( lc( @$a[2] ) eq "shuffle" ) {
$return = $return =
ONKYO_AVR_ZONE_SendCommand( $IOhash, "net-usb", "random" ); ONKYO_AVR_ZONE_SendCommand( $hash, "net-usb-z", "random" );
} }
elsif ( lc( @$a[2] ) eq "menu" ) { elsif ( lc( @$a[2] ) eq "menu" ) {
$return = $return =
ONKYO_AVR_ZONE_SendCommand( $IOhash, "net-usb", "men" ); ONKYO_AVR_ZONE_SendCommand( $hash, "net-usb-z", "men" );
} }
else { else {
$return = "Unsupported remoteControl command: " . @$a[2]; $return = "Unsupported remoteControl command: " . @$a[2];
@ -1102,7 +1101,7 @@ sub ONKYO_AVR_ZONE_Set($$$) {
"Device power is turned off, this function is unavailable at that stage."; "Device power is turned off, this function is unavailable at that stage.";
} }
else { else {
$return = ONKYO_AVR_ZONE_SendCommand( $IOhash, "net-usb", "play" ); $return = ONKYO_AVR_ZONE_SendCommand( $hash, "net-usb-z", "play" );
} }
} }
@ -1115,7 +1114,7 @@ sub ONKYO_AVR_ZONE_Set($$$) {
"Device power is turned off, this function is unavailable at that stage."; "Device power is turned off, this function is unavailable at that stage.";
} }
else { else {
$return = ONKYO_AVR_ZONE_SendCommand( $IOhash, "net-usb", "pause" ); $return = ONKYO_AVR_ZONE_SendCommand( $hash, "net-usb-z", "pause" );
} }
} }
@ -1128,7 +1127,7 @@ sub ONKYO_AVR_ZONE_Set($$$) {
"Device power is turned off, this function is unavailable at that stage."; "Device power is turned off, this function is unavailable at that stage.";
} }
else { else {
$return = ONKYO_AVR_ZONE_SendCommand( $IOhash, "net-usb", "stop" ); $return = ONKYO_AVR_ZONE_SendCommand( $hash, "net-usb-z", "stop" );
} }
} }
@ -1142,7 +1141,7 @@ sub ONKYO_AVR_ZONE_Set($$$) {
} }
else { else {
$return = $return =
ONKYO_AVR_ZONE_SendCommand( $IOhash, "net-usb", "random" ); ONKYO_AVR_ZONE_SendCommand( $hash, "net-usb-z", "random" );
} }
} }
@ -1156,7 +1155,7 @@ sub ONKYO_AVR_ZONE_Set($$$) {
} }
else { else {
$return = $return =
ONKYO_AVR_ZONE_SendCommand( $IOhash, "net-usb", "repeat" ); ONKYO_AVR_ZONE_SendCommand( $hash, "net-usb-z", "repeat" );
} }
} }
@ -1170,7 +1169,7 @@ sub ONKYO_AVR_ZONE_Set($$$) {
} }
else { else {
$return = $return =
ONKYO_AVR_ZONE_SendCommand( $IOhash, "net-usb", "trdown" ); ONKYO_AVR_ZONE_SendCommand( $hash, "net-usb-z", "trdown" );
} }
} }
@ -1183,31 +1182,7 @@ sub ONKYO_AVR_ZONE_Set($$$) {
"Device power is turned off, this function is unavailable at that stage."; "Device power is turned off, this function is unavailable at that stage.";
} }
else { else {
$return = ONKYO_AVR_ZONE_SendCommand( $IOhash, "net-usb", "trup" ); $return = ONKYO_AVR_ZONE_SendCommand( $hash, "net-usb-z", "trup" );
}
}
# sleep
elsif ( lc( @$a[1] ) eq "sleep" ) {
if ( !defined( @$a[2] ) ) {
$return = "No argument given, choose one of minutes off";
}
else {
Log3 $name, 3, "ONKYO_AVR_ZONE set $name " . @$a[1] . " " . @$a[2];
my $_ = @$a[2];
if ( $_ eq "off" ) {
$return = ONKYO_AVR_ZONE_SendCommand( $IOhash, "sleep", "off" );
}
elsif ( m/^\d+$/ && $_ > 0 && $_ <= 90 ) {
$return =
ONKYO_AVR_ZONE_SendCommand( $IOhash, "sleep",
ONKYO_AVR_dec2hex($_) );
}
else {
$return =
"Argument does not seem to be a valid integer between 0 and 90";
}
} }
} }
@ -1222,14 +1197,13 @@ sub ONKYO_AVR_ZONE_Set($$$) {
if ( $state eq "on" ) { if ( $state eq "on" ) {
if ( !defined( @$a[2] ) || @$a[2] eq "toggle" ) { if ( !defined( @$a[2] ) || @$a[2] eq "toggle" ) {
$return = $return = ONKYO_AVR_ZONE_SendCommand( $hash, "mute", "toggle" );
ONKYO_AVR_ZONE_SendCommand( $IOhash, "mute", "toggle" );
} }
elsif ( lc( @$a[2] ) eq "off" ) { elsif ( lc( @$a[2] ) eq "off" ) {
$return = ONKYO_AVR_ZONE_SendCommand( $IOhash, "mute", "off" ); $return = ONKYO_AVR_ZONE_SendCommand( $hash, "mute", "off" );
} }
elsif ( lc( @$a[2] ) eq "on" ) { elsif ( lc( @$a[2] ) eq "on" ) {
$return = ONKYO_AVR_ZONE_SendCommand( $IOhash, "mute", "on" ); $return = ONKYO_AVR_ZONE_SendCommand( $hash, "mute", "on" );
} }
else { else {
$return = "Argument does not seem to be one of on off toogle"; $return = "Argument does not seem to be one of on off toogle";
@ -1252,7 +1226,7 @@ sub ONKYO_AVR_ZONE_Set($$$) {
my $_ = @$a[2]; my $_ = @$a[2];
if ( m/^\d+$/ && $_ >= 0 && $_ <= 100 ) { if ( m/^\d+$/ && $_ >= 0 && $_ <= 100 ) {
$return = $return =
ONKYO_AVR_ZONE_SendCommand( $IOhash, "volume", ONKYO_AVR_ZONE_SendCommand( $hash, "volume",
ONKYO_AVR_dec2hex($_) ); ONKYO_AVR_dec2hex($_) );
} }
else { else {
@ -1273,11 +1247,11 @@ sub ONKYO_AVR_ZONE_Set($$$) {
if ( $state eq "on" ) { if ( $state eq "on" ) {
if ( lc( @$a[1] ) eq "volumeup" ) { if ( lc( @$a[1] ) eq "volumeup" ) {
$return = $return =
ONKYO_AVR_ZONE_SendCommand( $IOhash, "volume", "level-up" ); ONKYO_AVR_ZONE_SendCommand( $hash, "volume", "level-up" );
} }
else { else {
$return = $return =
ONKYO_AVR_ZONE_SendCommand( $IOhash, "volume", "level-down" ); ONKYO_AVR_ZONE_SendCommand( $hash, "volume", "level-down" );
} }
} }
else { else {
@ -1291,43 +1265,39 @@ sub ONKYO_AVR_ZONE_Set($$$) {
$return = "No input given"; $return = "No input given";
} }
else { else {
Log3 $name, 3, "ONKYO_AVR_ZONE set $name " . @$a[1] . " " . @$a[2];
if ( $state eq "off" ) { if ( $state eq "off" ) {
$return = fhem "set $name on"; $return = ONKYO_AVR_ZONE_SendCommand( $hash, "power", "on" );
$return = $return .= fhem "sleep 2;set $name input " . @$a[2];
ONKYO_AVR_ZONE_SendCommand( $IOhash, "input", @$a[2] );
} }
else { else {
$return = Log3 $name, 3,
ONKYO_AVR_ZONE_SendCommand( $IOhash, "input", @$a[2] ); "ONKYO_AVR_ZONE set $name " . @$a[1] . " " . @$a[2];
$return = ONKYO_AVR_ZONE_SendCommand( $hash, "input", @$a[2] );
} }
} }
} }
# inputUp # inputUp
elsif ( lc( @$a[1] ) eq "inputup" ) { elsif ( lc( @$a[1] ) eq "inputup" ) {
Log3 $name, 3, "ONKYO_AVR_ZONE set $name " . @$a[1];
if ( $state eq "off" ) { if ( $state eq "off" ) {
$return = fhem "set $name on"; $return = ONKYO_AVR_ZONE_SendCommand( $hash, "power", "on" );
$return = ONKYO_AVR_ZONE_SendCommand( $IOhash, "input", "up" ); $return .= fhem "sleep 2;set $name inputUp";
} }
else { else {
$return = ONKYO_AVR_ZONE_SendCommand( $IOhash, "input", "up" ); Log3 $name, 3, "ONKYO_AVR_ZONE set $name " . @$a[1];
$return = ONKYO_AVR_ZONE_SendCommand( $hash, "input", "up" );
} }
} }
# inputDown # inputDown
elsif ( lc( @$a[1] ) eq "inputdown" ) { elsif ( lc( @$a[1] ) eq "inputdown" ) {
Log3 $name, 3, "ONKYO_AVR_ZONE set $name " . @$a[1];
if ( $state eq "off" ) { if ( $state eq "off" ) {
$return = fhem "set $name on"; $return = ONKYO_AVR_ZONE_SendCommand( $hash, "power", "on" );
$return = ONKYO_AVR_ZONE_SendCommand( $IOhash, "input", "down" ); $return .= fhem "sleep 2;set $name inputDown";
} }
else { else {
$return = ONKYO_AVR_ZONE_SendCommand( $IOhash, "input", "down" ); Log3 $name, 3, "ONKYO_AVR_ZONE set $name " . @$a[1];
$return = ONKYO_AVR_ZONE_SendCommand( $hash, "input", "down" );
} }
} }
@ -1339,7 +1309,7 @@ sub ONKYO_AVR_ZONE_Set($$$) {
$return = "No argument given"; $return = "No argument given";
} }
else { else {
$return = ONKYO_AVR_ZONE_SendCommand( $IOhash, @$a[1], @$a[2] ); $return = ONKYO_AVR_ZONE_SendCommand( $hash, @$a[1], @$a[2] );
} }
} }
@ -1434,15 +1404,6 @@ sub ONKYO_AVR_ZONE_SendCommand($$$) {
return; return;
} }
###################################
sub ONKYO_AVR_dec2hex($) {
my ($dec) = @_;
my $hex = uc( sprintf( "%x", $dec ) );
return "0" . $hex if ( length($hex) eq 1 );
return $hex;
}
################################### ###################################
sub ONKYO_AVR_ZONE_GetStateAV($) { sub ONKYO_AVR_ZONE_GetStateAV($) {
my ($hash) = @_; my ($hash) = @_;

View File

@ -154,7 +154,6 @@ my $ONKYO_cmds_hr = {
'listening-mode' => 'LMZ', 'listening-mode' => 'LMZ',
'mute' => 'ZMT', 'mute' => 'ZMT',
'net-usb-z' => 'NTZ', 'net-usb-z' => 'NTZ',
'net-usb-time-seek' => 'NTS',
'power' => 'ZPW', 'power' => 'ZPW',
'preset' => 'PRZ', 'preset' => 'PRZ',
're-eq-academy-filter' => 'RAZ', 're-eq-academy-filter' => 'RAZ',
@ -168,7 +167,6 @@ my $ONKYO_cmds_hr = {
'internet-radio-preset' => 'NP3', 'internet-radio-preset' => 'NP3',
'mute' => 'MT3', 'mute' => 'MT3',
'net-usb-z' => 'NT3', 'net-usb-z' => 'NT3',
'net-usb-time-seek' => 'NTS',
'power' => 'PW3', 'power' => 'PW3',
'preset' => 'PR3', 'preset' => 'PR3',
'input' => 'SL3', 'input' => 'SL3',
@ -180,7 +178,6 @@ my $ONKYO_cmds_hr = {
'internet-radio-preset' => 'NP4', 'internet-radio-preset' => 'NP4',
'mute' => 'MT4', 'mute' => 'MT4',
'net-usb-z' => 'NT4', 'net-usb-z' => 'NT4',
'net-usb-time-seek' => 'NTS',
'power' => 'PW4', 'power' => 'PW4',
'preset' => 'PR4', 'preset' => 'PR4',
'input' => 'SL4', 'input' => 'SL4',