mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 06:39:11 +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:
parent
3534c94909
commit
e65ce0a8b1
@ -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
|
||||
section for details.<br>
|
||||
<br><br>
|
||||
From featurelevel 5.7 on the set command replaces:
|
||||
From featurelevel 5.7 on the set (and setreading) command replaces:
|
||||
<ul>
|
||||
<li>[device:reading] with the corresponding reading of device, if both device
|
||||
and reading exists.</li>
|
||||
@ -1196,7 +1196,8 @@ The following local attributes are used by a wider range of devices:
|
||||
<br><br>
|
||||
Set the reading <reading> for the device <code><name></code> to
|
||||
<value> 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>
|
||||
Examples:
|
||||
<ul>
|
||||
|
@ -1188,7 +1188,7 @@ Die folgenden lokalen Attribute werden von mehreren Geräten verwendet:
|
||||
werden können. Lesen Sie bitte den entsprechenden Abschnitt für
|
||||
das Gerät für Details durch.
|
||||
<br><br>
|
||||
Ab featurelevel 5.7 ersetzt das set Befehl
|
||||
Ab featurelevel 5.7 ersetzt das set und setreading Befehl
|
||||
<ul>
|
||||
<li>[device:reading] mit dem Wert des Readings für device, falls sowohl
|
||||
device, als auch Reading existiert, und nicht leer ist.</li>
|
||||
@ -1271,7 +1271,8 @@ Die folgenden lokalen Attribute werden von mehreren Geräten verwendet:
|
||||
durchgeführt.
|
||||
<br>
|
||||
Siehe den Abschnitt über <a href="#devspec">Geräte-Spezifikation</a>
|
||||
für Details der <devspec>.<br>
|
||||
für Details der <devspec> und die Beschreibung des set Befehls
|
||||
für Ersetzung.<br>
|
||||
<br>
|
||||
Beispiel:
|
||||
<ul>
|
||||
|
11
fhem/fhem.pl
11
fhem/fhem.pl
@ -1507,8 +1507,9 @@ CommandShutdown($$)
|
||||
|
||||
#####################################
|
||||
sub
|
||||
ReplaceSetMagic(@) # Forum #38276
|
||||
ReplaceSetMagic($@) # Forum #38276
|
||||
{
|
||||
my $nsplit = shift;
|
||||
my $a = join(" ", @_);
|
||||
|
||||
$a =~ s/\[([a-z0-9._]+):([A-z0-9._]+)\]/{
|
||||
@ -1521,7 +1522,7 @@ ReplaceSetMagic(@) # Forum #38276
|
||||
$@ ? $1 : $x
|
||||
}/eg;
|
||||
|
||||
return (undef, split(" ", $a));
|
||||
return (undef, split(" ", $a, $nsplit));
|
||||
}
|
||||
|
||||
#####################################
|
||||
@ -1541,7 +1542,7 @@ DoSet(@)
|
||||
|
||||
@a = ReplaceEventMap($dev, \@a, 0) if($attr{$dev}{eventMap});
|
||||
my $err;
|
||||
($err, @a) = ReplaceSetMagic(@a) if($featurelevel >= 5.7);
|
||||
($err, @a) = ReplaceSetMagic(0, @a) if($featurelevel >= 5.7);
|
||||
return $err if($err);
|
||||
|
||||
$hash->{".triggerUsed"} = 0;
|
||||
@ -2008,6 +2009,10 @@ CommandSetReading($$)
|
||||
my @a = split(" ", $def, 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;
|
||||
foreach my $sdev (devspec2array($a[0])) {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user