2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-12 16:46:35 +00:00

73_AutoShuttersControl: fix IsDay Fn for weekend condition and more

git-svn-id: https://svn.fhem.de/fhem/trunk@23008 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
LeonGaultier 2020-10-23 05:32:18 +00:00
parent bce86b5c76
commit 72c8bbd2b9
7 changed files with 115 additions and 61 deletions

View File

@ -1,5 +1,8 @@
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
# Do not insert empty lines here, update check depends on it.
- bugfix: 73_AutoShuttersControl: fix IsDay Fn for weekend condition
- fix detected IsDay for Brightness
- https://git.cooltux.net/FHEM/mod-AutoShuttersControl/issues/25
- feature: 72_XiaomiDevice: New fan type FA1
- change: 50_TelegramBot: sendVideo and support for video format
- bugfix: 89_FULLY: Removed log messages

View File

@ -2,7 +2,7 @@
#
# Developed with Kate
#
# (c) 2018-2020 Copyright: Marko Oldenburg (leongaultier at gmail dot com)
# (c) 2018-2020 Copyright: Marko Oldenburg (fhemdevelopment at cooltux dot net)
# All rights reserved
#
# Special thanks goes to:
@ -41,6 +41,12 @@
# !!!!! - Innerhalb einer Shutterschleife kein CommandAttr verwenden. Bring Fehler!!! Kommen Raumnamen in die Shutterliste !!!!!!
#
package main;
use Meta;
package FHEM::AutoShuttersControl;
use strict;
@ -1258,7 +1264,7 @@ sub Initialize {
],
"release_status": "testing",
"license": "GPL_2",
"version": "v0.10.9",
"version": "v0.10.10",
"author": [
"Marko Oldenburg <leongaultier@gmail.com>"
],

View File

