fix Perlcode use in Position Attributs

This commit is contained in:
Marko Oldenburg
2020-04-17 16:28:16 +02:00
parent 775219b034
commit 770fd0d26f

View File

@@ -4428,14 +4428,15 @@ sub _SetCmdFn {
CommandSet( CommandSet(
undef, undef,
( (
$shutters->getSlatDevice ne 'none' ? $shutters->getSlatDevice $shutters->getSlatDevice ne 'none'
? $shutters->getSlatDevice
: $shuttersDev : $shuttersDev
) )
. ' ' . ' '
. $shutters->getSlatPosCmd . $shutters->getSlatPosCmd . ' '
. ' '
. $slatPos . $slatPos
) if ( $slatPos > -1 )
if ( $slatPos > -1
&& $shutters->getSlatPosCmd ne 'none' ); && $shutters->getSlatPosCmd ne 'none' );
$shutters->setSelfDefenseAbsent( 0, 0 ) $shutters->setSelfDefenseAbsent( 0, 0 )
@@ -4484,7 +4485,7 @@ sub _perlCodeCheck {
my $exec = shift; my $exec = shift;
my $val = undef; my $val = undef;
if ( $exec =~ m{^\{(.+)\}$}xms ) { if ( $exec =~ m{\A\{(.+)\}\z}xms ) {
$val = main::AnalyzePerlCommand( undef, $1 ); $val = main::AnalyzePerlCommand( undef, $1 );
} }
@@ -5590,13 +5591,50 @@ sub _getPosition {
); );
$self->{ $self->{shuttersDev} }->{$attr}->{LASTGETTIME} = $self->{ $self->{shuttersDev} }->{$attr}->{LASTGETTIME} =
int( gettimeofday() ); int( gettimeofday() );
my ( $position, $posAssignment ) =
my $position;
my $posAssignment;
if (
AttrVal( $self->{shuttersDev}, $attr,
$userAttrList{$userAttrList}
[ AttrVal( $self->{shuttersDev}, 'ASC', 2 ) ] ) =~
m{\A\{.+\}\z}xms
)
{
my $response = FHEM::AutoShuttersControl::_perlCodeCheck(
AttrVal(
$self->{shuttersDev},
$attr,
$userAttrList{$userAttrList}
[ AttrVal( $self->{shuttersDev}, 'ASC', 2 ) ]
)
);
( $position, $posAssignment ) = split ':', $response;
$position = (
$position =~ m{\A\d+(\.\d+)?\z}xms
? $position
: $userAttrList{$userAttrList}
[ AttrVal( $self->{shuttersDev}, 'ASC', 2 ) ]
);
$posAssignment = (
$posAssignment =~ m{\A\d+(\.\d+)?\z}xms
? $posAssignment
: 'none'
);
}
else {
( $position, $posAssignment ) =
FHEM::AutoShuttersControl::GetAttrValues( FHEM::AutoShuttersControl::GetAttrValues(
$self->{shuttersDev}, $self->{shuttersDev},
$attr, $attr,
$userAttrList{$userAttrList} $userAttrList{$userAttrList}
[ AttrVal( $self->{shuttersDev}, 'ASC', 2 ) ] [ AttrVal( $self->{shuttersDev}, 'ASC', 2 ) ]
); );
}
### erwartetes Ergebnis ### erwartetes Ergebnis
# DEVICE:READING # DEVICE:READING
@@ -5714,7 +5752,9 @@ sub getSlatDevice {
); );
$shutters->getSlatPosCmd; $shutters->getSlatPosCmd;
return ( $self->{ $self->{shuttersDev} }->{ASC_SlatPosCmd_SlatDevice}->{device} ); return (
$self->{ $self->{shuttersDev} }->{ASC_SlatPosCmd_SlatDevice}->{device}
);
} }
sub getPrivacyUpTime { sub getPrivacyUpTime {
@@ -8585,7 +8625,7 @@ sub getBlockAscDrivesAfterManual {
], ],
"release_status": "testing", "release_status": "testing",
"license": "GPL_2", "license": "GPL_2",
"version": "v0.9.4", "version": "v0.9.5",
"author": [ "author": [
"Marko Oldenburg <leongaultier@gmail.com>" "Marko Oldenburg <leongaultier@gmail.com>"
], ],