mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 18:59:33 +00:00
09357f54df
git-svn-id: https://svn.fhem.de/fhem/trunk@21551 2b470e98-0d58-463d-a4d8-8e2adae1ed80
64 lines
1.4 KiB
Perl
64 lines
1.4 KiB
Perl
# $Id$
|
|
|
|
package main;
|
|
use strict;
|
|
use warnings;
|
|
|
|
sub count_Initialize {
|
|
$cmds{count} = { Fn => "CommandCount",
|
|
Hlp=>"[filter],count devices"};
|
|
}
|
|
|
|
sub CommandCount
|
|
{
|
|
my ($cl, $param) = @_;
|
|
my $str = "";
|
|
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);
|
|
if ($n == 1) {
|
|
$n = (defined($defs{$list[0]})) ? 1 : "No";
|
|
$fill = "s" if ($n eq "No");
|
|
} else {
|
|
$fill = "s"
|
|
}
|
|
$str = "\nCount: $n device$fill for devspec $param\n";
|
|
}
|
|
|
|
return $str unless $raw;
|
|
return $n;
|
|
}
|
|
|
|
1;
|
|
|
|
=pod
|
|
=item summary count devices based on devspec
|
|
=item summary_DE zählt Geräte, die einer devspec entsprechen
|
|
=item command
|
|
=begin html
|
|
|
|
<a name="count"></a>
|
|
<h3>count</h3>
|
|
<ul>
|
|
<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
|
|
|
|
=cut
|