2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-02-28 02:44:53 +00:00

fhem.pl: add the set replace magic to setreading

git-svn-id: https://svn.fhem.de/fhem/trunk@10054 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2015-11-30 06:32:35 +00:00
parent 3534c94909
commit e65ce0a8b1
3 changed files with 14 additions and 7 deletions

View File

@ -1126,7 +1126,7 @@ The following local attributes are used by a wider range of devices:
Each device has different set parameters, see the corresponding device Each device has different set parameters, see the corresponding device
section for details.<br> section for details.<br>
<br><br> <br><br>
From featurelevel 5.7 on the set 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:reading] with the corresponding reading of device, if both device
and reading exists.</li> and reading exists.</li>
@ -1196,7 +1196,8 @@ The following local attributes are used by a wider range of devices:
<br><br> <br><br>
Set the reading &lt;reading&gt; for the device <code>&lt;name&gt;</code> to Set the reading &lt;reading&gt; for the device <code>&lt;name&gt;</code> to
&lt;value&gt; without sending out commands to the device, but triggering &lt;value&gt; without sending out commands to the device, but triggering
events and eventMap/stateFormat transformations as usual. events and eventMap/stateFormat transformations as usual. See the set
command documentation for replacement description.
<br><br> <br><br>
Examples: Examples:
<ul> <ul>

View File

@ -1188,7 +1188,7 @@ Die folgenden lokalen Attribute werden von mehreren Ger&auml;ten verwendet:
werden k&ouml;nnen. Lesen Sie bitte den entsprechenden Abschnitt f&uuml;r werden k&ouml;nnen. Lesen Sie bitte den entsprechenden Abschnitt f&uuml;r
das Ger&auml;t f&uuml;r Details durch. das Ger&auml;t f&uuml;r Details durch.
<br><br> <br><br>
Ab featurelevel 5.7 ersetzt das set Befehl Ab featurelevel 5.7 ersetzt das set und setreading Befehl
<ul> <ul>
<li>[device:reading] mit dem Wert des Readings f&uuml;r device, falls sowohl <li>[device:reading] mit dem Wert des Readings f&uuml;r device, falls sowohl
device, als auch Reading existiert, und nicht leer ist.</li> device, als auch Reading existiert, und nicht leer ist.</li>
@ -1271,7 +1271,8 @@ Die folgenden lokalen Attribute werden von mehreren Ger&auml;ten verwendet:
durchgef&uuml;hrt. durchgef&uuml;hrt.
<br> <br>
Siehe den Abschnitt &uuml;ber <a href="#devspec">Ger&auml;te-Spezifikation</a> Siehe den Abschnitt &uuml;ber <a href="#devspec">Ger&auml;te-Spezifikation</a>
f&uuml;r Details der &lt;devspec&gt;.<br> f&uuml;r Details der &lt;devspec&gt; und die Beschreibung des set Befehls
f&uuml;r Ersetzung.<br>
<br> <br>
Beispiel: Beispiel:
<ul> <ul>

View File

@ -1507,8 +1507,9 @@ CommandShutdown($$)
##################################### #####################################
sub sub
ReplaceSetMagic(@) # Forum #38276 ReplaceSetMagic($@) # Forum #38276
{ {
my $nsplit = shift;
my $a = join(" ", @_); my $a = join(" ", @_);
$a =~ s/\[([a-z0-9._]+):([A-z0-9._]+)\]/{ $a =~ s/\[([a-z0-9._]+):([A-z0-9._]+)\]/{
@ -1521,7 +1522,7 @@ ReplaceSetMagic(@) # Forum #38276
$@ ? $1 : $x $@ ? $1 : $x
}/eg; }/eg;
return (undef, split(" ", $a)); return (undef, split(" ", $a, $nsplit));
} }
##################################### #####################################
@ -1541,7 +1542,7 @@ DoSet(@)
@a = ReplaceEventMap($dev, \@a, 0) if($attr{$dev}{eventMap}); @a = ReplaceEventMap($dev, \@a, 0) if($attr{$dev}{eventMap});
my $err; my $err;
($err, @a) = ReplaceSetMagic(@a) if($featurelevel >= 5.7); ($err, @a) = ReplaceSetMagic(0, @a) if($featurelevel >= 5.7);
return $err if($err); return $err if($err);
$hash->{".triggerUsed"} = 0; $hash->{".triggerUsed"} = 0;
@ -2008,6 +2009,10 @@ CommandSetReading($$)
my @a = split(" ", $def, 3); my @a = split(" ", $def, 3);
return "Usage: setreading <name> <reading> <value>\n$namedef" if(@a != 3); return "Usage: setreading <name> <reading> <value>\n$namedef" if(@a != 3);
my $err;
($err, @a) = ReplaceSetMagic(3,@a) if($featurelevel >= 5.7);
return $err if($err);
my @rets; my @rets;
foreach my $sdev (devspec2array($a[0])) { foreach my $sdev (devspec2array($a[0])) {