mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-04 22:19:38 +00:00
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:
parent
c5563891b5
commit
a6ed754308
@ -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,23 +655,32 @@ 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];
|
||||||
|
#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]));
|
$unit = $strings[$startIndex + 1] if (defined ($strings[$startIndex + 1]));
|
||||||
}
|
}
|
||||||
#string or raw
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$value = join(" ", @strings[$startIndex..(int(@strings) - 1)]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#numeric value?
|
||||||
|
#if ($strings[$startIndex] =~ /^[+-]?\d*[.,]?\d+/)
|
||||||
|
#{
|
||||||
|
# $value = $strings[$startIndex];
|
||||||
|
# $unit = $strings[$startIndex + 1] if (defined ($strings[$startIndex + 1]));
|
||||||
|
#}
|
||||||
|
#string or raw
|
||||||
|
#else
|
||||||
|
#{
|
||||||
|
# $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");
|
||||||
|
|
||||||
return ($reading, $value, $unit);
|
return ($reading, $value, $unit);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user