add error handling to set attributs and password
This commit is contained in:
parent
fcd10d6478
commit
973f81a1d5
@ -1,2 +1,2 @@
|
|||||||
UPD 2020-06-17_12:01:37 3338 FHEM/98_backupToStorage.pm
|
UPD 2020-06-17_12:01:37 3338 FHEM/98_backupToStorage.pm
|
||||||
UPD 2020-06-17_12:02:54 8823 lib/FHEM/backupToStorage.pm
|
UPD 2020-06-17_14:37:42 9679 lib/FHEM/backupToStorage.pm
|
||||||
|
@ -47,10 +47,6 @@ BEGIN {
|
|||||||
GP_Import(
|
GP_Import(
|
||||||
qw(
|
qw(
|
||||||
readingsSingleUpdate
|
readingsSingleUpdate
|
||||||
readingsBulkUpdate
|
|
||||||
readingsBulkUpdateIfChanged
|
|
||||||
readingsBeginUpdate
|
|
||||||
readingsEndUpdate
|
|
||||||
defs
|
defs
|
||||||
modules
|
modules
|
||||||
setKeyValue
|
setKeyValue
|
||||||
@ -145,6 +141,18 @@ sub Notify {
|
|||||||
if ( grep /^backup.done/,
|
if ( grep /^backup.done/,
|
||||||
@{$events} && $devname eq 'global' && $init_done );
|
@{$events} && $devname eq 'global' && $init_done );
|
||||||
|
|
||||||
|
CheckAttributsForCredentials($hash)
|
||||||
|
if (
|
||||||
|
(
|
||||||
|
grep /^DELETEATTR.$name.(bTS_Host|bTS_User)$/,
|
||||||
|
@{$events}
|
||||||
|
or grep /^ATTR.$name.(bTS_Host|bTS_User).\S+$/,
|
||||||
|
@{$events}
|
||||||
|
)
|
||||||
|
&& $devname eq 'global'
|
||||||
|
&& $init_done
|
||||||
|
);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -352,4 +360,26 @@ sub DeletePassword {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub CheckAttributsForCredentials {
|
||||||
|
my $hash = shift;
|
||||||
|
|
||||||
|
my $name = $hash->{NAME};
|
||||||
|
|
||||||
|
my $ncUser = AttrVal( $name, 'bTS_User', 'none' );
|
||||||
|
my $ncPass = ReadPassword( $hash, $name );
|
||||||
|
my $ncHost = AttrVal( $name, 'bTS_Host', 'none' );
|
||||||
|
my $ncPath = AttrVal( $name, 'bTS_Path', 'none' );
|
||||||
|
my $status = 'ready';
|
||||||
|
|
||||||
|
$status eq 'ready'
|
||||||
|
&& $ncUser eq 'none' ? 'no user credential attribut'
|
||||||
|
: $status eq 'ready'
|
||||||
|
&& $ncHost eq 'none' ? 'no host credential attribut'
|
||||||
|
: $status eq 'ready'
|
||||||
|
&& !defined($ncPass) ? 'no password set'
|
||||||
|
: $status;
|
||||||
|
|
||||||
|
return readingsSingleUpdate( $hash, 'state', $status, 1 );
|
||||||
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user