Code cleaning, ping presence

This commit is contained in:
Marko Oldenburg 2017-04-23 12:46:46 +02:00
parent 58c8b9a5df
commit 03216f6ba3

View File

@ -56,7 +56,7 @@ use Blocking;
my $version = "0.2.1.7";
my $version = "0.6.0";
@ -228,7 +228,6 @@ sub LGTV_WebOS_Define($$) {
$hash->{helper}{device}{channelguide}{counter} = 0;
$hash->{helper}{device}{registered} = 0;
$hash->{helper}{device}{runsetcmd} = 0;
$hash->{helper}{countDisconn} = 0;
Log3 $name, 3, "LGTV_WebOS ($name) - defined with host $host";
@ -237,12 +236,9 @@ sub LGTV_WebOS_Define($$) {
$attr{$name}{room} = 'LGTV' if( !defined( $attr{$name}{room} ) );
CommandDeleteReading(undef,$name . ' presence') if( AttrVal($name,'pingPresence', 0) == 0 );
readingsSingleUpdate($hash,'state','off', 1);
$modules{LGTV_WebOS}{defptr}{$hash->{HOST}} = $hash;
if( $init_done ) {
LGTV_WebOS_TimerStatusRequest($hash);
} else {
@ -348,6 +344,8 @@ 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','-');
@ -591,8 +589,6 @@ sub LGTV_WebOS_Close($) {
delete($hash->{CD});
delete($selectlist{$name});
readingsSingleUpdate($hash, 'state', 'off',1);
Log3 $name, 4, "LGTV_WebOS ($name) - Socket Disconnected";
}
@ -627,16 +623,7 @@ sub LGTV_WebOS_Read($) {
if( !defined($len) or !$len ) {
if( $hash->{helper}{countDisconn} == 2 ) {
Log3 $name, 4, "LGTV_WebOS ($name) - connection closed by remote Host";
LGTV_WebOS_Close($hash);
$hash->{helper}{countDisconn} = 0;
} else {
$hash->{helper}{countDisconn} = $hash->{helper}{countDisconn} + 1;
}
return;
}
@ -1502,6 +1489,12 @@ sub LGTV_WebOS_PresenceAborted($) {
Valid Values: 0 => no recurring TV Guide updates, 1 => recurring TV Guide updates.
</ul>
</ul>
<ul>
<ul>
<li>pingPresence</li>
current state of ping presence from TV. create a reading presence with values absent or present.
</ul>
</ul>
</ul>
=end html