add new attribut ASC_Shading_BetweenTheTime

for Shading In drive only between the Time
This commit is contained in:
2020-07-09 11:09:49 +02:00
parent fa82a77665
commit eb28fef84f
6 changed files with 46 additions and 7 deletions

View File

@ -239,6 +239,7 @@ our %userAttrList = (
'ASC_Shading_MinMax_Elevation' => '-',
'ASC_Shading_Min_OutsideTemperature' => '-',
'ASC_Shading_WaitingPeriod' => '-',
'ASC_Shading_BetweenTheTime' => '-',
'ASC_Drive_Delay' => '-',
'ASC_Drive_DelayStart' => '-',
'ASC_Shutter_IdleDetection' => '-',

View File

@ -62,6 +62,7 @@ our @EXPORT_OK = qw(
AverageBrightness
PerlCodeCheck
IsAdv
IsInTime
);
our %EXPORT_TAGS = (
ALL => [
@ -80,6 +81,7 @@ our %EXPORT_TAGS = (
AverageBrightness
PerlCodeCheck
IsAdv
IsInTime
)
],
);
@ -1156,4 +1158,22 @@ sub IsAdv {
return $adv;
}
sub IsInTime {
my $dfi = shift;
$dfi =~ s/{([^\x7d]*)}/$cmdFromAnalyze=$1; eval $1/ge; # Forum #69787
my ($sec,$min,$hour,$mday,$month,$year,$wday,$yday,$isdst) = localtime(gettimeofday());
my $dhms = sprintf("%s\@%02d:%02d:%02d", $wday, $hour, $min, $sec);
foreach my $ft (split(" ", $dfi)) {
my ($from, $to) = split("-", $ft);
if(defined($from) && defined($to)) {
$from = "$wday\@$from" if(index($from,"@") < 0);
$to = "$wday\@$to" if(index($to, "@") < 0);
return 1 if($from le $dhms && $dhms le $to);
}
}
return 0;
}
1;

View File

@ -512,8 +512,8 @@ sub ShadingProcessingDriveCommand {
$FHEM::Automation::ShuttersControl::shutters->setShadingStatus(
$FHEM::Automation::ShuttersControl::shutters->getShadingStatus );
if (
$FHEM::Automation::ShuttersControl::shutters->getShadingStatus eq 'in'
if ( IsInTime($FHEM::Automation::ShuttersControl::shutters->getShadingBetweenTheTime)
&& $FHEM::Automation::ShuttersControl::shutters->getShadingStatus eq 'in'
&& $getShadingPos != $getStatus
&& (
FHEM::Automation::ShuttersControl::CheckIfShuttersWindowRecOpen(

View File

@ -1781,6 +1781,21 @@ sub getDown {
return AttrVal( $self->{shuttersDev}, 'ASC_Down', 'astro' );
}
sub setShadingBetweenTheTime {
my $self = shift;
my $attrVal = shift;
_setAttributs( $self->{shuttersDev}, 'ASC_Shading_BetweenTheTime', $attrVal );
return;
}
sub getShadingBetweenTheTime {
my $self = shift;
return AttrVal( $self->{shuttersDev}, 'ASC_Shading_BetweenTheTime', '00:00-24:00' );
}
sub setTimeUpEarly {
my $self = shift;
my $attrVal = shift;