2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-04 17:36:39 +00:00

98_dummy.pm: add readingList attribute (Forum #38383)

git-svn-id: https://svn.fhem.de/fhem/trunk@8809 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2015-06-23 18:02:33 +00:00
parent 46f0a1660c
commit e68bf58f2b

View File

@ -12,7 +12,7 @@ dummy_Initialize($)
$hash->{SetFn} = "dummy_Set"; $hash->{SetFn} = "dummy_Set";
$hash->{DefFn} = "dummy_Define"; $hash->{DefFn} = "dummy_Define";
$hash->{AttrList} = "setList ". $readingFnAttributes; $hash->{AttrList} = "readingList setList ". $readingFnAttributes;
} }
################################### ###################################
@ -26,6 +26,13 @@ dummy_Set($@)
my $setList = AttrVal($name, "setList", " "); my $setList = AttrVal($name, "setList", " ");
return "Unknown argument ?, choose one of $setList" if($a[0] eq "?"); return "Unknown argument ?, choose one of $setList" if($a[0] eq "?");
my @rl = split(" ", AttrVal($name, "readingList", ""));
if(@rl && grep /\b$a[0]\b/, @rl) {
my $v = shift @a;
readingsSingleUpdate($hash, $v, join(" ",@a), 1);
return;
}
my $v = join(" ", @a); my $v = join(" ", @a);
Log3 $name, 4, "dummy set $name $v"; Log3 $name, 4, "dummy set $name $v";
@ -84,11 +91,15 @@ dummy_Define($$)
<a name="dummyattr"></a> <a name="dummyattr"></a>
<b>Attributes</b> <b>Attributes</b>
<ul> <ul>
<li><a name="readingList">readingList</a><br>
Space separated list of readings, which will be set, if the first
argument of the set command matches one of them.</li>
<li><a name="setList">setList</a><br> <li><a name="setList">setList</a><br>
Space separated list of commands, which will be returned upon "set name ?", Space separated list of commands, which will be returned upon "set name
so the FHEMWEB frontend can construct a dropdown and offer on/off ?", so the FHEMWEB frontend can construct a dropdown and offer on/off
switches. Example: attr dummyName setList on off switches. Example: attr dummyName setList on off </li>
</li>
<li><a href="#readingFnAttributes">readingFnAttributes</a></li> <li><a href="#readingFnAttributes">readingFnAttributes</a></li>
</ul> </ul>
<br> <br>
@ -135,13 +146,15 @@ dummy_Define($$)
<a name="dummyattr"></a> <a name="dummyattr"></a>
<b>Attributes</b> <b>Attributes</b>
<ul> <ul>
<li><a name="setList">setList</a><br> <li><a name="readingList">readingList</a><br>
Liste mit Werten durch Leerzeichen getrennt. Diese Liste wird mit "set Leerzeichen getrennte Liste mit Readings, die mit "set" gesetzt werden
name ?" ausgegeben. Damit kann das FHEMWEB-Frontend Auswahl-Men&uuml;s k&ouml;nnen.</li>
oder Schalter erzeugen.<br>
Beispiel: attr dummyName setList on off <li><a name="setList">setList</a><br>
Liste mit Werten durch Leerzeichen getrennt. Diese Liste wird mit "set
name ?" ausgegeben. Damit kann das FHEMWEB-Frontend Auswahl-Men&uuml;s
oder Schalter erzeugen.<br> Beispiel: attr dummyName setList on off </li>
</li>
<li><a href="#readingFnAttributes">readingFnAttributes</a></li> <li><a href="#readingFnAttributes">readingFnAttributes</a></li>
</ul> </ul>
<br> <br>