From d73df1f11ee223fc2fc3ba76f6e53e7f13066ef9 Mon Sep 17 00:00:00 2001
From: borisneubert <>
Date: Fri, 27 Apr 2012 14:07:27 +0000
Subject: [PATCH] added group attribute for use in FHEMWEB
git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@1491 2b470e98-0d58-463d-a4d8-8e2adae1ed80
---
CHANGED | 1 +
docs/commandref.html | 46 +++++++++++++++++++++++++++++++++-
webfrontend/pgm2/01_FHEMWEB.pm | 45 +++++++++++++++++++++++++--------
3 files changed, 81 insertions(+), 11 deletions(-)
diff --git a/CHANGED b/CHANGED
index 91a43e3fa..370a3a5cf 100644
--- a/CHANGED
+++ b/CHANGED
@@ -25,6 +25,7 @@
- feature: new module 02_RSS.pm
- feature: at attribute alignTime added
- feature: FHEMWEB attribute values via dropdown, slider for dimmer
+ - feature: new attribute group for FHEMWEB (Boris)
- 2011-12-31 (5.2)
- bugfix: applying smallscreen attributes to firefox/opera
diff --git a/docs/commandref.html b/docs/commandref.html
index 10fab337c..9e914fd3c 100644
--- a/docs/commandref.html
+++ b/docs/commandref.html
@@ -368,18 +368,57 @@ A line ending with \ will be concatenated with the next one, so long lines
room
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
- specified komma separated.
+ specified comma-separated.
Devices in the room hidden will not appear in the web output, or set
the FHEMWEB attribute to selectively disable
rooms for certain FHEMWEB instances.
+
+ group
+ Group devices. Recognized by web-pgm2 (module FHEMWEB, 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.
+ If this attribute is not set then the device type is used as the
+ grouping attribute.
+
+
showtime
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
devices.
+
+
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.
+
+
+
+ event-on-update-reading
+ If not set, every update of any reading creates an event, which e.g. is handled
+ by notify or FileLog. The attribute takes
+ a comma-separated list of readings. If set, only updates of the listed readings create
+ events.
+
+
+
+ event-on-change-reading
+ 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.
+
+
+ The precedence of event-on-update-reading and event-on-change-reading is as follows:
+
+ - If both attributes are not set, any update of any reading of the device creates an event.
+ - If any of the attributes is set, no events occur for updates or changes of readings
+ not listed in any of the attributes.
+ - 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.
+
+
@@ -390,7 +429,10 @@ A line ending with \ will be concatenated with the next one, so long lines
attr global verbose 3
attr lamp room kitchen
+ attr lamp group lights
attr lamp loglevel 6
+ attr weatherstation event-on-update-reading wind,temperature,humidity
+ attr weatherstation event-on-change-reading israining
@@ -7972,6 +8014,8 @@ KlikAanKlikUit, NEXA, CHACON, HomeEasy UK.
You need to define an RFXtrx433
+
+ See also room and group attributes.
diff --git a/webfrontend/pgm2/01_FHEMWEB.pm b/webfrontend/pgm2/01_FHEMWEB.pm
index 099b8d104..a412b8d9f 100755
--- a/webfrontend/pgm2/01_FHEMWEB.pm
+++ b/webfrontend/pgm2/01_FHEMWEB.pm
@@ -904,25 +904,49 @@ FW_showRoom()
FW_pO "";
FW_pO "
"; # Need for equal width of subtables
-
my $rf = ($FW_room ? "&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 group ,,
+ # 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
- $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$type |
";
+ FW_pO "\n$g |
";
FW_pO "";
- FW_pO "";
+ FW_pO "";
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};
pF "\n", ($row&1)?"odd":"even";
@@ -978,6 +1002,7 @@ FW_showRoom()
# Now the weblinks
my $buttons = 1;
+ $FW_room = "" if(!defined($FW_room));
my @list = ($FW_room eq "all" ? keys %defs : keys %{$FW_rooms{$FW_room}});
foreach my $d (sort @list) {
next if(IsIgnored($d));
|