70_PHTV: fix Use of uninitialized value $cmd

git-svn-id: https://svn.fhem.de/fhem/trunk@13398 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
loredo
2017-02-12 12:30:28 +00:00
parent 0ae6f98b38
commit dcb9b7f883

View File

@@ -446,9 +446,9 @@ sub PHTV_Set($@) {
return return
"No configuration found. Please set ambiHue attributes first." "No configuration found. Please set ambiHue attributes first."
unless ( AttrVal( $name, "ambiHueLeft", undef ) unless ( AttrVal( $name, "ambiHueLeft", undef )
&& AttrVal( $name, "ambiHueRight", undef ) || AttrVal( $name, "ambiHueRight", undef )
&& AttrVal( $name, "ambiHueTop", undef ) || AttrVal( $name, "ambiHueTop", undef )
&& AttrVal( $name, "ambiHueBottom", undef ) ); || AttrVal( $name, "ambiHueBottom", undef ) );
# enable internal Ambilight color # enable internal Ambilight color
PHTV_SendCommand( $hash, "ambilight/mode", PHTV_SendCommand( $hash, "ambilight/mode",
@@ -1596,48 +1596,29 @@ sub PHTV_ReceiveCommand($$$) {
Log3 $name, 4, "PHTV $name: RCV $service/" . urlDecode($cmd); Log3 $name, 4, "PHTV $name: RCV $service/" . urlDecode($cmd);
} }
if ( $data ne "" ) { if ( $data =~
if ( $data =~ /^{/ || $data =~ /^\[/ ) { m/^\s*(([{\[].*)|(<html>\s*<head>\s*<title>\s*Ok\s*<\/title>\s*<\/head>\s*<body>\s*Ok\s*<\/body>\s*<\/html>))\s*$/i
)
{
$return = decode_json( Encode::encode_utf8($2) ) if ($2);
$return = "ok" if ($3);
if ( !defined($cmd) || ref($cmd) eq "HASH" || $cmd eq "" ) { if ( !defined($cmd) || ref($cmd) eq "HASH" || $cmd eq "" ) {
Log3 $name, 5, "PHTV $name: RES $service\n" . $data; Log3 $name, 5, "PHTV $name: RES $service\n" . $data;
} }
else { else {
Log3 $name, 5, Log3 $name, 5,
"PHTV $name: RES $service/" "PHTV $name: RES $service/" . urlDecode($cmd) . "\n" . $data;
. urlDecode($cmd) . "\n"
. $data;
} }
$hash->{helper}{supportedAPIcmds}{$service} = 1 $hash->{helper}{supportedAPIcmds}{$service} = 1
unless ( unless ( defined( $hash->{helper}{supportedAPIcmds}{$service} )
defined( $hash->{helper}{supportedAPIcmds}{$service} ) || $service =~ /^channels\/.*/
&& $service =~ /^channels\/.*/ || $service =~ /^channellists\/.*/ );
&& $service =~ /^channellists\/.*/ );
$return = decode_json( Encode::encode_utf8($data) );
} }
elsif ( $data eq elsif ( $data ne "" ) {
"<html><head><title>Ok</title></head><body>Ok</body></html>" )
{
if ( !defined($cmd) || ref($cmd) eq "HASH" || $cmd eq "" ) {
Log3 $name, 4, "PHTV $name: RES $service - ok";
}
else {
Log3 $name, 4,
"PHTV $name: RES $service/" . urlDecode($cmd) . " - ok";
}
$hash->{helper}{supportedAPIcmds}{$service} = 1
unless (
defined( $hash->{helper}{supportedAPIcmds}{$service} )
&& $service =~ /^channels\/.*/
&& $service =~ /^channellists\/.*/ );
$return = "ok";
}
else {
if ( !defined($cmd) || ref($cmd) eq "HASH" || $cmd eq "" ) { if ( !defined($cmd) || ref($cmd) eq "HASH" || $cmd eq "" ) {
Log3 $name, 5, "PHTV $name: RES ERROR $service\n" . $data; Log3 $name, 5, "PHTV $name: RES ERROR $service\n" . $data;
} }
@@ -1648,9 +1629,7 @@ sub PHTV_ReceiveCommand($$$) {
. $data; . $data;
} }
unless ( unless ( defined( $hash->{helper}{supportedAPIcmds}{$service} ) ) {
defined( $hash->{helper}{supportedAPIcmds}{$service} ) )
{
$hash->{helper}{supportedAPIcmds}{$service} = 0; $hash->{helper}{supportedAPIcmds}{$service} = 0;
Log3 $name, 4, Log3 $name, 4,
"PHTV $name: API command '" "PHTV $name: API command '"
@@ -1660,7 +1639,6 @@ sub PHTV_ReceiveCommand($$$) {
return undef; return undef;
} }
}
####################### #######################
# process return data # process return data
@@ -1824,7 +1802,18 @@ sub PHTV_ReceiveCommand($$$) {
# sources/current # sources/current
elsif ( $service eq "sources/current" ) { elsif ( $service eq "sources/current" ) {
if ( ref($return) eq "HASH" ) { if ( ref($return) eq "HASH" ) {
$cmd = $hash->{helper}{device}{sourceName}{ $return->{id} }; if ( defined( $return->{id} ) ) {
$return->{id} =~ s/^\s+//;
$return->{id} =~ s/\s+$//;
$cmd = (
$hash->{helper}{device}{sourceName}{ $return->{id} }
? $hash->{helper}{device}{sourceName}{ $return->{id} }
: "-"
);
}
else {
$cmd = "-";
}
# Alias handling # Alias handling
$cmd = $hash->{helper}{device}{inputAliases}{$cmd} $cmd = $hash->{helper}{device}{inputAliases}{$cmd}