diverse Flowanpassungen, Bugfixes für null Values
This commit is contained in:
parent
7af196bada
commit
04e73fd3c2
@ -68,8 +68,8 @@ use TcpServerUtils;
|
||||
eval "use JSON;1" or $missingModul .= "JSON ";
|
||||
|
||||
|
||||
my $modulversion = "3.9.52";
|
||||
my $flowsetversion = "3.9.52";
|
||||
my $modulversion = "3.9.55";
|
||||
my $flowsetversion = "3.9.55";
|
||||
|
||||
|
||||
|
||||
@ -111,7 +111,6 @@ sub AMADCommBridge_Initialize($) {
|
||||
|
||||
$hash->{AttrFn} = "AMADCommBridge_Attr";
|
||||
$hash->{AttrList} = "expertMode:1 ".
|
||||
"port ".
|
||||
"disable:1 ".
|
||||
$readingFnAttributes;
|
||||
|
||||
@ -196,29 +195,6 @@ sub AMADCommBridge_Attr(@) {
|
||||
}
|
||||
}
|
||||
|
||||
elsif( $attrName eq "port" ) {
|
||||
if( $cmd eq "set" ) {
|
||||
|
||||
$hash->{PORT} = $attrVal;
|
||||
|
||||
delete $modules{AMADCommBridge}{defptr}{BRIDGE};
|
||||
TcpServer_Close( $hash );
|
||||
Log3 $name, 3, "AMADCommBridge ($name) - CommBridge Port changed. CommBridge are closed and new open!";
|
||||
|
||||
AMADCommBridge_CommBridge_Open( $hash );
|
||||
|
||||
} else {
|
||||
|
||||
$hash->{PORT} = 8090;
|
||||
|
||||
delete $modules{AMADCommBridge}{defptr}{BRIDGE};
|
||||
TcpServer_Close( $hash );
|
||||
Log3 $name, 3, "AMADCommBridge ($name) - CommBridge Port changed. CommBridge are closed and new open!";
|
||||
|
||||
AMADCommBridge_Open( $hash );
|
||||
}
|
||||
}
|
||||
|
||||
return undef;
|
||||
}
|
||||
|
||||
@ -286,14 +262,14 @@ sub AMADCommBridge_ErrorHandling($$$) {
|
||||
if( $dhash->{helper}{infoErrorCounter} > 0 ) {
|
||||
|
||||
readingsBeginUpdate( $dhash );
|
||||
readingsBulkUpdate( $dhash, "lastStatusRequestState", "statusRequest_error" );
|
||||
readingsBulkUpdateIfChanged( $dhash, "lastStatusRequestState", "statusRequest_error", 1 );
|
||||
|
||||
if( ReadingsVal( $dname, "flow_Informations", "active" ) eq "inactive" && ReadingsVal( $dname, "flow_SetCommands", "active" ) eq "inactive" ) {
|
||||
|
||||
Log3 $dname, 5, "AMADCommBridge ($dname) - statusRequestERROR: CHECK THE LAST ERROR READINGS FOR MORE INFO, DEVICE IS SET OFFLINE";
|
||||
|
||||
readingsBulkUpdate( $dhash, "deviceState", "offline" );
|
||||
readingsBulkUpdate ( $dhash, "state", "AMAD Flows inactive, device set offline");
|
||||
readingsBulkUpdateIfChanged( $dhash, "deviceState", "offline", 1 );
|
||||
readingsBulkUpdateIfChanged ( $dhash, "state", "AMAD Flows inactive, device set offline",1);
|
||||
}
|
||||
|
||||
elsif( $dhash->{helper}{infoErrorCounter} > 7 && $dhash->{helper}{setCmdErrorCounter} > 4 ) {
|
||||
@ -301,7 +277,7 @@ sub AMADCommBridge_ErrorHandling($$$) {
|
||||
Log3 $dname, 5, "AMADCommBridge ($dname) - statusRequestERROR: UNKNOWN ERROR, PLEASE CONTACT THE DEVELOPER, DEVICE DISABLED";
|
||||
|
||||
$attr{$dname}{disable} = 1;
|
||||
readingsBulkUpdate ( $dhash, "state", "Unknown Error, device disabled");
|
||||
readingsBulkUpdateIfChanged ( $dhash, "state", "Unknown Error, device disabled", 1);
|
||||
|
||||
$dhash->{helper}{infoErrorCounter} = 0;
|
||||
$dhash->{helper}{setCmdErrorCounter} = 0;
|
||||
@ -318,8 +294,8 @@ sub AMADCommBridge_ErrorHandling($$$) {
|
||||
|
||||
Log3 $dname, 5, "AMADCommBridge ($dname) - statusRequestERROR: To many Errors please check your Network or Device Configuration, DEVICE IS SET OFFLINE";
|
||||
|
||||
readingsBulkUpdate( $dhash, "deviceState", "offline" );
|
||||
readingsBulkUpdate ( $dhash, "state", "To many Errors, device set offline");
|
||||
readingsBulkUpdateIfChanged( $dhash, "deviceState", "offline", 1 );
|
||||
readingsBulkUpdateIfChanged ( $dhash, "state", "To many Errors, device set offline", 1);
|
||||
$dhash->{helper}{infoErrorCounter} = 0;
|
||||
}
|
||||
|
||||
@ -335,10 +311,10 @@ sub AMADCommBridge_ErrorHandling($$$) {
|
||||
if( $err ne "" ) {
|
||||
|
||||
readingsBeginUpdate( $dhash );
|
||||
readingsBulkUpdate ( $dhash, "state", "$err") if( ReadingsVal( $dname, "state", 1 ) ne "initialized" );
|
||||
readingsBulkUpdateIfChanged ( $dhash, "state", "$err") if( ReadingsVal( $dname, "state", 1 ) ne "initialized" );
|
||||
$dhash->{helper}{infoErrorCounter} = ( $dhash->{helper}{infoErrorCounter} + 1 );
|
||||
|
||||
readingsBulkUpdate( $dhash, "lastStatusRequestState", "statusRequest_error" );
|
||||
readingsBulkUpdateIfChanged( $dhash, "lastStatusRequestState", "statusRequest_error", 1 );
|
||||
|
||||
if( $err =~ /timed out/ ) {
|
||||
|
||||
@ -365,10 +341,10 @@ sub AMADCommBridge_ErrorHandling($$$) {
|
||||
if( $data eq "" and exists( $param->{code} ) && $param->{code} ne 200 ) {
|
||||
|
||||
readingsBeginUpdate( $dhash );
|
||||
readingsBulkUpdate ( $dhash, "state", $param->{code} ) if( ReadingsVal( $dname, "state", 1 ) ne "initialized" );
|
||||
readingsBulkUpdateIfChanged ( $dhash, "state", $param->{code}, 1 ) if( ReadingsVal( $dname, "state", 1 ) ne "initialized" );
|
||||
$dhash->{helper}{infoErrorCounter} = ( $dhash->{helper}{infoErrorCounter} + 1 );
|
||||
|
||||
readingsBulkUpdate( $dhash, "lastStatusRequestState", "statusRequest_error" );
|
||||
readingsBulkUpdateIfChanged( $dhash, "lastStatusRequestState", "statusRequest_error", 1 );
|
||||
|
||||
if( $param->{code} ne 200 ) {
|
||||
|
||||
@ -384,10 +360,10 @@ sub AMADCommBridge_ErrorHandling($$$) {
|
||||
|
||||
if( ( $data =~ /Error/i ) and exists( $param->{code} ) ) {
|
||||
readingsBeginUpdate( $dhash );
|
||||
readingsBulkUpdate( $dhash, "state", $param->{code} ) if( ReadingsVal( $dname, "state" ,0) ne "initialized" );
|
||||
readingsBulkUpdateIfChanged( $dhash, "state", $param->{code}, 1 ) if( ReadingsVal( $dname, "state" ,0) ne "initialized" );
|
||||
$dhash->{helper}{infoErrorCounter} = ( $dhash->{helper}{infoErrorCounter} + 1 );
|
||||
|
||||
readingsBulkUpdate( $dhash, "lastStatusRequestState", "statusRequest_error" );
|
||||
readingsBulkUpdateIfChanged( $dhash, "lastStatusRequestState", "statusRequest_error", 1 );
|
||||
|
||||
if( $param->{code} eq 404 && ReadingsVal( $dname, "flow_Informations", "inactive" ) eq "inactive" ) {
|
||||
|
||||
@ -421,14 +397,14 @@ sub AMADCommBridge_ErrorHandling($$$) {
|
||||
if( $dhash->{helper}{setCmdErrorCounter} > 2 ) {
|
||||
|
||||
readingsBeginUpdate( $dhash );
|
||||
readingsBulkUpdate( $dhash, "lastSetCommandState", "statusRequest_error" );
|
||||
readingsBulkUpdateIfChanged( $dhash, "lastSetCommandState", "statusRequest_error", 1 );
|
||||
|
||||
if( ReadingsVal( $dname, "flow_Informations", "active" ) eq "inactive" && ReadingsVal( $dname, "flow_SetCommands", "active" ) eq "inactive" ) {
|
||||
|
||||
Log3 $dname, 5, "AMADCommBridge ($dname) - setCommandERROR: CHECK THE LAST ERROR READINGS FOR MORE INFO, DEVICE IS SET OFFLINE";
|
||||
|
||||
readingsBulkUpdate( $dhash, "deviceState", "offline" );
|
||||
readingsBulkUpdate( $dhash, "state", "AMAD Flows inactive, device set offline" );
|
||||
readingsBulkUpdateIfChanged( $dhash, "deviceState", "offline", 1 );
|
||||
readingsBulkUpdateIfChanged( $dhash, "state", "AMAD Flows inactive, device set offline", 1 );
|
||||
}
|
||||
|
||||
elsif( $dhash->{helper}{infoErrorCounter} > 7 && $dhash->{helper}{setCmdErrorCounter} > 4 ) {
|
||||
@ -436,7 +412,7 @@ sub AMADCommBridge_ErrorHandling($$$) {
|
||||
Log3 $dname, 5, "AMADCommBridge ($dname) - setCommandERROR: UNKNOWN ERROR, PLEASE CONTACT THE DEVELOPER, DEVICE DISABLED";
|
||||
|
||||
$attr{$dname}{disable} = 1;
|
||||
readingsBulkUpdate( $dhash, "state", "Unknown Error, device disabled" );
|
||||
readingsBulkUpdateIfChanged( $dhash, "state", "Unknown Error, device disabled", 1 );
|
||||
$dhash->{helper}{infoErrorCounter} = 0;
|
||||
$dhash->{helper}{setCmdErrorCounter} = 0;
|
||||
|
||||
@ -452,8 +428,8 @@ sub AMADCommBridge_ErrorHandling($$$) {
|
||||
|
||||
Log3 $dname, 5, "AMADCommBridge ($dname) - setCommandERROR: To many Errors please check your Network or Device Configuration, DEVICE IS SET OFFLINE";
|
||||
|
||||
readingsBulkUpdate( $dhash, "deviceState", "offline" );
|
||||
readingsBulkUpdate( $dhash, "state", "To many Errors, device set offline" );
|
||||
readingsBulkUpdateIfChanged( $dhash, "deviceState", "offline", 1 );
|
||||
readingsBulkUpdateIfChanged( $dhash, "state", "To many Errors, device set offline", 1 );
|
||||
$dhash->{helper}{setCmdErrorCounter} = 0;
|
||||
}
|
||||
|
||||
@ -468,10 +444,10 @@ sub AMADCommBridge_ErrorHandling($$$) {
|
||||
if( defined( $err ) ) {
|
||||
if( $err ne "" ) {
|
||||
readingsBeginUpdate( $dhash );
|
||||
readingsBulkUpdate( $dhash, "state", $err ) if( ReadingsVal( $dname, "state", 0 ) ne "initialized" );
|
||||
readingsBulkUpdateIfChanged( $dhash, "state", $err, 1 ) if( ReadingsVal( $dname, "state", 0 ) ne "initialized" );
|
||||
$dhash->{helper}{setCmdErrorCounter} = ($dhash->{helper}{setCmdErrorCounter} + 1);
|
||||
|
||||
readingsBulkUpdate( $dhash, "lastSetCommandState", "setCmd_error" );
|
||||
readingsBulkUpdateIfChanged( $dhash, "lastSetCommandState", "setCmd_error", 1 );
|
||||
|
||||
if( $err =~ /timed out/ ) {
|
||||
|
||||
@ -498,11 +474,11 @@ sub AMADCommBridge_ErrorHandling($$$) {
|
||||
if( $data eq "" and exists( $param->{code} ) && $param->{code} ne 200 ) {
|
||||
|
||||
readingsBeginUpdate( $dhash );
|
||||
readingsBulkUpdate( $dhash, "state", $param->{code} ) if( ReadingsVal( $dhash, "state", 0 ) ne "initialized" );
|
||||
readingsBulkUpdateIfChanged( $dhash, "state", $param->{code}, 1 ) if( ReadingsVal( $dhash, "state", 0 ) ne "initialized" );
|
||||
|
||||
$dhash->{helper}{setCmdErrorCounter} = ( $dhash->{helper}{setCmdErrorCounter} + 1 );
|
||||
|
||||
readingsBulkUpdate($dhash, "lastSetCommandState", "setCmd_error" );
|
||||
readingsBulkUpdateIfChanged($dhash, "lastSetCommandState", "setCmd_error", 1 );
|
||||
|
||||
readingsEndUpdate( $dhash, 1 );
|
||||
|
||||
@ -514,15 +490,15 @@ sub AMADCommBridge_ErrorHandling($$$) {
|
||||
if( ( $data =~ /Error/i ) and exists( $param->{code} ) ) {
|
||||
|
||||
readingsBeginUpdate( $dhash );
|
||||
readingsBulkUpdate( $dhash, "state", $param->{code} ) if( ReadingsVal( $dname, "state", 0 ) ne "initialized" );
|
||||
readingsBulkUpdateIfChanged( $dhash, "state", $param->{code}, 1 ) if( ReadingsVal( $dname, "state", 0 ) ne "initialized" );
|
||||
|
||||
$dhash->{helper}{setCmdErrorCounter} = ( $dhash->{helper}{setCmdErrorCounter} + 1 );
|
||||
|
||||
readingsBulkUpdate( $dhash, "lastSetCommandState", "setCmd_error" );
|
||||
readingsBulkUpdateIfChanged( $dhash, "lastSetCommandState", "setCmd_error", 1 );
|
||||
|
||||
if( $param->{code} eq 404 ) {
|
||||
|
||||
readingsBulkUpdate( $dhash, "lastSetCommandError", "" );
|
||||
readingsBulkUpdateIfChanged( $dhash, "lastSetCommandError", "", 1 );
|
||||
Log3 $dname, 5, "AMADCommBridge ($dname) - setCommandERROR: setCommands flow is inactive on your device!";
|
||||
|
||||
} else {
|
||||
@ -728,7 +704,7 @@ sub AMADCommBridge_ResponseProcessing($$) {
|
||||
$decode_json = eval{decode_json($json)};
|
||||
|
||||
if($@){
|
||||
Log3 $bname, 3, "AMADCommBridge ($name) - ERROR while request: $@";
|
||||
Log3 $bname, 4, "AMADCommBridge ($name) - ERROR while request: $@";
|
||||
readingsSingleUpdate($bhash, "JSON info", "JSON ERROR", 1);
|
||||
$response = "header lines: \r\n AMADCommBridge receive a JSON error\r\n AMADCommBridge to do nothing\r\n";
|
||||
$c = $hash->{CD};
|
||||
@ -816,8 +792,8 @@ sub AMADCommBridge_ResponseProcessing($$) {
|
||||
my $fhemCmd = $decode_json->{payload}{voiceinputdata};
|
||||
|
||||
readingsBeginUpdate( $bhash);
|
||||
readingsBulkUpdate( $bhash, "receiveVoiceCommand", $fhemCmd );
|
||||
readingsBulkUpdate( $bhash, "receiveVoiceDevice", $fhemDevice );
|
||||
readingsBulkUpdateIfChanged( $bhash, "receiveVoiceCommand", $fhemCmd, 1 );
|
||||
readingsBulkUpdateIfChanged( $bhash, "receiveVoiceDevice", $fhemDevice, 1 );
|
||||
readingsEndUpdate( $bhash, 1 );
|
||||
Log3 $bname, 4, "AMADCommBridge ($name) - AMADCommBridge_CommBridge: set reading receive voice command: $fhemCmd from Device $fhemDevice";
|
||||
|
||||
|
@ -54,8 +54,8 @@ use Encode qw(encode);
|
||||
eval "use JSON;1" or $missingModul .= "JSON ";
|
||||
|
||||
|
||||
my $modulversion = "3.9.52";
|
||||
my $flowsetversion = "3.9.52";
|
||||
my $modulversion = "3.9.55";
|
||||
my $flowsetversion = "3.9.55";
|
||||
|
||||
|
||||
|
||||
@ -178,8 +178,8 @@ sub AMADDevice_Define($$) {
|
||||
$attr{$name}{room} = "AMAD" if( !defined( $attr{$name}{room} ) );
|
||||
|
||||
readingsBeginUpdate($hash);
|
||||
readingsBulkUpdate( $hash, "state", "initialized");
|
||||
readingsBulkUpdate( $hash, "deviceState", "unknown");
|
||||
readingsBulkUpdateIfChanged( $hash, "state", "initialized",1);
|
||||
readingsBulkUpdateIfChanged( $hash, "deviceState", "unknown",1);
|
||||
readingsEndUpdate($hash,1);
|
||||
|
||||
|
||||
@ -376,7 +376,7 @@ sub AMADDevice_WriteReadings($$) {
|
||||
#### schreiben der Readings
|
||||
|
||||
Log3 $name, 5, "AMADDevice ($name) - Processing data: $decode_json";
|
||||
readingsSingleUpdate( $hash, "state", "active", 1) if( ReadingsVal( $name, "state", 0 ) ne "initialized" or ReadingsVal( $name, "state", 0 ) ne "active" );
|
||||
readingsSingleUpdate( $hash, "state", "active", 1) if( ReadingsVal( $name, "state", 0 ) ne "initialized" and ReadingsVal( $name, "state", 0 ) ne "active" );
|
||||
|
||||
### Event Readings
|
||||
my $t;
|
||||
@ -386,20 +386,22 @@ sub AMADDevice_WriteReadings($$) {
|
||||
readingsBeginUpdate($hash);
|
||||
|
||||
while( ( $t, $v ) = each %{$decode_json->{payload}} ) {
|
||||
readingsBulkUpdate( $hash, $t, $v ) if( defined( $v ) );
|
||||
|
||||
$v =~ s/\bnull\b/off/g if( ($t eq "nextAlarmDay" or $t eq "nextAlarmTime") and $v eq "null" );
|
||||
$v =~ s/\bnull\b//g;
|
||||
|
||||
readingsBulkUpdateIfChanged( $hash, $t, $v, 1 ) if( defined( $v ) );
|
||||
}
|
||||
|
||||
readingsBulkUpdate( $hash, "deviceState", "offline" ) if( $decode_json->{payload}{airplanemode} && $decode_json->{payload}{airplanemode} eq "on" );
|
||||
readingsBulkUpdate( $hash, "deviceState", "online" ) if( $decode_json->{payload}{airplanemode} && $decode_json->{payload}{airplanemode} eq "off" );
|
||||
readingsBulkUpdateIfChanged( $hash, "deviceState", "offline", 1 ) if( $decode_json->{payload}{airplanemode} && $decode_json->{payload}{airplanemode} eq "on" );
|
||||
readingsBulkUpdateIfChanged( $hash, "deviceState", "online", 1 ) if( $decode_json->{payload}{airplanemode} && $decode_json->{payload}{airplanemode} eq "off" );
|
||||
|
||||
readingsBulkUpdate( $hash, "lastStatusRequestState", "statusRequest_done" );
|
||||
readingsBulkUpdateIfChanged( $hash, "lastStatusRequestState", "statusRequest_done", 1 );
|
||||
|
||||
$hash->{helper}{infoErrorCounter} = 0;
|
||||
### End Response Processing
|
||||
|
||||
readingsBulkUpdate( $hash, "state", "active" ) if( ReadingsVal( $name, "state", 0 ) eq "initialized" );
|
||||
readingsBulkUpdateIfChanged( $hash, "state", "active", 1 ) if( ReadingsVal( $name, "state", 0 ) eq "initialized" );
|
||||
readingsEndUpdate( $hash, 1 );
|
||||
|
||||
$hash->{helper}{deviceStateErrorCounter} = 0 if( $hash->{helper}{deviceStateErrorCounter} > 0 and ReadingsVal( $name, "deviceState", "offline") eq "online" );
|
||||
@ -790,14 +792,14 @@ sub AMADDevice_checkDeviceState($) {
|
||||
|
||||
RemoveInternalTimer( $hash );
|
||||
|
||||
if( ReadingsAge( $name, "deviceState", 90 ) > 90 ) {
|
||||
if( ReadingsAge( $name, "deviceState", 240 ) > 240 ) {
|
||||
|
||||
AMADDevice_statusRequest( $hash ) if( $hash->{helper}{deviceStateErrorCounter} == 0 );
|
||||
readingsSingleUpdate( $hash, "deviceState", "offline", 1 ) if( ReadingsAge( $name, "deviceState", 180) > 180 and $hash->{helper}{deviceStateErrorCounter} > 0 );
|
||||
readingsSingleUpdate( $hash, "deviceState", "offline", 1 ) if( ReadingsAge( $name, "deviceState", 300) > 300 and $hash->{helper}{deviceStateErrorCounter} > 0 );
|
||||
$hash->{helper}{deviceStateErrorCounter} = ( $hash->{helper}{deviceStateErrorCounter} + 1 );
|
||||
}
|
||||
|
||||
InternalTimer( gettimeofday()+90, "AMADDevice_checkDeviceState", $hash, 0 );
|
||||
InternalTimer( gettimeofday()+240, "AMADDevice_checkDeviceState", $hash, 0 );
|
||||
|
||||
Log3 $name, 4, "AMADDevice ($name) - AMADDevice_checkDeviceState: set new Timer";
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user