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:
parent
57eb68292f
commit
9b87051a4d
@ -1088,8 +1088,8 @@ The following local attributes are used by a wider range of devices:
|
|||||||
<ul>
|
<ul>
|
||||||
<li>You can use the r:, i: or a: prefix to restrict the search to one
|
<li>You can use the r:, i: or a: prefix to restrict the search to one
|
||||||
type, analogue to the devspec filtering.</li>
|
type, analogue to the devspec filtering.</li>
|
||||||
<li>The suffix :d retrieves the first number and converts it to an
|
<li>The suffix :d retrieves the first number</li>
|
||||||
integer.</li>
|
<li>The suffix :i retrieves the integer part of the first number.</li>
|
||||||
<li>The suffix :r<n> retrieves the first number and rounds it to
|
<li>The suffix :r<n> retrieves the first number and rounds it to
|
||||||
<n> decimal places. If <n> is missing, then rounds it to
|
<n> decimal places. If <n> is missing, then rounds it to
|
||||||
one decimal place.</li>
|
one decimal place.</li>
|
||||||
|
@ -1157,7 +1157,8 @@ Die folgenden lokalen Attribute werden von mehreren Geräten verwendet:
|
|||||||
<ul>
|
<ul>
|
||||||
<li>Man kann einen der Präfixe r:, i: oder a: verwenden, um die
|
<li>Man kann einen der Präfixe r:, i: oder a: verwenden, um die
|
||||||
Suche einzuschränken, genau wie im devspec.</li>
|
Suche einzuschrä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<n> extrahiert die erste Zahl, und rundet sie auf
|
<li>Das Suffix :r<n> extrahiert die erste Zahl, und rundet sie auf
|
||||||
<n> Dezimalstellen. Falls <n> fehlt, dann wird auf eine
|
<n> Dezimalstellen. Falls <n> fehlt, dann wird auf eine
|
||||||
Dezimalstelle gerundet.</li>
|
Dezimalstelle gerundet.</li>
|
||||||
|
@ -1674,15 +1674,15 @@ ReplaceSetMagic($$@) # Forum #38276
|
|||||||
$val = $attr{$d}{$n} if(!defined($val) && (!$t || $t eq "a:") && $attr{$d});
|
$val = $attr{$d}{$n} if(!defined($val) && (!$t || $t eq "a:") && $attr{$d});
|
||||||
return $all if(!defined($val));
|
return $all if(!defined($val));
|
||||||
|
|
||||||
if($s && $val =~ /(-?\d+(\.\d+)?)/) {
|
if($s =~ /:d|:r|:i/ && $val =~ /(-?\d+(\.\d+)?)/) {
|
||||||
$val = $1;
|
$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)?/);
|
$val = round($val, defined($1) ? $1 : 1) if($s =~ /^:r(\d)?/);
|
||||||
}
|
}
|
||||||
return $val;
|
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;
|
rsmVal($1,$2,$3,$4,$5)/egi;
|
||||||
|
|
||||||
$evalSpecials->{'%DEV'} = $hash->{NAME};
|
$evalSpecials->{'%DEV'} = $hash->{NAME};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user