Code cleaning, ping presence
This commit is contained in:
		@@ -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}{channelguide}{counter}  = 0;
 | 
				
			||||||
    $hash->{helper}{device}{registered}             = 0;
 | 
					    $hash->{helper}{device}{registered}             = 0;
 | 
				
			||||||
    $hash->{helper}{device}{runsetcmd}              = 0;
 | 
					    $hash->{helper}{device}{runsetcmd}              = 0;
 | 
				
			||||||
    $hash->{helper}{countDisconn}                   = 0;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Log3 $name, 3, "LGTV_WebOS ($name) - defined with host $host";
 | 
					    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} ) );
 | 
					    $attr{$name}{room} = 'LGTV' if( !defined( $attr{$name}{room} ) );
 | 
				
			||||||
    CommandDeleteReading(undef,$name . ' presence') if( AttrVal($name,'pingPresence', 0) == 0 );
 | 
					    CommandDeleteReading(undef,$name . ' presence') if( AttrVal($name,'pingPresence', 0) == 0 );
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    readingsSingleUpdate($hash,'state','off', 1);
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    $modules{LGTV_WebOS}{defptr}{$hash->{HOST}} = $hash;
 | 
					    $modules{LGTV_WebOS}{defptr}{$hash->{HOST}} = $hash;
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    if( $init_done ) {
 | 
					    if( $init_done ) {
 | 
				
			||||||
        LGTV_WebOS_TimerStatusRequest($hash);
 | 
					        LGTV_WebOS_TimerStatusRequest($hash);
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
@@ -348,6 +344,8 @@ sub LGTV_WebOS_TimerStatusRequest($) {
 | 
				
			|||||||
        
 | 
					        
 | 
				
			||||||
        LGTV_WebOS_Presence($hash) if( AttrVal($name,'pingPresence', 0) == 1 );
 | 
					        LGTV_WebOS_Presence($hash) if( AttrVal($name,'pingPresence', 0) == 1 );
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
 | 
					        readingsBulkUpdate($hash, 'state', 'off');
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
        readingsBulkUpdate($hash,'channel','-');
 | 
					        readingsBulkUpdate($hash,'channel','-');
 | 
				
			||||||
        readingsBulkUpdate($hash,'channelName','-');
 | 
					        readingsBulkUpdate($hash,'channelName','-');
 | 
				
			||||||
        readingsBulkUpdate($hash,'channelMedia','-');
 | 
					        readingsBulkUpdate($hash,'channelMedia','-');
 | 
				
			||||||
@@ -591,8 +589,6 @@ sub LGTV_WebOS_Close($) {
 | 
				
			|||||||
    delete($hash->{CD});
 | 
					    delete($hash->{CD});
 | 
				
			||||||
    delete($selectlist{$name});
 | 
					    delete($selectlist{$name});
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    readingsSingleUpdate($hash, 'state', 'off',1);
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    Log3 $name, 4, "LGTV_WebOS ($name) - Socket Disconnected";
 | 
					    Log3 $name, 4, "LGTV_WebOS ($name) - Socket Disconnected";
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -627,16 +623,7 @@ sub LGTV_WebOS_Read($) {
 | 
				
			|||||||
    
 | 
					    
 | 
				
			||||||
    if( !defined($len) or !$len ) {
 | 
					    if( !defined($len) or !$len ) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if( $hash->{helper}{countDisconn} == 2 ) {
 | 
					        LGTV_WebOS_Close($hash);
 | 
				
			||||||
        
 | 
					 | 
				
			||||||
            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;
 | 
					        return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -1502,6 +1489,12 @@ sub LGTV_WebOS_PresenceAborted($) {
 | 
				
			|||||||
            Valid Values: 0 => no recurring TV Guide updates, 1 => recurring TV Guide updates.
 | 
					            Valid Values: 0 => no recurring TV Guide updates, 1 => recurring TV Guide updates.
 | 
				
			||||||
        </ul>
 | 
					        </ul>
 | 
				
			||||||
    </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>
 | 
					</ul>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
=end html
 | 
					=end html
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user