2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-12 22:56:34 +00:00

82_LGTV_WebOS: 1.2.0 bugfix - hack for properly fhem freez after set off

git-svn-id: https://svn.fhem.de/fhem/trunk@15307 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
LeonGaultier 2017-10-23 14:51:59 +00:00
parent 615680cec1
commit ee90b4b562
2 changed files with 31 additions and 15 deletions

View File

@ -1,5 +1,7 @@
# 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.
- bugfix: 82_LGTV_WebOS: 1.2.0 bugfix - hack for properly fhem freez after
tvswitch off and more
- change: 93_DbLog: V2.22.13, output of reopen command improved
- bugfix: 93_DbLog: V2.22.12, avoid illegible messages in "state"
- feature: 59_WUup: add set-command "update"

View File

@ -67,7 +67,7 @@ use Blocking;
my $version = "1.0.1";
my $version = "1.2.0";
@ -258,7 +258,7 @@ sub LGTV_WebOS_Define($$) {
if( $init_done ) {
LGTV_WebOS_TimerStatusRequest($hash);
} else {
InternalTimer( gettimeofday()+15, "LGTV_WebOS_TimerStatusRequest", $hash, 0 );
InternalTimer( gettimeofday()+15, "LGTV_WebOS_TimerStatusRequest", $hash );
}
return undef;
@ -332,8 +332,6 @@ sub LGTV_WebOS_TimerStatusRequest($) {
Log3 $name, 4, "LGTV_WebOS ($name) - run get functions";
readingsBulkUpdate($hash, 'state', 'on');
LGTV_WebOS_Presence($hash) if( AttrVal($name,'pingPresence', 0) == 1 );
if($hash->{helper}{device}{channelguide}{counter} > 2 and AttrVal($name,'channelGuide', 0) == 1 and ReadingsVal($name,'launchApp', 'TV') eq 'TV' ) {
@ -344,15 +342,16 @@ sub LGTV_WebOS_TimerStatusRequest($) {
} else {
LGTV_WebOS_GetAudioStatus($hash);
InternalTimer( gettimeofday()+2, 'LGTV_WebOS_GetCurrentChannel', $hash, 0 ) if( ReadingsVal($name,'launchApp', 'TV') eq 'TV' );
InternalTimer( gettimeofday()+4, 'LGTV_WebOS_GetForgroundAppInfo', $hash, 0 );
InternalTimer( gettimeofday()+6, 'LGTV_WebOS_Get3DStatus', $hash, 0 );
InternalTimer( gettimeofday()+8, 'LGTV_WebOS_GetExternalInputList', $hash, 0 );
InternalTimer( gettimeofday()+2, 'LGTV_WebOS_GetCurrentChannel', $hash ) if( ReadingsVal($name,'launchApp', 'TV') eq 'TV' );
InternalTimer( gettimeofday()+4, 'LGTV_WebOS_GetForgroundAppInfo', $hash );
InternalTimer( gettimeofday()+6, 'LGTV_WebOS_Get3DStatus', $hash );
InternalTimer( gettimeofday()+8, 'LGTV_WebOS_GetExternalInputList', $hash );
}
} elsif( IsDisabled($name) ) {
LGTV_WebOS_Close($hash);
LGTV_WebOS_Presence($hash) if( AttrVal($name,'pingPresence', 0) == 1 );
$hash->{helper}{device}{runsetcmd} = 0;
readingsBulkUpdate($hash, 'state', 'disabled');
@ -360,8 +359,6 @@ sub LGTV_WebOS_TimerStatusRequest($) {
LGTV_WebOS_Presence($hash) if( AttrVal($name,'pingPresence', 0) == 1 );
readingsBulkUpdate($hash, 'state', 'off');
readingsBulkUpdate($hash,'channel','-');
readingsBulkUpdate($hash,'channelName','-');
readingsBulkUpdate($hash,'channelMedia','-');
@ -380,7 +377,7 @@ sub LGTV_WebOS_TimerStatusRequest($) {
LGTV_WebOS_Open($hash) if( !IsDisabled($name) and not $hash->{CD} );
$hash->{helper}{device}{channelguide}{counter} = $hash->{helper}{device}{channelguide}{counter} +1;
InternalTimer( gettimeofday()+10,"LGTV_WebOS_TimerStatusRequest", $hash, 1 );
InternalTimer( gettimeofday()+10,"LGTV_WebOS_TimerStatusRequest", $hash );
}
sub LGTV_WebOS_Set($@) {
@ -590,7 +587,6 @@ sub LGTV_WebOS_Open($) {
$hash->{CD} = $socket; # sysread / close won't work on fileno
$selectlist{$name} = $hash;
Log3 $name, 4, "LGTV_WebOS ($name) - Socket Connected";
LGTV_WebOS_Handshake($hash);
@ -610,6 +606,8 @@ sub LGTV_WebOS_Close($) {
delete($hash->{CD});
delete($selectlist{$name});
readingsSingleUpdate($hash,'state','off',1);
Log3 $name, 4, "LGTV_WebOS ($name) - Socket Disconnected";
}
@ -787,7 +785,7 @@ sub LGTV_WebOS_ResponseProcessing($$) {
if ($keyAccept eq $expectedResponse) {
Log3 $name, 3, "LGTV_WebOS ($name) - Sucessfull WS connection to $hash->{HOST}";
readingsSingleUpdate($hash, 'state', 'on', 1 );
readingsSingleUpdate($hash,'state','on',1);
} else {
LGTV_WebOS_Close($hash);
@ -990,6 +988,8 @@ sub LGTV_WebOS_WriteReadings($$) {
readingsBulkUpdate($hash,'channelNextStartTime','-');
readingsBulkUpdate($hash,'channelNextEndTime','-');
}
readingsBulkUpdateIfChanged($hash,'state','on');
readingsEndUpdate($hash, 1);
}
@ -1397,12 +1397,14 @@ sub LGTV_WebOS_PresenceDone($) {
delete($hash->{helper}{RUNNING_PID});
Log3 $name, 4, "Sub LGTV_WebOS_PresenceDone ($name) - Der Helper ist diabled. Daher wird hier abgebrochen" if($hash->{helper}{DISABLED});
Log3 $name, 4, "Sub LGTV_WebOS_PresenceDone ($name) - Helper is disabled. Stop processing" if($hash->{helper}{DISABLED});
return if($hash->{helper}{DISABLED});
readingsSingleUpdate($hash, 'presence', $response, 1);
Log3 $name, 4, "Sub LGTV_WebOS_PresenceDone ($name) - Abschluss!";
LGTV_WebOS_SocketClosePresenceAbsent($hash,$response);
Log3 $name, 4, "Sub LGTV_WebOS_PresenceDone ($name) - presence done";
}
sub LGTV_WebOS_PresenceAborted($) {
@ -1417,6 +1419,18 @@ sub LGTV_WebOS_PresenceAborted($) {
Log3 $name, 4, "Sub LGTV_WebOS_PresenceAborted ($name) - The BlockingCall Process terminated unexpectedly. Timedout!";
}
sub LGTV_WebOS_SocketClosePresenceAbsent($$) {
my ($hash,$presence) = @_;
my $name = $hash->{NAME};
LGTV_WebOS_Close($hash)
if( $presence eq 'absent' and not IsDisabled($name) and $hash->{CD} ); # https://forum.fhem.de/index.php/topic,66671.msg694578.html#msg694578
# Sobald pingPresence absent meldet und der Socket noch steht soll er geschlossen werden, da sonst FHEM nach 4-6 min für 10 min blockiert
}
sub LGTV_WebOS_WakeUp_Udp($@) {
my ($hash,$mac_addr,$host,$port) = @_;