add 'no critic' sections, add keepAliveCheckTime to

commandref
This commit is contained in:
Marko Oldenburg 2022-01-06 07:30:04 +01:00
parent cc7e18d589
commit a7ee9a7902

View File

@ -54,9 +54,13 @@ my $missingModul = "";
eval { require MIME::Base64; 1 } or $missingModul .= "MIME::Base64 "; eval { require MIME::Base64; 1 } or $missingModul .= "MIME::Base64 ";
eval { require IO::Socket::INET; 1 } or $missingModul .= "IO::Socket::INET "; eval { require IO::Socket::INET; 1 } or $missingModul .= "IO::Socket::INET ";
## no critic (Conditional "use" statement. Use "require" to conditionally include a module (Modules::ProhibitConditionalUseStatements))
eval { use Digest::SHA qw /sha1_hex/; 1 } or $missingModul .= "Digest::SHA "; eval { use Digest::SHA qw /sha1_hex/; 1 } or $missingModul .= "Digest::SHA ";
eval { use Encode qw /encode_utf8 decode_utf8/; 1 } eval { use Encode qw /encode_utf8 decode_utf8/; 1 }
or $missingModul .= "Encode "; or $missingModul .= "Encode ";
## use critic
eval { require Blocking; 1 } or $missingModul .= "Blocking "; eval { require Blocking; 1 } or $missingModul .= "Blocking ";
# try to use JSON::MaybeXS wrapper # try to use JSON::MaybeXS wrapper
@ -401,7 +405,8 @@ sub LGTV_WebOS_TimerStatusRequest {
return; return;
} }
sub LGTV_WebOS_Set { sub LGTV_WebOS_Set
{ ## no critic (Subroutine "LGTV_WebOS_Set" with high complexity score)
my ( $hash, $name, $cmd, @args ) = @_; my ( $hash, $name, $cmd, @args ) = @_;
my ( $arg, @params ) = @args; my ( $arg, @params ) = @args;
@ -624,10 +629,13 @@ sub LGTV_WebOS_Set {
$list .= $list .=
' 3D:on,off stop:noArg play:noArg pause:noArg rewind:noArg fastForward:noArg clearInputList:noArg channel'; ' 3D:on,off stop:noArg play:noArg pause:noArg rewind:noArg fastForward:noArg clearInputList:noArg channel';
$list .= $list .=
## no critic (Expression form of map. See page 169 of PBP)
' launchApp:' . join( ',', => map qq{$_} => keys %openApps ); ' launchApp:' . join( ',', => map qq{$_} => keys %openApps );
$list .= ' input:' $list .= ' input:' . join(
. join( ',', ',',
=> map qq{$_} => keys %{ $hash->{helper}{device}{inputs} } ) ## no critic (Expression form of map. See page 169 of PBP)
=> map qq{$_} => keys %{ $hash->{helper}{device}{inputs} }
)
if ( defined( $hash->{helper}{device}{inputs} ) if ( defined( $hash->{helper}{device}{inputs} )
&& ref( $hash->{helper}{device}{inputs} ) eq "HASH" ); && ref( $hash->{helper}{device}{inputs} ) eq "HASH" );
@ -754,7 +762,9 @@ sub LGTV_WebOS_Read {
if ( $buf =~ /(\{"type":".+}}$)/x ) { if ( $buf =~ /(\{"type":".+}}$)/x ) {
$buf =~ /(\{"type":".+}}$)/x; $buf =~ /(\{"type":".+}}$)/x;
## no critic (Capture variable used outside conditional. See page 253 of PBP)
$buf = $1; $buf = $1;
## use critic
Log3( $name, 4, Log3( $name, 4,
"LGTV_WebOS ($name) - received correct JSON string, start response processing: $buf" "LGTV_WebOS ($name) - received correct JSON string, start response processing: $buf"
@ -1703,19 +1713,20 @@ sub LGTV_WebOS_PresenceRun {
my $tmp; my $tmp;
my $response; my $response;
$tmp = qx(ping -c 3 -w 2 $host 2>&1); $tmp = qx(ping -c 3 -w 2 $host 2>&1); ## no critic (Backtick operator used)
if ( defined($tmp) && $tmp ne "" ) { if ( defined($tmp) && $tmp ne "" ) {
chomp $tmp; chomp $tmp;
Log3( $name, 4, Log3( $name, 4,
"LGTV_WebOS ($name) - ping command returned with output:\n$tmp" ); "LGTV_WebOS ($name) - ping command returned with output:\n$tmp" );
$response = "$name|" $response = $name . '|' . (
. ( $tmp =~
( $tmp =~ /\d+ [Bb]ytes (from|von)/x && $tmp !~ /[Uu]nreachable/x ) /\d+ [Bb]ytes (from|von)/ ## no critic (Regular expression without "/x")
? "present" && $tmp !~ /[Uu]nreachable/x
: "absent" ? 'present'
); : 'absent'
);
} }
else { else {
@ -1901,6 +1912,12 @@ sub LGTV_WebOS_WakeUp_Udp {
current state of ping presence from TV. create a reading presence with values absent or present. current state of ping presence from TV. create a reading presence with values absent or present.
</ul> </ul>
</ul> </ul>
<ul>
<ul>
<li>keepAliveCheckTime</li>
value in seconds - keepAliveCheck is check read data input from tcp socket and prevented FHEM freeze.
</ul>
</ul>
<ul> <ul>
<ul> <ul>
<li>wakeOnLanMAC</li> <li>wakeOnLanMAC</li>
@ -2034,6 +2051,15 @@ sub LGTV_WebOS_WakeUp_Udp {
</ul> </ul>
</ul> </ul>
</ul> </ul>
<ul>
<ul>
<ul>
<li>keepAliveCheckTime</li>
Wert in Sekunden - keepAliveCheckTime
kontrolliert in einer bestimmten Zeit ob noch Daten über die TCP Schnittstelle kommen und verhindert somit FHEM Freezes
</ul>
</ul>
</ul>
<ul> <ul>
<ul> <ul>
<ul> <ul>
@ -2088,7 +2114,7 @@ sub LGTV_WebOS_WakeUp_Udp {
], ],
"release_status": "stable", "release_status": "stable",
"license": "GPL_2", "license": "GPL_2",
"version": "v3.4.1", "version": "v3.4.2",
"author": [ "author": [
"Marko Oldenburg <fhemdevelopment@cooltux.net>" "Marko Oldenburg <fhemdevelopment@cooltux.net>"
], ],