10_KNX.pm: ABU 20160414 Changed SplitFn according to thread 52122

git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@11250 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
andi291 2016-04-16 17:09:44 +00:00
parent c5563891b5
commit a6ed754308

View File

@ -8,6 +8,8 @@
# ABU 20160326 Added fix for stateFormat # ABU 20160326 Added fix for stateFormat
# ABU 20160327 Removed readingRegex, writingRegex, created stateRegex, stateCmd, added reading-name support, fixed dblog-split # ABU 20160327 Removed readingRegex, writingRegex, created stateRegex, stateCmd, added reading-name support, fixed dblog-split
# ABU 20160403 Fixed various minor perl warnings # ABU 20160403 Fixed various minor perl warnings
# ABU 20160413 Changed SplitFn
# ABU 20160414 Changed SplitFn again
package main; package main;
@ -623,6 +625,10 @@ sub KNX_DbLog_split($) {
my $tempStr = join (", ", @_); my $tempStr = join (", ", @_);
Log (5, "splitFn - enter, attributes: $tempStr"); Log (5, "splitFn - enter, attributes: $tempStr");
#detect reading - real reading or state?
my $isReading = "false";
$isReading = "true" if ($event =~ m/: /);
#split input-string #split input-string
my @strings = split (" ", $event); my @strings = split (" ", $event);
@ -631,14 +637,15 @@ sub KNX_DbLog_split($) {
return undef if (not defined ($strings[0])); return undef if (not defined ($strings[0]));
#userreading? #real reading?
if ($strings[0] =~ m/([sg]etG\d+:)|(sender:)|(.*-[sg]et:.*)/) if ($isReading =~ m/true/)
{ {
#first one is always reading #first one is always reading
$reading = $strings[0]; $reading = $strings[0];
$reading =~ s/:?$//; $reading =~ s/:?$//;
$startIndex = 1; $startIndex = 1;
} }
#plain state
else else
{ {
#for reading state nothing is supplied #for reading state nothing is supplied
@ -648,22 +655,31 @@ sub KNX_DbLog_split($) {
return undef if (not defined ($strings[$startIndex])); return undef if (not defined ($strings[$startIndex]));
#on / off #per default join all single pieces
if ($strings[$startIndex] =~ m/([oO][nN])|([oO][fF][fF])/) $value = join(" ", @strings[$startIndex..(int(@strings) - 1)]);
{
$value = $strings[$startIndex];
}
#numeric value? #numeric value?
elsif ($strings[$startIndex] =~ /^[+-]?\d*[.,]?\d+/) if ($strings[$startIndex] =~ /^[+-]?\d*[.,]?\d+/)
{ {
$value = $strings[$startIndex]; $value = $strings[$startIndex];
$unit = $strings[$startIndex + 1] if (defined ($strings[$startIndex + 1])); #single numeric value? Assume second par is unit...
if ((defined ($strings[$startIndex + 1])) && !($strings[$startIndex+1] =~ /^[+-]?\d*[.,]?\d+/))
{
$unit = $strings[$startIndex + 1] if (defined ($strings[$startIndex + 1]));
}
} }
#numeric value?
#if ($strings[$startIndex] =~ /^[+-]?\d*[.,]?\d+/)
#{
# $value = $strings[$startIndex];
# $unit = $strings[$startIndex + 1] if (defined ($strings[$startIndex + 1]));
#}
#string or raw #string or raw
else #else
{ #{
$value = join(" ", @strings[$startIndex..(int(@strings) - 1)]); # $value = join(" ", @strings[$startIndex..(int(@strings) - 1)]);
} #}
Log (5, "splitFn - READING: $reading, VALUE: $value, UNIT: $unit"); Log (5, "splitFn - READING: $reading, VALUE: $value, UNIT: $unit");