70_ONKYO_AVR.pm: fix album art dispatching and add more flexible channel handling
git-svn-id: https://svn.fhem.de/fhem/trunk@12257 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
@@ -1015,6 +1015,10 @@ sub ONKYO_AVR_Read($) {
|
|||||||
readingsBulkUpdate( $hash, "currentAlbumArtURI", "" );
|
readingsBulkUpdate( $hash, "currentAlbumArtURI", "" );
|
||||||
readingsBulkUpdate( $hash, "currentAlbumArtURL",
|
readingsBulkUpdate( $hash, "currentAlbumArtURL",
|
||||||
$hash->{helper}{currentCover} );
|
$hash->{helper}{currentCover} );
|
||||||
|
|
||||||
|
$zoneDispatch->{currentAlbumArtURI} = "";
|
||||||
|
$zoneDispatch->{currentAlbumArtURL} =
|
||||||
|
$hash->{helper}{currentCover};
|
||||||
}
|
}
|
||||||
elsif ($2 eq "2"
|
elsif ($2 eq "2"
|
||||||
&& $type ne "link"
|
&& $type ne "link"
|
||||||
@@ -1041,6 +1045,9 @@ sub ONKYO_AVR_Read($) {
|
|||||||
|
|
||||||
readingsBulkUpdate( $hash, "currentAlbumArtURI", $AlbumArtURI );
|
readingsBulkUpdate( $hash, "currentAlbumArtURI", $AlbumArtURI );
|
||||||
readingsBulkUpdate( $hash, "currentAlbumArtURL", $AlbumArtURL );
|
readingsBulkUpdate( $hash, "currentAlbumArtURL", $AlbumArtURL );
|
||||||
|
|
||||||
|
$zoneDispatch->{currentAlbumArtURI} = $AlbumArtURI;
|
||||||
|
$zoneDispatch->{currentAlbumArtURL} = $AlbumArtURL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -1105,12 +1112,21 @@ sub ONKYO_AVR_Read($) {
|
|||||||
|
|
||||||
# channel
|
# channel
|
||||||
my $channel = $1 || "00";
|
my $channel = $1 || "00";
|
||||||
|
my $channelUc = uc($channel);
|
||||||
$hash->{CHANNEL} = $channel;
|
$hash->{CHANNEL} = $channel;
|
||||||
$channel = lc($channel);
|
$channel = lc($channel);
|
||||||
my $channelname = "";
|
my $channelname = "";
|
||||||
|
|
||||||
|
# Get all details for command
|
||||||
|
my $command_details =
|
||||||
|
ONKYOdb::ONKYO_GetRemotecontrolCommandDetails( "1",
|
||||||
|
ONKYOdb::ONKYO_GetRemotecontrolCommand( "1", "net-service" ) );
|
||||||
|
|
||||||
|
# we know the channel name from receiver info
|
||||||
if (
|
if (
|
||||||
defined(
|
defined( $hash->{helper}{receiver} )
|
||||||
|
&& ref( $hash->{helper}{receiver} ) eq "HASH"
|
||||||
|
&& defined(
|
||||||
$hash->{helper}{receiver}{device}{netservicelist}
|
$hash->{helper}{receiver}{device}{netservicelist}
|
||||||
{netservice}{$channel}{name}
|
{netservice}{$channel}{name}
|
||||||
)
|
)
|
||||||
@@ -1121,15 +1137,34 @@ sub ONKYO_AVR_Read($) {
|
|||||||
{netservice}{$channel}{name};
|
{netservice}{$channel}{name};
|
||||||
$channelname =~ s/\s/_/g;
|
$channelname =~ s/\s/_/g;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# we know the channel name from ONKYOdb
|
||||||
|
elsif ( defined( $command_details->{values}{$channelUc} ) ) {
|
||||||
|
if (
|
||||||
|
ref( $command_details->{values}{$channelUc}{name} ) eq
|
||||||
|
"ARRAY" )
|
||||||
|
{
|
||||||
|
$channelname =
|
||||||
|
$command_details->{values}{$channelUc}{name}[0];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$channelname = $command_details->{values}{$channelUc}{name};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# some specials for net-usb-list-title-info
|
||||||
elsif ( $channel =~ /^f./ ) {
|
elsif ( $channel =~ /^f./ ) {
|
||||||
$channelname = "USB_Front" if $channel eq "f0";
|
$channelname = "USB_Front" if $channel eq "f0";
|
||||||
$channelname = "USB_Rear" if $channel eq "f1";
|
$channelname = "USB_Rear" if $channel eq "f1";
|
||||||
$channelname = "Internet_Radio" if $channel eq "f2";
|
$channelname = "Internet_Radio" if $channel eq "f2";
|
||||||
$channelname = "" if $channel eq "f3";
|
$channelname = "" if $channel eq "f3";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# we don't know the channel name, sorry
|
||||||
else {
|
else {
|
||||||
Log3 $name, 4,
|
Log3 $name, 4,
|
||||||
"ONKYO_AVR $name: net-usb-list-title-info: received unknown channel ID $channel";
|
"ONKYO_AVR $name: net-usb-list-title-info: received unknown channel ID $channel";
|
||||||
|
$channelname = $channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ReadingsVal( $name, "channel", "-" ) ne $channelname ) {
|
if ( ReadingsVal( $name, "channel", "-" ) ne $channelname ) {
|
||||||
@@ -1162,8 +1197,8 @@ sub ONKYO_AVR_Read($) {
|
|||||||
$zoneDispatch->{CHANNEL_RAW} = $hash->{CHANNEL};
|
$zoneDispatch->{CHANNEL_RAW} = $hash->{CHANNEL};
|
||||||
$zoneDispatch->{channel} = $channelname;
|
$zoneDispatch->{channel} = $channelname;
|
||||||
$zoneDispatch->{currentAlbum} = "";
|
$zoneDispatch->{currentAlbum} = "";
|
||||||
$zoneDispatch->{currentAlbumURI} = $currentAlbumArtURI;
|
$zoneDispatch->{currentAlbumArtURI} = $currentAlbumArtURI;
|
||||||
$zoneDispatch->{currentAlbumURL} = $currentAlbumArtURL;
|
$zoneDispatch->{currentAlbumArtURL} = $currentAlbumArtURL;
|
||||||
$zoneDispatch->{currentArtist} = "";
|
$zoneDispatch->{currentArtist} = "";
|
||||||
$zoneDispatch->{currentTitle} = "";
|
$zoneDispatch->{currentTitle} = "";
|
||||||
$zoneDispatch->{currentTrackPosition} = "--:--";
|
$zoneDispatch->{currentTrackPosition} = "--:--";
|
||||||
@@ -1497,8 +1532,8 @@ sub ONKYO_AVR_Read($) {
|
|||||||
"--:--" );
|
"--:--" );
|
||||||
|
|
||||||
$zoneDispatch->{currentAlbum} = "";
|
$zoneDispatch->{currentAlbum} = "";
|
||||||
$zoneDispatch->{currentAlbumURI} = $currentAlbumArtURI;
|
$zoneDispatch->{currentAlbumArtURI} = $currentAlbumArtURI;
|
||||||
$zoneDispatch->{currentAlbumURL} = $currentAlbumArtURL;
|
$zoneDispatch->{currentAlbumArtURL} = $currentAlbumArtURL;
|
||||||
$zoneDispatch->{currentArtist} = "";
|
$zoneDispatch->{currentArtist} = "";
|
||||||
$zoneDispatch->{currentTitle} = "";
|
$zoneDispatch->{currentTitle} = "";
|
||||||
$zoneDispatch->{currentTrackPosition} = "--:--";
|
$zoneDispatch->{currentTrackPosition} = "--:--";
|
||||||
@@ -1542,7 +1577,40 @@ sub ONKYO_AVR_Read($) {
|
|||||||
elsif ( $cmd =~ /^net-usb/ && $value ne "on" && $value ne "off" ) {
|
elsif ( $cmd =~ /^net-usb/ && $value ne "on" && $value ne "off" ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
elsif ( $cmd =~ /^net-keyboard/ ) {
|
||||||
|
}
|
||||||
|
|
||||||
|
# net-popup-*
|
||||||
elsif ( $cmd eq "net-popup-message" ) {
|
elsif ( $cmd eq "net-popup-message" ) {
|
||||||
|
if ( $value =~
|
||||||
|
/^(B|T|L)(.*[a-z])([A-Z].*[a-z.!?])(0|1|2)([A-Z].*[a-z])$/ )
|
||||||
|
{
|
||||||
|
readingsBulkUpdate( $hash, "net-popup-type", "top" )
|
||||||
|
if ( $1 eq "T" );
|
||||||
|
readingsBulkUpdate( $hash, "net-popup-type", "bottom" )
|
||||||
|
if ( $1 eq "B" );
|
||||||
|
readingsBulkUpdate( $hash, "net-popup-type", "list" )
|
||||||
|
if ( $1 eq "L" );
|
||||||
|
readingsBulkUpdate( $hash, "net-popup-title", $2 );
|
||||||
|
readingsBulkUpdate( $hash, "net-popup-text", $3 );
|
||||||
|
readingsBulkUpdate( $hash, "net-popup-button-position", "hidden" )
|
||||||
|
if ( $4 eq "0" || $4 eq "" );
|
||||||
|
readingsBulkUpdate( $hash, "net-popup-button-position", $4 )
|
||||||
|
if ( $4 ne "0" && $4 ne "" );
|
||||||
|
readingsBulkUpdate( $hash, "net-popup-button1-text", $5 );
|
||||||
|
|
||||||
|
$zoneDispatch->{"net-popup-type"} =
|
||||||
|
ReadingsVal( $name, "net-popup-type", "" );
|
||||||
|
$zoneDispatch->{"net-popup-title"} = $2;
|
||||||
|
$zoneDispatch->{"net-popup-text"} = $3;
|
||||||
|
$zoneDispatch->{"net-popup-button-position"} =
|
||||||
|
ReadingsVal( $name, "net-popup-button-position", "" );
|
||||||
|
$zoneDispatch->{"net-popup-button1-text"} = $5;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Log3 $name, 4,
|
||||||
|
"ONKYO_AVR $name: Could not decompile net-popup-message: $value";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# tone-*
|
# tone-*
|
||||||
@@ -1621,7 +1689,7 @@ sub ONKYO_AVR_Read($) {
|
|||||||
|
|
||||||
$presetName =~ s/\s/_/g;
|
$presetName =~ s/\s/_/g;
|
||||||
|
|
||||||
if ( $id eq ONKYO_AVR_dec2hex($value) ) {
|
if ( $id eq $value ) {
|
||||||
$value = $presetName;
|
$value = $presetName;
|
||||||
last;
|
last;
|
||||||
}
|
}
|
||||||
@@ -1950,6 +2018,7 @@ sub ONKYO_AVR_Set($$$) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# list of network channels/services
|
# list of network channels/services
|
||||||
|
my $channels_src = "internal";
|
||||||
if ( defined( $hash->{helper}{receiver} )
|
if ( defined( $hash->{helper}{receiver} )
|
||||||
&& ref( $hash->{helper}{receiver} ) eq "HASH"
|
&& ref( $hash->{helper}{receiver} ) eq "HASH"
|
||||||
&& defined( $hash->{helper}{receiver}{device}{netservicelist}{count} )
|
&& defined( $hash->{helper}{receiver}{device}{netservicelist}{count} )
|
||||||
@@ -1978,9 +2047,21 @@ sub ONKYO_AVR_Set($$$) {
|
|||||||
|
|
||||||
$channels_txt =~ s/\s/_/g;
|
$channels_txt =~ s/\s/_/g;
|
||||||
$channels_txt = substr( $channels_txt, 0, -1 );
|
$channels_txt = substr( $channels_txt, 0, -1 );
|
||||||
|
$channels_src = "receiver";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# use general list of possible channels
|
||||||
else {
|
else {
|
||||||
$channels_txt = ReadingsVal( $name, "channelList", "" );
|
# Find out valid channels
|
||||||
|
my $channels =
|
||||||
|
ONKYOdb::ONKYO_GetRemotecontrolValue( "1",
|
||||||
|
ONKYOdb::ONKYO_GetRemotecontrolCommand( "1", "net-service" ) );
|
||||||
|
|
||||||
|
foreach my $channel ( sort keys %{$channels} ) {
|
||||||
|
$channels_txt .= $channel . ","
|
||||||
|
if ( !( $channel =~ /^(up|down|query)$/ ) );
|
||||||
|
}
|
||||||
|
$channels_txt = substr( $channels_txt, 0, -1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
# for each reading, check if there is a known command for it
|
# for each reading, check if there is a known command for it
|
||||||
@@ -2113,7 +2194,14 @@ sub ONKYO_AVR_Set($$$) {
|
|||||||
|
|
||||||
# create channelList reading for frontends
|
# create channelList reading for frontends
|
||||||
readingsBulkUpdate( $hash, "channelList", $channels_txt )
|
readingsBulkUpdate( $hash, "channelList", $channels_txt )
|
||||||
if ( ReadingsVal( $name, "channelList", "-" ) ne $channels_txt );
|
if (
|
||||||
|
(
|
||||||
|
$channels_src eq "internal"
|
||||||
|
&& ReadingsVal( $name, "channelList", "-" ) eq "-"
|
||||||
|
)
|
||||||
|
|| ( $channels_src eq "receiver"
|
||||||
|
&& ReadingsVal( $name, "channelList", "-" ) ne $channels_txt )
|
||||||
|
);
|
||||||
|
|
||||||
# channel
|
# channel
|
||||||
if ( lc( @$a[1] ) eq "channel" ) {
|
if ( lc( @$a[1] ) eq "channel" ) {
|
||||||
@@ -2129,54 +2217,73 @@ sub ONKYO_AVR_Set($$$) {
|
|||||||
$return = ONKYO_AVR_SendCommand( $hash, "input", "2B" );
|
$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 ( ReadingsVal( $name, "channel", "" ) ne @$a[2]
|
||||||
ReadingsVal( $name, "channel", "" ) ne @$a[2]
|
|| ( defined( @$a[3] ) && defined( @$a[4] ) ) )
|
||||||
&& defined(
|
|
||||||
$hash->{helper}{receiver}{device}{netservicelist}
|
|
||||||
{netservice}
|
|
||||||
)
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
my $servicename = "";
|
my $servicename = "";
|
||||||
my $channelname = @$a[2];
|
my $channelname = @$a[2];
|
||||||
$channelname =~ s/_/ /g;
|
|
||||||
|
|
||||||
foreach my $id (
|
if (
|
||||||
sort keys %{
|
defined( $hash->{helper}{receiver} )
|
||||||
$hash->{helper}{receiver}{device}{netservicelist}
|
&& ref( $hash->{helper}{receiver} ) eq "HASH"
|
||||||
{netservice}
|
&& defined(
|
||||||
}
|
$hash->{helper}{receiver}{device}{netservicelist}{count}
|
||||||
|
)
|
||||||
|
&& $hash->{helper}{receiver}{device}{netservicelist}{count}
|
||||||
|
> 0
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (
|
|
||||||
defined(
|
$channelname =~ s/_/ /g;
|
||||||
$hash->{helper}{receiver}{device}
|
|
||||||
{netservicelist}{netservice}{$id}{value}
|
foreach my $id (
|
||||||
)
|
sort keys %{
|
||||||
&& $hash->{helper}{receiver}{device}
|
$hash->{helper}{receiver}{device}{netservicelist}
|
||||||
{netservicelist}{netservice}{$id}{value} eq "1"
|
{netservice}
|
||||||
&& $hash->{helper}{receiver}{device}
|
}
|
||||||
{netservicelist}{netservice}{$id}{name} eq $channelname
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
$servicename .= uc($id);
|
if (
|
||||||
$servicename .= "0" if ( !defined( @$a[3] ) );
|
defined(
|
||||||
$servicename .= @$a[3] if ( defined( @$a[3] ) );
|
$hash->{helper}{receiver}{device}
|
||||||
$servicename .= @$a[4] if ( defined( @$a[4] ) );
|
{netservicelist}{netservice}{$id}{value}
|
||||||
|
)
|
||||||
last;
|
&& $hash->{helper}{receiver}{device}
|
||||||
|
{netservicelist}{netservice}{$id}{value} eq "1"
|
||||||
|
&& $hash->{helper}{receiver}{device}
|
||||||
|
{netservicelist}{netservice}{$id}{name} eq
|
||||||
|
$channelname
|
||||||
|
)
|
||||||
|
{
|
||||||
|
$servicename .= uc($id);
|
||||||
|
last;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
my $channels = ONKYOdb::ONKYO_GetRemotecontrolValue(
|
||||||
|
"1",
|
||||||
|
ONKYOdb::ONKYO_GetRemotecontrolCommand(
|
||||||
|
"1", "net-service"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
$return = "Unknown network service name " . @$a[2]
|
$servicename = $channels->{$channelname}
|
||||||
if ( $servicename eq "" );
|
if ( defined( $channels->{$channelname} ) );
|
||||||
|
}
|
||||||
|
|
||||||
Log3 $name, 3, "ONKYO_AVR set $name " . @$a[1] . " " . @$a[2];
|
Log3 $name, 3, "ONKYO_AVR set $name " . @$a[1] . " " . @$a[2];
|
||||||
|
|
||||||
|
$servicename = uc($channelname)
|
||||||
|
if ( $servicename eq "" );
|
||||||
|
|
||||||
|
$servicename .= "0" if ( !defined( @$a[3] ) );
|
||||||
|
$servicename .= "1" . @$a[3] if ( defined( @$a[3] ) );
|
||||||
|
$servicename .= @$a[4] if ( defined( @$a[4] ) );
|
||||||
|
|
||||||
$return =
|
$return =
|
||||||
ONKYO_AVR_SendCommand( $hash, "net-service", $servicename )
|
ONKYO_AVR_SendCommand( $hash, "net-service", $servicename );
|
||||||
if ( $servicename ne "" );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user