mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-16 10:46:03 +00:00
98_CustomReadings.pm: Improved parsing of the readingDefinitions that allows commas between curly braces
git-svn-id: https://svn.fhem.de/fhem/trunk@7042 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
39a9f164a5
commit
b26d327611
@ -43,13 +43,22 @@ sub CustomReadings_read($)
|
||||
# Get the readingDefinitions and remove all newlines from the attribute
|
||||
my $readingDefinitions = AttrVal( $name, "readingDefinitions", "");
|
||||
$readingDefinitions =~ s/\n//g;
|
||||
|
||||
my @definitionList = split(',', $readingDefinitions);
|
||||
|
||||
my @used = ("state");
|
||||
|
||||
readingsBeginUpdate($hash);
|
||||
foreach (@definitionList) {
|
||||
my @definition = split(':', $_, 2);
|
||||
|
||||
my @definitionList = split(",", $readingDefinitions);
|
||||
while (@definitionList) {
|
||||
my $param = shift(@definitionList);
|
||||
|
||||
while ($param && $param =~ /{/ && $param !~ /}/ ) {
|
||||
my $next = shift(@definitionList);
|
||||
last if( !defined($next) );
|
||||
$param .= ",". $next;
|
||||
}
|
||||
|
||||
my @definition = split(':', $param, 2);
|
||||
push(@used, $definition[0]);
|
||||
|
||||
my $value = eval($definition[1]);
|
||||
@ -62,7 +71,7 @@ sub CustomReadings_read($)
|
||||
|
||||
readingsBulkUpdate($hash, $definition[0], $value);
|
||||
}
|
||||
|
||||
|
||||
readingsEndUpdate($hash, 1);
|
||||
|
||||
foreach my $r (keys %{$hash->{READINGS}}) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user