mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 06:39:11 +00:00
98_weekprofile: new command get associations
git-svn-id: https://svn.fhem.de/fhem/trunk@21059 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
d1c7c00389
commit
34017c2a68
@ -1,6 +1,7 @@
|
||||
# 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.
|
||||
- feature: 6.0 released
|
||||
- feature: 98_weekprofile: new command get associations
|
||||
- feature: 6.0 released
|
||||
|
||||
- 2020-01-26 (6.0)
|
||||
- new: MSwitch_Wizard: preparation for Mswitch V3.0
|
||||
|
@ -815,6 +815,50 @@ sub weekprofile_Get($$@)
|
||||
return $names;
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
$list .= ' associations:0,1' if ($useTopics);
|
||||
if($cmd eq "associations") {
|
||||
my $retType = 1;
|
||||
$retType = $params[0] if(@params >= 1);
|
||||
my @not_asso = ();
|
||||
my @json_arr = ();
|
||||
my $retHTML = "<table><thead><tr>";
|
||||
$retHTML .= "<th width='150'><b>Device</b></th><th width='150'><b>Profile</b></th></tr>";
|
||||
$retHTML .= "<th> </th><th></th></tr>";
|
||||
$retHTML .= "</thead><tbody>";
|
||||
foreach my $dev (@{$hash->{SNDDEVLIST}}) {
|
||||
my $entry = {};
|
||||
$entry->{DEVICE}->{NAME} = $dev->{NAME};
|
||||
$entry->{PROFILE}->{NAME} = "";
|
||||
my $prfName = AttrVal($dev->{NAME},"weekprofile",undef);
|
||||
if (!defined($prfName)) {
|
||||
push @not_asso, $dev->{NAME};
|
||||
push @json_arr , $entry;
|
||||
next;
|
||||
}
|
||||
my ($prf,$idx) = weekprofile_findPRF($hash, $prfName, undef, 0);
|
||||
my $color = defined($prf) ? "" : "color:red" ;
|
||||
|
||||
$entry->{PROFILE}->{NAME} = $prfName;
|
||||
$entry->{PROFILE}->{EXISTS} = defined($prf) + 0;
|
||||
push @json_arr , $entry;
|
||||
$retHTML .= "<tr><td style='text-align:left'>$dev->{NAME}</td><td style='text-align:center;$color'>$prfName</td></tr>";
|
||||
}
|
||||
$retHTML .= "<tr><td colspan='2'><i>Not associated devices</i></td></tr>" if (scalar(@not_asso));
|
||||
foreach my $devname (@not_asso) {
|
||||
$retHTML .= "<tr><td style='text-align:left'>$devname</td><td style='text-align:center'></td></tr>";
|
||||
}
|
||||
$retHTML.= "</tbody></table>";
|
||||
my $ret = $retHTML;
|
||||
if ($retType == 1) {
|
||||
my $json_text = undef;
|
||||
my $json = JSON->new->allow_nonref;
|
||||
eval { $json_text = $json->encode(\@json_arr) };
|
||||
$ret = $json_text;
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
if($cmd eq "sndDevList") {
|
||||
my $json = JSON->new->allow_nonref;
|
||||
my @sortDevList = sort {lc($a->{ALIAS}) cmp lc($b->{ALIAS})} @{$hash->{SNDDEVLIST}};
|
||||
@ -842,9 +886,11 @@ sub weekprofile_findPRF($$$$)
|
||||
|
||||
my $found = undef;
|
||||
my $idx = 0;
|
||||
my $topicOk = 0;
|
||||
|
||||
foreach my $prf (@{$hash->{PROFILES}}){
|
||||
if ( ($prf->{NAME} eq $name) && ($prf->{TOPIC} eq $topic) ){
|
||||
$topicOk = defined($topic) ? ($prf->{TOPIC} eq $topic) : 1;
|
||||
if ( ($prf->{NAME} eq $name) && $topicOk ){
|
||||
$found = $prf;
|
||||
last;
|
||||
}
|
||||
@ -1587,6 +1633,11 @@ sub weekprofile_getEditLNK_MasterDev($$)
|
||||
<li>topic_names<br>
|
||||
Return a comma seperated list of topic names.
|
||||
</li>
|
||||
<li>associations [ReturnType (0|1)]<br>
|
||||
Returns a list of supported devices with the associated profile.<br>
|
||||
ReturnType 0: HTML table</br>
|
||||
ReturnType 1: json list</br>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<a name="weekprofilereadings"></a>
|
||||
@ -1759,6 +1810,11 @@ sub weekprofile_getEditLNK_MasterDev($$)
|
||||
</code>
|
||||
Ist name 'topicname:profilename' wird '0' der Name der Referenz zurück gegeben.
|
||||
</li>
|
||||
<li>associations [Rückgabetyp (0|1)]<br>
|
||||
Gibt eine Liste der unterstützten Geräte mit dem verbundenen\zugeordnetem Profilnamen zurück.<br>
|
||||
Rückgabetyp 0: HTML Tabelle</br>
|
||||
Rückgabetyp 1: json Liste</br>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<a name="weekprofilereadings"></a>
|
||||
|
Loading…
Reference in New Issue
Block a user