2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 06:39:11 +00:00

fhem.pl: add -temporary option to the define command (Forum #39610)

git-svn-id: https://svn.fhem.de/fhem/trunk@9118 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2015-08-23 12:43:56 +00:00
parent 07bb31b3c5
commit 6182d2fb3f
3 changed files with 36 additions and 4 deletions

View File

@ -732,7 +732,7 @@ The following local attributes are used by a wider range of devices:
<a name="define"></a>
<h3>define</h3>
<ul>
<code>define &lt;name&gt; &lt;type&gt; &lt;type-specific&gt;</code><br>
<code>define [option] &lt;name&gt; &lt;type&gt; &lt;type-specific&gt;</code><br>
<br>
Define a device. You need devices if you want to manipulate them (e.g.
set on/off), and the logfile is also more readable if it contains e.g.
@ -744,6 +744,19 @@ The following local attributes are used by a wider range of devices:
Each device takes different additional arguments at definition, see the
corresponding device section for details.<br>
<br>
Options:<br>
<ul>
<li>-temporary<br>
Add the TEMPORARY flag to the definition, which will prevent saving the
device to fhem.cfg.
</li><br>
<li>-ignoreErr<br>
Reduce the number of errors displayed when a certain FHEM-module cannot
be loaded. Used by fhem.cfg.demo, as using the RSS example requires the
installation of several uncommon perl modules.
</li><br>
</ul>
</ul>
<a name="defmod"></a>

View File

@ -760,7 +760,7 @@ Die folgenden lokalen Attribute werden von mehreren Ger&auml;ten verwendet:
<a name="define"></a>
<h3>define</h3>
<ul>
<code>define &lt;name&gt; &lt;type&gt; &lt;type-specific&gt;</code><br>
<code>define [option] &lt;name&gt; &lt;type&gt; &lt;type-specific&gt;</code><br>
<br>
Definiert ein Ger&auml;t. Sie m&uuml;ssen Ger&auml;te einrichten um sie zu
@ -773,7 +773,19 @@ Die folgenden lokalen Attribute werden von mehreren Ger&auml;ten verwendet:
Je nach Typ ben&ouml;tigt man unterscheidliche Argumente, lesen Sie sich
bitte die zu dem jeweiligen Ger&auml;t geh&ouml;renden Abschnitte durch.
<br>
<br><br>
Optionen:<br>
<ul>
<li>-temporary<br>
Setzt den TEMPORARY Marker, was das Abspeichern dieser Definition in
fhem.cfg verhindert.
</li><br>
<li>-ignoreErr<br>
Reduziert die Anzahl der Fehlermeldungen, falls ein FHEM-Modul nicht
geladen werden kann. Wird in fhem.cfg.demo verwendet, da das RSS Beispiel
etliche, normalerweise nicht installierte perl-Module ben&ouml;tigt.
</li><br>
</ul>
</ul>
<a name="defmod"></a>

View File

@ -1627,7 +1627,7 @@ CommandDefine($$)
{
my ($cl, $def) = @_;
my @a = split("[ \t]+", $def, 3);
my $ignoreErr;
my ($ignoreErr, $temporary);
# used by RSS in fhem.cfg.demo, with no GD installed
if($a[0] && $a[0] eq "-ignoreErr") {
@ -1635,6 +1635,12 @@ CommandDefine($$)
@a = split("[ \t][ \t]*", $def, 3);
$ignoreErr = 1;
}
if($a[0] && $a[0] eq "-temporary") { # Forum #39610
$def =~ s/\s*-temporary\s*//;
@a = split("[ \t][ \t]*", $def, 3);
$temporary = 1;
}
my $name = $a[0];
return "Usage: define <name> <type> <type dependent arguments>"
if(int(@a) < 2);
@ -1679,6 +1685,7 @@ CommandDefine($$)
delete $attr{$name};
} else {
$hash{TEMPORARY} = 1 if($temporary);
foreach my $da (sort keys (%defaultattr)) { # Default attributes
CommandAttr($cl, "$name $da $defaultattr{$da}");
}