2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-12 02:39:57 +00:00

01_FHEMWEB.pm: extraRooms from justme1968 (Forum #97351)

git-svn-id: https://svn.fhem.de/fhem/trunk@18627 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2019-02-18 08:14:24 +00:00
parent e8e15bab8e
commit 5c862301b4
3 changed files with 94 additions and 23 deletions

View File

@ -108,6 +108,7 @@ my %FW_icons; # List of icons
my @FW_iconDirs; # Directory search order for icons
my $FW_RETTYPE; # image/png or the like
my %FW_rooms; # hash of all rooms
my %FW_extraRooms; # hash of extra rooms
my @FW_roomsArr; # ordered list of rooms
my %FW_groups; # hash of all groups
my %FW_types; # device types, for sorting
@ -167,6 +168,7 @@ FHEMWEB_Initialize($)
editFileList:textField-long
endPlotNow:1,0
endPlotToday:1,0
extraRooms:textField-long
forbiddenroom
fwcompress:0,1
hiddengroup
@ -1253,6 +1255,19 @@ FW_updateHashes()
$FW_types{$d} = $t;
}
%FW_extraRooms = ();
if(my $extra = AttrVal($FW_wname, "extraRooms", undef)) {
foreach my $room (split(/ |\n/, $extra)) {
next if(!$room || $room =~ /^#/);
$room =~ m/name=([^:]+):devspec=([^\s]+)/;
my $r = $1;
my $d = "#devspec=$2";
$FW_rooms{$r}{$d} = 1;
$FW_extraRooms{$r} = $d;
}
}
$FW_room = AttrVal($FW_detail, "room", "Unsorted") if($FW_detail);
if(AttrVal($FW_wname, "sortRooms", "")) { # Slow!
@ -1605,8 +1620,16 @@ FW_roomOverview($)
next if($r eq "hidden" || $FW_hiddenroom{$r});
$FW_room = AttrVal($FW_wname, "defaultRoom", $r)
if(!$FW_room && $FW_ss);
push @list1, FW_htmlEscape($r);
push @list2, "$FW_ME?room=".urlEncode($r);
if(my $devspec = $FW_extraRooms{$r}) {
my $r = $r;
$r =~ s/ / /g;
push @list1, FW_htmlEscape($r);
push @list2, "$FW_ME?room=".urlEncode($devspec);
} else {
push @list1, FW_htmlEscape($r);
push @list2, "$FW_ME?room=".urlEncode($r);
}
}
my $sfx = AttrVal("global", "language", "EN");
$sfx = ($sfx eq "EN" ? "" : "_$sfx");
@ -1656,6 +1679,9 @@ FW_roomOverview($)
my $tblnr = 1;
my $roomEscaped = FW_htmlEscape($FW_room);
my $current;
$current = "$FW_ME?room=".urlEncode($FW_room) if($FW_room);
$current = "$FW_ME?cmd=".urlEncode($cmd) if($cmd);
foreach(my $idx = 0; $idx < @list1; $idx++) {
my ($l1, $l2) = ($list1[$idx], $list2[$idx]);
if(!$l1) {
@ -1666,7 +1692,7 @@ FW_roomOverview($)
}
} else {
FW_pF "<tr%s>", $l1 eq $roomEscaped ? " class=\"sel\"" : "";
FW_pF "<tr%s>", ($current && $current eq $l2) ? " class=\"sel\"" : "";
my $class = "menu_$l1";
$class =~ s/[^A-Z0-9]/_/gi;
@ -2719,6 +2745,14 @@ FW_Attr(@)
}
}
if($attrName eq "extraRooms") {
foreach my $room (split(/ |\n/, $param[0])) {
next if(!$room || $room =~ /^#/);
return "Bad extraRooms entry $room, not name=<name>:devspec=<devspec>"
if($room !~ m/name=([^:]+):devspec=([^\s]+)/);
}
}
if($attrName eq "longpoll" && $type eq "set" && $param[0] eq "websocket") {
return "$devName: Could not load Digest::SHA on startup, no websocket"
if(!$FW_use{sha});
@ -3702,6 +3736,17 @@ FW_show($$)
</li>
<br>
<a name="extraRooms"></a>
<li>extraRooms<br>
Space or newline separated list of dynamic rooms to add to the room
list.<br>
Example:<br>
attr WEB extraRooms
name=open:devspec=contact=open.*
name=closed:devspec=contact=closed.*
</li>
<br>
<a name="forbiddenroom"></a>
<li>forbiddenroom<br>
just like hiddenroom (see below), but accessing the room or the
@ -4124,15 +4169,6 @@ FW_show($$)
</ul>
</ul>
<a name="cmdshow"></a>
<h3>show</h3>
<ul>
<code>show [devspec]</code><br>
<br><br>
Show a temporary room with devices from &lt;devspec&gt;<br>
Note: this command is only available through the FHEMWEB interface
</ul>
=end html
=begin html_DE
@ -4431,6 +4467,17 @@ FW_show($$)
am aktuellen Tag, sonst wird die aktuelle Woche/Monat angezeigt.
</li><br>
<a name="extraRooms"></a>
<li>extraRooms<br>
Durch Leerzeichen oder Zeilenumbruch getrennte Liste von dynamischen
R&auml;umen, die zus&auml;tzlich angezeigt werden sollen.
Beispiel:<br>
attr WEB extraRooms
name=Offen:devspec=contact=open.*
name=Geschlossen:devspec=contact=closed.*
</li><br>
<a name="forbiddenroom"></a>
<li>forbiddenroom<br>
Wie hiddenroom, aber der Zugriff auf die Raum- oder Detailansicht
@ -4854,16 +4901,6 @@ FW_show($$)
</ul></li>
</ul>
<a name="cmdshow"></a>
<h3>show</h3>
<ul>
<code>show [devspec]</code><br>
<br><br>
Zeigt einen tempor&auml;ren Raum mit dem Inhalt der &lt;devspec&gt;<br>
Achtung: dieser Befehl steht nur &uuml;ber das FHEMWEB Interface zur
Verf&uuml;gung.
</ul>
</ul>
=end html_DE

View File

@ -67,7 +67,8 @@
<a href="#setdefaultattr">setdefaultattr</a> &nbsp; <!-- define a default attribute -->
<a href="#setreading">setreading</a> &nbsp; <!-- set a reading for a FHEM device -->
<a href="#setstate">setstate</a> &nbsp; <!-- set the main state of a FHEM device -->
<a href="#setuuid">setuuid</a> &nbsp; <!-- set the FUUID internal -->
<a href="#setuuid">setuuid</a> &nbsp; <!-- set the FUUID internal -->
<a href="#show">show</a> &nbsp; <!-- show temporary room (FHEMWEN only) -->
<a href="#shutdown">shutdown</a> &nbsp; <!-- shut down (terminate) FHEM -->
<a href="#sleep">sleep</a> &nbsp; <!-- sleep (delay execution) for a while -->
<a href="#trigger">trigger</a> &nbsp; <!-- generate a FHEM event -->
@ -1308,6 +1309,21 @@ The following local attributes are used by a wider range of devices:
</ul>
<!-- setstate end -->
<a name="show"></a>
<h3>show</h3>
<ul>
<code>show &lt;devspec&gt;</code>
<br><br>
show a temporary room with devices from &lt;devspec&gt;. The command ist only
available through FHEMWEB.<br> See the <a href="#devspec">Device
specification</a> section for details on &lt;devspec&gt;.
<br><br>
Example:
<ul>
<code>show TYPE=CUL_HM</code><br>
</ul>
</ul>
<!-- show end -->
<a name="shutdown"></a>
<h3>shutdown</h3>

View File

@ -69,6 +69,7 @@
<a href="#setreading">setreading</a> &nbsp; <!-- setzt ein Reading f&uuml;r ein FHEM Ger&auml;t -->
<a href="#setstate">setstate</a> &nbsp; <!-- setzt den Status eines FHEM Ger&aumles -->
<a href="#setuuid">setuuid</a> &nbsp; <!-- setzt den internen FUUID Wert -->
<a href="#show">show</a> &nbsp; <!-- zeigt tempor&aunl;ren Raum. nur in FHEMWB -->
<a href="#shutdown">shutdown</a> &nbsp; <!-- beendet FHEM -->
<a href="#sleep">sleep</a> &nbsp; <!-- verz&ouml;gerte Ausf&uuml;hrung -->
<a href="#trigger">trigger</a> &nbsp; <!-- generiert ein FHEM Event -->
@ -1391,6 +1392,23 @@ Die folgenden lokalen Attribute werden von mehreren Ger&auml;ten verwendet:
</ul>
<!-- setstate end -->
<a name="show"></a>
<h3>show</h3>
<ul>
<code>show &lt;devspec&gt;</code>
<br><br>
Zeigt einen tempor&auml;ren Raum mit Ger&auml;ten aus &lt;devspec&gt;,
verf&uuml;gbar nur &uuml;ber FHEMWEB.<br> Siehe den Abschnitt &uuml;ber <a
href="#devspec">Ger&auml;te-Spezifikation</a> f&uuml;r Details der
&lt;devspec&gt;.<br>
<br><br>
Example:
<ul>
<code>show TYPE=CUL_HM</code><br>
</ul>
</ul>
<!-- show end -->
<a name="shutdown"></a>
<h3>shutdown</h3>
<ul>