fix first start and set state reading
geändert: lib/FHEM/backupToStorage.pm
This commit is contained in:
		@@ -1,2 +1,2 @@
 | 
			
		||||
UPD 2020-06-17_15:03:50 3368 FHEM/98_backupToStorage.pm
 | 
			
		||||
UPD 2020-06-17_15:30:50 10123 lib/FHEM/backupToStorage.pm
 | 
			
		||||
UPD 2020-06-17_15:39:04 10502 lib/FHEM/backupToStorage.pm
 | 
			
		||||
 
 | 
			
		||||
@@ -79,17 +79,6 @@ sub Define {
 | 
			
		||||
    $hash->{VERSION}   = version->parse($VERSION)->normal;
 | 
			
		||||
    $hash->{NOTIFYDEV} = 'global';
 | 
			
		||||
 | 
			
		||||
    readingsSingleUpdate( $hash, 'state',
 | 
			
		||||
        ( 
 | 
			
		||||
               (AttrVal( $name, 'bTS_Host', 'none' ) eq 'none'
 | 
			
		||||
            || AttrVal( $name, 'bTS_User', 'none' ) eq 'none'
 | 
			
		||||
            || !defined( ReadPassword( $hash, $name ) ) )
 | 
			
		||||
          ? 'please set storage account credentials first'
 | 
			
		||||
          : 'ready'
 | 
			
		||||
        )
 | 
			
		||||
        , 1
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    Log3( $name, 3, "backupToStorage ($name) - defined" );
 | 
			
		||||
 | 
			
		||||
    return;
 | 
			
		||||
@@ -143,20 +132,44 @@ sub Notify {
 | 
			
		||||
          . Dumper $events);    # mit Dumper
 | 
			
		||||
 | 
			
		||||
    PushToStorage($hash)
 | 
			
		||||
      if ( grep /^backup.done/,
 | 
			
		||||
      if ( grep m{^backup.done}xms,
 | 
			
		||||
        @{$events} && $devname eq 'global' && $init_done );
 | 
			
		||||
 | 
			
		||||
    CheckAttributsForCredentials($hash)
 | 
			
		||||
      if (
 | 
			
		||||
        (
 | 
			
		||||
            grep /^DELETEATTR.$name.(bTS_Host|bTS_User)$/,
 | 
			
		||||
            grep m{^DELETEATTR.$name.(bTS_Host|bTS_User)$}xms,
 | 
			
		||||
            @{$events}
 | 
			
		||||
            or grep /^ATTR.$name.(bTS_Host|bTS_User).\S+$/,
 | 
			
		||||
            or grep m{^ATTR.$name.(bTS_Host|bTS_User).\S+$}xms,
 | 
			
		||||
            @{$events}
 | 
			
		||||
        )
 | 
			
		||||
        && $devname eq 'global'
 | 
			
		||||
        && $init_done
 | 
			
		||||
      );
 | 
			
		||||
      
 | 
			
		||||
    readingsSingleUpdate( $hash, 'state',
 | 
			
		||||
        ( 
 | 
			
		||||
               (AttrVal( $name, 'bTS_Host', 'none' ) eq 'none'
 | 
			
		||||
            || AttrVal( $name, 'bTS_User', 'none' ) eq 'none'
 | 
			
		||||
            || !defined( ReadPassword( $hash, $name ) ) )
 | 
			
		||||
          ? 'please set storage account credentials first'
 | 
			
		||||
          : 'ready'
 | 
			
		||||
        )
 | 
			
		||||
        , 1
 | 
			
		||||
    )
 | 
			
		||||
      if (
 | 
			
		||||
        (
 | 
			
		||||
            grep m{^DEFINED.$name$}xms,
 | 
			
		||||
            @{$events} && $devname eq 'global' && $init_done
 | 
			
		||||
        )
 | 
			
		||||
        || (
 | 
			
		||||
            grep m{^INITIALIZED$}xms,
 | 
			
		||||
            @{$events} or grep m{^REREADCFG$}xms,
 | 
			
		||||
            @{$events} or grep m{^MODIFIED.$name$}xms,
 | 
			
		||||
            @{$events}
 | 
			
		||||
        )
 | 
			
		||||
        && $devname eq 'global'
 | 
			
		||||
      );
 | 
			
		||||
 | 
			
		||||
    return;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user