mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-10 09:16:53 +00:00
98_weekprofile: sorted lists
git-svn-id: https://svn.fhem.de/fhem/trunk@10738 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
f5913921d7
commit
aa591d854e
@ -1,5 +1,6 @@
|
|||||||
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
||||||
# Do not insert empty lines here, update check depends on it.
|
# Do not insert empty lines here, update check depends on it.
|
||||||
|
- change: 98_weekprofile: return sorted lists
|
||||||
- change: YAMAHA_AVR: reading/event newFirmware will only be triggered for
|
- change: YAMAHA_AVR: reading/event newFirmware will only be triggered for
|
||||||
RX-Vx71, RX-Vx73, RX-Ax10 or RX-Ax20 as newer models do not
|
RX-Vx71, RX-Vx73, RX-Ax10 or RX-Ax20 as newer models do not
|
||||||
support this information anymore
|
support this information anymore
|
||||||
|
@ -433,6 +433,11 @@ sub weekprofile_Define($$)
|
|||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
##############################################
|
##############################################
|
||||||
|
sub sort_by_name
|
||||||
|
{
|
||||||
|
return lc("$a->{TOPIC}:$a->{NAME}") cmp lc("$b->{TOPIC}:$b->{NAME}");
|
||||||
|
}
|
||||||
|
##############################################
|
||||||
sub weekprofile_Get($$@)
|
sub weekprofile_Get($$@)
|
||||||
{
|
{
|
||||||
my ($hash, $name, $cmd, @params) = @_;
|
my ($hash, $name, $cmd, @params) = @_;
|
||||||
@ -444,7 +449,7 @@ sub weekprofile_Get($$@)
|
|||||||
my $useTopics = AttrVal($name,"useTopics",0);
|
my $useTopics = AttrVal($name,"useTopics",0);
|
||||||
|
|
||||||
$list.= 'profile_data:' if ($prfCnt > 0);
|
$list.= 'profile_data:' if ($prfCnt > 0);
|
||||||
foreach my $prf (@{$hash->{PROFILES}}){
|
foreach my $prf (sort sort_by_name @{$hash->{PROFILES}}){
|
||||||
$list.= $prf->{TOPIC}.":" if ($useTopics);
|
$list.= $prf->{TOPIC}.":" if ($useTopics);
|
||||||
$list.= $prf->{NAME}."," if ($useTopics || (!$useTopics && ($prf->{TOPIC} eq 'default')));
|
$list.= $prf->{NAME}."," if ($useTopics || (!$useTopics && ($prf->{TOPIC} eq 'default')));
|
||||||
}
|
}
|
||||||
@ -477,7 +482,7 @@ sub weekprofile_Get($$@)
|
|||||||
my $topic = 'default';
|
my $topic = 'default';
|
||||||
$topic = $params[0] if(@params == 1);
|
$topic = $params[0] if(@params == 1);
|
||||||
|
|
||||||
foreach my $prf (@{$hash->{PROFILES}}){
|
foreach my $prf (sort sort_by_name @{$hash->{PROFILES}}){
|
||||||
$names .=$prf->{NAME}."," if ($topic eq $prf->{TOPIC});
|
$names .=$prf->{NAME}."," if ($topic eq $prf->{TOPIC});
|
||||||
$names .="$prf->{TOPIC}:$prf->{NAME}," if ($topic eq '*');
|
$names .="$prf->{TOPIC}:$prf->{NAME}," if ($topic eq '*');
|
||||||
}
|
}
|
||||||
@ -495,7 +500,7 @@ sub weekprofile_Get($$@)
|
|||||||
my $topic = 'default';
|
my $topic = 'default';
|
||||||
|
|
||||||
if ($params[0] eq '*') {
|
if ($params[0] eq '*') {
|
||||||
foreach my $prf (@{$hash->{PROFILES}}){
|
foreach my $prf (sort sort_by_name @{$hash->{PROFILES}}){
|
||||||
next if (!defined($prf->{REF}));
|
next if (!defined($prf->{REF}));
|
||||||
$refs .= "$prf->{TOPIC}:$prf->{NAME}>$prf->{REF},";
|
$refs .= "$prf->{TOPIC}:$prf->{NAME}>$prf->{REF},";
|
||||||
}
|
}
|
||||||
@ -514,7 +519,7 @@ sub weekprofile_Get($$@)
|
|||||||
$list.= ' topic_names:noArg' if ($useTopics);
|
$list.= ' topic_names:noArg' if ($useTopics);
|
||||||
if($cmd eq "topic_names") {
|
if($cmd eq "topic_names") {
|
||||||
my $names = '';
|
my $names = '';
|
||||||
foreach my $topic (@{$hash->{TOPICS}}) {
|
foreach my $topic (sort {lc($a) cmp lc($b)} @{$hash->{TOPICS}}) {
|
||||||
$names .= "$topic,";
|
$names .= "$topic,";
|
||||||
}
|
}
|
||||||
if ($names) {
|
if ($names) {
|
||||||
@ -526,7 +531,8 @@ sub weekprofile_Get($$@)
|
|||||||
|
|
||||||
if($cmd eq "sndDevList") {
|
if($cmd eq "sndDevList") {
|
||||||
my $json = JSON->new;
|
my $json = JSON->new;
|
||||||
my $json_text = $json->encode($hash->{SNDDEVLIST});
|
my @sortDevList = sort {lc($a->{ALIAS}) cmp lc($b->{ALIAS})} @{$hash->{SNDDEVLIST}};
|
||||||
|
my $json_text = $json->encode(\@sortDevList);
|
||||||
return $json_text;
|
return $json_text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user