2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-10 09:16:53 +00:00

98_count.pm: add parameter "raw"

git-svn-id: https://svn.fhem.de/fhem/trunk@18543 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
betateilchen 2019-02-09 12:13:20 +00:00
parent 16afd76e51
commit 37a996903e

View File

@ -5,7 +5,6 @@ use strict;
use warnings;
sub count_Initialize($$) {
$cmds{count} = { Fn => "CommandCount",
Hlp=>"[filter],count devices"};
}
@ -14,14 +13,16 @@ sub CommandCount($$)
{
my ($cl, $param) = @_;
my $str = "";
my $fill = "";
my $fill = $str;
my $n = 0;
my $raw = $n;
if(!$param) { # List of all devices
$n = keys %defs;
$fill = "s" if $n != 1;
$str = "\nCount: $n device$fill in total.\n";
} else { # devspecArray
$raw = $param =~ s/ raw$//i;
$n = 0;
my @list = devspec2array($param,$cl);
$n = int(@list);
@ -34,7 +35,8 @@ sub CommandCount($$)
$str = "\nCount: $n device$fill for devspec $param\n";
}
return $str;
return $str unless $raw;
return $n;
}
1;
@ -48,10 +50,12 @@ sub CommandCount($$)
<a name="count"></a>
<h3>count</h3>
<ul>
<code>count [devspec]</code>
<code>count [devspec] [raw]</code>
<br><br>
Count devices specified by devspec.<br/>
If no devspec given, count will return number of totally defined devices.<br/>
Count will return the plain number of devices if "raw" passed as last part of the command.<br/>
This is useful for processing the number of devices itself.<br/>
</ul>
=end html