From 9b87051a4dfaacd871e697a75deba559e2208972 Mon Sep 17 00:00:00 2001
From: rudolfkoenig <>
Date: Wed, 5 Apr 2017 12:27:20 +0000
Subject: [PATCH] fhem.pl: SetMagic fixes (Forum #38276)
git-svn-id: https://svn.fhem.de/fhem/trunk@13905 2b470e98-0d58-463d-a4d8-8e2adae1ed80
---
fhem/docs/commandref_frame.html | 4 ++--
fhem/docs/commandref_frame_DE.html | 3 ++-
fhem/fhem.pl | 6 +++---
3 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/fhem/docs/commandref_frame.html b/fhem/docs/commandref_frame.html
index e53cff81b..3078f94fe 100644
--- a/fhem/docs/commandref_frame.html
+++ b/fhem/docs/commandref_frame.html
@@ -1088,8 +1088,8 @@ The following local attributes are used by a wider range of devices:
- You can use the r:, i: or a: prefix to restrict the search to one
type, analogue to the devspec filtering.
- - The suffix :d retrieves the first number and converts it to an
- integer.
+ - The suffix :d retrieves the first number
+ - The suffix :i retrieves the integer part of the first number.
- The suffix :r<n> retrieves the first number and rounds it to
<n> decimal places. If <n> is missing, then rounds it to
one decimal place.
diff --git a/fhem/docs/commandref_frame_DE.html b/fhem/docs/commandref_frame_DE.html
index e6f4e35c6..2c8c1ab25 100644
--- a/fhem/docs/commandref_frame_DE.html
+++ b/fhem/docs/commandref_frame_DE.html
@@ -1157,7 +1157,8 @@ Die folgenden lokalen Attribute werden von mehreren Geräten verwendet:
- Man kann einen der Präfixe r:, i: oder a: verwenden, um die
Suche einzuschränken, genau wie im devspec.
- - Das Suffix :d extrahiert die erste Zahl als Ganzzahl.
+ - Das Suffix :d extrahiert die erste Zahl.
+ - Das Suffix :i extrahiert die erste Zahl als Ganzzahl.
- Das Suffix :r<n> extrahiert die erste Zahl, und rundet sie auf
<n> Dezimalstellen. Falls <n> fehlt, dann wird auf eine
Dezimalstelle gerundet.
diff --git a/fhem/fhem.pl b/fhem/fhem.pl
index 10f6a1143..a93406ff5 100755
--- a/fhem/fhem.pl
+++ b/fhem/fhem.pl
@@ -1674,15 +1674,15 @@ ReplaceSetMagic($$@) # Forum #38276
$val = $attr{$d}{$n} if(!defined($val) && (!$t || $t eq "a:") && $attr{$d});
return $all if(!defined($val));
- if($s && $val =~ /(-?\d+(\.\d+)?)/) {
+ if($s =~ /:d|:r|:i/ && $val =~ /(-?\d+(\.\d+)?)/) {
$val = $1;
- $s = ":r0" if($s eq ":d");
+ $val = int($val) if ( $s eq ":i" );
$val = round($val, defined($1) ? $1 : 1) if($s =~ /^:r(\d)?/);
}
return $val;
}
- $a =~ s/(\[([ari]:)?([a-z0-9._]+):([a-z0-9._-]+)(:(t|sec|d|r|r\d))?\])/
+ $a =~ s/(\[([ari]:)?([a-z0-9._]+):([a-z0-9._-]+)(:(t|sec|i|d|r|r\d))?\])/
rsmVal($1,$2,$3,$4,$5)/egi;
$evalSpecials->{'%DEV'} = $hash->{NAME};