test
This commit is contained in:
		@@ -481,13 +481,6 @@ sub ErrorHandling($$$) {
 | 
				
			|||||||
    my $hash = $param->{hash};
 | 
					    my $hash = $param->{hash};
 | 
				
			||||||
    my $name = $hash->{NAME};
 | 
					    my $name = $hash->{NAME};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    print( 'TESLA DEBUG1 - Path: ' . $param->{setCmd} . "\n" );
 | 
					 | 
				
			||||||
    print( 'TESLA DEBUG1 - ResponseString: ' . Dumper $data . "\n" );
 | 
					 | 
				
			||||||
    print( 'TESLA DEBUG1 - Error: ' . $err . "\n" )
 | 
					 | 
				
			||||||
      if (  defined($err) and $err);
 | 
					 | 
				
			||||||
    print( 'TESLA DEBUG1 - Code: ' . $param->{code} . "\n" )
 | 
					 | 
				
			||||||
      if ( exists($param->{code}) );
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#         my $path = $param->{setCmd};   # temporär
 | 
					#         my $path = $param->{setCmd};   # temporär
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#     #### temporär
 | 
					#     #### temporär
 | 
				
			||||||
@@ -520,98 +513,104 @@ sub ErrorHandling($$$) {
 | 
				
			|||||||
#         $data = '{"site_name":"Meine Powerwall2AC","timezone":"Europe/Berlin"}';
 | 
					#         $data = '{"site_name":"Meine Powerwall2AC","timezone":"Europe/Berlin"}';
 | 
				
			||||||
#     }
 | 
					#     }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#     ### Begin Error Handling
 | 
					    ### Begin Error Handling
 | 
				
			||||||
# 
 | 
					
 | 
				
			||||||
#     if ( defined($err) ) {
 | 
					    if ( defined($err) ) {
 | 
				
			||||||
#         if ( $err ne '' ) {
 | 
					        if ( $err ne '' ) {
 | 
				
			||||||
# 
 | 
					
 | 
				
			||||||
#             readingsBeginUpdate($hash);
 | 
					            readingsBeginUpdate($hash);
 | 
				
			||||||
#             readingsBulkUpdate( $hash, 'state',            $err, 1 );
 | 
					            readingsBulkUpdate( $hash, 'state',            $err, 1 );
 | 
				
			||||||
#             readingsBulkUpdate( $hash, 'lastRequestError', $err, 1 );
 | 
					            readingsBulkUpdate( $hash, 'lastRequestError', $err, 1 );
 | 
				
			||||||
#             readingsEndUpdate( $hash, 1 );
 | 
					            readingsEndUpdate( $hash, 1 );
 | 
				
			||||||
# 
 | 
					
 | 
				
			||||||
#             Log3 $name, 3, "TeslaPowerwall2AC ($name) - RequestERROR: $err";
 | 
					            Log3 $name, 3, "TeslaPowerwall2AC ($name) - RequestERROR: $err";
 | 
				
			||||||
# 
 | 
					
 | 
				
			||||||
#             $hash->{actionQueue} = [];
 | 
					            $hash->{actionQueue} = [];
 | 
				
			||||||
#             return;
 | 
					            return;
 | 
				
			||||||
#         }
 | 
					        }
 | 
				
			||||||
#     }
 | 
					    }
 | 
				
			||||||
# 
 | 
					
 | 
				
			||||||
#     if ( $data eq '' and exists( $param->{code} ) && $param->{code} ne 200 ) {
 | 
					    if ( $data eq '' and exists( $param->{code} ) && $param->{code} != 200 ) {
 | 
				
			||||||
# 
 | 
					
 | 
				
			||||||
#         readingsBeginUpdate($hash);
 | 
					        readingsBeginUpdate($hash);
 | 
				
			||||||
#         readingsBulkUpdate( $hash, 'state', $param->{code}, 1 );
 | 
					        readingsBulkUpdate( $hash, 'state', $param->{code}, 1 );
 | 
				
			||||||
# 
 | 
					
 | 
				
			||||||
#         readingsBulkUpdate( $hash, 'lastRequestError', $param->{code}, 1 );
 | 
					        readingsBulkUpdate( $hash, 'lastRequestError', $param->{code}, 1 );
 | 
				
			||||||
# 
 | 
					
 | 
				
			||||||
#         Log3 $name, 3,
 | 
					        Log3 $name, 3,
 | 
				
			||||||
#           "TeslaPowerwall2AC ($name) - RequestERROR: " . $param->{code};
 | 
					          "TeslaPowerwall2AC ($name) - RequestERROR: " . $param->{code};
 | 
				
			||||||
# 
 | 
					
 | 
				
			||||||
#         readingsEndUpdate( $hash, 1 );
 | 
					        readingsEndUpdate( $hash, 1 );
 | 
				
			||||||
# 
 | 
					
 | 
				
			||||||
#         Log3 $name, 5,
 | 
					        Log3 $name, 5,
 | 
				
			||||||
#             "TeslaPowerwall2AC ($name) - RequestERROR: received http code "
 | 
					            "TeslaPowerwall2AC ($name) - RequestERROR: received http code "
 | 
				
			||||||
#           . $param->{code}
 | 
					          . $param->{code}
 | 
				
			||||||
#           . " without any data after requesting";
 | 
					          . " without any data after requesting";
 | 
				
			||||||
# 
 | 
					
 | 
				
			||||||
#         $hash->{actionQueue} = [];
 | 
					        $hash->{actionQueue} = [];
 | 
				
			||||||
#         return;
 | 
					        return;
 | 
				
			||||||
#     }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (  $data =~ /Error/i
 | 
				
			||||||
 | 
					      and exists($param->{code})
 | 
				
			||||||
 | 
					      and $param->{code} != 200 )
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        readingsBeginUpdate($hash);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        readingsBulkUpdate( $hash, 'state',            $param->{code}, 1 );
 | 
				
			||||||
 | 
					        readingsBulkUpdate( $hash, 'lastRequestError', $param->{code}, 1 );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        readingsEndUpdate( $hash, 1 );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        Log3 $name, 3,
 | 
				
			||||||
 | 
					          "TeslaPowerwall2AC ($name) - statusRequestERROR: http error "
 | 
				
			||||||
 | 
					          . $param->{code};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $hash->{actionQueue} = [];
 | 
				
			||||||
 | 
					        return;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if ( $data =~ m#{"code":(\d+),"error":"(.+)","message":"(.+)"}$# ) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        readingsBeginUpdate($hash);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        readingsBulkUpdate( $hash, 'state', $1, 1 );
 | 
				
			||||||
 | 
					        readingsBulkUpdate(
 | 
				
			||||||
 | 
					            $hash,
 | 
				
			||||||
 | 
					            'lastRequestError',
 | 
				
			||||||
 | 
					            'Path: '
 | 
				
			||||||
 | 
					              . $param->{setCmd} . ' '
 | 
				
			||||||
 | 
					              . $1
 | 
				
			||||||
 | 
					              . ' - Error: '
 | 
				
			||||||
 | 
					              . $2
 | 
				
			||||||
 | 
					              . ' Messages: '
 | 
				
			||||||
 | 
					              . $3,
 | 
				
			||||||
 | 
					            1
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        readingsEndUpdate( $hash, 1 );        
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    #### End Error Handling
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    print( 'TESLA DEBUG1 - Path: ' . $param->{setCmd} . "\n" );
 | 
				
			||||||
 | 
					    print( 'TESLA DEBUG1 - ResponseString: ' . Dumper $data . "\n" );
 | 
				
			||||||
 | 
					    print( 'TESLA DEBUG1 - Error: ' . $err . "\n" )
 | 
				
			||||||
 | 
					      if (  defined($err) and $err);
 | 
				
			||||||
 | 
					    print( 'TESLA DEBUG1 - Code: ' . $param->{code} . "\n" )
 | 
				
			||||||
 | 
					      if ( exists($param->{code}) );
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
      
 | 
					      
 | 
				
			||||||
#     if ( ( $data =~ /Error/i ) and exists( $param->{code} ) ) {
 | 
					 | 
				
			||||||
# 
 | 
					 | 
				
			||||||
#         readingsBeginUpdate($hash);
 | 
					 | 
				
			||||||
# 
 | 
					 | 
				
			||||||
#         readingsBulkUpdate( $hash, 'state',            $param->{code}, 1 );
 | 
					 | 
				
			||||||
#         readingsBulkUpdate( $hash, 'lastRequestError', $param->{code}, 1 );
 | 
					 | 
				
			||||||
# 
 | 
					 | 
				
			||||||
#         readingsEndUpdate( $hash, 1 );
 | 
					 | 
				
			||||||
# 
 | 
					 | 
				
			||||||
#         Log3 $name, 3,
 | 
					 | 
				
			||||||
#           "TeslaPowerwall2AC ($name) - statusRequestERROR: http error "
 | 
					 | 
				
			||||||
#           . $param->{code};
 | 
					 | 
				
			||||||
# 
 | 
					 | 
				
			||||||
#         $hash->{actionQueue} = [];
 | 
					 | 
				
			||||||
#         return;
 | 
					 | 
				
			||||||
#     }
 | 
					 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
#     if ( $data =~ m#{"code":(\d+),"error":"(.+)","message":"(.+)"}$# ) {
 | 
					 | 
				
			||||||
# 
 | 
					 | 
				
			||||||
#         readingsBeginUpdate($hash);
 | 
					 | 
				
			||||||
# 
 | 
					 | 
				
			||||||
#         readingsBulkUpdate( $hash, 'state', $1, 1 );
 | 
					 | 
				
			||||||
#         readingsBulkUpdate(
 | 
					 | 
				
			||||||
#             $hash,
 | 
					 | 
				
			||||||
#             'lastRequestError',
 | 
					 | 
				
			||||||
#             'Path: '
 | 
					 | 
				
			||||||
#               . $param->{setCmd} . ' '
 | 
					 | 
				
			||||||
#               . $1
 | 
					 | 
				
			||||||
#               . ' - Error: '
 | 
					 | 
				
			||||||
#               . $2
 | 
					 | 
				
			||||||
#               . ' Messages: '
 | 
					 | 
				
			||||||
#               . $3,
 | 
					 | 
				
			||||||
#             1
 | 
					 | 
				
			||||||
#         );
 | 
					 | 
				
			||||||
# 
 | 
					 | 
				
			||||||
#         readingsEndUpdate( $hash, 1 );
 | 
					 | 
				
			||||||
# 
 | 
					 | 
				
			||||||
#         #         $hash->{actionQueue} = [];
 | 
					 | 
				
			||||||
#         #         return;
 | 
					 | 
				
			||||||
#         ### End Error Handling
 | 
					 | 
				
			||||||
#     }
 | 
					 | 
				
			||||||
# 
 | 
					 | 
				
			||||||
    Write($hash)
 | 
					    Write($hash)
 | 
				
			||||||
      if ( defined( $hash->{actionQueue} )
 | 
					      if ( defined( $hash->{actionQueue} )
 | 
				
			||||||
        and scalar( @{ $hash->{actionQueue} } ) > 0 );
 | 
					        and scalar( @{ $hash->{actionQueue} } ) > 0 );
 | 
				
			||||||
# 
 | 
					
 | 
				
			||||||
#     Log3 $name, 4, "TeslaPowerwall2AC ($name) - Recieve JSON data: $data";
 | 
					    Log3 $name, 4, "TeslaPowerwall2AC ($name) - Recieve JSON data: $data";
 | 
				
			||||||
# 
 | 
					 
 | 
				
			||||||
#     print( 'TESLA DEBUG2 - ResponseString: ' . Dumper $data );
 | 
					    ResponseProcessing( $hash, $param->{setCmd}, $data );
 | 
				
			||||||
#     print( 'TESLA DEBUG2 - Error: ' . $err . "\n" )
 | 
					 | 
				
			||||||
#       unless (  defined($err)
 | 
					 | 
				
			||||||
#             and $err);
 | 
					 | 
				
			||||||
# 
 | 
					 | 
				
			||||||
#     ResponseProcessing( $hash, $param->{setCmd}, $data );
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
sub ResponseProcessing($$$) {
 | 
					sub ResponseProcessing($$$) {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user