From 31dc910625de4be4513268bcbe21bfc9eb9eb8bd Mon Sep 17 00:00:00 2001
From: rudolfkoenig <>
Date: Mon, 29 Sep 2014 19:52:15 +0000
Subject: [PATCH] fhem.pl: Add userattr for signle devices.
git-svn-id: https://svn.fhem.de/fhem/trunk@6632 2b470e98-0d58-463d-a4d8-8e2adae1ed80
---
fhem/CHANGED | 1 +
fhem/docs/commandref_frame.html | 6 ++++--
fhem/docs/commandref_frame_DE.html | 9 ++++++---
fhem/fhem.pl | 12 ++++++++++--
4 files changed, 21 insertions(+), 7 deletions(-)
diff --git a/fhem/CHANGED b/fhem/CHANGED
index 7bf6d350a..1f77b321a 100644
--- a/fhem/CHANGED
+++ b/fhem/CHANGED
@@ -1,5 +1,6 @@
# 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: userattr is now also device attribute
- feature: ZWave: Fibaro_FGRM222 MANUFACTURER_PROPRIETARY class
- feature: sequence: reportEvents attribtue added
- feature: SYSMON: RAM and SWAP Readings on OSX
diff --git a/fhem/docs/commandref_frame.html b/fhem/docs/commandref_frame.html
index 846c90958..41e01329a 100644
--- a/fhem/docs/commandref_frame.html
+++ b/fhem/docs/commandref_frame.html
@@ -1255,8 +1255,10 @@ A line ending with \ will be concatenated with the next one, so long lines
userattr
A space separated list which contains the names of additional
- attributes. Without specifying them you will not be able to set them
- (in order to prevent typos).
+ attributes for all devices. Without specifying them you will not be
+ able to set them (in order to prevent typos).
+ userattr can also specified for other devices, in this case
+ these additinal attribute names are only valid for this device.
diff --git a/fhem/docs/commandref_frame_DE.html b/fhem/docs/commandref_frame_DE.html
index d03a055ad..893f9cfad 100644
--- a/fhem/docs/commandref_frame_DE.html
+++ b/fhem/docs/commandref_frame_DE.html
@@ -1346,9 +1346,12 @@ Zeilen erstreckende Befehle, indem man keine \ am Zeilenende eingeben muss.
userattr
- Enthält eine durch Leerzeichen getrennte Liste in welcher die Namen
- zusätzlicher Attribute aufgeführt sind. Diese müssen zuerst in dieser Liste
- definiert werden, bevor sie angewendet werden können.
+ Enthält eine durch Leerzeichen getrennte Liste in welcher die
+ Namen zusätzlicher Attribute aufgeführt sind. Diese
+ müssen zuerst in dieser Liste definiert werden, bevor sie
+ (bei allen Geräten) angewendet werden können.
+ userattr kann auch für einzelne Geräte spezifiziert werden,
+ um weitere Attribute für diese Geräte zu definieren.
diff --git a/fhem/fhem.pl b/fhem/fhem.pl
index 3f1520569..4a1cb693a 100755
--- a/fhem/fhem.pl
+++ b/fhem/fhem.pl
@@ -240,7 +240,7 @@ $modules{Global}{ORDER} = -1;
$modules{Global}{LOADED} = 1;
$modules{Global}{AttrList} =
"archivecmd apiversion archivedir configfile lastinclude logfile " .
- "modpath nrarchive pidfilename port statefile title userattr " .
+ "modpath nrarchive pidfilename port statefile title " .
"mseclog:1,0 version nofork:1,0 logdir holiday2we " .
"autoload_undefined_devices:1,0 dupTimeout latitude longitude altitude " .
"backupcmd backupdir backupsymlink backup_before_update " .
@@ -1361,7 +1361,12 @@ CommandSave($$)
print $fh "define $d $defs{$d}{TYPE}\n";
}
}
- foreach my $a (sort keys %{$attr{$d}}) {
+
+ foreach my $a (sort {
+ return -1 if($a eq "userattr"); # userattr must be first
+ return 1 if($b eq "userattr");
+ return $a cmp $b;
+ } keys %{$attr{$d}}) {
next if($d eq "global" &&
($a eq "configfile" || $a eq "version"));
my $val = $attr{$d}{$a};
@@ -2062,6 +2067,9 @@ getAllAttr($)
if($modules{$defs{$d}{TYPE}}{AttrList});
$list .= " " . $attr{global}{userattr}
if($attr{global}{userattr});
+ $list .= " " . $attr{$d}{userattr}
+ if($attr{$d} && $attr{$d}{userattr});
+ $list .= " userattr";
return $list;
}