make part of associatedWith

This commit is contained in:
Marko Oldenburg
2019-05-03 13:36:39 +02:00
parent 120fc78952
commit 8efa2058cf

View File

@ -44,7 +44,7 @@ use strict;
use warnings; use warnings;
use FHEM::Meta; use FHEM::Meta;
my $version = '0.6.5.9'; my $version = '0.6.5.10';
sub AutoShuttersControl_Initialize($) { sub AutoShuttersControl_Initialize($) {
my ($hash) = @_; my ($hash) = @_;
@ -698,18 +698,6 @@ sub WriteReadingsShuttersList($) {
'none' 'none'
) eq 'none' ) eq 'none'
); );
### associatedWith damit man sieht das der Rollladen mit einem ASC Device verbunden ist
readingsSingleUpdate(
$defs{$_},
'associatedWith',
(
ReadingsVal( $_, 'associatedWith', $name ) eq $name
? $name
: ReadingsVal( $_, 'associatedWith', 'none' ) . ',' . $name
),
0
);
} }
readingsBulkUpdate( $hash, 'state', 'active' ); readingsBulkUpdate( $hash, 'state', 'active' );
readingsEndUpdate( $hash, 0 ); readingsEndUpdate( $hash, 0 );
@ -740,6 +728,23 @@ sub UserAttributs_Readings_ForShutters($$) {
not defined( $attr{$_}{ ( split( ':', $attrib ) )[0] } ) not defined( $attr{$_}{ ( split( ':', $attrib ) )[0] } )
and $attrib eq 'ASC_Pos_Reading' ); and $attrib eq 'ASC_Pos_Reading' );
} }
### associatedWith damit man sieht das der Rollladen mit einem ASC Device verbunden ist
my $associatedString =
ReadingsVal( $_, 'associatedWith', 'none' );
if ( $associatedString ne 'none' ) {
my %hash;
%hash = map { ( $_ => 1 ) }
split( ',', "$associatedString,$name" );
readingsSingleUpdate( $defs{$_},
'associatedWith', join( ',', sort keys %hash ), 0 );
}
else {
readingsSingleUpdate( $defs{$_},
'associatedWith', $name, 0 );
}
#######################################
} }
## Oder das Attribut wird wieder gelöscht. ## Oder das Attribut wird wieder gelöscht.
elsif ( $cmd eq 'del' ) { elsif ( $cmd eq 'del' ) {
@ -750,6 +755,21 @@ sub UserAttributs_Readings_ForShutters($$) {
$_ . ' .?(AutoShuttersControl|ASC)_.*' ); $_ . ' .?(AutoShuttersControl|ASC)_.*' );
CommandDeleteAttr( undef, $_ . ' ASC' ); CommandDeleteAttr( undef, $_ . ' ASC' );
delFromDevAttrList( $_, $attrib ); delFromDevAttrList( $_, $attrib );
### associatedWith wird wieder entfernt
my $associatedString =
ReadingsVal( $_, 'associatedWith', 'none' );
my %hash;
%hash = map { ( $_ => 1 ) }
grep { " $name " !~ m/ $_ / }
split( ',', "$associatedString,$name" );
if ( keys %hash > 1 ) {
readingsSingleUpdate( $defs{$_},
'associatedWith', join( ',', sort keys %hash ), 0 );
}
else { CommandDeleteReading( undef, $_ . ' associatedWith' ); }
###################################
} }
} }
} }
@ -772,9 +792,9 @@ sub AddNotifyDev($@) {
my %hash; my %hash;
%hash = map { ( $_ => 1 ) } %hash = map { ( $_ => 1 ) }
split( ",", "$notifyDev,$dev" ); split( ',', "$notifyDev,$dev" );
$hash->{NOTIFYDEV} = join( ",", sort keys %hash ); $hash->{NOTIFYDEV} = join( ',', sort keys %hash );
my @devs = split( ',', $dev ); my @devs = split( ',', $dev );
foreach (@devs) { foreach (@devs) {
@ -802,13 +822,13 @@ sub DeleteNotifyDev($@) {
if ( !keys %{ $hash->{monitoredDevs}{$notifyDev} } ) { if ( !keys %{ $hash->{monitoredDevs}{$notifyDev} } ) {
delete $hash->{monitoredDevs}{$notifyDev}; delete $hash->{monitoredDevs}{$notifyDev};
my $notifyDevString = $hash->{NOTIFYDEV}; my $notifyDevString = $hash->{NOTIFYDEV};
$notifyDevString = "" if ( !$notifyDevString ); $notifyDevString = '' if ( !$notifyDevString );
my %hash; my %hash;
%hash = map { ( $_ => 1 ) } %hash = map { ( $_ => 1 ) }
grep { " $notifyDev " !~ m/ $_ / } grep { " $notifyDev " !~ m/ $_ / }
split( ",", "$notifyDevString,$notifyDev" ); split( ',', "$notifyDevString,$notifyDev" );
$hash->{NOTIFYDEV} = join( ",", sort keys %hash ); $hash->{NOTIFYDEV} = join( ',', sort keys %hash );
} }
} }
readingsSingleUpdate( $hash, '.monitoredDevs', readingsSingleUpdate( $hash, '.monitoredDevs',
@ -2984,8 +3004,7 @@ sub ShuttersSunrise($$) {
else { else {
$shuttersSunriseUnixtime = $shuttersSunriseUnixtime =
computeAlignTime( '24:00', computeAlignTime( '24:00',
$shutters->getTimeUpWeHoliday ) $shutters->getTimeUpWeHoliday ) + 86400;
+ 86400;
} }
} }
} }
@ -3711,11 +3730,13 @@ sub getWindProtectionStatus { # Werte protection, unprotection
sub getRainProtectionStatus { # Werte protection, unprotection sub getRainProtectionStatus { # Werte protection, unprotection
my $self = shift; my $self = shift;
return ( defined( $self->{ $self->{shuttersDev} }->{RainProtection} ) return (
defined( $self->{ $self->{shuttersDev} }->{RainProtection} )
and and
defined( $self->{ $self->{shuttersDev} }->{RainProtection}->{VAL} ) defined( $self->{ $self->{shuttersDev} }->{RainProtection}->{VAL} )
? $self->{ $self->{shuttersDev} }->{RainProtection}->{VAL} ? $self->{ $self->{shuttersDev} }->{RainProtection}->{VAL}
: 'unprotection' ); : 'unprotection'
);
} }
sub getShadingStatusTimestamp { sub getShadingStatusTimestamp {