add more sub routine to take low PBP complexity score
This commit is contained in:
parent
ecd35d4526
commit
65b2ef48d1
145
82_LGTV_WebOS.pm
145
82_LGTV_WebOS.pm
@ -956,43 +956,30 @@ sub LGTV_WebOS_ResponseProcessing {
|
||||
return;
|
||||
}
|
||||
|
||||
sub LGTV_WebOS_WriteReadings {
|
||||
my ( $hash, $decode_json ) = @_;
|
||||
sub LGTV_WebOS_WriteServiceReadings {
|
||||
my $hash = shift;
|
||||
my $decode_json = shift;
|
||||
|
||||
my $name = $hash->{NAME};
|
||||
my $response;
|
||||
|
||||
Log3 $name, 4, "LGTV_WebOS ($name) - Beginn Readings writing";
|
||||
|
||||
readingsBeginUpdate($hash);
|
||||
|
||||
if ( ref( $decode_json->{payload}{services} ) eq "ARRAY"
|
||||
&& scalar( @{ $decode_json->{payload}{services} } ) > 0 )
|
||||
{
|
||||
for my $services ( @{ $decode_json->{payload}{services} } ) {
|
||||
|
||||
readingsBulkUpdateIfChanged(
|
||||
$hash,
|
||||
'service_' . $services->{name},
|
||||
'v.' . $services->{version}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
elsif ( ref( $decode_json->{payload}{devices} ) eq "ARRAY"
|
||||
&& scalar( @{ $decode_json->{payload}{devices} } ) > 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
sub LGTV_WebOS_WriteDeviceReadings {
|
||||
my $hash = shift;
|
||||
my $decode_json = shift;
|
||||
|
||||
for my $devices ( @{ $decode_json->{payload}{devices} } ) {
|
||||
|
||||
if (
|
||||
!defined(
|
||||
$hash->{helper}{device}{inputs}{ $devices->{label} }
|
||||
)
|
||||
|| !defined(
|
||||
$hash->{helper}{device}{inputapps}{ $devices->{appId} }
|
||||
)
|
||||
)
|
||||
if ( !defined( $hash->{helper}{device}{inputs}{ $devices->{label} } )
|
||||
|| !
|
||||
defined( $hash->{helper}{device}{inputapps}{ $devices->{appId} } ) )
|
||||
{
|
||||
|
||||
$hash->{helper}{device}{inputs}
|
||||
@ -1007,20 +994,21 @@ sub LGTV_WebOS_WriteReadings {
|
||||
'connect_' . $devices->{connected}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
elsif ( ref( $decode_json->{payload}{programList} ) eq "ARRAY"
|
||||
&& scalar( @{ $decode_json->{payload}{programList} } ) > 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
sub LGTV_WebOS_WriteProgramlistReadings {
|
||||
my $hash = shift;
|
||||
my $decode_json = shift;
|
||||
|
||||
require Date::Parse;
|
||||
my $count = 0;
|
||||
for my $programList ( @{ $decode_json->{payload}{programList} } ) {
|
||||
|
||||
if (
|
||||
str2time(
|
||||
LGTV_WebOS_FormartStartEndTime(
|
||||
$programList->{localEndTime}
|
||||
)
|
||||
LGTV_WebOS_FormartStartEndTime( $programList->{localEndTime} )
|
||||
) > time()
|
||||
)
|
||||
{
|
||||
@ -1068,11 +1056,13 @@ sub LGTV_WebOS_WriteReadings {
|
||||
return if ( $count > 1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
elsif (defined( $decode_json->{payload}{'mute'} )
|
||||
|| defined( $decode_json->{payload}{'muted'} ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
sub LGTV_WebOS_WriteMuteReadings {
|
||||
my $hash = shift;
|
||||
my $decode_json = shift;
|
||||
|
||||
if (
|
||||
defined( $decode_json->{payload}{'mute'} )
|
||||
@ -1112,9 +1102,14 @@ sub LGTV_WebOS_WriteReadings {
|
||||
|
||||
readingsBulkUpdateIfChanged( $hash, 'mute', 'off' );
|
||||
}
|
||||
}
|
||||
|
||||
elsif ( defined( $decode_json->{payload}{status3D}{status} ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
sub LGTV_WebOS_Write3dReadings {
|
||||
my $hash = shift;
|
||||
my $decode_json = shift;
|
||||
|
||||
if ( $decode_json->{payload}{status3D}{status} eq 'false'
|
||||
|| $decode_json->{payload}{status3D}{status} == 0 )
|
||||
{
|
||||
@ -1131,9 +1126,13 @@ sub LGTV_WebOS_WriteReadings {
|
||||
|
||||
readingsBulkUpdateIfChanged( $hash, '3DMode',
|
||||
$decode_json->{payload}{status3D}{pattern} );
|
||||
}
|
||||
|
||||
elsif ( defined( $decode_json->{payload}{appId} ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
sub LGTV_WebOS_WriteAppIdReadings {
|
||||
my $hash = shift;
|
||||
my $decode_json = shift;
|
||||
|
||||
if (
|
||||
(
|
||||
@ -1141,22 +1140,19 @@ sub LGTV_WebOS_WriteReadings {
|
||||
|| $decode_json->{payload}{appId} =~ /com.webos.app.hdmi/x
|
||||
)
|
||||
&& defined(
|
||||
$hash->{helper}{device}{inputapps}
|
||||
{ $decode_json->{payload}{appId} }
|
||||
$hash->{helper}{device}{inputapps}{ $decode_json->{payload}{appId} }
|
||||
)
|
||||
&& $hash->{helper}{device}{inputapps}
|
||||
{ $decode_json->{payload}{appId} }
|
||||
&& $hash->{helper}{device}{inputapps}{ $decode_json->{payload}{appId} }
|
||||
)
|
||||
{
|
||||
|
||||
readingsBulkUpdateIfChanged( $hash, 'input',
|
||||
$hash->{helper}{device}{inputapps}
|
||||
{ $decode_json->{payload}{appId} } );
|
||||
$hash->{helper}{device}{inputapps}{ $decode_json->{payload}{appId} }
|
||||
);
|
||||
readingsBulkUpdateIfChanged( $hash, 'launchApp', '-' );
|
||||
|
||||
}
|
||||
elsif (
|
||||
defined( $openAppsPackageName{ $decode_json->{payload}{appId} } )
|
||||
elsif ( defined( $openAppsPackageName{ $decode_json->{payload}{appId} } )
|
||||
&& $openAppsPackageName{ $decode_json->{payload}{appId} } )
|
||||
{
|
||||
|
||||
@ -1165,9 +1161,14 @@ sub LGTV_WebOS_WriteReadings {
|
||||
readingsBulkUpdateIfChanged( $hash, 'input', '-' );
|
||||
}
|
||||
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if ( defined( $decode_json->{type} ) ) {
|
||||
sub LGTV_WebOS_WriteTypeReadings {
|
||||
my $hash = shift;
|
||||
my $decode_json = shift;
|
||||
|
||||
my $response;
|
||||
|
||||
if ( $decode_json->{type} eq 'registered'
|
||||
&& defined( $decode_json->{payload}{'client-key'} ) )
|
||||
@ -1211,6 +1212,50 @@ sub LGTV_WebOS_WriteReadings {
|
||||
$hash->{helper}{device}{runsetcmd} - 1
|
||||
if ( $hash->{helper}{device}{runsetcmd} > 0 );
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
sub LGTV_WebOS_WriteReadings {
|
||||
my ( $hash, $decode_json ) = @_;
|
||||
|
||||
my $name = $hash->{NAME};
|
||||
my $response;
|
||||
|
||||
Log3 $name, 4, "LGTV_WebOS ($name) - Beginn Readings writing";
|
||||
|
||||
readingsBeginUpdate($hash);
|
||||
|
||||
if ( ref( $decode_json->{payload}{services} ) eq "ARRAY"
|
||||
&& scalar( @{ $decode_json->{payload}{services} } ) > 0 )
|
||||
{
|
||||
LGTV_WebOS_WriteServiceReadings( $hash, $decode_json );
|
||||
}
|
||||
elsif ( ref( $decode_json->{payload}{devices} ) eq "ARRAY"
|
||||
&& scalar( @{ $decode_json->{payload}{devices} } ) > 0 )
|
||||
{
|
||||
LGTV_WebOS_WriteDeviceReadings( $hash, $decode_json );
|
||||
}
|
||||
elsif ( ref( $decode_json->{payload}{programList} ) eq "ARRAY"
|
||||
&& scalar( @{ $decode_json->{payload}{programList} } ) > 0 )
|
||||
{
|
||||
LGTV_WebOS_WriteProgramlistReadings( $hash, $decode_json );
|
||||
}
|
||||
|
||||
if ( defined( $decode_json->{payload}{'mute'} )
|
||||
|| defined( $decode_json->{payload}{'muted'} ) )
|
||||
{
|
||||
LGTV_WebOS_WriteMuteReadings( $hash, $decode_json );
|
||||
}
|
||||
elsif ( defined( $decode_json->{payload}{status3D}{status} ) ) {
|
||||
LGTV_WebOS_Write3dReadings( $hash, $decode_json );
|
||||
}
|
||||
elsif ( defined( $decode_json->{payload}{appId} ) ) {
|
||||
LGTV_WebOS_WriteAppIdReadings( $hash, $decode_json );
|
||||
}
|
||||
|
||||
if ( defined( $decode_json->{type} ) ) {
|
||||
$response = LGTV_WebOS_WriteTypeReadings( $hash, $decode_json );
|
||||
}
|
||||
|
||||
readingsBulkUpdateIfChanged( $hash, 'lgKey',
|
||||
|
Loading…
x
Reference in New Issue
Block a user