added group attribute for use in FHEMWEB

git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@1491 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
borisneubert 2012-04-27 14:07:27 +00:00
parent 92690db8e6
commit d73df1f11e
3 changed files with 81 additions and 11 deletions

View File

@ -25,6 +25,7 @@
- feature: new module 02_RSS.pm - feature: new module 02_RSS.pm
- feature: at attribute alignTime added - feature: at attribute alignTime added
- feature: FHEMWEB attribute values via dropdown, slider for dimmer - feature: FHEMWEB attribute values via dropdown, slider for dimmer
- feature: new attribute group for FHEMWEB (Boris)
- 2011-12-31 (5.2) - 2011-12-31 (5.2)
- bugfix: applying smallscreen attributes to firefox/opera - bugfix: applying smallscreen attributes to firefox/opera

View File

@ -368,18 +368,57 @@ A line ending with \ will be concatenated with the next one, so long lines
<li>room<br> <li>room<br>
Filter/group devices. Recognized by web-pgm2 and web-pgm3. A device Filter/group devices. Recognized by web-pgm2 and web-pgm3. A device
can appear in more than one room, in this case the rooms have to be can appear in more than one room, in this case the rooms have to be
specified komma separated.<br> specified comma-separated.<br>
Devices in the room hidden will not appear in the web output, or set Devices in the room hidden will not appear in the web output, or set
the <a href="#hiddenroom"> FHEMWEB attribute to selectively disable the <a href="#hiddenroom"> FHEMWEB attribute to selectively disable
rooms for certain FHEMWEB instances. rooms for certain FHEMWEB instances.
</li> </li>
<a name="group"></a>
<li>group<br>
Group devices. Recognized by web-pgm2 (module <a href="#FHEMWEB">FHEMWEB</a>, it makes
devices in the same group appear in the same box).
This is used to further group
devices together. A device can appear in more than one group, in this
case the groups have to be specified comma-separated.<br>
If this attribute is not set then the device type is used as the
grouping attribute.
</li>
<a name="showtime"></a> <a name="showtime"></a>
<li>showtime<br> <li>showtime<br>
Used in the webfrontend pgm2 to show the time of last activity Used in the webfrontend pgm2 to show the time of last activity
instead of the state in the summary view. Useful e.g. for FS20 PIRI instead of the state in the summary view. Useful e.g. for FS20 PIRI
devices. devices.
</li> </li>
<br><br>The following attributes are accepted but not yet honored by all modules. Only modules
that make use of the standardized readings updating mechanism in fhem.pl react on it.
<br><br>
<a name="event-on-update-reading"></a>
<li>event-on-update-reading<br>
If not set, every update of any reading creates an event, which e.g. is handled
by <a href="#notify">notify</a> or <a href="#FileLog">FileLog</a>. The attribute takes
a comma-separated list of readings. If set, only updates of the listed readings create
events.
</li>
<a name="event-on-change-reading"></a>
<li>event-on-change-reading<br>
The attribute takes a comma-separated list of readings. If set, only changes of the listed readings create events. In other words, if a reading listed here is updated with the new value
identical to the old value, no event is created.
</li><br>
The precedence of event-on-update-reading and event-on-change-reading is as follows:
<ol>
<li>If both attributes are not set, any update of any reading of the device creates an event.</li>
<li>If any of the attributes is set, no events occur for updates or changes of readings
not listed in any of the attributes.</li>
<li>If a reading is listed in event-on-update-reading, an update of the reading creates an
event no matter whether the reading is also listed in event-on-change-reading.</li>
</ol>
</ul> </ul>
<br> <br>
@ -390,7 +429,10 @@ A line ending with \ will be concatenated with the next one, so long lines
<ul> <ul>
<code>attr global verbose 3</code><br> <code>attr global verbose 3</code><br>
<code>attr lamp room kitchen</code><br> <code>attr lamp room kitchen</code><br>
<code>attr lamp group lights</code><br>
<code>attr lamp loglevel 6</code><br> <code>attr lamp loglevel 6</code><br>
<code>attr weatherstation event-on-update-reading wind,temperature,humidity</code><br>
<code>attr weatherstation event-on-change-reading israining</code><br>
</ul> </ul>
<br> <br>
@ -7972,6 +8014,8 @@ KlikAanKlikUit, NEXA, CHACON, HomeEasy UK. <br> You need to define an RFXtrx433
<br> <br>
</ul> </ul>
See also <a href="#room">room</a> and <a href="#group">group</a> attributes.
</ul> </ul>

View File

@ -904,25 +904,49 @@ FW_showRoom()
FW_pO "<div id=\"content\">"; FW_pO "<div id=\"content\">";
FW_pO "<table>"; # Need for equal width of subtables FW_pO "<table>"; # Need for equal width of subtables
my $rf = ($FW_room ? "&amp;room=$FW_room" : ""); # stay in the room my $rf = ($FW_room ? "&amp;room=$FW_room" : ""); # stay in the room
my $row=1;
foreach my $type (sort keys %FW_types) { # array of all device names in the room except weblinkes
my @devs= grep { ($FW_rooms{$FW_room}{$_}||$FW_room eq "all") &&
!IsIgnored($_) } keys %defs;
# hash devicename => groups, the name of the default group is the name of the device type
my %group;
my @groups;
my %seen = ();
foreach my $dev (@devs) {
# ignore weblinks
next if($defs{$dev}{TYPE} eq "weblink");
# please note that a device can be in more than one group: attr <name> group <group1>,<group2>,<group3>
# we determine it here once including its default value; in the future the default might become
# configurable
$group{$dev}= AttrVal($dev,"group",$defs{$dev}{TYPE});
push @groups, grep { !$seen{$_}++ } split(",",$group{$dev}); # unique addition
}
next if(!$type || $type eq "weblink"); # row counter
my $row=1;
# iterate over the distinct groups
foreach my $g (sort @groups) {
################# #################
# Check if there is a device of this type in the room # Check if there is a device of this type in the room
$FW_room = "" if(!defined($FW_room));
my @devs = grep { ($FW_rooms{$FW_room}{$_}||$FW_room eq "all") &&
!IsIgnored($_) } keys %{$FW_types{$type}};
next if(!@devs);
FW_pO "\n<tr><td><div class=\"devType\">$type</div></td></tr>"; FW_pO "\n<tr><td><div class=\"devType\">$g</div></td></tr>";
FW_pO "<tr><td>"; FW_pO "<tr><td>";
FW_pO "<table class=\"block wide\" id=\"$type\">"; FW_pO "<table class=\"block wide\" id=\"$g\">";
foreach my $d (sort @devs) { foreach my $d (sort @devs) {
next unless(grep {$_ =~ $g} $group{$d});
# if(defined($devs{$d}{fhem}{interface})) {
# display the device according to the interface library items
# } else {
# display the device according to its device type (as below)
# }
my $type = $defs{$d}{TYPE}; my $type = $defs{$d}{TYPE};
pF "\n<tr class=\"%s\">", ($row&1)?"odd":"even"; pF "\n<tr class=\"%s\">", ($row&1)?"odd":"even";
@ -978,6 +1002,7 @@ FW_showRoom()
# Now the weblinks # Now the weblinks
my $buttons = 1; my $buttons = 1;
$FW_room = "" if(!defined($FW_room));
my @list = ($FW_room eq "all" ? keys %defs : keys %{$FW_rooms{$FW_room}}); my @list = ($FW_room eq "all" ? keys %defs : keys %{$FW_rooms{$FW_room}});
foreach my $d (sort @list) { foreach my $d (sort @list) {
next if(IsIgnored($d)); next if(IsIgnored($d));