mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-21 07:56:03 +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:
parent
bd831c955d
commit
4c4aa82446
@ -1,5 +1,6 @@
|
|||||||
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
# 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.
|
# 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
|
- change: 57_SSCal: expand composite Event, fix API behavior if entry with
|
||||||
'is_all_day' is at first position
|
'is_all_day' is at first position
|
||||||
- change: 70_DENON_AVR: soundmode related improvements (thx Shasow3561)
|
- change: 70_DENON_AVR: soundmode related improvements (thx Shasow3561)
|
||||||
|
@ -318,8 +318,8 @@ my $DENON_db = {
|
|||||||
'VVD' => 'Vivid',
|
'VVD' => 'Vivid',
|
||||||
'STM' => 'Stream',
|
'STM' => 'Stream',
|
||||||
'CTM' => 'Custom',
|
'CTM' => 'Custom',
|
||||||
'DAY' => 'Day',
|
'DAY' => 'ISF_Day',
|
||||||
'NGT' => 'Night',
|
'NGT' => 'ISF_Night',
|
||||||
},
|
},
|
||||||
'PW' => {
|
'PW' => {
|
||||||
'on' => 'ON',
|
'on' => 'ON',
|
||||||
@ -978,7 +978,7 @@ DENON_GetKey($$;$) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub DENON_AVR_PerformHttpRequest {
|
sub DENON_AVR_RequestDeviceinfo {
|
||||||
my ($hash) = @_;
|
my ($hash) = @_;
|
||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
|
|
||||||
@ -990,13 +990,62 @@ sub DENON_AVR_PerformHttpRequest {
|
|||||||
hash => $hash,
|
hash => $hash,
|
||||||
method => "GET",
|
method => "GET",
|
||||||
header => "User-Agent: FHEM\r\nAccept: application/xml",
|
header => "User-Agent: FHEM\r\nAccept: application/xml",
|
||||||
callback => \&DENON_AVR_ParseHttpResponse
|
callback => \&DENON_AVR_ParseDeviceinfoResponse
|
||||||
};
|
};
|
||||||
|
|
||||||
HttpUtils_NonblockingGet($param);
|
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 ($param, $err, $data) = @_;
|
||||||
my $hash = $param->{hash};
|
my $hash = $param->{hash};
|
||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
@ -1009,16 +1058,13 @@ sub DENON_AVR_ParseHttpResponse {
|
|||||||
readingsBulkUpdate($hash, 'httpError', $err, 0);
|
readingsBulkUpdate($hash, 'httpError', $err, 0);
|
||||||
readingsEndUpdate($hash, 0);
|
readingsEndUpdate($hash, 0);
|
||||||
} elsif($data ne "") {
|
} elsif($data ne "") {
|
||||||
Log3 $name, 5, "DENON_AVR ($name) - Deviceinfo.xml\n$data";
|
readingsDelete($hash, 'httpState');
|
||||||
my $ref = XMLin($data, KeyAttr => { }, ForceArray => [ ]);
|
readingsDelete($hash, 'httpError');
|
||||||
|
|
||||||
my $codes = {
|
my $productTypeName = $data =~ s/<productTypeName>|<\/productTypeName>//rg;
|
||||||
'0' => 'Denon',
|
Log3 $name, 4, "DENON_AVR ($name) - productTypeName: $productTypeName";
|
||||||
'1' => 'Marantz'
|
|
||||||
};
|
|
||||||
my $brandCode = $ref->{BrandCode};
|
|
||||||
|
|
||||||
$hash->{model} = $codes->{$brandCode} . ' ' . $ref->{ModelName};
|
$hash->{model} = $productTypeName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1069,7 +1115,7 @@ DENON_AVR_Define($$)
|
|||||||
return $msg;
|
return $msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
RemoveInternalTimer($hash);
|
RemoveInternalTimer($hash);
|
||||||
DevIo_CloseDev($hash);
|
DevIo_CloseDev($hash);
|
||||||
|
|
||||||
my $name = $a[0];
|
my $name = $a[0];
|
||||||
@ -1114,7 +1160,7 @@ DENON_AVR_Define($$)
|
|||||||
{
|
{
|
||||||
$hash->{IP} = $a[2];
|
$hash->{IP} = $a[2];
|
||||||
use XML::Simple qw(:strict);
|
use XML::Simple qw(:strict);
|
||||||
DENON_AVR_PerformHttpRequest($hash);
|
DENON_AVR_RequestDeviceinfo($hash);
|
||||||
|
|
||||||
$hash->{DeviceName} = $hash->{DeviceName} . ":23"
|
$hash->{DeviceName} = $hash->{DeviceName} . ":23"
|
||||||
if ( $hash->{DeviceName} !~ m/^(.+):([0-9]+)$/ );
|
if ( $hash->{DeviceName} !~ m/^(.+):([0-9]+)$/ );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user