removed reading API-status, status now in state of device

This commit is contained in:
Philipp Wo 2019-10-24 09:04:28 +02:00
parent 60b04ceb8c
commit 0b54ae4e83
1 changed files with 5 additions and 15 deletions

View File

@ -343,16 +343,12 @@ sub TadoAPI_callback($$$){
if($param->{code} == 401 || $param->{code} == 400){
$apiStatus = 1;
readingsBeginUpdate($hash);
readingsBulkUpdate($hash, "API-Status", "reachable");
readingsEndUpdate( $hash, 1 );
$hash->{STATE}="reachable";
Log3 $name, 3, "TadoAPI $name" . ": " . "API is reachable. Callback Status: " . $param->{code} if $debug;
}else{
$apiStatus = 0;
readingsBeginUpdate($hash);
readingsBulkUpdate($hash, "API-Status", "offline");
readingsEndUpdate( $hash, 1 );
$hash->{STATE}="error";
Log3 $name, 3, "TadoAPI $name" . ": " . "API error: apiStatus $apiStatus ($err)" if $debug;
}
@ -454,17 +450,13 @@ sub TadoAPI_requestNewToken(@) {
Log3 $name, 3, "TadoAPI $name" . ": " . "Retrived new authentication token successfully. Valid until " . localtime($hash->{TOKEN_LIFETIME}) if $debug;
#return to apistatus
readingsBeginUpdate($hash);
readingsBulkUpdate($hash, "API-Status", "reachable");
readingsEndUpdate( $hash, 1 );
$hash->{STATE}="reachable";
return 1;
}else{
Log3 $name, 3, "TadoAPI $name" . ": " . "Error in token retrival [Authentication Error]";
print $Response->status_line."\n" if $debug;
#apiStatus down
readingsBeginUpdate($hash);
readingsBulkUpdate($hash, "API-Status", "error");
readingsEndUpdate( $hash, 1 );
$hash->{STATE}="error";
return 0;
}
return undef;
@ -507,9 +499,7 @@ sub TadoAPI_refreshToken(@) {
if($Response->code == 500){
Log3 $name, 3, "TadoAPI $name" . ": " . "error: not connected - response: 500" if $debug;
$apiStatus = 0;
readingsBeginUpdate($hash);
readingsBulkUpdate($hash, "API-Status", "error");
readingsEndUpdate( $hash, 1 );
$hash->{STATE}="error";
}
else{
TadoAPI_requestNewToken($hash);