Fix dauerhaftes disabled des Device nach Set Befehl
This commit is contained in:
parent
e9835d7548
commit
956110aa53
34
74_AMAD.pm
34
74_AMAD.pm
@ -249,11 +249,12 @@ sub AMAD_Set($$@) {
|
||||
Log3 $name, 5, "AMAD ($name) - set $name $cmd ".join(" ", @val);
|
||||
|
||||
return "set command only works if STATE not equal initialized, please wait for next interval run" if( $hash->{STATE} eq "initialized");
|
||||
|
||||
return "Cannot set command, FHEM Device is disabled" if( AttrVal( $name, "disable", "0" ) eq "1" );
|
||||
|
||||
return AMAD_SelectSetCmd( $hash, $cmd, @val ) if( @val )
|
||||
|| ( lc $cmd eq 'statusrequest' );
|
||||
return AMAD_SelectSetCmd( $hash, $cmd, @val ) if( @val ) && ( ReadingsVal( $name, "deviceState", "online" ) eq "offline" ) && ( lc $cmd eq 'devicestate' );
|
||||
return "Cannot set command, FHEM Device is offline" if( ReadingsVal( $name, "deviceState", "online" ) eq "offline" );
|
||||
|
||||
return AMAD_SelectSetCmd( $hash, $cmd, @val ) if( @val ) || ( lc $cmd eq 'statusrequest' );
|
||||
}
|
||||
|
||||
return "Unknown argument $cmd, bearword as argument or wrong parameter(s), choose one of $list";
|
||||
@ -406,11 +407,10 @@ sub AMAD_RetrieveAutomagicInfoFinished($$$) {
|
||||
|
||||
### End Error Handling
|
||||
|
||||
|
||||
$hash->{helper}{infoErrorCounter} = 0;
|
||||
|
||||
### Begin Response Processing
|
||||
$hash->{STATE} = "active" if( $hash->{STATE} eq "initialized" || $hash->{STATE} ne "active" );
|
||||
$hash->{helper}{infoErrorCounter} = 0;
|
||||
|
||||
my @valuestring = split( '@@@@', $data );
|
||||
my %buffer;
|
||||
@ -432,6 +432,8 @@ sub AMAD_RetrieveAutomagicInfoFinished($$$) {
|
||||
readingsBulkUpdate( $hash, "lastStatusRequestState", "statusRequest_done" );
|
||||
|
||||
readingsEndUpdate( $hash, 1 );
|
||||
|
||||
$hash->{helper}{infoErrorCounter} = 0;
|
||||
### End Response Processing
|
||||
|
||||
$hash->{STATE} = "active" if( $hash->{STATE} eq "initialized" );
|
||||
@ -501,7 +503,8 @@ sub AMAD_HTTP_POSTerrorHandling($$$) {
|
||||
readingsBulkUpdate( $hash, "lastSetCommandError", "check automagicApp on your device" );
|
||||
|
||||
Log3 $name, 4, "AMAD ($name) - Please check the AutomagicAPP on your Device";
|
||||
} else {
|
||||
}
|
||||
elsif( $hash->{helper}{setCmdErrorCounter} > 4 ) {
|
||||
readingsBulkUpdate( $hash, "lastSetCommandError", "unknown error, please contact the developer" );
|
||||
|
||||
Log3 $name, 4, "AMAD ($name) - UNKNOWN ERROR, PLEASE CONTACT THE DEVELOPER, DEVICE DISABLED";
|
||||
@ -537,24 +540,17 @@ sub AMAD_HTTP_POSTerrorHandling($$$) {
|
||||
}
|
||||
}
|
||||
|
||||
if( $data eq "" and exists( $param->{code} ) ) {
|
||||
if( $data eq "" and exists( $param->{code} ) && $param->{code} ne 200 ) {
|
||||
$hash->{STATE} = $param->{code} if( $hash->{STATE} ne "initialized" );
|
||||
$hash->{helper}{setCmdErrorCounter} = ( $hash->{helper}{setCmdErrorCounter} + 1 );
|
||||
|
||||
readingsBeginUpdate( $hash );
|
||||
|
||||
if( $param->{code} ne 200 ) {
|
||||
readingsBulkUpdate($hash, "lastSetCommandState", "cmd_error" );
|
||||
readingsBulkUpdate($hash, "lastSetCommandError", "http Error ".$param->{code} );
|
||||
}
|
||||
readingsBulkUpdate( $hash, "lastSetCommandState" ,"cmd_done" );
|
||||
readingsEndUpdate( $hash, 1 );
|
||||
|
||||
Log3 $name, 5, "AMAD ($name) - AMAD_HTTP_POST: received http code ".$param->{code};
|
||||
|
||||
Log3 $name, 4, "AMAD ($name) - Starte Update GetUpdateLocal";
|
||||
AMAD_GetUpdateLocal( $hash );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -570,11 +566,19 @@ sub AMAD_HTTP_POSTerrorHandling($$$) {
|
||||
} else {
|
||||
readingsBulkUpdate( $hash, "lastSetCommandError", "http error ".$param->{code} );
|
||||
}
|
||||
readingsEndUpdate( $hash, 1 );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
readingsEndUpdate( $hash, 1 );
|
||||
### End Error Handling
|
||||
|
||||
readingsSingleUpdate( $hash, "lastSetCommandState", "cmd_done", 1 );
|
||||
$hash->{helper}{infoErrorCounter} = 0;
|
||||
|
||||
Log3 $name, 4, "AMAD ($name) - Starte Update GetUpdateLocal";
|
||||
AMAD_GetUpdateLocal( $hash );
|
||||
|
||||
return undef;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user