@ -506,7 +506,7 @@ sub Notify {
{ # Kommt ein globales Event und beinhaltet folgende Syntax wird die Funktion zur Verarbeitung aufgerufen
if (
grep
m{^(ATTR|DELETEATTR)\s(.*ASC_Time_Up_WE_Holiday|.*ASC_Up|.*ASC_Down|.*ASC_AutoAstroModeMorning|.*ASC_AutoAstroModeMorningHorizon|.*ASC_AutoAstroModeEvening|.*ASC_AutoAstroModeEveningHorizon|.*ASC_Time_Up_Early|.*ASC_Time_Up_Late|.*ASC_Time_Down_Early|.*ASC_Time_Down_Late|.*ASC_autoAstroModeMorning|.*ASC_autoAstroModeMorningHorizon|.*ASC_PrivacyDownValue_beforeNightClose|.*ASC_PrivacyUpValue_beforeDayOpen|.*ASC_autoAstroModeEvening|.*ASC_autoAstroModeEveningHorizon|.*ASC_Roommate_Device|.*ASC_WindowRec|.*ASC_residentsDev|.*ASC_rainSensor|.*ASC_windSensor|.*ASC_tempSensor|.*ASC_BrightnessSensor|.*ASC_twilightDevice|.*ASC_ExternalTrigger|.*ASC_Shading_StateChange_SunnyCloudy)(\s.*|$)}xms,
m{^(ATTR|DELETEATTR)\s(.*ASC_Time_Up_WE_Holiday|.*ASC_Up|.*ASC_Down|.*ASC_AutoAstroModeMorning|.*ASC_AutoAstroModeMorningHorizon|.*ASC_AutoAstroModeEvening|.*ASC_AutoAstroModeEveningHorizon|.*ASC_Time_Up_Early|.*ASC_Time_Up_Late|.*ASC_Time_Down_Early|.*ASC_Time_Down_Late|.*ASC_autoAstroModeMorning|.*ASC_autoAstroModeMorningHorizon|.*ASC_PrivacyDownValue_beforeNightClose|.*ASC_PrivacyUpValue_beforeDayOpen|.*ASC_autoAstroModeEvening|.*ASC_autoAstroModeEveningHorizon|.*ASC_Roommate_Device|.*ASC_WindowRec|.*ASC_residentsDev|.*ASC_rainSensor|.*ASC_windSensor|.*ASC_tempSensor|.*ASC_BrightnessSensor|.*ASC_twilightDevice|.*ASC_ExternalTrigger|.*ASC_Shading_StateChange_SunnyCloudy|.*ASC_TempSensor|.*ASC_Shading_Mode)(\s.*|$)}xms,
@{$events}
)
{
@ -571,7 +571,7 @@ sub Set {
elsif ( lc $cmd eq 'controlshading' ) {
return "usage: $cmd" if ( scalar( @{$aArg} ) > 1 );
my $response = CheckASC_ConditionsForShadingFn($hash);
my $response = CheckASC_ConditionsForShadingFn($hash,$aArg->[0]);
readingsSingleUpdate(
$hash, $cmd,
(
@ -985,8 +985,6 @@ sub ShuttersCommandSet {
(
CheckIfShuttersWindowRecOpen($shuttersDev) == 2
&& $shutters->getShuttersPlace eq 'terrace'
&& ( $shutters->getLockOut eq 'soft'
|| $shutters->getLockOut eq 'hard' )
&& !$shutters->getQueryShuttersPos($posValue)
)
|| (
@ -1017,7 +1015,9 @@ sub ShuttersCommandSet {
)
|| ( CheckIfShuttersWindowRecOpen($shuttersDev) == 2
&& $shutters->getShuttersPlace eq 'terrace'
&& !$shutters->getQueryShuttersPos($posValue) )
&& !$shutters->getQueryShuttersPos($posValue)
&& ( $shutters->getLockOut eq 'soft'
|| $shutters->getLockOut eq 'hard' ) )
|| ( $shutters->getRainProtectionStatus eq 'protected'
|| $shutters->getWindProtectionStatus eq 'protected' )
)

View File

@ -209,8 +209,21 @@ m{^(DELETEATTR|ATTR) #global ATTR myASC ASC_tempSensor Cellar
(.*)?}xms
)
{
CommandSet( undef, $name . ' controlShading on' )
if ( ReadingsVal( $name, 'controlShading', 'off' ) ne 'off' );
# ATTR RolloKinZimSteven_F1 ASC_Shading_Mode off
if ( $events =~ m{^ATTR\s(.*)\sASC_Shading_Mode\s(off)}xms ) {
my %funcHash = (
hash => $hash,
shuttersdevice => $1,
value => $2,
attrEvent => 1,
);
FHEM::Automation::ShuttersControl::Shading::_CheckShuttersConditionsForShadingFn(\%funcHash);
}
else {
CommandSet( undef, $name . ' controlShading on' )
if ( ReadingsVal( $name, 'controlShading', 'off' ) ne 'off' );
}
}
}
@ -913,11 +926,13 @@ sub EventProcessingResidents {
for my $shuttersDev ( @{ $hash->{helper}{shuttersList} } ) {
$FHEM::Automation::ShuttersControl::shutters->setShuttersDev(
$shuttersDev);
my $getModeUp =
$FHEM::Automation::ShuttersControl::shutters->getModeUp;
my $getModeDown =
$FHEM::Automation::ShuttersControl::shutters->getModeDown;
$FHEM::Automation::ShuttersControl::shutters->setHardLockOut('off');
if (
$FHEM::Automation::ShuttersControl::ascDev->getSelfDefense eq
'on'
@ -1594,7 +1609,7 @@ sub EventProcessingBrightness {
if ( $events =~ m{$reading:\s(\d+(\.\d+)?)}xms ) {
my $brightnessMinVal;
if ( $FHEM::Automation::ShuttersControl::shutters->getBrightnessMinVal >
-1 )
-2 )
{
$brightnessMinVal =
$FHEM::Automation::ShuttersControl::shutters->getBrightnessMinVal;
@ -1606,7 +1621,7 @@ sub EventProcessingBrightness {
my $brightnessMaxVal;
if ( $FHEM::Automation::ShuttersControl::shutters->getBrightnessMaxVal >
-1 )
-2 )
{
$brightnessMaxVal =
$FHEM::Automation::ShuttersControl::shutters->getBrightnessMaxVal;

View File

@ -257,13 +257,13 @@ sub _IsDay {
$FHEM::Automation::ShuttersControl::shutters->setShuttersDev($shuttersDev);
my $brightnessMinVal = (
$FHEM::Automation::ShuttersControl::shutters->getBrightnessMinVal > -1
$FHEM::Automation::ShuttersControl::shutters->getBrightnessMinVal > -2
? $FHEM::Automation::ShuttersControl::shutters->getBrightnessMinVal
: $FHEM::Automation::ShuttersControl::ascDev->getBrightnessMinVal
);
my $brightnessMaxVal = (
$FHEM::Automation::ShuttersControl::shutters->getBrightnessMaxVal > -1
$FHEM::Automation::ShuttersControl::shutters->getBrightnessMaxVal > -2
? $FHEM::Automation::ShuttersControl::shutters->getBrightnessMaxVal
: $FHEM::Automation::ShuttersControl::ascDev->getBrightnessMaxVal
);
@ -284,7 +284,15 @@ sub _IsDay {
$FHEM::Automation::ShuttersControl::shutters
->getTimeUpEarly ) / 86400
)
&& !IsWe()
&& ( !IsWe()
|| ( IsWe()
&& ( $FHEM::Automation::ShuttersControl::ascDev
->getSunriseTimeWeHoliday eq 'off'
|| $FHEM::Automation::ShuttersControl::shutters
->getTimeUpWeHoliday eq '01:25'
)
)
)
)
|| (
int( gettimeofday() / 86400 ) != int(
@ -336,7 +344,7 @@ sub _IsDay {
&& !$FHEM::Automation::ShuttersControl::shutters
->getSunset
)
|| !$FHEM::Automation::ShuttersControl::shutters->getSunset
|| $FHEM::Automation::ShuttersControl::shutters->getSunrise
) ? 1 : 0
)
if ( $FHEM::Automation::ShuttersControl::shutters->getDown eq

View File

@ -83,7 +83,8 @@ BEGIN {
}
sub CheckASC_ConditionsForShadingFn {
my $hash = shift;
my $hash = shift;
my $value = shift;
my $error;
@ -96,10 +97,17 @@ sub CheckASC_ConditionsForShadingFn {
my $count = 1;
for my $shuttersDev ( @{ $hash->{helper}{shuttersList} } ) {
my %funcHash = (
hash => $hash,
shuttersdevice => $shuttersDev,
value => $value,
attrEvent => 0,
);
InternalTimer(
gettimeofday() + $count,
'FHEM::Automation::ShuttersControl::Shading::_CheckShuttersConditionsForShadingFn',
$shuttersDev
\%funcHash
);
$count++;
@ -113,7 +121,11 @@ sub CheckASC_ConditionsForShadingFn {
}
sub _CheckShuttersConditionsForShadingFn {
my $shuttersDev = shift;
my $funcHash = shift;
my $hash = $funcHash->{hash};
my $shuttersDev = $funcHash->{shuttersdevice};
my $value = $funcHash->{value};
$FHEM::Automation::ShuttersControl::shutters->setShuttersDev($shuttersDev);
my $shuttersDevHash = $defs{$shuttersDev};
@ -121,59 +133,67 @@ sub _CheckShuttersConditionsForShadingFn {
my $errorMessage;
my $warnMessage;
my $infoMessage;
if ( $value eq 'off' ) {
$FHEM::Automation::ShuttersControl::shutters->setShadingStatus('out');
$infoMessage .= ' shading was deactivated ' . ($funcHash->{attrEvent} ? 'in the device' : 'globally');
$errorMessage .= '';
ShadingProcessingDriveCommand( $hash, $shuttersDev );
}
else {
$infoMessage .= (
$FHEM::Automation::ShuttersControl::shutters->getShadingMode ne 'off'
&& $FHEM::Automation::ShuttersControl::ascDev
->getAutoShuttersControlShading eq 'on'
&& $FHEM::Automation::ShuttersControl::shutters->getOutTemp == -100
? ' shading active, global temp sensor is set, but shutters temperature sensor is not set'
: ''
);
$infoMessage .= (
$FHEM::Automation::ShuttersControl::shutters->getShadingMode ne 'off'
&& $FHEM::Automation::ShuttersControl::ascDev
->getAutoShuttersControlShading eq 'on'
&& $FHEM::Automation::ShuttersControl::shutters->getOutTemp == -100
? ' shading active, global temp sensor is set, but shutters temperature sensor is not set'
: ''
);
$warnMessage .= (
$FHEM::Automation::ShuttersControl::shutters->getShadingMode eq 'off'
&& $FHEM::Automation::ShuttersControl::ascDev
->getAutoShuttersControlShading eq 'on'
? ' global shading active but ASC_Shading_Mode attribut is not set or off'
: ''
);
$warnMessage .= (
$FHEM::Automation::ShuttersControl::shutters->getShadingMode eq 'off'
&& $FHEM::Automation::ShuttersControl::ascDev
->getAutoShuttersControlShading eq 'on'
? ' global shading active but ASC_Shading_Mode attribut is not set or off'
: ''
);
$errorMessage .= (
$FHEM::Automation::ShuttersControl::shutters->getShadingMode ne 'off'
&& $FHEM::Automation::ShuttersControl::ascDev
->getAutoShuttersControlShading ne 'on'
&& $FHEM::Automation::ShuttersControl::ascDev
->getAutoShuttersControlShading ne 'off'
? ' ASC_Shading_Mode attribut is set but global shading has errors, look at ASC device '
. '<a href="'
. '/fhem?detail='
. ReadingsVal( $shuttersDev, 'associatedWith', 'ASC device' )
. $::FW_CSRF . '">'
. ReadingsVal( $shuttersDev, 'associatedWith', 'ASC device' )
. '</a>'
: ''
);
$errorMessage .= (
$FHEM::Automation::ShuttersControl::shutters->getShadingMode ne 'off'
&& $FHEM::Automation::ShuttersControl::ascDev
->getAutoShuttersControlShading ne 'on'
&& $FHEM::Automation::ShuttersControl::ascDev
->getAutoShuttersControlShading ne 'off'
? ' ASC_Shading_Mode attribut is set but global shading has errors, look at ASC device '
. '<a href="'
. '/fhem?detail='
. ReadingsVal( $shuttersDev, 'associatedWith', 'ASC device' )
. $::FW_CSRF . '">'
. ReadingsVal( $shuttersDev, 'associatedWith', 'ASC device' )
. '</a>'
: ''
);
$errorMessage .= (
$FHEM::Automation::ShuttersControl::shutters->getBrightness == -1
&& $FHEM::Automation::ShuttersControl::shutters->getShadingMode ne
'off'
? ' no brightness sensor found, please set ASC_BrightnessSensor attribut'
: ''
);
$errorMessage .= (
$FHEM::Automation::ShuttersControl::shutters->getBrightness == -1
&& $FHEM::Automation::ShuttersControl::shutters->getShadingMode ne
'off'
? ' no brightness sensor found, please set ASC_BrightnessSensor attribut'
: ''
);
}
$message .= ' ERROR: ' . $errorMessage
if ( defined($errorMessage)
if ( defined($errorMessage)
&& $errorMessage ne '' );
$message .= ' WARN: ' . $warnMessage
if ( defined($warnMessage)
if ( defined($warnMessage)
&& $warnMessage ne ''
&& $errorMessage eq '' );
$message .= ' INFO: ' . $infoMessage
if ( defined($infoMessage)
if ( defined($infoMessage)
&& $infoMessage ne ''
&& $errorMessage eq '' );
@ -452,6 +472,8 @@ sub ShadingProcessing {
|| $FHEM::Automation::ShuttersControl::shutters->getModeUp eq 'off'
|| $FHEM::Automation::ShuttersControl::shutters->getModeUp eq
'absent'
|| $FHEM::Automation::ShuttersControl::shutters->getModeUp eq
'gone'
|| ( $FHEM::Automation::ShuttersControl::shutters->getModeUp eq
'home'
&& $homemode ne 'asleep' )

View File

@ -738,9 +738,9 @@ sub _getBrightnessSensor {
$self->{ $self->{shuttersDev} }->{ASC_BrightnessSensor}->{reading} =
( $reading ne 'none' ? $reading : 'brightness' );
$self->{ $self->{shuttersDev} }->{ASC_BrightnessSensor}->{triggermin} =
( $min ne 'none' ? $min : -1 );
( $min ne 'none' ? $min : -2 );
$self->{ $self->{shuttersDev} }->{ASC_BrightnessSensor}->{triggermax} =
( $max ne 'none' ? $max : -1 );
( $max ne 'none' ? $max : -2 );
return $self->{ $self->{shuttersDev} }->{ASC_BrightnessSensor}->{device};
}