2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-02-26 10:34:52 +00:00

fhem.pl: SetMagic fixes (Forum #38276)

git-svn-id: https://svn.fhem.de/fhem/trunk@13905 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2017-04-05 12:27:20 +00:00
parent 57eb68292f
commit 9b87051a4d
3 changed files with 7 additions and 6 deletions

View File

@ -1088,8 +1088,8 @@ The following local attributes are used by a wider range of devices:
<ul>
<li>You can use the r:, i: or a: prefix to restrict the search to one
type, analogue to the devspec filtering.</li>
<li>The suffix :d retrieves the first number and converts it to an
integer.</li>
<li>The suffix :d retrieves the first number</li>
<li>The suffix :i retrieves the integer part of the first number.</li>
<li>The suffix :r&lt;n&gt; retrieves the first number and rounds it to
&lt;n&gt; decimal places. If &lt;n&gt; is missing, then rounds it to
one decimal place.</li>

View File

@ -1157,7 +1157,8 @@ Die folgenden lokalen Attribute werden von mehreren Ger&auml;ten verwendet:
<ul>
<li>Man kann einen der Pr&auml;fixe r:, i: oder a: verwenden, um die
Suche einzuschr&auml;nken, genau wie im devspec.</li>
<li>Das Suffix :d extrahiert die erste Zahl als Ganzzahl.</li>
<li>Das Suffix :d extrahiert die erste Zahl.</li>
<li>Das Suffix :i extrahiert die erste Zahl als Ganzzahl.</li>
<li>Das Suffix :r&lt;n&gt; extrahiert die erste Zahl, und rundet sie auf
&lt;n&gt; Dezimalstellen. Falls &lt;n&gt; fehlt, dann wird auf eine
Dezimalstelle gerundet.</li>

View File

@ -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};