2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 12:49:34 +00:00

fhem.pl: fix list bug and doc (Forum #104279)

git-svn-id: https://svn.fhem.de/fhem/trunk@20318 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2019-10-06 12:16:21 +00:00
parent c66ac5a10d
commit f613e6ed79
3 changed files with 40 additions and 37 deletions

View File

@ -941,7 +941,7 @@ The following local attributes are used by a wider range of devices:
<a name="list"></a> <a name="list"></a>
<h3>list</h3> <h3>list</h3>
<ul> <ul>
<code>list [devspec] [value]</code><br> <code>list [devspec] [value ...]</code><br>
or<br> or<br>
<code>list {-r|-R} devspec</code><br> <code>list {-r|-R} devspec</code><br>
<br><br> <br><br>
@ -951,13 +951,15 @@ The following local attributes are used by a wider range of devices:
See the <a href="#devspec">Device specification</a> section for details on See the <a href="#devspec">Device specification</a> section for details on
&lt;devspec&gt;. &lt;devspec&gt;.
<br> <br>
If value is specified, then output this property (like DEF, TYPE, etc) or If &lt;value&gt; is specified, then output this property (internal, reading
reading (actuator, measured-temp) for all devices from the devspec. or attribute) for all devices from the devspec. &lt;value&gt; can be
restricted with prefix i: for internals, r: for readings and a: for
attributes.
<br><br> <br><br>
Example: Example:
<pre><code> fhem> list <pre><code> fhem&gt; list
Type list <name> for detailed info. Type list &lt;name&gt; for detailed info.
Internal: Internal:
global (Internal) global (Internal)
@ -988,7 +990,7 @@ The following local attributes are used by a wider range of devices:
</code></pre> </code></pre>
If specifying <code>name</code>, then a detailed status for <code>name</code> If specifying <code>name</code>, then a detailed status for <code>name</code>
will be displayed, e.g.: will be displayed, e.g.:
<pre><code> fhem> list fl <pre><code> fhem&gt; list fl
Internals: Internals:
CODE 5102 CODE 5102

View File

@ -996,7 +996,7 @@ Die folgenden lokalen Attribute werden von mehreren Ger&auml;ten verwendet:
<a name="list"></a> <a name="list"></a>
<h3>list</h3> <h3>list</h3>
<ul> <ul>
<code>list [devspec] [value]</code><br> <code>list [devspec] [value ...]</code><br>
oder<br> oder<br>
<code>list {-r|-R} devspec</code><br> <code>list {-r|-R} devspec</code><br>
<br><br> <br><br>
@ -1004,11 +1004,14 @@ Die folgenden lokalen Attribute werden von mehreren Ger&auml;ten verwendet:
&quot;at&quot;-Definitionen. Dies ist eines der wenigen Befehle, die im &quot;at&quot;-Definitionen. Dies ist eines der wenigen Befehle, die im
Normalfall eine Zeichenkette ausgeben.<br> Siehe den Abschnitt &uuml;ber <a Normalfall eine Zeichenkette ausgeben.<br> Siehe den Abschnitt &uuml;ber <a
href="#devspec">Ger&auml;te-Spezifikation</a> f&uuml;r Details der href="#devspec">Ger&auml;te-Spezifikation</a> f&uuml;r Details der
&lt;devspec&gt;.<br> &lt;devspec&gt;.<br><br>
<br> Wenn value angegeben ist, der von ( DEF, TYPE, usw) oder reading Wenn &lt;value&gt; angegeben ist, dann wird dieses Wert (Internal, Reading
(actuator, measured-temp) f&uuml;r alle Ger&auml;te die in devspec angegeben oder Attribut) ausgegeben, soweit es vorhanden ist. Die Werte k&ouml;nnen mit
sind. <br><br> Beispiel: einem Pr&auml;fix eingeschr&auml;nkt werden: i: f&uuml;r Internals, r:
f&uuml;r Readings und a: f&uuml;r Attribute.
<br><br> Beispiel:
<pre><code>fhem&gt; list <pre><code>fhem&gt; list
Type list <name> for detailed info. Type list <name> for detailed info.

View File

@ -2508,6 +2508,7 @@ CommandList($$)
my @list = devspec2array($arg[0],$cl); my @list = devspec2array($arg[0],$cl);
if($arg[1]) { if($arg[1]) {
foreach my $sdev (@list) { # Show a Hash-Entry or Reading for each device foreach my $sdev (@list) { # Show a Hash-Entry or Reading for each device
next if(!$defs{$sdev});
my $first = 1; my $first = 1;
foreach my $n (@arg[1..@arg-1]) { foreach my $n (@arg[1..@arg-1]) {
@ -2518,20 +2519,19 @@ CommandList($$)
$n = $2; $n = $2;
} }
if($defs{$sdev}) {
if(defined($defs{$sdev}{$n}) && (!$fType || $fType eq "i:")) { if(defined($defs{$sdev}{$n}) && (!$fType || $fType eq "i:")) {
my $val = $defs{$sdev}{$n}; my $val = $defs{$sdev}{$n};
if(ref($val) eq 'HASH') { if(ref($val) eq 'HASH') {
$val = ($val->{NAME} ? $val->{NAME} : # ??? $val = ($val->{NAME} ? $val->{NAME} : # ???
join(" ", map { "$_=$val->{$_}" } sort keys %{$val})); join(" ", map { "$_=$val->{$_}" } sort keys %{$val}));
} }
$str .= sprintf("%-20s %*s %*s %s\n", $first?$sdev:'', $str .= sprintf("%-20s %*s %*s %s\n", ($first++==1)?$sdev:'',
$arg[2]?19:0, '', $arg[2]?-15:0, $arg[2]?$n:'', $val); $arg[2]?19:0, '', $arg[2]?-15:0, $arg[2]?$n:'', $val);
} elsif($defs{$sdev}{READINGS} && } elsif($defs{$sdev}{READINGS} &&
defined($defs{$sdev}{READINGS}{$n}) defined($defs{$sdev}{READINGS}{$n})
&& (!$fType || $fType eq "r:")) { && (!$fType || $fType eq "r:")) {
$str .= sprintf("%-20s %s %*s %s\n", $first?$sdev:'', $str .= sprintf("%-20s %s %*s %s\n", ($first++==1)?$sdev:'',
$defs{$sdev}{READINGS}{$n}{TIME}, $defs{$sdev}{READINGS}{$n}{TIME},
$arg[2]?-15:0, $arg[2]?$n:'', $arg[2]?-15:0, $arg[2]?$n:'',
$defs{$sdev}{READINGS}{$n}{VAL}); $defs{$sdev}{READINGS}{$n}{VAL});
@ -2539,14 +2539,12 @@ CommandList($$)
} elsif($attr{$sdev} && } elsif($attr{$sdev} &&
defined($attr{$sdev}{$n}) defined($attr{$sdev}{$n})
&& (!$fType || $fType eq "a:")) { && (!$fType || $fType eq "a:")) {
$str .= sprintf("%-20s %*s %*s %s\n", $first?$sdev:'', $str .= sprintf("%-20s %*s %*s %s\n",($first++==1)?$sdev:'',
$arg[2]?19:0, '', $arg[2]?-15:0, $arg[2]?$n:'', $arg[2]?19:0, '', $arg[2]?-15:0, $arg[2]?$n:'',
$attr{$sdev}{$n}); $attr{$sdev}{$n});
} }
} }
$first = 0;
}
} }
} elsif(@list == 1) { # Details } elsif(@list == 1) { # Details