mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-04 22:19:38 +00:00
fhem.pl: Replace-Magic replaces now attributes and internals too, just like
devspec (Forum #38276) git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@13893 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
575d50ab32
commit
b031693152
@ -1083,10 +1083,11 @@ The following local attributes are used by a wider range of devices:
|
|||||||
<br><br>
|
<br><br>
|
||||||
From featurelevel 5.7 on the set and setreading command replaces:
|
From featurelevel 5.7 on the set and setreading command replaces:
|
||||||
<ul>
|
<ul>
|
||||||
<li>[device:reading] with the corresponding reading of device, if both device
|
<li>[device:name] with the reading, internal or attribute of the device, if
|
||||||
and reading exists.</li>
|
both device and the reading, internal or attribute exists. You can use the
|
||||||
<li>[device:reading:d] same as above, but only the number is retrieved, see
|
r:, i: or a: prefix to restrict the search to one type, analogue to the
|
||||||
ReadingsNum </li>
|
devspec filtering.</li>
|
||||||
|
<li>[device:name:d] same as above, but only the number is retrieved</li>
|
||||||
<li>{(perlExpression)} with the result of perlExpression.
|
<li>{(perlExpression)} with the result of perlExpression.
|
||||||
The $DEV variable is additionally available, designating the set device
|
The $DEV variable is additionally available, designating the set device
|
||||||
name.
|
name.
|
||||||
@ -1650,6 +1651,14 @@ The following local attributes are used by a wider range of devices:
|
|||||||
ReadingsNum(<devicename>,<reading>,<defaultvalue>)<br>
|
ReadingsNum(<devicename>,<reading>,<defaultvalue>)<br>
|
||||||
Return the reading as a number, i.e. delete non-numerical values.
|
Return the reading as a number, i.e. delete non-numerical values.
|
||||||
</li><br>
|
</li><br>
|
||||||
|
<li>ReadingsTimestamp(<devicename>,<reading>,<
|
||||||
|
defaultvalue>)<br>
|
||||||
|
returns the timestamp of the reading.
|
||||||
|
</li><br>
|
||||||
|
<li>ReadingsAge(<devicename>,<reading>,<defaultvalue>)
|
||||||
|
<br>
|
||||||
|
returns the age of the reading in seconds.
|
||||||
|
</li><br>
|
||||||
<li>
|
<li>
|
||||||
AttrVal(<devicename>,<attribute>,<defaultvalue>)<br>
|
AttrVal(<devicename>,<attribute>,<defaultvalue>)<br>
|
||||||
Return the attribute of the device
|
Return the attribute of the device
|
||||||
|
@ -1151,10 +1151,12 @@ Die folgenden lokalen Attribute werden von mehreren Geräten verwendet:
|
|||||||
<br><br>
|
<br><br>
|
||||||
Ab featurelevel 5.7 ersetzt das set und setreading Befehl
|
Ab featurelevel 5.7 ersetzt das set und setreading Befehl
|
||||||
<ul>
|
<ul>
|
||||||
<li>[device:reading] mit dem Wert des Readings für device, falls sowohl
|
<li>[device:name] mit dem Wert des Readings, Internals oder Attributes
|
||||||
device, als auch Reading existiert, und nicht leer ist.</li>
|
für device, falls sowohl device, als auch Reading, Internal oder
|
||||||
<li>[device:reading:d] wie ohne :d, aber alles nicht-numerische wird
|
Attribut existiert, und nicht leer ist. Man kann einen der Prefixe r:, i:
|
||||||
entfernt, siehe ReadingsNum</li>
|
oder a: verwenden, um die Suche einzuschraenken, genau wie im devspec.</li>
|
||||||
|
<li>[device:name:d] wie ohne :d, aber alles nicht-numerische wird
|
||||||
|
entfernt.</li>
|
||||||
<li>{(perlExpression)} mit dem Ergebnis der perlExpression.
|
<li>{(perlExpression)} mit dem Ergebnis der perlExpression.
|
||||||
$DEV wird dabei mit dem Namen des vom set betroffenen Gerätes ersetzt.
|
$DEV wird dabei mit dem Namen des vom set betroffenen Gerätes ersetzt.
|
||||||
</li>
|
</li>
|
||||||
@ -1786,6 +1788,13 @@ Die folgenden lokalen Attribute werden von mehreren Geräten verwendet:
|
|||||||
Wie ReadingsVal, löscht aber alles, was kein Zahl ist, um den Wert
|
Wie ReadingsVal, löscht aber alles, was kein Zahl ist, um den Wert
|
||||||
bei Berechnungen verwenden zu können.
|
bei Berechnungen verwenden zu können.
|
||||||
</li><br>
|
</li><br>
|
||||||
|
<li>ReadingsTimestamp(<devicename>)<br>
|
||||||
|
gibt den Zeitstempel des Readings zurück.
|
||||||
|
</li><br>
|
||||||
|
<li>ReadingsAge(<devicename>,<reading>,<defaultvalue>)
|
||||||
|
<br>
|
||||||
|
gibt das Alter des Readings in Sekunden zurück.
|
||||||
|
</li><br>
|
||||||
<li>
|
<li>
|
||||||
AttrVal(<devicename>,<attribute>,<defaultvalue>)<br>
|
AttrVal(<devicename>,<attribute>,<defaultvalue>)<br>
|
||||||
Gibt die gesetzteb Attribute des Gerätes zurück
|
Gibt die gesetzteb Attribute des Gerätes zurück
|
||||||
|
22
fhem.pl
22
fhem.pl
@ -1620,10 +1620,24 @@ ReplaceSetMagic($$@) # Forum #38276
|
|||||||
my $a = join(" ", @_);
|
my $a = join(" ", @_);
|
||||||
my $oa = $a;
|
my $oa = $a;
|
||||||
|
|
||||||
$a =~ s/\[([a-z0-9._]+):([a-z0-9._-]+)(:d)?\]/{
|
sub
|
||||||
my $x = $3 ? ReadingsNum($1,$2,"") : ReadingsVal($1,$2,"");
|
rsmVal($$$$$)
|
||||||
$x eq "" ? "[$1:$2".($3?$3:"")."]" : $x
|
{
|
||||||
}/egi;
|
my ($all, $t, $d, $n, $s, $val) = @_;
|
||||||
|
my $hash = $defs{$d};
|
||||||
|
return $all if(!$hash);
|
||||||
|
if(!$t || $t eq "r:") {
|
||||||
|
my $r = $hash->{READINGS};
|
||||||
|
$val = $r->{$n}{VAL} if($r && $r->{$n});
|
||||||
|
}
|
||||||
|
$val = $hash->{$n} if(!defined($val) && (!$t || $t eq "i:"));
|
||||||
|
$val = $attr{$d}{$n} if(!defined($val) && (!$t || $t eq "a:") && $attr{$d});
|
||||||
|
return $all if(!defined($val));
|
||||||
|
$val =~ s/[^-\.\d]//g if($s);
|
||||||
|
return $val;
|
||||||
|
}
|
||||||
|
|
||||||
|
$a=~s/(\[(.:)?([a-z0-9._]+):([a-z0-9._-]+)(:d)?\])/rsmVal($1,$2,$3,$4,$5)/egi;
|
||||||
|
|
||||||
$evalSpecials->{'%DEV'} = $hash->{NAME};
|
$evalSpecials->{'%DEV'} = $hash->{NAME};
|
||||||
$a =~ s/{\((.*?)\)}/AnalyzePerlCommand($hash->{CL},$1,1)/egs;
|
$a =~ s/{\((.*?)\)}/AnalyzePerlCommand($hash->{CL},$1,1)/egs;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user