mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 18:59:33 +00:00
70_ONKYO_AVR.pm,71_ONKYO_AVR_ZONE.pm,ONKYOdb.pm: add setter for preset and balance
git-svn-id: https://svn.fhem.de/fhem/trunk@11584 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
4bae3ba6af
commit
7b9c6c22f8
@ -445,7 +445,7 @@ sub ONKYO_AVR_Read($) {
|
||||
|
||||
# return as decimal
|
||||
elsif ($value_raw =~ m/^[0-9A-Fa-f][0-9A-Fa-f]$/
|
||||
&& $cmd_raw =~ /^(MVL|SLP)$/ )
|
||||
&& $cmd_raw =~ /^(MVL|SLP|PRS|PRZ|PRM|PTS|NPR|NPZ)$/ )
|
||||
{
|
||||
$value = ONKYO_AVR_hex2dec($value_raw);
|
||||
Log3 $name, 5,
|
||||
@ -712,6 +712,19 @@ sub ONKYO_AVR_Read($) {
|
||||
$attr{$name}{inputs} = $inputs;
|
||||
}
|
||||
|
||||
# Safe preset names
|
||||
my $presets;
|
||||
foreach my $id (
|
||||
keys %{ $hash->{helper}{receiver}{device}{presetlist}{preset} }
|
||||
)
|
||||
{
|
||||
my $name = trim( $hash->{helper}{receiver}{device}{presetlist}{preset}{$id}{name} );
|
||||
next if ( !$name || $name eq "" );
|
||||
|
||||
$name =~ s/\s/_/g;
|
||||
$hash->{helper}{receiver}{preset}{$id} = $name;
|
||||
}
|
||||
|
||||
# Zones
|
||||
my $reading = "zones";
|
||||
if ( defined( $hash->{helper}{receiver}{device}{zonelist}{zone} ) )
|
||||
@ -845,8 +858,8 @@ sub ONKYO_AVR_Read($) {
|
||||
$usbFront = "GoogleUSB" if ( $2 eq "G" );
|
||||
$usbFront = "disabled" if ( $2 eq "x" );
|
||||
|
||||
readingsBulkUpdate( $hash, "usbFront", $usbFront )
|
||||
if ( ReadingsVal( $name, "usbFront", "-" ) ne $usbFront );
|
||||
readingsBulkUpdate( $hash, "USB_Front", $usbFront )
|
||||
if ( ReadingsVal( $name, "USB_Front", "-" ) ne $usbFront );
|
||||
|
||||
# usbRear
|
||||
my $usbRear = "none";
|
||||
@ -857,8 +870,8 @@ sub ONKYO_AVR_Read($) {
|
||||
$usbRear = "GoogleUSB" if ( $3 eq "G" );
|
||||
$usbRear = "disabled" if ( $3 eq "x" );
|
||||
|
||||
readingsBulkUpdate( $hash, "usbRear", $usbRear )
|
||||
if ( ReadingsVal( $name, "usbRear", "-" ) ne $usbRear );
|
||||
readingsBulkUpdate( $hash, "USB_Rear", $usbRear )
|
||||
if ( ReadingsVal( $name, "USB_Rear", "-" ) ne $usbRear );
|
||||
|
||||
}
|
||||
}
|
||||
@ -1427,6 +1440,31 @@ sub ONKYO_AVR_Read($) {
|
||||
$value = $prefix . ONKYO_AVR_hex2dec($value);
|
||||
}
|
||||
|
||||
# preset
|
||||
elsif ( $cmd eq "preset" ) {
|
||||
|
||||
if ( defined( $hash->{helper}{receiver}{preset} ) ) {
|
||||
|
||||
foreach
|
||||
my $id ( sort keys %{ $hash->{helper}{receiver}{preset} } )
|
||||
{
|
||||
my $presetName =
|
||||
$hash->{helper}{receiver}{preset}{$id};
|
||||
next if ( !$presetName || $presetName eq "" );
|
||||
|
||||
$presetName =~ s/\s/_/g;
|
||||
|
||||
if ( $id eq ONKYO_AVR_dec2hex($value) ) {
|
||||
$value = $presetName;
|
||||
last;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$value = "" if ( $value eq "0" );
|
||||
$zoneDispatch->{preset} = $value;
|
||||
}
|
||||
|
||||
readingsBulkUpdate( $hash, $cmd, $value )
|
||||
if ( ReadingsVal( $name, $cmd, "-" ) ne $value );
|
||||
|
||||
@ -1438,8 +1476,11 @@ sub ONKYO_AVR_Read($) {
|
||||
|
||||
readingsEndUpdate( $hash, 1 );
|
||||
|
||||
Dispatch( $hash, $zoneDispatch, undef )
|
||||
if ( $zoneDispatch && $definedZones > 0 );
|
||||
if ( $zoneDispatch && $definedZones > 1 ) {
|
||||
Log3 $name, 5,
|
||||
"ONKYO_AVR $name: Forwarding information from main zone1 to slave zones";
|
||||
Dispatch( $hash, $zoneDispatch, undef );
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
@ -1768,7 +1809,7 @@ sub ONKYO_AVR_Set($$$) {
|
||||
ONKYOdb::ONKYO_GetRemotecontrolCommand( $zone, $reading );
|
||||
my @readingExceptions = (
|
||||
"volume", "input", "mute", "sleep", "center-temporary-level",
|
||||
"subwoofer-temporary-level"
|
||||
"subwoofer-temporary-level", "balance", "preset",
|
||||
);
|
||||
|
||||
if ( $cmd_raw && !( grep $_ eq $reading, @readingExceptions ) ) {
|
||||
@ -1819,6 +1860,36 @@ sub ONKYO_AVR_Set($$$) {
|
||||
}
|
||||
}
|
||||
|
||||
my $preset_txt = "";
|
||||
if ( defined( $hash->{helper}{receiver}{preset} ) ) {
|
||||
|
||||
foreach my $id (
|
||||
sort
|
||||
keys %{ $hash->{helper}{receiver}{preset} }
|
||||
)
|
||||
{
|
||||
my $presetName =
|
||||
$hash->{helper}{receiver}{preset}{$id};
|
||||
next if ( !$presetName || $presetName eq "" );
|
||||
|
||||
$preset_txt = "preset:" if ( $preset_txt eq "" );
|
||||
$preset_txt .= ","
|
||||
if ( $preset_txt eq "preset:"
|
||||
&& ReadingsVal( $name, "preset", "-" ) eq "" );
|
||||
|
||||
$presetName =~ s/\s/_/g;
|
||||
$preset_txt .= $presetName . ",";
|
||||
}
|
||||
}
|
||||
$preset_txt = substr( $preset_txt, 0, -1 ) if ( $preset_txt ne "" );
|
||||
|
||||
if ( $preset_txt eq "" ) {
|
||||
$preset_txt = "preset:";
|
||||
$preset_txt .= "," if ( ReadingsVal( $name, "preset", "-" ) eq "" );
|
||||
$preset_txt .=
|
||||
"1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40";
|
||||
}
|
||||
|
||||
my $shuffle_txt = "shuffle:";
|
||||
$shuffle_txt .= "," if ( ReadingsVal( $name, "shuffle", "-" ) eq "-" );
|
||||
$shuffle_txt .= "off,on,on-album,on-folder";
|
||||
@ -1830,9 +1901,10 @@ sub ONKYO_AVR_Set($$$) {
|
||||
my $usage =
|
||||
"Unknown argument '"
|
||||
. @$a[1]
|
||||
. "', choose one of toggle:noArg on:noArg off:noArg volume:slider,0,1,100 volumeUp:noArg volumeDown:noArg mute:off,on muteT:noArg play:noArg pause:noArg stop:noArg previous:noArg next:noArg shuffleT:noArg repeatT:noArg remoteControl:play,pause,repeat,stop,top,down,up,right,delete,display,ff,left,mode,return,rew,select,setup,0,1,2,3,4,5,6,7,8,9,prev,next,shuffle,menu channelDown:noArg channelUp:noArg input:"
|
||||
. "', choose one of toggle:noArg on:noArg off:noArg volume:slider,0,1,100 volumeDown:noArg volumeUp:noArg mute:off,on muteT:noArg play:noArg pause:noArg stop:noArg previous:noArg next:noArg shuffleT:noArg repeatT:noArg remoteControl:play,pause,repeat,stop,top,down,up,right,delete,display,ff,left,mode,return,rew,select,setup,0,1,2,3,4,5,6,7,8,9,prev,next,shuffle,menu channelDown:noArg channelUp:noArg inputDown:noArg inputUp:noArg internet-radio-preset:1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40 input:"
|
||||
. $inputs_txt;
|
||||
$usage .= " channel:$channels_txt";
|
||||
$usage .= " presetDown:noArg presetUp:noArg $preset_txt";
|
||||
$usage .= " $shuffle_txt";
|
||||
$usage .= " $repeat_txt";
|
||||
$usage .= $implicit_txt if ( $implicit_txt ne "" );
|
||||
@ -1930,6 +2002,85 @@ sub ONKYO_AVR_Set($$$) {
|
||||
}
|
||||
}
|
||||
|
||||
# preset
|
||||
elsif ( lc( @$a[1] ) eq "preset" ) {
|
||||
Log3 $name, 3, "ONKYO_AVR set $name " . @$a[1] . " " . @$a[2];
|
||||
|
||||
if ( !defined( @$a[2] ) ) {
|
||||
$return = "No argument given";
|
||||
}
|
||||
else {
|
||||
if ( $state eq "off" ) {
|
||||
$return =
|
||||
"Device power is turned off, this function is unavailable at that stage.";
|
||||
}
|
||||
elsif ( lc( @$a[2] ) eq "up" ) {
|
||||
$return = ONKYO_AVR_SendCommand( $hash, lc( @$a[1] ), "UP" );
|
||||
}
|
||||
elsif ( lc( @$a[2] ) eq "down" ) {
|
||||
$return = ONKYO_AVR_SendCommand( $hash, lc( @$a[1] ), "DOWN" );
|
||||
}
|
||||
elsif ( @$a[2] =~ /^\d*$/ ) {
|
||||
$return = ONKYO_AVR_SendCommand(
|
||||
$hash,
|
||||
lc( @$a[1] ),
|
||||
ONKYO_AVR_dec2hex( @$a[2] )
|
||||
);
|
||||
}
|
||||
elsif ( defined( $hash->{helper}{receiver}{preset} ) ) {
|
||||
|
||||
foreach
|
||||
my $id ( sort keys %{ $hash->{helper}{receiver}{preset} } )
|
||||
{
|
||||
my $presetName =
|
||||
$hash->{helper}{receiver}{preset}{$id};
|
||||
next if ( !$presetName || $presetName eq "" );
|
||||
|
||||
$presetName =~ s/\s/_/g;
|
||||
|
||||
if ( $presetName eq @$a[2] ) {
|
||||
$return =
|
||||
ONKYO_AVR_SendCommand( $hash, lc( @$a[1] ), uc($id) );
|
||||
|
||||
last;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# presetDown
|
||||
elsif ( lc( @$a[1] ) eq "presetdown" ) {
|
||||
Log3 $name, 3, "ONKYO_AVR set $name " . @$a[1];
|
||||
|
||||
if ( $presence eq "absent" ) {
|
||||
$return = "Device needs to be ON to change input.";
|
||||
}
|
||||
elsif ( $state eq "off" ) {
|
||||
$return = fhem "set $name on";
|
||||
$return = ONKYO_AVR_SendCommand( $hash, "preset", "down" );
|
||||
}
|
||||
else {
|
||||
$return = ONKYO_AVR_SendCommand( $hash, "preset", "down" );
|
||||
}
|
||||
}
|
||||
|
||||
# presetUp
|
||||
elsif ( lc( @$a[1] ) eq "presetup" ) {
|
||||
Log3 $name, 3, "ONKYO_AVR set $name " . @$a[1];
|
||||
|
||||
if ( $presence eq "absent" ) {
|
||||
$return = "Device needs to be ON to change input.";
|
||||
}
|
||||
elsif ( $state eq "off" ) {
|
||||
$return = fhem "set $name on";
|
||||
$return = ONKYO_AVR_SendCommand( $hash, "preset", "up" );
|
||||
}
|
||||
else {
|
||||
$return = ONKYO_AVR_SendCommand( $hash, "preset", "up" );
|
||||
}
|
||||
}
|
||||
|
||||
# tone-*
|
||||
elsif ( lc( @$a[1] ) =~ /^(tone.*)-(bass|treble)$/ ) {
|
||||
Log3 $name, 3, "ONKYO_AVR set $name " . @$a[1] . " " . @$a[2];
|
||||
@ -2378,16 +2529,48 @@ sub ONKYO_AVR_Set($$$) {
|
||||
else {
|
||||
Log3 $name, 3, "ONKYO_AVR set $name " . @$a[1] . " " . @$a[2];
|
||||
|
||||
if ( $state eq "off" ) {
|
||||
if ( $presence eq "absent" ) {
|
||||
$return = "Device needs to be ON to change input.";
|
||||
}
|
||||
elsif ( $state eq "off" ) {
|
||||
$return = fhem "set $name on";
|
||||
$return = ONKYO_AVR_SendCommand( $hash, "input", @$a[2] );
|
||||
}
|
||||
elsif ( $state eq "on" ) {
|
||||
else {
|
||||
$return = ONKYO_AVR_SendCommand( $hash, "input", @$a[2] );
|
||||
}
|
||||
else {
|
||||
$return = "Device needs to be ON to change input.";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# inputUp
|
||||
elsif ( lc( @$a[1] ) eq "inputup" ) {
|
||||
Log3 $name, 3, "ONKYO_AVR set $name " . @$a[1];
|
||||
|
||||
if ( $presence eq "absent" ) {
|
||||
$return = "Device needs to be ON to change input.";
|
||||
}
|
||||
elsif ( $state eq "off" ) {
|
||||
$return = fhem "set $name on";
|
||||
$return = ONKYO_AVR_SendCommand( $hash, "input", "up" );
|
||||
}
|
||||
else {
|
||||
$return = ONKYO_AVR_SendCommand( $hash, "input", "up" );
|
||||
}
|
||||
}
|
||||
|
||||
# inputDown
|
||||
elsif ( lc( @$a[1] ) eq "inputdown" ) {
|
||||
Log3 $name, 3, "ONKYO_AVR set $name " . @$a[1];
|
||||
|
||||
if ( $presence eq "absent" ) {
|
||||
$return = "Device needs to be ON to change input.";
|
||||
}
|
||||
elsif ( $state eq "off" ) {
|
||||
$return = fhem "set $name on";
|
||||
$return = ONKYO_AVR_SendCommand( $hash, "input", "down" );
|
||||
}
|
||||
else {
|
||||
$return = ONKYO_AVR_SendCommand( $hash, "input", "down" );
|
||||
}
|
||||
}
|
||||
|
||||
@ -2781,6 +2964,12 @@ sub ONKYO_AVR_RClayout() {
|
||||
<li>
|
||||
<b>input</b> - switches between inputs
|
||||
</li>
|
||||
<li>
|
||||
<b>inputDown</b> - switches one input down
|
||||
</li>
|
||||
<li>
|
||||
<b>inputUp</b> - switches one input up
|
||||
</li>
|
||||
<li>
|
||||
<b>mute</b> on,off - controls volume mute
|
||||
</li>
|
||||
@ -2805,6 +2994,15 @@ sub ONKYO_AVR_RClayout() {
|
||||
<li>
|
||||
<b>power</b> on,off - set power mode
|
||||
</li>
|
||||
<li>
|
||||
<b>preset</b> - switches between presets
|
||||
</li>
|
||||
<li>
|
||||
<b>presetDown</b> - switches one preset down
|
||||
</li>
|
||||
<li>
|
||||
<b>presetUp</b> - switches one preset up
|
||||
</li>
|
||||
<li>
|
||||
<b>previous</b> - back to previous track
|
||||
</li>
|
||||
|
@ -246,6 +246,39 @@ sub ONKYO_AVR_ZONE_Parse($$) {
|
||||
if ( ReadingsVal( $name, "presence", "-" ) ne "present" );
|
||||
}
|
||||
|
||||
# balance
|
||||
elsif ( $cmd eq "balance" ) {
|
||||
my $prefix = "";
|
||||
$prefix = "-" if ( $value =~ /^\-.*/ );
|
||||
$value = substr( $value, 1 ) if ( $value =~ /^[\+|\-].*/ );
|
||||
|
||||
$value = $prefix . ONKYO_AVR_hex2dec($value);
|
||||
}
|
||||
|
||||
# preset
|
||||
elsif ( $cmd eq "preset" ) {
|
||||
|
||||
if ( defined( $IOhash->{helper}{receiver}{preset} ) ) {
|
||||
|
||||
foreach my $id (
|
||||
sort keys %{ $IOhash->{helper}{receiver}{preset} } )
|
||||
{
|
||||
my $presetName =
|
||||
$IOhash->{helper}{receiver}{preset}{$id};
|
||||
next if ( !$presetName || $presetName eq "" );
|
||||
|
||||
$presetName =~ s/\s/_/g;
|
||||
|
||||
if ( $id eq ONKYO_AVR_dec2hex($value) ) {
|
||||
$value = $presetName;
|
||||
last;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$value = "" if ( $value eq "0" );
|
||||
}
|
||||
|
||||
# tone
|
||||
if ( $cmd =~ /^tone/ ) {
|
||||
if ( $value =~ /^B(..)T(..)$/ ) {
|
||||
@ -546,7 +579,10 @@ sub ONKYO_AVR_ZONE_Set($$$) {
|
||||
foreach my $reading ( keys %{ $hash->{READINGS} } ) {
|
||||
my $cmd_raw =
|
||||
ONKYOdb::ONKYO_GetRemotecontrolCommand( $zone, $reading );
|
||||
my @readingExceptions = ( "volume", "input", "mute", "sleep" );
|
||||
my @readingExceptions = (
|
||||
"volume", "input", "mute", "sleep", "center-temporary-level",
|
||||
"subwoofer-temporary-level", "balance", "preset",
|
||||
);
|
||||
|
||||
if ( $cmd_raw && !( grep $_ eq $reading, @readingExceptions ) ) {
|
||||
my $cmd_details =
|
||||
@ -583,9 +619,44 @@ sub ONKYO_AVR_ZONE_Set($$$) {
|
||||
elsif ( $reading =~ /^tone.*-([a-zA-Z]+)$/ ) {
|
||||
$implicit_txt .= " $reading:slider,-10,1,10";
|
||||
}
|
||||
|
||||
# balance
|
||||
elsif ( $reading eq "balance" ) {
|
||||
$implicit_txt .= " $reading:slider,-10,1,10";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
my $preset_txt = "";
|
||||
if ( defined( $IOhash->{helper}{receiver}{preset} ) ) {
|
||||
|
||||
foreach my $id (
|
||||
sort
|
||||
keys %{ $IOhash->{helper}{receiver}{preset} }
|
||||
)
|
||||
{
|
||||
my $presetName =
|
||||
$IOhash->{helper}{receiver}{preset}{$id};
|
||||
next if ( !$presetName || $presetName eq "" );
|
||||
|
||||
$preset_txt = "preset:" if ( $preset_txt eq "" );
|
||||
$preset_txt .= ","
|
||||
if ( $preset_txt eq "preset:"
|
||||
&& ReadingsVal( $name, "preset", "-" ) eq "" );
|
||||
|
||||
$presetName =~ s/\s/_/g;
|
||||
$preset_txt .= $presetName . ",";
|
||||
}
|
||||
}
|
||||
$preset_txt = substr( $preset_txt, 0, -1 ) if ( $preset_txt ne "" );
|
||||
|
||||
if ( $preset_txt eq "" ) {
|
||||
$preset_txt = "preset:";
|
||||
$preset_txt .= "," if ( ReadingsVal( $name, "preset", "-" ) eq "" );
|
||||
$preset_txt .=
|
||||
"1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40";
|
||||
}
|
||||
|
||||
my $shuffle_txt = "shuffle:";
|
||||
$shuffle_txt .= "," if ( ReadingsVal( $name, "shuffle", "-" ) eq "-" );
|
||||
$shuffle_txt .= "off,on,on-album,on-folder";
|
||||
@ -597,9 +668,10 @@ sub ONKYO_AVR_ZONE_Set($$$) {
|
||||
my $usage =
|
||||
"Unknown argument '"
|
||||
. @$a[1]
|
||||
. "', choose one of toggle:noArg on:noArg off:noArg volume:slider,0,1,100 volumeUp:noArg volumeDown:noArg mute:off,on muteT:noArg play:noArg pause:noArg stop:noArg previous:noArg next:noArg shuffleT:noArg repeatT:noArg remoteControl:play,pause,repeat,stop,top,down,up,right,delete,display,ff,left,mode,return,rew,select,setup,0,1,2,3,4,5,6,7,8,9,prev,next,shuffle,menu channelDown:noArg channelUp:noArg input:"
|
||||
. "', choose one of toggle:noArg on:noArg off:noArg volume:slider,0,1,100 volumeDown:noArg volumeUp:noArg mute:off,on muteT:noArg play:noArg pause:noArg stop:noArg previous:noArg next:noArg shuffleT:noArg repeatT:noArg remoteControl:play,pause,repeat,stop,top,down,up,right,delete,display,ff,left,mode,return,rew,select,setup,0,1,2,3,4,5,6,7,8,9,prev,next,shuffle,menu channelDown:noArg channelUp:noArg inputDown:noArg inputUp:noArg internet-radio-preset:1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40 input:"
|
||||
. $inputs_txt;
|
||||
$usage .= " channel:$channels_txt";
|
||||
$usage .= " presetDown:noArg presetUp:noArg $preset_txt";
|
||||
$usage .= " $shuffle_txt";
|
||||
$usage .= " $repeat_txt";
|
||||
$usage .= $implicit_txt if ( $implicit_txt ne "" );
|
||||
@ -669,7 +741,8 @@ sub ONKYO_AVR_ZONE_Set($$$) {
|
||||
}
|
||||
|
||||
$return =
|
||||
ONKYO_AVR_SendCommand( $IOhash, "net-service", $servicename )
|
||||
ONKYO_AVR_ZONE_SendCommand( $IOhash, "net-service",
|
||||
$servicename )
|
||||
if ( $servicename ne "" );
|
||||
|
||||
$return = "Unknown network service name " . @$a[2]
|
||||
@ -696,6 +769,88 @@ sub ONKYO_AVR_ZONE_Set($$$) {
|
||||
}
|
||||
}
|
||||
|
||||
# preset
|
||||
elsif ( lc( @$a[1] ) eq "preset" ) {
|
||||
Log3 $name, 3, "ONKYO_AVR_ZONE set $name " . @$a[1] . " " . @$a[2];
|
||||
|
||||
if ( !defined( @$a[2] ) ) {
|
||||
$return = "No argument given";
|
||||
}
|
||||
else {
|
||||
if ( $state eq "off" ) {
|
||||
$return =
|
||||
"Device power is turned off, this function is unavailable at that stage.";
|
||||
}
|
||||
elsif ( lc( @$a[2] ) eq "up" ) {
|
||||
$return =
|
||||
ONKYO_AVR_ZONE_SendCommand( $hash, lc( @$a[1] ), "UP" );
|
||||
}
|
||||
elsif ( lc( @$a[2] ) eq "down" ) {
|
||||
$return =
|
||||
ONKYO_AVR_ZONE_SendCommand( $hash, lc( @$a[1] ), "DOWN" );
|
||||
}
|
||||
elsif ( @$a[2] =~ /^\d*$/ ) {
|
||||
$return = ONKYO_AVR_ZONE_SendCommand(
|
||||
$hash,
|
||||
lc( @$a[1] ),
|
||||
ONKYO_AVR_dec2hex( @$a[2] )
|
||||
);
|
||||
}
|
||||
elsif ( defined( $IOhash->{helper}{receiver}{preset} ) ) {
|
||||
|
||||
foreach
|
||||
my $id ( sort keys %{ $IOhash->{helper}{receiver}{preset} } )
|
||||
{
|
||||
my $presetName =
|
||||
$IOhash->{helper}{receiver}{preset}{$id};
|
||||
next if ( !$presetName || $presetName eq "" );
|
||||
|
||||
$presetName =~ s/\s/_/g;
|
||||
|
||||
if ( $presetName eq @$a[2] ) {
|
||||
$return =
|
||||
ONKYO_AVR_ZONE_SendCommand( $hash, lc( @$a[1] ),
|
||||
uc($id) );
|
||||
|
||||
last;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# presetDown
|
||||
elsif ( lc( @$a[1] ) eq "presetdown" ) {
|
||||
Log3 $name, 3, "ONKYO_AVR set $name " . @$a[1];
|
||||
|
||||
if ( $presence eq "absent" ) {
|
||||
$return = "Device needs to be ON to change input.";
|
||||
}
|
||||
elsif ( $state eq "off" ) {
|
||||
$return = fhem "set $name on";
|
||||
$return = ONKYO_AVR_ZONE_SendCommand( $hash, "preset", "down" );
|
||||
}
|
||||
else {
|
||||
$return = ONKYO_AVR_ZONE_SendCommand( $hash, "preset", "down" );
|
||||
}
|
||||
}
|
||||
|
||||
# presetUp
|
||||
elsif ( lc( @$a[1] ) eq "presetup" ) {
|
||||
Log3 $name, 3, "ONKYO_AVR set $name " . @$a[1];
|
||||
|
||||
if ( $presence eq "absent" ) {
|
||||
$return = "Device needs to be ON to change input.";
|
||||
}
|
||||
elsif ( $state eq "off" ) {
|
||||
$return = fhem "set $name on";
|
||||
$return = ONKYO_AVR_ZONE_SendCommand( $hash, "preset", "up" );
|
||||
}
|
||||
else {
|
||||
$return = ONKYO_AVR_ZONE_SendCommand( $hash, "preset", "up" );
|
||||
}
|
||||
}
|
||||
|
||||
# tone-*
|
||||
elsif ( lc( @$a[1] ) =~ /^(tone.*)-(bass|treble)$/ ) {
|
||||
Log3 $name, 3, "ONKYO_AVR_ZONE set $name " . @$a[1] . " " . @$a[2];
|
||||
@ -713,14 +868,14 @@ sub ONKYO_AVR_ZONE_Set($$$) {
|
||||
$setVal = "B" if ( $2 eq "bass" );
|
||||
$setVal = "T" if ( $2 eq "treble" );
|
||||
$return =
|
||||
ONKYO_AVR_SendCommand( $hash, lc($1), $setVal . "UP" );
|
||||
ONKYO_AVR_ZONE_SendCommand( $hash, lc($1), $setVal . "UP" );
|
||||
}
|
||||
elsif ( lc( @$a[2] ) eq "down" ) {
|
||||
my $setVal;
|
||||
$setVal = "B" if ( $2 eq "bass" );
|
||||
$setVal = "T" if ( $2 eq "treble" );
|
||||
$return =
|
||||
ONKYO_AVR_SendCommand( $hash, lc($1), $setVal . "DOWN" );
|
||||
ONKYO_AVR_ZONE_SendCommand( $hash, lc($1), $setVal . "DOWN" );
|
||||
}
|
||||
elsif ( @$a[2] =~ /^-*\d+$/ ) {
|
||||
my $setVal;
|
||||
@ -735,7 +890,45 @@ sub ONKYO_AVR_ZONE_Set($$$) {
|
||||
$setVal2 = substr( $setVal2, 1 ) if ( $setVal2 ne "00" );
|
||||
|
||||
$return =
|
||||
ONKYO_AVR_SendCommand( $hash, lc($1), $setVal . $setVal2 );
|
||||
ONKYO_AVR_ZONE_SendCommand( $hash, lc($1),
|
||||
$setVal . $setVal2 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# balance
|
||||
elsif ( lc( @$a[1] ) eq "balance" ) {
|
||||
Log3 $name, 3, "ONKYO_AVR set $name " . @$a[1] . " " . @$a[2];
|
||||
|
||||
if ( !defined( @$a[2] ) ) {
|
||||
$return = "No argument given";
|
||||
}
|
||||
else {
|
||||
if ( $state eq "off" ) {
|
||||
$return =
|
||||
"Device power is turned off, this function is unavailable at that stage.";
|
||||
}
|
||||
elsif ( lc( @$a[2] ) eq "up" ) {
|
||||
$return = ONKYO_AVR_ZONE_SendCommand( $hash, lc($1), "UP" );
|
||||
}
|
||||
elsif ( lc( @$a[2] ) eq "down" ) {
|
||||
$return = ONKYO_AVR_ZONE_SendCommand( $hash, lc($1), "DOWN" );
|
||||
}
|
||||
elsif ( @$a[2] =~ /^-*\d+$/ ) {
|
||||
my $setVal;
|
||||
$setVal = "+" if ( @$a[2] > 0 );
|
||||
$setVal = "-" if ( @$a[2] < 0 );
|
||||
|
||||
my $setVal2 = @$a[2];
|
||||
$setVal2 = substr( $setVal2, 1 ) if ( $setVal2 < 0 );
|
||||
$setVal2 = ONKYO_AVR_dec2hex($setVal2);
|
||||
$setVal2 = substr( $setVal2, 1 ) if ( $setVal2 ne "00" );
|
||||
|
||||
$return = ONKYO_AVR_ZONE_SendCommand(
|
||||
$hash,
|
||||
lc( @$a[1] ),
|
||||
$setVal . $setVal2
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -854,23 +1047,26 @@ sub ONKYO_AVR_ZONE_Set($$$) {
|
||||
|| lc( @$a[2] ) eq "9" )
|
||||
{
|
||||
$return =
|
||||
ONKYO_AVR_SendCommand( $hash, "net-usb-z", lc( @$a[2] ) );
|
||||
ONKYO_AVR_ZONE_SendCommand( $hash, "net-usb-z",
|
||||
lc( @$a[2] ) );
|
||||
}
|
||||
elsif ( lc( @$a[2] ) eq "prev" ) {
|
||||
$return =
|
||||
ONKYO_AVR_SendCommand( $hash, "net-usb-z", "trdown" );
|
||||
ONKYO_AVR_ZONE_SendCommand( $hash, "net-usb-z",
|
||||
"trdown" );
|
||||
}
|
||||
elsif ( lc( @$a[2] ) eq "next" ) {
|
||||
$return =
|
||||
ONKYO_AVR_SendCommand( $hash, "net-usb-z", "trup" );
|
||||
ONKYO_AVR_ZONE_SendCommand( $hash, "net-usb-z", "trup" );
|
||||
}
|
||||
elsif ( lc( @$a[2] ) eq "shuffle" ) {
|
||||
$return =
|
||||
ONKYO_AVR_SendCommand( $hash, "net-usb-z", "random" );
|
||||
ONKYO_AVR_ZONE_SendCommand( $hash, "net-usb-z",
|
||||
"random" );
|
||||
}
|
||||
elsif ( lc( @$a[2] ) eq "menu" ) {
|
||||
$return =
|
||||
ONKYO_AVR_SendCommand( $hash, "net-usb-z", "men" );
|
||||
ONKYO_AVR_ZONE_SendCommand( $hash, "net-usb-z", "men" );
|
||||
}
|
||||
else {
|
||||
$return = "Unsupported remoteControl command: " . @$a[2];
|
||||
@ -1054,16 +1250,48 @@ sub ONKYO_AVR_ZONE_Set($$$) {
|
||||
else {
|
||||
Log3 $name, 3, "ONKYO_AVR_ZONE set $name " . @$a[1] . " " . @$a[2];
|
||||
|
||||
if ( $state eq "off" ) {
|
||||
if ( $presence eq "absent" ) {
|
||||
$return = "Device needs to be ON to change input.";
|
||||
}
|
||||
elsif ( $state eq "off" ) {
|
||||
$return = fhem "set $name on";
|
||||
$return = ONKYO_AVR_ZONE_SendCommand( $hash, "input", @$a[2] );
|
||||
}
|
||||
elsif ( $state eq "on" ) {
|
||||
else {
|
||||
$return = ONKYO_AVR_ZONE_SendCommand( $hash, "input", @$a[2] );
|
||||
}
|
||||
else {
|
||||
$return = "Device needs to be ON to change input.";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# inputUp
|
||||
elsif ( lc( @$a[1] ) eq "inputup" ) {
|
||||
Log3 $name, 3, "ONKYO_AVR_ZONE set $name " . @$a[1];
|
||||
|
||||
if ( $presence eq "absent" ) {
|
||||
$return = "Device needs to be ON to change input.";
|
||||
}
|
||||
elsif ( $state eq "off" ) {
|
||||
$return = fhem "set $name on";
|
||||
$return = ONKYO_AVR_ZONE_SendCommand( $hash, "input", "up" );
|
||||
}
|
||||
else {
|
||||
$return = ONKYO_AVR_ZONE_SendCommand( $hash, "input", "up" );
|
||||
}
|
||||
}
|
||||
|
||||
# inputDown
|
||||
elsif ( lc( @$a[1] ) eq "inputdown" ) {
|
||||
Log3 $name, 3, "ONKYO_AVR_ZONE set $name " . @$a[1];
|
||||
|
||||
if ( $presence eq "absent" ) {
|
||||
$return = "Device needs to be ON to change input.";
|
||||
}
|
||||
elsif ( $state eq "off" ) {
|
||||
$return = fhem "set $name on";
|
||||
$return = ONKYO_AVR_ZONE_SendCommand( $hash, "input", "down" );
|
||||
}
|
||||
else {
|
||||
$return = ONKYO_AVR_ZONE_SendCommand( $hash, "input", "down" );
|
||||
}
|
||||
}
|
||||
|
||||
@ -1239,6 +1467,12 @@ sub ONKYO_AVR_ZONE_GetStateAV($) {
|
||||
<li>
|
||||
<b>input</b> - switches between inputs
|
||||
</li>
|
||||
<li>
|
||||
<b>inputDown</b> - switches one input down
|
||||
</li>
|
||||
<li>
|
||||
<b>inputUp</b> - switches one input up
|
||||
</li>
|
||||
<li>
|
||||
<b>mute</b> on,off - controls volume mute
|
||||
</li>
|
||||
@ -1263,6 +1497,15 @@ sub ONKYO_AVR_ZONE_GetStateAV($) {
|
||||
<li>
|
||||
<b>power</b> on,off - set power mode
|
||||
</li>
|
||||
<li>
|
||||
<b>preset</b> - switches between presets
|
||||
</li>
|
||||
<li>
|
||||
<b>presetDown</b> - switches one preset down
|
||||
</li>
|
||||
<li>
|
||||
<b>presetUp</b> - switches one preset up
|
||||
</li>
|
||||
<li>
|
||||
<b>previous</b> - back to previous track
|
||||
</li>
|
||||
|
@ -102,7 +102,7 @@ my $ONKYO_cmds_hr = {
|
||||
'net-usb-track-info' => 'NTR',
|
||||
'net-usb' => 'NTC',
|
||||
'preset' => 'PRS',
|
||||
'preset-memory' => 'UPM',
|
||||
'preset-memory' => 'PRM',
|
||||
'pty-scan' => 'PTS',
|
||||
'rds-information' => 'RDS',
|
||||
'record-output' => 'SLR',
|
||||
@ -438,37 +438,29 @@ my $ONKYO_values_hr = {
|
||||
'stop' => 'STOP'
|
||||
},
|
||||
'CPT' => {
|
||||
'0' => '0',
|
||||
'1' => '1',
|
||||
'10' => '10',
|
||||
'2' => '2',
|
||||
'3' => '3',
|
||||
'4' => '4',
|
||||
'5' => '5',
|
||||
'6' => '6',
|
||||
'7' => '7',
|
||||
'8' => '8',
|
||||
'9' => '9',
|
||||
'disp' => 'DISP',
|
||||
'down' => 'DOWN',
|
||||
'enter' => 'ENTER',
|
||||
'ff' => 'FF',
|
||||
'left' => 'LEFT',
|
||||
'mode' => 'MODE',
|
||||
'pause' => 'PAUSE',
|
||||
'play' => 'PLAY',
|
||||
'prsdn' => 'PRSDN',
|
||||
'prsup' => 'PRSUP',
|
||||
'repeat' => 'REPEAT',
|
||||
'return' => 'RETURN',
|
||||
'rew' => 'REW',
|
||||
'right' => 'RIGHT',
|
||||
'setup' => 'SETUP',
|
||||
'shuffle' => 'SHUFFLE',
|
||||
'skip-f' => 'SKIP.F',
|
||||
'skip-r' => 'SKIP.R',
|
||||
'stop' => 'STOP',
|
||||
'up' => 'UP'
|
||||
'0' => '0',
|
||||
'1' => '1',
|
||||
'10' => '10',
|
||||
'2' => '2',
|
||||
'3' => '3',
|
||||
'4' => '4',
|
||||
'5' => '5',
|
||||
'6' => '6',
|
||||
'7' => '7',
|
||||
'8' => '8',
|
||||
'9' => '9',
|
||||
'disp' => 'DISP',
|
||||
'down' => 'DOWN',
|
||||
'enter' => 'ENTER',
|
||||
'ff' => 'FF',
|
||||
'left' => 'LEFT',
|
||||
'mode' => 'MODE',
|
||||
'pause' => 'PAUSE',
|
||||
'play' => 'PLAY',
|
||||
'skip-f' => 'SKIP.F',
|
||||
'skip-r' => 'SKIP.R',
|
||||
'stop' => 'STOP',
|
||||
'up' => 'UP'
|
||||
},
|
||||
'CT1' => {
|
||||
'ff' => 'FF',
|
||||
@ -831,14 +823,14 @@ my $ONKYO_values_hr = {
|
||||
'up' => 'UP',
|
||||
'video' => 'VIDEO'
|
||||
},
|
||||
'PRM' => {
|
||||
'xrange(1, 40)' => '(1, 40)',
|
||||
'xrange(1, 30)' => '(1, 30)'
|
||||
},
|
||||
'PRS' => {
|
||||
'xrange(1, 40)' => '(1, 40)',
|
||||
'xrange(1, 30)' => '(1, 30)',
|
||||
'up' => 'UP',
|
||||
'down' => 'DOWN',
|
||||
'query' => 'QSTN',
|
||||
'up' => 'UP',
|
||||
},
|
||||
'PRM' => {
|
||||
'xrange(1, 40)' => '(1, 40)',
|
||||
'xrange(1, 30)' => '(1, 30)'
|
||||
},
|
||||
@ -1270,13 +1262,6 @@ my $ONKYO_values_hr = {
|
||||
'trup' => 'TRUP',
|
||||
'up' => 'UP'
|
||||
},
|
||||
'PRS' => {
|
||||
'down' => 'DOWN',
|
||||
'query' => 'QSTN',
|
||||
'up' => 'UP',
|
||||
'xrange(1, 40)' => '(1, 40)',
|
||||
'xrange(1, 30)' => '(1, 30)'
|
||||
},
|
||||
'PRZ' => {
|
||||
'down' => 'DOWN',
|
||||
'query' => 'QSTN',
|
||||
@ -1445,13 +1430,6 @@ my $ONKYO_values_hr = {
|
||||
'xrange(1, 40)' => '(1, 40)',
|
||||
'xrange(1, 30)' => '(1, 30)'
|
||||
},
|
||||
'PRS' => {
|
||||
'down' => 'DOWN',
|
||||
'query' => 'QSTN',
|
||||
'up' => 'UP',
|
||||
'xrange(1, 40)' => '(1, 40)',
|
||||
'xrange(1, 30)' => '(1, 30)'
|
||||
},
|
||||
'PW3' => {
|
||||
'off' => '00',
|
||||
'on' => '01',
|
||||
@ -1585,13 +1563,6 @@ my $ONKYO_values_hr = {
|
||||
'xrange(1, 40)' => '(1, 40)',
|
||||
'xrange(1, 30)' => '(1, 30)'
|
||||
},
|
||||
'PRS' => {
|
||||
'down' => 'DOWN',
|
||||
'query' => 'QSTN',
|
||||
'up' => 'UP',
|
||||
'xrange(1, 40)' => '(1, 40)',
|
||||
'xrange(1, 30)' => '(1, 30)'
|
||||
},
|
||||
'PW4' => {
|
||||
'off' => '00',
|
||||
'on' => '01',
|
||||
@ -6299,40 +6270,6 @@ ii-> Service icon
|
||||
}
|
||||
}
|
||||
},
|
||||
'PRS',
|
||||
{
|
||||
'description' => 'Preset Command',
|
||||
'name' => 'preset',
|
||||
'values' => {
|
||||
'{1,40}',
|
||||
{
|
||||
'description' =>
|
||||
'sets Preset No. 1 - 40 { In hexadecimal representation}',
|
||||
'name' => 'no-1-40'
|
||||
},
|
||||
'{1,30}',
|
||||
{
|
||||
'description' =>
|
||||
'sets Preset No. 1 - 30 { In hexadecimal representation}',
|
||||
'name' => 'no-1-30'
|
||||
},
|
||||
'UP',
|
||||
{
|
||||
'description' => 'sets Preset No. Wrap-Around Up',
|
||||
'name' => 'up'
|
||||
},
|
||||
'DOWN',
|
||||
{
|
||||
'description' => 'sets Preset No. Wrap-Around Down',
|
||||
'name' => 'down'
|
||||
},
|
||||
'QSTN',
|
||||
{
|
||||
'description' => 'gets The Preset No.',
|
||||
'name' => 'query'
|
||||
}
|
||||
}
|
||||
},
|
||||
'PRZ',
|
||||
{
|
||||
'description' => 'Preset Command',
|
||||
@ -7024,40 +6961,6 @@ ii-> Service icon
|
||||
}
|
||||
}
|
||||
},
|
||||
'PRS',
|
||||
{
|
||||
'description' => 'Preset Command',
|
||||
'name' => 'preset',
|
||||
'values' => {
|
||||
'{1,40}',
|
||||
{
|
||||
'description' =>
|
||||
'sets Preset No. 1 - 40 { In hexadecimal representation}',
|
||||
'name' => 'no-1-40'
|
||||
},
|
||||
'{1,30}',
|
||||
{
|
||||
'description' =>
|
||||
'sets Preset No. 1 - 30 { In hexadecimal representation}',
|
||||
'name' => 'no-1-30'
|
||||
},
|
||||
'UP',
|
||||
{
|
||||
'description' => 'sets Preset No. Wrap-Around Up',
|
||||
'name' => 'up'
|
||||
},
|
||||
'DOWN',
|
||||
{
|
||||
'description' => 'sets Preset No. Wrap-Around Down',
|
||||
'name' => 'down'
|
||||
},
|
||||
'QSTN',
|
||||
{
|
||||
'description' => 'gets The Preset No.',
|
||||
'name' => 'query'
|
||||
}
|
||||
}
|
||||
},
|
||||
'PR3',
|
||||
{
|
||||
'description' => 'Preset Command',
|
||||
@ -7580,40 +7483,6 @@ ii-> Service icon
|
||||
}
|
||||
}
|
||||
},
|
||||
'PRS',
|
||||
{
|
||||
'description' => 'Preset Command',
|
||||
'name' => 'preset',
|
||||
'values' => {
|
||||
'{1,40}',
|
||||
{
|
||||
'description' =>
|
||||
'sets Preset No. 1 - 40 { In hexadecimal representation}',
|
||||
'name' => 'no-1-40'
|
||||
},
|
||||
'{1,30}',
|
||||
{
|
||||
'description' =>
|
||||
'sets Preset No. 1 - 30 { In hexadecimal representation}',
|
||||
'name' => 'no-1-30'
|
||||
},
|
||||
'UP',
|
||||
{
|
||||
'description' => 'sets Preset No. Wrap-Around Up',
|
||||
'name' => 'up'
|
||||
},
|
||||
'DOWN',
|
||||
{
|
||||
'description' => 'sets Preset No. Wrap-Around Down',
|
||||
'name' => 'down'
|
||||
},
|
||||
'QSTN',
|
||||
{
|
||||
'description' => 'gets The Preset No.',
|
||||
'name' => 'query'
|
||||
}
|
||||
}
|
||||
},
|
||||
'PR4',
|
||||
{
|
||||
'description' => 'Preset Command',
|
||||
|
Loading…
Reference in New Issue
Block a user