mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-10 03:06:37 +00:00
93_DbLog: fix behavior if value is empty and attribute addStateEvent is set (default), Forum: #106769
git-svn-id: https://svn.fhem.de/fhem/trunk@20863 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
a077250285
commit
abd303277f
@ -1,5 +1,7 @@
|
|||||||
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
# 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.
|
# Do not insert empty lines here, update check depends on it.
|
||||||
|
- bugfix: 93_DbLog: fix behavior if value is empty and attribute
|
||||||
|
addStateEvent is set (default), Forum: #106769
|
||||||
- bugfix: 73_AutoShuttersControl: fix IsDay Bug then use Privacy Down
|
- bugfix: 73_AutoShuttersControl: fix IsDay Bug then use Privacy Down
|
||||||
- bugfix: 95_Astro: make tzset() more robust, change Version
|
- bugfix: 95_Astro: make tzset() more robust, change Version
|
||||||
- change: 73_AutoShuttersControl: little Bugfix, add devStateIcon Fn
|
- change: 73_AutoShuttersControl: little Bugfix, add devStateIcon Fn
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
# modified and maintained by Tobias Faust since 2012-06-26 until 2016
|
# modified and maintained by Tobias Faust since 2012-06-26 until 2016
|
||||||
# e-mail: tobias dot faust at online dot de
|
# e-mail: tobias dot faust at online dot de
|
||||||
#
|
#
|
||||||
# redesigned and maintained 2016-2019 by DS_Starter with credits by: JoeAllb, DeeSpe
|
# redesigned and maintained 2016-2020 by DS_Starter with credits by: JoeAllb, DeeSpe
|
||||||
# e-mail: heiko dot maaz at t-online dot de
|
# e-mail: heiko dot maaz at t-online dot de
|
||||||
#
|
#
|
||||||
# reduceLog() created by Claudiu Schuster (rapster)
|
# reduceLog() created by Claudiu Schuster (rapster)
|
||||||
@ -30,6 +30,8 @@ no if $] >= 5.017011, warnings => 'experimental::smartmatch';
|
|||||||
|
|
||||||
# Version History intern by DS_Starter:
|
# Version History intern by DS_Starter:
|
||||||
our %DbLog_vNotesIntern = (
|
our %DbLog_vNotesIntern = (
|
||||||
|
"4.9.5" => "01.01.2020 do not reopen database connection if device is disabled (fix) ",
|
||||||
|
"4.9.4" => "29.12.2019 correct behavior if value is empty and attribute addStateEvent is set (default), Forum: #106769 ",
|
||||||
"4.9.3" => "28.12.2019 check date/time format got from SVG, Forum: #101005 ",
|
"4.9.3" => "28.12.2019 check date/time format got from SVG, Forum: #101005 ",
|
||||||
"4.9.2" => "16.12.2019 add \$DEVICE to attr DbLogValueFn for readonly access to the device name ",
|
"4.9.2" => "16.12.2019 add \$DEVICE to attr DbLogValueFn for readonly access to the device name ",
|
||||||
"4.9.1" => "13.11.2019 escape \ with \\ in DbLog_Push and DbLog_PushAsync ",
|
"4.9.1" => "13.11.2019 escape \ with \\ in DbLog_Push and DbLog_PushAsync ",
|
||||||
@ -634,6 +636,7 @@ sub DbLog_Set($@) {
|
|||||||
return undef,$skip_trigger;
|
return undef,$skip_trigger;
|
||||||
}
|
}
|
||||||
elsif ($a[1] eq 'reopen') {
|
elsif ($a[1] eq 'reopen') {
|
||||||
|
return if(IsDisabled($name));
|
||||||
if ($dbh) {
|
if ($dbh) {
|
||||||
eval {$dbh->commit() if(!$dbh->{AutoCommit});};
|
eval {$dbh->commit() if(!$dbh->{AutoCommit});};
|
||||||
if ($@) {
|
if ($@) {
|
||||||
@ -966,8 +969,8 @@ return $ret;
|
|||||||
################################################################
|
################################################################
|
||||||
# Parsefunktion, abhaengig vom Devicetyp
|
# Parsefunktion, abhaengig vom Devicetyp
|
||||||
################################################################
|
################################################################
|
||||||
sub DbLog_ParseEvent($$$) {
|
sub DbLog_ParseEvent($$$$) {
|
||||||
my ($device, $type, $event)= @_;
|
my ($name,$device, $type, $event)= @_;
|
||||||
my (@result,$reading,$value,$unit);
|
my (@result,$reading,$value,$unit);
|
||||||
|
|
||||||
# Splitfunktion der Eventquelle aufrufen (ab 2.9.1)
|
# Splitfunktion der Eventquelle aufrufen (ab 2.9.1)
|
||||||
@ -992,7 +995,7 @@ sub DbLog_ParseEvent($$$) {
|
|||||||
#default
|
#default
|
||||||
if(!defined($reading)) { $reading = ""; }
|
if(!defined($reading)) { $reading = ""; }
|
||||||
if(!defined($value)) { $value = ""; }
|
if(!defined($value)) { $value = ""; }
|
||||||
if( $value eq "" ) {
|
if($value eq "" && !AttrVal($name, "addStateEvent", 1)) {
|
||||||
$reading = "state";
|
$reading = "state";
|
||||||
$value = $event;
|
$value = $event;
|
||||||
}
|
}
|
||||||
@ -1000,8 +1003,8 @@ sub DbLog_ParseEvent($$$) {
|
|||||||
#globales Abfangen von
|
#globales Abfangen von
|
||||||
# - temperature
|
# - temperature
|
||||||
# - humidity
|
# - humidity
|
||||||
if ($reading =~ m(^temperature)) { $unit= "°C"; } # wenn reading mit temperature beginnt
|
if ($reading =~ m(^temperature)) { $unit = "°C"; } # wenn reading mit temperature beginnt
|
||||||
elsif($reading =~ m(^humidity)) { $unit= "%"; }
|
elsif($reading =~ m(^humidity)) { $unit = "%"; }
|
||||||
|
|
||||||
# the interpretation of the argument depends on the device type
|
# the interpretation of the argument depends on the device type
|
||||||
# EMEM, M232Counter, M232Voltage return plain numbers
|
# EMEM, M232Counter, M232Voltage return plain numbers
|
||||||
@ -1011,26 +1014,24 @@ sub DbLog_ParseEvent($$$) {
|
|||||||
}
|
}
|
||||||
#OneWire
|
#OneWire
|
||||||
elsif(($type eq "OWMULTI")) {
|
elsif(($type eq "OWMULTI")) {
|
||||||
if(int(@parts)>1) {
|
if(int(@parts) > 1) {
|
||||||
$reading = "data";
|
$reading = "data";
|
||||||
$value = $event;
|
$value = $event;
|
||||||
} else {
|
} else {
|
||||||
@parts = split(/\|/, AttrVal($device, $reading."VUnit", ""));
|
@parts = split(/\|/, AttrVal($device, $reading."VUnit", ""));
|
||||||
$unit = $parts[1] if($parts[1]);
|
$unit = $parts[1] if($parts[1]);
|
||||||
if(lc($reading) =~ m/temp/) {
|
if(lc($reading) =~ m/temp/) {
|
||||||
$value=~ s/ \(Celsius\)//;
|
$value =~ s/ \(Celsius\)//;
|
||||||
$value=~ s/([-\.\d]+).*/$1/;
|
$value =~ s/([-\.\d]+).*/$1/;
|
||||||
$unit= "°C";
|
$unit = "°C";
|
||||||
}
|
} elsif (lc($reading) =~ m/(humidity|vwc)/) {
|
||||||
elsif(lc($reading) =~ m/(humidity|vwc)/) {
|
$value =~ s/ \(\%\)//;
|
||||||
$value=~ s/ \(\%\)//;
|
$unit = "%";
|
||||||
$unit= "%";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# Onewire
|
# Onewire
|
||||||
elsif(($type eq "OWAD") ||
|
elsif(($type eq "OWAD") || ($type eq "OWSWITCH")) {
|
||||||
($type eq "OWSWITCH")) {
|
|
||||||
if(int(@parts)>1) {
|
if(int(@parts)>1) {
|
||||||
$reading = "data";
|
$reading = "data";
|
||||||
$value = $event;
|
$value = $event;
|
||||||
@ -1042,7 +1043,7 @@ sub DbLog_ParseEvent($$$) {
|
|||||||
|
|
||||||
# ZWAVE
|
# ZWAVE
|
||||||
elsif ($type eq "ZWAVE") {
|
elsif ($type eq "ZWAVE") {
|
||||||
if ( $value=~/([-\.\d]+)\s([a-z].*)/i ) {
|
if ( $value =~/([-\.\d]+)\s([a-z].*)/i ) {
|
||||||
$value = $1;
|
$value = $1;
|
||||||
$unit = $2;
|
$unit = $2;
|
||||||
}
|
}
|
||||||
@ -1050,7 +1051,7 @@ sub DbLog_ParseEvent($$$) {
|
|||||||
|
|
||||||
# FBDECT
|
# FBDECT
|
||||||
elsif ($type eq "FBDECT") {
|
elsif ($type eq "FBDECT") {
|
||||||
if ( $value=~/([\.\d]+)\s([a-z].*)/i ) {
|
if ( $value =~/([\.\d]+)\s([a-z].*)/i ) {
|
||||||
$value = $1;
|
$value = $1;
|
||||||
$unit = $2;
|
$unit = $2;
|
||||||
}
|
}
|
||||||
@ -1058,117 +1059,109 @@ sub DbLog_ParseEvent($$$) {
|
|||||||
|
|
||||||
# MAX
|
# MAX
|
||||||
elsif(($type eq "MAX")) {
|
elsif(($type eq "MAX")) {
|
||||||
$unit= "°C" if(lc($reading) =~ m/temp/);
|
$unit = "°C" if(lc($reading) =~ m/temp/);
|
||||||
$unit= "%" if(lc($reading) eq "valveposition");
|
$unit = "%" if(lc($reading) eq "valveposition");
|
||||||
}
|
}
|
||||||
|
|
||||||
# FS20
|
# FS20
|
||||||
elsif(($type eq "FS20") || ($type eq "X10")) {
|
elsif(($type eq "FS20") || ($type eq "X10")) {
|
||||||
if($reading =~ m/^dim(\d+).*/o) {
|
if($reading =~ m/^dim(\d+).*/o) {
|
||||||
$value = $1;
|
$value = $1;
|
||||||
$reading= "dim";
|
$reading = "dim";
|
||||||
$unit= "%";
|
$unit = "%";
|
||||||
}
|
} elsif(!defined($value) || $value eq "") {
|
||||||
elsif(!defined($value) || $value eq "") {
|
$value = $reading;
|
||||||
$value= $reading;
|
$reading = "data";
|
||||||
$reading= "data";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# FHT
|
# FHT
|
||||||
elsif($type eq "FHT") {
|
elsif($type eq "FHT") {
|
||||||
if($reading =~ m(-from[12]\ ) || $reading =~ m(-to[12]\ )) {
|
if($reading =~ m(-from[12]\ ) || $reading =~ m(-to[12]\ )) {
|
||||||
@parts= split(/ /,$event);
|
@parts = split(/ /,$event);
|
||||||
$reading= $parts[0];
|
$reading = $parts[0];
|
||||||
$value= $parts[1];
|
$value = $parts[1];
|
||||||
$unit= "";
|
$unit = "";
|
||||||
}
|
} elsif($reading =~ m(-temp)) {
|
||||||
elsif($reading =~ m(-temp)) { $value=~ s/ \(Celsius\)//; $unit= "°C"; }
|
$value =~ s/ \(Celsius\)//; $unit= "°C";
|
||||||
elsif($reading =~ m(temp-offset)) { $value=~ s/ \(Celsius\)//; $unit= "°C"; }
|
} elsif($reading =~ m(temp-offset)) {
|
||||||
elsif($reading =~ m(^actuator[0-9]*)) {
|
$value =~ s/ \(Celsius\)//; $unit= "°C";
|
||||||
|
} elsif($reading =~ m(^actuator[0-9]*)) {
|
||||||
if($value eq "lime-protection") {
|
if($value eq "lime-protection") {
|
||||||
$reading= "actuator-lime-protection";
|
$reading = "actuator-lime-protection";
|
||||||
undef $value;
|
undef $value;
|
||||||
}
|
} elsif($value =~ m(^offset:)) {
|
||||||
elsif($value =~ m(^offset:)) {
|
$reading = "actuator-offset";
|
||||||
$reading= "actuator-offset";
|
@parts = split(/: /,$value);
|
||||||
@parts= split(/: /,$value);
|
$value = $parts[1];
|
||||||
$value= $parts[1];
|
|
||||||
if(defined $value) {
|
if(defined $value) {
|
||||||
$value=~ s/%//; $value= $value*1.; $unit= "%";
|
$value =~ s/%//; $value = $value*1.; $unit = "%";
|
||||||
}
|
}
|
||||||
}
|
} elsif($value =~ m(^unknown_)) {
|
||||||
elsif($value =~ m(^unknown_)) {
|
@parts = split(/: /,$value);
|
||||||
@parts= split(/: /,$value);
|
$reading = "actuator-" . $parts[0];
|
||||||
$reading= "actuator-" . $parts[0];
|
$value = $parts[1];
|
||||||
$value= $parts[1];
|
|
||||||
if(defined $value) {
|
if(defined $value) {
|
||||||
$value=~ s/%//; $value= $value*1.; $unit= "%";
|
$value =~ s/%//; $value = $value*1.; $unit = "%";
|
||||||
}
|
}
|
||||||
}
|
} elsif($value =~ m(^synctime)) {
|
||||||
elsif($value =~ m(^synctime)) {
|
$reading = "actuator-synctime";
|
||||||
$reading= "actuator-synctime";
|
|
||||||
undef $value;
|
undef $value;
|
||||||
}
|
} elsif($value eq "test") {
|
||||||
elsif($value eq "test") {
|
$reading = "actuator-test";
|
||||||
$reading= "actuator-test";
|
|
||||||
undef $value;
|
undef $value;
|
||||||
}
|
} elsif($value eq "pair") {
|
||||||
elsif($value eq "pair") {
|
$reading = "actuator-pair";
|
||||||
$reading= "actuator-pair";
|
|
||||||
undef $value;
|
undef $value;
|
||||||
}
|
} else {
|
||||||
else {
|
$value =~ s/%//; $value = $value*1.; $unit = "%";
|
||||||
$value=~ s/%//; $value= $value*1.; $unit= "%";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# KS300
|
# KS300
|
||||||
elsif($type eq "KS300") {
|
elsif($type eq "KS300") {
|
||||||
if($event =~ m(T:.*)) { $reading= "data"; $value= $event; }
|
if($event =~ m(T:.*)) { $reading = "data"; $value = $event; }
|
||||||
elsif($event =~ m(avg_day)) { $reading= "data"; $value= $event; }
|
elsif($event =~ m(avg_day)) { $reading = "data"; $value = $event; }
|
||||||
elsif($event =~ m(avg_month)) { $reading= "data"; $value= $event; }
|
elsif($event =~ m(avg_month)) { $reading = "data"; $value = $event; }
|
||||||
elsif($reading eq "temperature") { $value=~ s/ \(Celsius\)//; $unit= "°C"; }
|
elsif($reading eq "temperature") { $value =~ s/ \(Celsius\)//; $unit = "°C"; }
|
||||||
elsif($reading eq "wind") { $value=~ s/ \(km\/h\)//; $unit= "km/h"; }
|
elsif($reading eq "wind") { $value =~ s/ \(km\/h\)//; $unit = "km/h"; }
|
||||||
elsif($reading eq "rain") { $value=~ s/ \(l\/m2\)//; $unit= "l/m2"; }
|
elsif($reading eq "rain") { $value =~ s/ \(l\/m2\)//; $unit = "l/m2"; }
|
||||||
elsif($reading eq "rain_raw") { $value=~ s/ \(counter\)//; $unit= ""; }
|
elsif($reading eq "rain_raw") { $value =~ s/ \(counter\)//; $unit = ""; }
|
||||||
elsif($reading eq "humidity") { $value=~ s/ \(\%\)//; $unit= "%"; }
|
elsif($reading eq "humidity") { $value =~ s/ \(\%\)//; $unit = "%"; }
|
||||||
elsif($reading eq "israining") {
|
elsif($reading eq "israining") {
|
||||||
$value=~ s/ \(yes\/no\)//;
|
$value =~ s/ \(yes\/no\)//;
|
||||||
$value=~ s/no/0/;
|
$value =~ s/no/0/;
|
||||||
$value=~ s/yes/1/;
|
$value =~ s/yes/1/;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# HMS
|
# HMS
|
||||||
elsif($type eq "HMS" ||
|
elsif($type eq "HMS" || $type eq "CUL_WS" || $type eq "OWTHERM") {
|
||||||
$type eq "CUL_WS" ||
|
if($event =~ m(T:.*)) {
|
||||||
$type eq "OWTHERM") {
|
$reading = "data"; $value= $event;
|
||||||
if($event =~ m(T:.*)) { $reading= "data"; $value= $event; }
|
} elsif($reading eq "temperature") {
|
||||||
elsif($reading eq "temperature") {
|
$value =~ s/ \(Celsius\)//;
|
||||||
$value=~ s/ \(Celsius\)//;
|
$value =~ s/([-\.\d]+).*/$1/; #OWTHERM
|
||||||
$value=~ s/([-\.\d]+).*/$1/; #OWTHERM
|
$unit = "°C";
|
||||||
$unit= "°C";
|
} elsif($reading eq "humidity") {
|
||||||
}
|
$value =~ s/ \(\%\)//; $unit= "%";
|
||||||
elsif($reading eq "humidity") { $value=~ s/ \(\%\)//; $unit= "%"; }
|
} elsif($reading eq "battery") {
|
||||||
elsif($reading eq "battery") {
|
$value =~ s/ok/1/;
|
||||||
$value=~ s/ok/1/;
|
$value =~ s/replaced/1/;
|
||||||
$value=~ s/replaced/1/;
|
$value =~ s/empty/0/;
|
||||||
$value=~ s/empty/0/;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# CUL_HM
|
# CUL_HM
|
||||||
elsif ($type eq "CUL_HM") {
|
elsif ($type eq "CUL_HM") {
|
||||||
# remove trailing %
|
$value =~ s/ \%$//; # remove trailing %
|
||||||
$value=~ s/ \%$//;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# BS
|
# BS
|
||||||
elsif($type eq "BS") {
|
elsif($type eq "BS") {
|
||||||
if($event =~ m(brightness:.*)) {
|
if($event =~ m(brightness:.*)) {
|
||||||
@parts= split(/ /,$event);
|
@parts = split(/ /,$event);
|
||||||
$reading= "lux";
|
$reading = "lux";
|
||||||
$value= $parts[4]*1.;
|
$value = $parts[4]*1.;
|
||||||
$unit= "lux";
|
$unit = "lux";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1176,22 +1169,21 @@ sub DbLog_ParseEvent($$$) {
|
|||||||
elsif($type eq "TRX_LIGHT") {
|
elsif($type eq "TRX_LIGHT") {
|
||||||
if($reading =~ m/^level (\d+)/) {
|
if($reading =~ m/^level (\d+)/) {
|
||||||
$value = $1;
|
$value = $1;
|
||||||
$reading= "level";
|
$reading = "level";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# RFXTRX Sensors
|
# RFXTRX Sensors
|
||||||
elsif($type eq "TRX_WEATHER") {
|
elsif($type eq "TRX_WEATHER") {
|
||||||
if($reading eq "energy_current") { $value=~ s/ W//; }
|
if($reading eq "energy_current") {
|
||||||
elsif($reading eq "energy_total") { $value=~ s/ kWh//; }
|
$value =~ s/ W//;
|
||||||
# elsif($reading eq "temperature") {TODO}
|
} elsif($reading eq "energy_total") {
|
||||||
# elsif($reading eq "temperature") {TODO
|
$value =~ s/ kWh//;
|
||||||
elsif($reading eq "battery") {
|
} elsif($reading eq "battery") {
|
||||||
if ($value=~ m/(\d+)\%/) {
|
if ($value =~ m/(\d+)\%/) {
|
||||||
$value= $1;
|
$value = $1;
|
||||||
}
|
} else {
|
||||||
else {
|
$value = ($value eq "ok");
|
||||||
$value= ($value eq "ok");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1199,42 +1191,42 @@ sub DbLog_ParseEvent($$$) {
|
|||||||
# Weather
|
# Weather
|
||||||
elsif($type eq "WEATHER") {
|
elsif($type eq "WEATHER") {
|
||||||
if($event =~ m(^wind_condition)) {
|
if($event =~ m(^wind_condition)) {
|
||||||
@parts= split(/ /,$event); # extract wind direction from event
|
@parts = split(/ /,$event); # extract wind direction from event
|
||||||
if(defined $parts[0]) {
|
if(defined $parts[0]) {
|
||||||
$reading = "wind_condition";
|
$reading = "wind_condition";
|
||||||
$value= "$parts[1] $parts[2] $parts[3]";
|
$value = "$parts[1] $parts[2] $parts[3]";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($reading eq "wind_condition") { $unit= "km/h"; }
|
if($reading eq "wind_condition") { $unit = "km/h"; }
|
||||||
elsif($reading eq "wind_chill") { $unit= "°C"; }
|
elsif($reading eq "wind_chill") { $unit = "°C"; }
|
||||||
elsif($reading eq "wind_direction") { $unit= ""; }
|
elsif($reading eq "wind_direction") { $unit = ""; }
|
||||||
elsif($reading =~ m(^wind)) { $unit= "km/h"; } # wind, wind_speed
|
elsif($reading =~ m(^wind)) { $unit = "km/h"; } # wind, wind_speed
|
||||||
elsif($reading =~ m(^temperature)) { $unit= "°C"; } # wenn reading mit temperature beginnt
|
elsif($reading =~ m(^temperature)) { $unit = "°C"; } # wenn reading mit temperature beginnt
|
||||||
elsif($reading =~ m(^humidity)) { $unit= "%"; }
|
elsif($reading =~ m(^humidity)) { $unit = "%"; }
|
||||||
elsif($reading =~ m(^pressure)) { $unit= "hPa"; }
|
elsif($reading =~ m(^pressure)) { $unit = "hPa"; }
|
||||||
elsif($reading =~ m(^pressure_trend)) { $unit= ""; }
|
elsif($reading =~ m(^pressure_trend)) { $unit = ""; }
|
||||||
}
|
}
|
||||||
|
|
||||||
# FHT8V
|
# FHT8V
|
||||||
elsif($type eq "FHT8V") {
|
elsif($type eq "FHT8V") {
|
||||||
if($reading =~ m(valve)) {
|
if($reading =~ m(valve)) {
|
||||||
@parts= split(/ /,$event);
|
@parts = split(/ /,$event);
|
||||||
$reading= $parts[0];
|
$reading = $parts[0];
|
||||||
$value= $parts[1];
|
$value = $parts[1];
|
||||||
$unit= "%";
|
$unit = "%";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Dummy
|
# Dummy
|
||||||
elsif($type eq "DUMMY") {
|
elsif($type eq "DUMMY") {
|
||||||
if( $value eq "" ) {
|
if( $value eq "" ) {
|
||||||
$reading= "data";
|
$reading = "data";
|
||||||
$value= $event;
|
$value = $event;
|
||||||
}
|
}
|
||||||
$unit= "";
|
$unit = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@result= ($reading,$value,$unit);
|
@result = ($reading,$value,$unit);
|
||||||
return @result;
|
return @result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1301,7 +1293,7 @@ sub DbLog_Log($$) {
|
|||||||
my $DbLogInclude = AttrVal($dev_name, "DbLogInclude", undef);
|
my $DbLogInclude = AttrVal($dev_name, "DbLogInclude", undef);
|
||||||
my $DbLogValueFn = AttrVal($dev_name, "DbLogValueFn","");
|
my $DbLogValueFn = AttrVal($dev_name, "DbLogValueFn","");
|
||||||
my $DbLogSelectionMode = AttrVal($name, "DbLogSelectionMode","Exclude");
|
my $DbLogSelectionMode = AttrVal($name, "DbLogSelectionMode","Exclude");
|
||||||
my $value_fn = AttrVal( $name, "valueFn", "" );
|
my $value_fn = AttrVal($name, "valueFn", "");
|
||||||
|
|
||||||
# Funktion aus Device spezifischer DbLogValueFn validieren
|
# Funktion aus Device spezifischer DbLogValueFn validieren
|
||||||
if( $DbLogValueFn =~ m/^\s*(\{.*\})\s*$/s ) {
|
if( $DbLogValueFn =~ m/^\s*(\{.*\})\s*$/s ) {
|
||||||
@ -1331,7 +1323,7 @@ sub DbLog_Log($$) {
|
|||||||
$timestamp = $dev_hash->{CHANGETIME}[$i] if(defined($dev_hash->{CHANGETIME}[$i]));
|
$timestamp = $dev_hash->{CHANGETIME}[$i] if(defined($dev_hash->{CHANGETIME}[$i]));
|
||||||
$event =~ s/\|/_ESC_/g; # escape Pipe "|"
|
$event =~ s/\|/_ESC_/g; # escape Pipe "|"
|
||||||
|
|
||||||
my @r = DbLog_ParseEvent($dev_name, $dev_type, $event);
|
my @r = DbLog_ParseEvent($name,$dev_name, $dev_type, $event);
|
||||||
$reading = $r[0];
|
$reading = $r[0];
|
||||||
$value = $r[1];
|
$value = $r[1];
|
||||||
$unit = $r[2];
|
$unit = $r[2];
|
||||||
@ -3182,13 +3174,13 @@ sub DbLog_Get($@) {
|
|||||||
|
|
||||||
$err = DbLog_checkTimeformat($from); # Forum: https://forum.fhem.de/index.php/topic,101005.0.html
|
$err = DbLog_checkTimeformat($from); # Forum: https://forum.fhem.de/index.php/topic,101005.0.html
|
||||||
if($err) {
|
if($err) {
|
||||||
Log3($name, 1, "DbLog $name - Wrong date/time format (from: $from) requested by SVG: $err");
|
Log3($name, 1, "DbLog $name - wrong date/time format (from: $from) requested by SVG: $err");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$err = DbLog_checkTimeformat($to); # Forum: https://forum.fhem.de/index.php/topic,101005.0.html
|
$err = DbLog_checkTimeformat($to); # Forum: https://forum.fhem.de/index.php/topic,101005.0.html
|
||||||
if($err) {
|
if($err) {
|
||||||
Log3($name, 1, "DbLog $name - Wrong date/time format (to: $to) requested by SVG: $err");
|
Log3($name, 1, "DbLog $name - wrong date/time format (to: $to) requested by SVG: $err");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4497,7 +4489,7 @@ sub DbLog_AddLog($$$$$) {
|
|||||||
$event = $dev_reading.": ".$read_val;
|
$event = $dev_reading.": ".$read_val;
|
||||||
|
|
||||||
# den zusammengestellten Event parsen lassen (evtl. Unit zuweisen)
|
# den zusammengestellten Event parsen lassen (evtl. Unit zuweisen)
|
||||||
my @r = DbLog_ParseEvent($dev_name, $dev_type, $event);
|
my @r = DbLog_ParseEvent($name,$dev_name, $dev_type, $event);
|
||||||
$dev_reading = $r[0];
|
$dev_reading = $r[0];
|
||||||
$read_val = $r[1];
|
$read_val = $r[1];
|
||||||
$ut = $r[2];
|
$ut = $r[2];
|
||||||
@ -5744,7 +5736,8 @@ sub DbLog_checkTimeformat ($) {
|
|||||||
eval { timelocal($time[2], $time[1], $time[0], $date[2], $date[1]-1, $date[0]-1900); };
|
eval { timelocal($time[2], $time[1], $time[0], $date[2], $date[1]-1, $date[0]-1900); };
|
||||||
|
|
||||||
if ($@) {
|
if ($@) {
|
||||||
return $@;
|
my $err = (split(" at ", $@))[0];
|
||||||
|
return $err;
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
# modified and maintained by Tobias Faust since 2012-06-26 until 2016
|
# modified and maintained by Tobias Faust since 2012-06-26 until 2016
|
||||||
# e-mail: tobias dot faust at online dot de
|
# e-mail: tobias dot faust at online dot de
|
||||||
#
|
#
|
||||||
# redesigned and maintained 2016-2019 by DS_Starter with credits by: JoeAllb, DeeSpe
|
# redesigned and maintained 2016-2020 by DS_Starter with credits by: JoeAllb, DeeSpe
|
||||||
# e-mail: heiko dot maaz at t-online dot de
|
# e-mail: heiko dot maaz at t-online dot de
|
||||||
#
|
#
|
||||||
# reduceLog() created by Claudiu Schuster (rapster)
|
# reduceLog() created by Claudiu Schuster (rapster)
|
||||||
@ -30,6 +30,7 @@ no if $] >= 5.017011, warnings => 'experimental::smartmatch';
|
|||||||
|
|
||||||
# Version History intern by DS_Starter:
|
# Version History intern by DS_Starter:
|
||||||
our %DbLog_vNotesIntern = (
|
our %DbLog_vNotesIntern = (
|
||||||
|
"4.9.5" => "01.01.2020 do not reopen database connection if device is disabled (fix) ",
|
||||||
"4.9.4" => "29.12.2019 correct behavior if value is empty and attribute addStateEvent is set (default), Forum: #106769 ",
|
"4.9.4" => "29.12.2019 correct behavior if value is empty and attribute addStateEvent is set (default), Forum: #106769 ",
|
||||||
"4.9.3" => "28.12.2019 check date/time format got from SVG, Forum: #101005 ",
|
"4.9.3" => "28.12.2019 check date/time format got from SVG, Forum: #101005 ",
|
||||||
"4.9.2" => "16.12.2019 add \$DEVICE to attr DbLogValueFn for readonly access to the device name ",
|
"4.9.2" => "16.12.2019 add \$DEVICE to attr DbLogValueFn for readonly access to the device name ",
|
||||||
@ -635,6 +636,7 @@ sub DbLog_Set($@) {
|
|||||||
return undef,$skip_trigger;
|
return undef,$skip_trigger;
|
||||||
}
|
}
|
||||||
elsif ($a[1] eq 'reopen') {
|
elsif ($a[1] eq 'reopen') {
|
||||||
|
return if(IsDisabled($name));
|
||||||
if ($dbh) {
|
if ($dbh) {
|
||||||
eval {$dbh->commit() if(!$dbh->{AutoCommit});};
|
eval {$dbh->commit() if(!$dbh->{AutoCommit});};
|
||||||
if ($@) {
|
if ($@) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user