mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-25 22:09:21 +00:00
70_ONKYO_AVR.pm,71_ONKYO_AVR_ZONE.pm,ONKYOdb.pm: implement tone setters
git-svn-id: https://svn.fhem.de/fhem/trunk@11579 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
a2ddca6b5f
commit
b2dea82964
@ -488,6 +488,8 @@ sub ONKYO_AVR_Read($) {
|
||||
|
||||
Log3 $name, 4,
|
||||
"ONKYO_AVR $name: con $cmd($cmd_raw$value_raw): FAIL: Don't know how to convert, not in ONKYOdb or zone may not be defined: $cmd_raw$value_raw";
|
||||
|
||||
return if ( !$cmd_raw || $cmd_raw eq "" );
|
||||
}
|
||||
|
||||
# reset connectionCheck timer
|
||||
@ -822,6 +824,45 @@ sub ONKYO_AVR_Read($) {
|
||||
}
|
||||
}
|
||||
|
||||
elsif ( $cmd eq "net-usb-device-status" ) {
|
||||
if ( $value =~ /^(.)(.)(.)$/ ) {
|
||||
|
||||
# networkConnection
|
||||
my $netConnStatus = "none";
|
||||
$netConnStatus = "ethernet" if ( $1 eq "E" );
|
||||
$netConnStatus = "wireless" if ( $1 eq "W" );
|
||||
|
||||
readingsBulkUpdate( $hash, "networkConnection", $netConnStatus )
|
||||
if ( ReadingsVal( $name, "networkConnection", "-" ) ne
|
||||
$netConnStatus );
|
||||
|
||||
# usbFront
|
||||
my $usbFront = "none";
|
||||
$usbFront = "iOS" if ( $2 eq "i" );
|
||||
$usbFront = "Memory_NAS" if ( $2 eq "M" );
|
||||
$usbFront = "wireless" if ( $2 eq "W" );
|
||||
$usbFront = "bluetooth" if ( $2 eq "B" );
|
||||
$usbFront = "GoogleUSB" if ( $2 eq "G" );
|
||||
$usbFront = "disabled" if ( $2 eq "x" );
|
||||
|
||||
readingsBulkUpdate( $hash, "usbFront", $usbFront )
|
||||
if ( ReadingsVal( $name, "usbFront", "-" ) ne $usbFront );
|
||||
|
||||
# usbRear
|
||||
my $usbRear = "none";
|
||||
$usbRear = "iOS" if ( $3 eq "i" );
|
||||
$usbRear = "Memory_NAS" if ( $3 eq "M" );
|
||||
$usbRear = "wireless" if ( $3 eq "W" );
|
||||
$usbRear = "bluetooth" if ( $3 eq "B" );
|
||||
$usbRear = "GoogleUSB" if ( $3 eq "G" );
|
||||
$usbRear = "disabled" if ( $3 eq "x" );
|
||||
|
||||
readingsBulkUpdate( $hash, "usbRear", $usbRear )
|
||||
if ( ReadingsVal( $name, "usbRear", "-" ) ne $usbRear );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
elsif ( $cmd eq "net-usb-jacket-art" ) {
|
||||
if ( $value =~ /^([0|1])([0|1|2])(.*)$/ ) {
|
||||
my $type = "bmp";
|
||||
@ -853,7 +894,7 @@ sub ONKYO_AVR_Read($) {
|
||||
"ONKYO_AVR $name: rcv $cmd($type) completed in "
|
||||
. $hash->{helper}{cover}{$type}{parts}
|
||||
. " parts. Saved to $AlbumArtURI";
|
||||
|
||||
|
||||
$hash->{helper}{cover}{$type}{data} = "SAVED to $AlbumArtURI";
|
||||
}
|
||||
}
|
||||
@ -1324,6 +1365,44 @@ sub ONKYO_AVR_Read($) {
|
||||
elsif ( $cmd eq "net-popup-message" ) {
|
||||
}
|
||||
|
||||
# tone-*
|
||||
elsif ( $cmd =~ /^tone-/ ) {
|
||||
if ( $value =~ /^B(..)T(..)$/ ) {
|
||||
my $bass = $1;
|
||||
my $treble = $2;
|
||||
my $bassName = $cmd . "-bass";
|
||||
my $trebleName = $cmd . "-treble";
|
||||
my $prefixBass = "";
|
||||
my $prefixTreble = "";
|
||||
|
||||
# tone-*-bass
|
||||
$prefixBass = "-" if ( $bass =~ /^\-.*/ );
|
||||
$bass = substr( $bass, 1 ) if ( $bass =~ /^[\+|\-].*/ );
|
||||
$bass = $prefixBass . ONKYO_AVR_hex2dec($bass);
|
||||
readingsBulkUpdate( $hash, $bassName, $bass )
|
||||
if ( ReadingsVal( $name, $bassName, "-" ) ne $bass );
|
||||
|
||||
# tone-*-treble
|
||||
$prefixTreble = "-" if ( $treble =~ /^\-.*/ );
|
||||
$treble = substr( $treble, 1 ) if ( $treble =~ /^[\+|\-].*/ );
|
||||
$treble = $prefixTreble . ONKYO_AVR_hex2dec($treble);
|
||||
readingsBulkUpdate( $hash, $trebleName, $treble )
|
||||
if ( ReadingsVal( $name, $trebleName, "-" ) ne $treble );
|
||||
}
|
||||
|
||||
# tone-subwoofer
|
||||
elsif ( $value =~ /^B(..)$/ ) {
|
||||
my $bass = $1;
|
||||
my $prefix = "";
|
||||
|
||||
$prefix = "-" if ( $bass =~ /^\-.*/ );
|
||||
$bass = substr( $bass, 1 ) if ( $bass =~ /^[\+|\-].*/ );
|
||||
$bass = $prefix . ONKYO_AVR_hex2dec($bass);
|
||||
readingsBulkUpdate( $hash, $cmd, $bass )
|
||||
if ( ReadingsVal( $name, $cmd, "-" ) ne $bass );
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
if ( $cmd eq "input" ) {
|
||||
|
||||
@ -1336,6 +1415,18 @@ sub ONKYO_AVR_Read($) {
|
||||
}
|
||||
}
|
||||
|
||||
# subwoofer-temporary-level
|
||||
# center-temporary-level
|
||||
elsif ($cmd eq "subwoofer-temporary-level"
|
||||
|| $cmd eq "center-temporary-level" )
|
||||
{
|
||||
my $prefix = "";
|
||||
$prefix = "-" if ( $value =~ /^\-.*/ );
|
||||
$value = substr( $value, 1 ) if ( $value =~ /^[\+|\-].*/ );
|
||||
|
||||
$value = $prefix . ONKYO_AVR_hex2dec($value);
|
||||
}
|
||||
|
||||
readingsBulkUpdate( $hash, $cmd, $value )
|
||||
if ( ReadingsVal( $name, $cmd, "-" ) ne $value );
|
||||
|
||||
@ -1531,8 +1622,14 @@ sub ONKYO_AVR_Get($$$) {
|
||||
{
|
||||
next
|
||||
if (
|
||||
$hash->{helper}{receiver}{device}{zonelist}{zone}{$zoneID}
|
||||
{value} ne "1" || $zoneID eq "1" );
|
||||
!defined(
|
||||
$hash->{helper}{receiver}{device}{zonelist}{zone}
|
||||
{$zoneID}{value}
|
||||
)
|
||||
|| $hash->{helper}{receiver}{device}{zonelist}{zone}
|
||||
{$zoneID}{value} ne "1"
|
||||
|| $zoneID eq "1"
|
||||
);
|
||||
$zones .= "," if ( $zones ne "" );
|
||||
$zones .= $zoneID;
|
||||
}
|
||||
@ -1669,7 +1766,10 @@ sub ONKYO_AVR_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"
|
||||
);
|
||||
|
||||
if ( $cmd_raw && !( grep $_ eq $reading, @readingExceptions ) ) {
|
||||
my $cmd_details =
|
||||
@ -1701,6 +1801,21 @@ sub ONKYO_AVR_Set($$$) {
|
||||
$implicit_txt .= " $reading:$value_list";
|
||||
}
|
||||
}
|
||||
|
||||
# tone-*
|
||||
elsif ( $reading =~ /^tone.*-([a-zA-Z]+)$/ ) {
|
||||
$implicit_txt .= " $reading:slider,-10,1,10";
|
||||
}
|
||||
|
||||
# center-temporary-level
|
||||
elsif ( $reading eq "center-temporary-level" ) {
|
||||
$implicit_txt .= " $reading:slider,-12,1,12";
|
||||
}
|
||||
|
||||
# subwoofer*-temporary-level
|
||||
elsif ( $reading =~ /^subwoofer.*-temporary-level$/ ) {
|
||||
$implicit_txt .= " $reading:slider,-15,1,12";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1802,7 +1917,7 @@ sub ONKYO_AVR_Set($$$) {
|
||||
Log3 $name, 3, "ONKYO_AVR set $name " . @$a[1] . " " . @$a[2];
|
||||
|
||||
if ( !defined( @$a[2] ) ) {
|
||||
$return = "No argument given, choose one of ?";
|
||||
$return = "No argument given";
|
||||
}
|
||||
else {
|
||||
if ( $presence eq "absent" ) {
|
||||
@ -1815,6 +1930,90 @@ sub ONKYO_AVR_Set($$$) {
|
||||
}
|
||||
}
|
||||
|
||||
# tone-*
|
||||
elsif ( lc( @$a[1] ) =~ /^(tone.*)-(bass|treble)$/ ) {
|
||||
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" ) {
|
||||
my $setVal;
|
||||
$setVal = "B" if ( $2 eq "bass" );
|
||||
$setVal = "T" if ( $2 eq "treble" );
|
||||
$return =
|
||||
ONKYO_AVR_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" );
|
||||
}
|
||||
elsif ( @$a[2] =~ /^-*\d+$/ ) {
|
||||
my $setVal;
|
||||
$setVal = "B" if ( $2 eq "bass" );
|
||||
$setVal = "T" if ( $2 eq "treble" );
|
||||
$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_SendCommand( $hash, lc($1), $setVal . $setVal2 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# center-temporary-level
|
||||
# subwoofer-temporary-level
|
||||
elsif (lc( @$a[1] ) eq "center-temporary-level"
|
||||
|| lc( @$a[1] ) eq "subwoofer-temporary-level" )
|
||||
{
|
||||
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($1), "UP" );
|
||||
}
|
||||
elsif ( lc( @$a[2] ) eq "down" ) {
|
||||
$return = ONKYO_AVR_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_SendCommand(
|
||||
$hash,
|
||||
lc( @$a[1] ),
|
||||
$setVal . $setVal2
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# toggle
|
||||
elsif ( lc( @$a[1] ) eq "toggle" ) {
|
||||
Log3 $name, 3, "ONKYO_AVR set $name " . @$a[1];
|
||||
|
@ -119,7 +119,8 @@ sub ONKYO_AVR_ZONE_Define($$$) {
|
||||
. $modules{ONKYO_AVR_ZONE}{defptr}{$IOname}{$zone}{NAME};
|
||||
}
|
||||
elsif ( !defined($IOhash) ) {
|
||||
return "No matching I/O device found, please define a ONKYO_AVR device first";
|
||||
return
|
||||
"No matching I/O device found, please define a ONKYO_AVR device first";
|
||||
}
|
||||
elsif ( !defined( $IOhash->{TYPE} ) || !defined( $IOhash->{NAME} ) ) {
|
||||
return "IODev does not seem to be existing";
|
||||
@ -221,7 +222,7 @@ sub ONKYO_AVR_ZONE_Parse($$) {
|
||||
}
|
||||
|
||||
# input
|
||||
if ( $cmd eq "input" ) {
|
||||
elsif ( $cmd eq "input" ) {
|
||||
|
||||
# Input alias handling
|
||||
if (
|
||||
@ -240,13 +241,44 @@ sub ONKYO_AVR_ZONE_Parse($$) {
|
||||
}
|
||||
|
||||
# power
|
||||
if ( $cmd eq "power" ) {
|
||||
elsif ( $cmd eq "power" ) {
|
||||
readingsBulkUpdate( $hash, "presence", "present" )
|
||||
if ( ReadingsVal( $name, "presence", "-" ) ne "present" );
|
||||
}
|
||||
|
||||
readingsBulkUpdate( $hash, $cmd, $value )
|
||||
if ( ReadingsVal( $name, $cmd, "-" ) ne $value );
|
||||
# tone
|
||||
if ( $cmd =~ /^tone/ ) {
|
||||
if ( $value =~ /^B(..)T(..)$/ ) {
|
||||
my $bass = $1;
|
||||
my $treble = $2;
|
||||
my $bassName = $cmd . "-bass";
|
||||
my $trebleName = $cmd . "-treble";
|
||||
my $prefixBass = "";
|
||||
my $prefixTreble = "";
|
||||
|
||||
# tone-bass
|
||||
$prefixBass = "-" if ( $bass =~ /^\-.*/ );
|
||||
$bass = substr( $bass, 1 ) if ( $bass =~ /^[\+|\-].*/ );
|
||||
$bass = $prefixBass . ONKYO_AVR_hex2dec($bass);
|
||||
readingsBulkUpdate( $hash, $bassName, $bass )
|
||||
if ( ReadingsVal( $name, $bassName, "-" ) ne $bass );
|
||||
|
||||
# tone-treble
|
||||
$prefixTreble = "-" if ( $treble =~ /^\-.*/ );
|
||||
$treble = substr( $treble, 1 )
|
||||
if ( $treble =~ /^[\+|\-].*/ );
|
||||
$treble = $prefixTreble . ONKYO_AVR_hex2dec($treble);
|
||||
readingsBulkUpdate( $hash, $trebleName, $treble )
|
||||
if (
|
||||
ReadingsVal( $name, $trebleName, "-" ) ne $treble );
|
||||
}
|
||||
}
|
||||
|
||||
# all other commands
|
||||
else {
|
||||
readingsBulkUpdate( $hash, $cmd, $value )
|
||||
if ( ReadingsVal( $name, $cmd, "-" ) ne $value );
|
||||
}
|
||||
}
|
||||
|
||||
# stateAV
|
||||
@ -546,6 +578,11 @@ sub ONKYO_AVR_ZONE_Set($$$) {
|
||||
$implicit_txt .= " $reading:$value_list";
|
||||
}
|
||||
}
|
||||
|
||||
# tone-*
|
||||
elsif ( $reading =~ /^tone.*-([a-zA-Z]+)$/ ) {
|
||||
$implicit_txt .= " $reading:slider,-10,1,10";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -659,6 +696,50 @@ sub ONKYO_AVR_ZONE_Set($$$) {
|
||||
}
|
||||
}
|
||||
|
||||
# tone-*
|
||||
elsif ( lc( @$a[1] ) =~ /^(tone.*)-(bass|treble)$/ ) {
|
||||
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" ) {
|
||||
my $setVal;
|
||||
$setVal = "B" if ( $2 eq "bass" );
|
||||
$setVal = "T" if ( $2 eq "treble" );
|
||||
$return =
|
||||
ONKYO_AVR_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" );
|
||||
}
|
||||
elsif ( @$a[2] =~ /^-*\d+$/ ) {
|
||||
my $setVal;
|
||||
$setVal = "B" if ( $2 eq "bass" );
|
||||
$setVal = "T" if ( $2 eq "treble" );
|
||||
$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_SendCommand( $hash, lc($1), $setVal . $setVal2 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# toggle
|
||||
elsif ( lc( @$a[1] ) eq "toggle" ) {
|
||||
Log3 $name, 3, "ONKYO_AVR_ZONE set $name " . @$a[1];
|
||||
|
@ -88,7 +88,7 @@ my $ONKYO_cmds_hr = {
|
||||
'net-popup-message' => 'NPU',
|
||||
'net-receiver-information' => 'NRI',
|
||||
'net-service' => 'NSV',
|
||||
'net-standby' => 'NSB',
|
||||
'network-standby' => 'NSB',
|
||||
'net-usb-album-name-info' => 'NAL',
|
||||
'net-usb-artist-name-info' => 'NAT',
|
||||
'net-usb-jacket-art' => 'NJA',
|
||||
@ -119,6 +119,7 @@ my $ONKYO_cmds_hr = {
|
||||
'speaker-layout' => 'SPL',
|
||||
'speaker-level-calibration' => 'SLC',
|
||||
'subwoofer-temporary-level' => 'SWL',
|
||||
'subwoofer2-temporary-level' => 'SW2',
|
||||
'phase-matching-bass' => 'PMB',
|
||||
'power' => 'PWR',
|
||||
'tape1-a' => 'CT1',
|
||||
@ -1031,6 +1032,12 @@ my $ONKYO_values_hr = {
|
||||
'up' => 'UP',
|
||||
'xrange(-15, 9, 12)' => '(-15, 0, 12)'
|
||||
},
|
||||
'SW2' => {
|
||||
'down' => 'DOWN',
|
||||
'query' => 'QSTN',
|
||||
'up' => 'UP',
|
||||
'xrange(-15, 9, 12)' => '(-15, 0, 12)'
|
||||
},
|
||||
'TCT' => {
|
||||
'b-xx' => 'B{xx}',
|
||||
'bass-down' => 'BDOWN',
|
||||
@ -2246,6 +2253,27 @@ my $ONKYO_cmddb = {
|
||||
}
|
||||
}
|
||||
},
|
||||
'SW2',
|
||||
{
|
||||
'description' => 'Subwoofer2 {temporary} Level Command',
|
||||
'name' => 'subwoofer2-temporary-level',
|
||||
'values' => {
|
||||
'{-15,0,12}',
|
||||
{
|
||||
'description' => 'sets Subwoofer Level -15dB - 0dB - +12dB',
|
||||
'name' => '15db-0db-12db'
|
||||
},
|
||||
'UP',
|
||||
{ 'description' => 'LEVEL + Key', 'name' => 'up' },
|
||||
'DOWN',
|
||||
{ 'description' => 'LEVEL KEY', 'name' => 'down' },
|
||||
'QSTN',
|
||||
{
|
||||
'description' => 'gets the Subwoofer Level',
|
||||
'name' => 'query'
|
||||
}
|
||||
}
|
||||
},
|
||||
'CTL',
|
||||
{
|
||||
'description' => 'Center {temporary} Level Command',
|
||||
@ -4647,7 +4675,7 @@ ii-> Service icon
|
||||
{
|
||||
'description' =>
|
||||
'Network Standby Settings (for Network Control Only and Available in AVR is PowerOn)',
|
||||
'name' => 'net-standby',
|
||||
'name' => 'network-standby',
|
||||
'values' => {
|
||||
'OFF',
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user