mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-10 09:16:53 +00:00
93_DbRep: prevent some attr eval as long as init_done is not set
git-svn-id: https://svn.fhem.de/fhem/trunk@28668 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
9fac130276
commit
1a08a84c89
@ -1,5 +1,6 @@
|
||||
# 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.
|
||||
- change: 93_DbRep: prevent some attr eval as long as init_done is not set
|
||||
- feature: 76_SolarForecast: currentMeterDev: opt. keys conprice, feedprice
|
||||
- change: 93_DbRep: executeBefore/AfterProc output: set verbose level to 3
|
||||
- change: 76_SolarForecast: minor code changes ones more
|
||||
|
@ -59,6 +59,7 @@ no if $] >= 5.017011, warnings => 'experimental::smartmatch';
|
||||
|
||||
# Version History intern
|
||||
my %DbRep_vNotesIntern = (
|
||||
"8.53.7" => "16.03.2024 prevent some attribute evaluation as long as init_done is not set ",
|
||||
"8.53.6" => "15.03.2024 change verbose level of DbRep_beforeproc, DbRep_afterproc to 3 ",
|
||||
"8.53.5" => "11.03.2024 some changes for MariaDB Perl driver usage, change DbRep_dbConnect".
|
||||
"support compression between client and server ",
|
||||
@ -1564,19 +1565,9 @@ sub DbRep_Attr {
|
||||
}
|
||||
}
|
||||
|
||||
if ($aName eq "fetchValueFn") {
|
||||
if($cmd eq "set") {
|
||||
my $VALUE = "Hello";
|
||||
if( $aVal =~ m/^\s*(\{.*\})\s*$/s ) { # Funktion aus Attr validieren
|
||||
$aVal = $1;
|
||||
}
|
||||
else {
|
||||
$aVal = "";
|
||||
}
|
||||
return "Your function does not match the form \"{<function>}\"" if(!$aVal);
|
||||
eval $aVal;
|
||||
return "Bad function: $@" if($@);
|
||||
}
|
||||
if ($aName eq "device") {
|
||||
my $awdev = $aVal;
|
||||
DbRep_modAssociatedWith ($hash,$cmd,$awdev);
|
||||
}
|
||||
|
||||
if ($aName eq "sqlCmdHistoryLength") {
|
||||
@ -1589,37 +1580,6 @@ sub DbRep_Attr {
|
||||
}
|
||||
}
|
||||
|
||||
if ($aName eq "userExitFn") {
|
||||
if($cmd eq "set") {
|
||||
if(!$aVal) {
|
||||
return "Usage of $aName is wrong. The function has to be specified as \"<UserExitFn> [reading:value]\" ";
|
||||
}
|
||||
if ($aVal =~ m/^\s*(\{.*\})\s*$/xs) { # unnamed Funktion direkt in userExitFn mit {...}
|
||||
$aVal = $1;
|
||||
my ($NAME,$READING,$VALUE) = ('','','');
|
||||
eval $aVal;
|
||||
return $@ if ($@);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($aName =~ /executeAfterProc|executeBeforeProc/xs) {
|
||||
if($cmd eq "set") {
|
||||
if ($aVal =~ m/^\s*(\{.*\}|{.*|.*})\s*$/xs && $aVal !~ /{".*"}/xs) {
|
||||
$aVal = $1;
|
||||
|
||||
my $fdv = __DbRep_fhemDefVars ();
|
||||
my ($today, $hms, $we) = ($fdv->{today}, $fdv->{hms}, $fdv->{we});
|
||||
my ($sec, $min, $hour) = ($fdv->{sec}, $fdv->{min}, $fdv->{hour});
|
||||
my ($mday, $month, $year) = ($fdv->{mday}, $fdv->{month}, $fdv->{year});
|
||||
my ($wday, $yday, $isdst) = ($fdv->{wday}, $fdv->{yday}, $fdv->{isdst});
|
||||
|
||||
eval $aVal;
|
||||
return $@ if ($@);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($aName eq "role") {
|
||||
if ($cmd eq "set") {
|
||||
if ($aVal eq "Agent") {
|
||||
@ -1648,18 +1608,56 @@ sub DbRep_Attr {
|
||||
delete($attr{$name}{icon}) if($do eq "Client");
|
||||
}
|
||||
|
||||
if($aName eq "device") {
|
||||
my $awdev = $aVal;
|
||||
DbRep_modAssociatedWith ($hash,$cmd,$awdev);
|
||||
if ($cmd eq 'set') {
|
||||
if ($aName eq 'fetchValueFn' && $init_done) {
|
||||
my $VALUE = "Hello";
|
||||
if ( $aVal =~ m/^\s*(\{.*\})\s*$/s ) { # Funktion aus Attr validieren
|
||||
$aVal = $1;
|
||||
}
|
||||
else {
|
||||
$aVal = "";
|
||||
}
|
||||
|
||||
return "Your function does not match the form \"{<function>}\"" if(!$aVal);
|
||||
|
||||
eval $aVal;
|
||||
return "Bad function: $@" if($@);
|
||||
}
|
||||
|
||||
if ($aName eq 'userExitFn' && $init_done) {
|
||||
if (!$aVal) {
|
||||
return "Usage of $aName is wrong. The function has to be specified as \"<UserExitFn> [reading:value]\" ";
|
||||
}
|
||||
|
||||
if ($aVal =~ m/^\s*(\{.*\})\s*$/xs) { # unnamed Funktion direkt in userExitFn mit {...}
|
||||
$aVal = $1;
|
||||
my ($NAME,$READING,$VALUE) = ('','','');
|
||||
eval $aVal;
|
||||
return $@ if($@);
|
||||
}
|
||||
}
|
||||
|
||||
if ($aName =~ /executeAfterProc|executeBeforeProc/xs && $init_done) {
|
||||
if ($aVal =~ m/^\s*(\{.*\}|{.*|.*})\s*$/xs && $aVal !~ /{".*"}/xs) {
|
||||
$aVal = $1;
|
||||
|
||||
my $fdv = __DbRep_fhemDefVars ();
|
||||
my ($today, $hms, $we) = ($fdv->{today}, $fdv->{hms}, $fdv->{we});
|
||||
my ($sec, $min, $hour) = ($fdv->{sec}, $fdv->{min}, $fdv->{hour});
|
||||
my ($mday, $month, $year) = ($fdv->{mday}, $fdv->{month}, $fdv->{year});
|
||||
my ($wday, $yday, $isdst) = ($fdv->{wday}, $fdv->{yday}, $fdv->{isdst});
|
||||
|
||||
eval $aVal;
|
||||
return $@ if ($@);
|
||||
}
|
||||
}
|
||||
|
||||
if ($cmd eq "set") {
|
||||
if ($aName =~ /valueFilter/) {
|
||||
eval { "Hallo" =~ m/$aVal/ };
|
||||
return "Bad regexp: $@" if($@);
|
||||
}
|
||||
|
||||
if ($aName eq "autoForward") {
|
||||
if ($aName eq "autoForward" && $init_done) {
|
||||
my $em = "Usage of $aName is wrong. The function has to be specified as ".
|
||||
"\"{ <destination-device> => \"<source-reading (Regex)> => [=> destination-reading]\" }\". ".
|
||||
"The specification can be made in several lines separated by comma.";
|
||||
@ -1842,11 +1840,11 @@ sub DbRep_Attr {
|
||||
}
|
||||
|
||||
if ($aName eq "ftpUse") {
|
||||
delete($attr{$name}{ftpUseSSL});
|
||||
delete $attr{$name}{ftpUseSSL};
|
||||
}
|
||||
|
||||
if ($aName eq "ftpUseSSL") {
|
||||
delete($attr{$name}{ftpUse});
|
||||
delete $attr{$name}{ftpUse};
|
||||
}
|
||||
|
||||
if ($aName eq "useAdminCredentials" && $aVal) {
|
||||
@ -12308,7 +12306,7 @@ sub DbRep_autoForward {
|
||||
my $hash = $defs{$name};
|
||||
my $av = AttrVal ($name, 'autoForward', '');
|
||||
|
||||
return if(!$av);
|
||||
return if(!$av || !$init_done);
|
||||
|
||||
$av =~ m/^\{(.*)\}/s;
|
||||
$av = $1;
|
||||
@ -18122,8 +18120,8 @@ return;
|
||||
<tr><td> <b>device</b> </td><td>: einschließen oder ausschließen von Datensätzen die <device> enthalten </td></tr>
|
||||
<tr><td> <b>reading</b> </td><td>: einschließen oder ausschließen von Datensätzen die <reading> enthalten </td></tr>
|
||||
<tr><td> <b>time.*</b> </td><td>: eine Reihe von Attributen zur Zeitabgrenzung </td></tr>
|
||||
<tr><td> executeBeforeProc </td><td>: ausführen FHEM Kommando (oder Perl-Routine) vor Ausführung </td></tr>
|
||||
<tr><td> executeAfterProc </td><td>: ausführen FHEM Kommando (oder Perl-Routine) nach Ausführung </td></tr>
|
||||
<tr><td> <b>executeBeforeProc</b> </td><td>: ausführen FHEM Kommando (oder Perl-Routine) vor Ausführung </td></tr>
|
||||
<tr><td> <b>executeAfterProc</b> </td><td>: ausführen FHEM Kommando (oder Perl-Routine) nach Ausführung </td></tr>
|
||||
<tr><td> <b>readingNameMap</b> </td><td>: die entstehenden Ergebnisreadings werden partiell umbenannt </td></tr>
|
||||
<tr><td> <b>valueFilter</b> </td><td>: ein zusätzliches REGEXP um die Datenselektion zu steuern. Der REGEXP wird auf das Datenbankfeld 'VALUE' angewendet. </td></tr>
|
||||
</table>
|
||||
|
Loading…
x
Reference in New Issue
Block a user