2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 06:39:11 +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>
<h3>list</h3>
<ul>
<code>list [devspec] [value]</code><br>
<code>list [devspec] [value ...]</code><br>
or<br>
<code>list {-r|-R} devspec</code><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
&lt;devspec&gt;.
<br>
If value is specified, then output this property (like DEF, TYPE, etc) or
reading (actuator, measured-temp) for all devices from the devspec.
If &lt;value&gt; is specified, then output this property (internal, reading
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>
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:
global (Internal)
@ -988,7 +990,7 @@ The following local attributes are used by a wider range of devices:
</code></pre>
If specifying <code>name</code>, then a detailed status for <code>name</code>
will be displayed, e.g.:
<pre><code> fhem> list fl
<pre><code> fhem&gt; list fl
Internals:
CODE 5102

View File

@ -996,7 +996,7 @@ Die folgenden lokalen Attribute werden von mehreren Ger&auml;ten verwendet:
<a name="list"></a>
<h3>list</h3>
<ul>
<code>list [devspec] [value]</code><br>
<code>list [devspec] [value ...]</code><br>
oder<br>
<code>list {-r|-R} devspec</code><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
Normalfall eine Zeichenkette ausgeben.<br> Siehe den Abschnitt &uuml;ber <a
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
(actuator, measured-temp) f&uuml;r alle Ger&auml;te die in devspec angegeben
sind. <br><br> Beispiel:
Wenn &lt;value&gt; angegeben ist, dann wird dieses Wert (Internal, Reading
oder Attribut) ausgegeben, soweit es vorhanden ist. Die Werte k&ouml;nnen mit
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
Type list <name> for detailed info.

View File

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