2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 06:39:11 +00:00

70_DENON_AVR: model reporting for newer AVRs

git-svn-id: https://svn.fhem.de/fhem/trunk@21347 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
delmar 2020-03-03 21:16:35 +00:00
parent bd831c955d
commit 4c4aa82446
2 changed files with 62 additions and 15 deletions

View File

@ -1,5 +1,6 @@
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
# Do not insert empty lines here, update check depends on it.
- change: 70_DENON_AVR: model reporting for newer AVRs
- change: 57_SSCal: expand composite Event, fix API behavior if entry with
'is_all_day' is at first position
- change: 70_DENON_AVR: soundmode related improvements (thx Shasow3561)

View File

@ -318,8 +318,8 @@ my $DENON_db = {
'VVD' => 'Vivid',
'STM' => 'Stream',
'CTM' => 'Custom',
'DAY' => 'Day',
'NGT' => 'Night',
'DAY' => 'ISF_Day',
'NGT' => 'ISF_Night',
},
'PW' => {
'on' => 'ON',
@ -978,7 +978,7 @@ DENON_GetKey($$;$) {
}
}
sub DENON_AVR_PerformHttpRequest {
sub DENON_AVR_RequestDeviceinfo {
my ($hash) = @_;
my $name = $hash->{NAME};
@ -990,13 +990,62 @@ sub DENON_AVR_PerformHttpRequest {
hash => $hash,
method => "GET",
header => "User-Agent: FHEM\r\nAccept: application/xml",
callback => \&DENON_AVR_ParseHttpResponse
callback => \&DENON_AVR_ParseDeviceinfoResponse
};
HttpUtils_NonblockingGet($param);
}
sub DENON_AVR_ParseHttpResponse {
sub DENON_AVR_ParseDeviceinfoResponse {
my ($param, $err, $data) = @_;
my $hash = $param->{hash};
my $name = $hash->{NAME};
my $return;
if($err ne "") {
Log3 $name, 0, "DENON_AVR ($name) - Error while requesting ".$param->{url}." - $err";
readingsBeginUpdate($hash);
readingsBulkUpdate($hash, 'httpState', 'ERROR', 0);
readingsBulkUpdate($hash, 'httpError', $err, 0);
readingsEndUpdate($hash, 0);
DENON_AVR_RequestProductTypeName($hash);
} elsif($data ne "") {
readingsDelete($hash, 'httpState');
readingsDelete($hash, 'httpError');
Log3 $name, 5, "DENON_AVR ($name) - Deviceinfo.xml\n$data";
my $ref = XMLin($data, KeyAttr => { }, ForceArray => [ ]);
my $codes = {
'0' => 'Denon',
'1' => 'Marantz'
};
my $brandCode = $ref->{BrandCode};
$hash->{model} = $codes->{$brandCode} . ' ' . $ref->{ModelName};
}
}
sub DENON_AVR_RequestProductTypeName {
my ($hash) = @_;
my $name = $hash->{NAME};
my $url = "http://$hash->{IP}/ajax/get_config?type=25";
Log3 $name, 4, "DENON_AVR ($name) - requesting $url";
my $param = {
url => "$url",
timeout => 5,
hash => $hash,
method => "GET",
header => "User-Agent: FHEM\r\nAccept: application/xml",
callback => \&DENON_AVR_ParseProductTypeName
};
HttpUtils_NonblockingGet($param);
}
sub DENON_AVR_ParseProductTypeName {
my ($param, $err, $data) = @_;
my $hash = $param->{hash};
my $name = $hash->{NAME};
@ -1009,16 +1058,13 @@ sub DENON_AVR_ParseHttpResponse {
readingsBulkUpdate($hash, 'httpError', $err, 0);
readingsEndUpdate($hash, 0);
} elsif($data ne "") {
Log3 $name, 5, "DENON_AVR ($name) - Deviceinfo.xml\n$data";
my $ref = XMLin($data, KeyAttr => { }, ForceArray => [ ]);
readingsDelete($hash, 'httpState');
readingsDelete($hash, 'httpError');
my $codes = {
'0' => 'Denon',
'1' => 'Marantz'
};
my $brandCode = $ref->{BrandCode};
my $productTypeName = $data =~ s/<productTypeName>|<\/productTypeName>//rg;
Log3 $name, 4, "DENON_AVR ($name) - productTypeName: $productTypeName";
$hash->{model} = $codes->{$brandCode} . ' ' . $ref->{ModelName};
$hash->{model} = $productTypeName;
}
}
@ -1069,7 +1115,7 @@ DENON_AVR_Define($$)
return $msg;
}
RemoveInternalTimer($hash);
RemoveInternalTimer($hash);
DevIo_CloseDev($hash);
my $name = $a[0];
@ -1114,7 +1160,7 @@ DENON_AVR_Define($$)
{
$hash->{IP} = $a[2];
use XML::Simple qw(:strict);
DENON_AVR_PerformHttpRequest($hash);
DENON_AVR_RequestDeviceinfo($hash);
$hash->{DeviceName} = $hash->{DeviceName} . ":23"
if ( $hash->{DeviceName} !~ m/^(.+):([0-9]+)$/ );