mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 18:59:33 +00:00
98_HTTPMOD: change userattr handling and fix doku
git-svn-id: https://svn.fhem.de/fhem/trunk@24185 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
03fe1c8974
commit
774bea905d
@ -660,7 +660,7 @@ sub UpgradeAttributes {
|
||||
if ($aName =~ /(.+)IDRegex$/) {
|
||||
my $new = $1 . "IdRegex";
|
||||
my $val = $attr{$name}{$aName};
|
||||
CommandAttr(undef, "$name $new $val"); # also adds new attr to userattr list through _Attr function
|
||||
CommandAttr(undef, "$name $new $val");
|
||||
CommandDeleteAttr(undef, "$name $aName");
|
||||
$dHash{$aName} = 1;
|
||||
Log3 $name, 3, "$name: upgraded attribute name $aName to new sytax $new";
|
||||
@ -3645,7 +3645,10 @@ sub AddToSendQueue {
|
||||
restricts the effect of errorLogLevel to such error messages that match this regex.
|
||||
|
||||
<li><b>Remarks regarding the automatically created userattr entries</b></li>
|
||||
Fhemweb allows attributes to be edited by clicking on them. However this does not work for attributes that match to a wildcard attribute. To circumvent this restriction HTTPMOD automatically adds an entry for each instance of a defined wildcard attribute to the device userattr list. E.g. if you define a reading[0-9]Name attribute as reading01Name, HTTPMOD will add reading01Name to the device userattr list. These entries only have the purpose of making editing in Fhemweb easier.
|
||||
Fhemweb allows attributes to be edited by clicking on them. However this did not work for attributes that match to a wildcard attribute in earlier versions.
|
||||
To circumvent this restriction HTTPMOD automatically added an entry for each instance of a defined wildcard attribute to the device userattr list.
|
||||
E.g. if you define a reading[0-9]Name attribute as reading01Name, HTTPMOD added reading01Name to the device userattr list.
|
||||
These entries only had the purpose of making editing in Fhemweb easier. In newer versions this has become obsolete.
|
||||
</ul>
|
||||
<br>
|
||||
<b>Author's notes</b><br><br>
|
||||
|
@ -474,8 +474,13 @@ sub SwapByteOrder {
|
||||
}
|
||||
|
||||
|
||||
#########################################################################
|
||||
############################################################################
|
||||
# set userAttr-Attribute for Regex-Attrs
|
||||
# with recent version of fhem userattrs are no longer needed
|
||||
# to edit them or match hints.
|
||||
# so remove all userattr entries for regex attrs
|
||||
# unless their hint is different from the one in the modules list
|
||||
#
|
||||
# pass device hash and new attr based on a regex attr
|
||||
sub ManageUserAttr {
|
||||
my $hash = shift;
|
||||
@ -509,13 +514,13 @@ sub ManageUserAttr {
|
||||
UALOOP:
|
||||
foreach my $userAttr (split(" ", $uaList)) { # for every userAttr
|
||||
my ($userAttrName, $userAttrHint)
|
||||
= $userAttr =~ m{ \A ([^:]+) (:?.*) }xms; # split module attr list entry in name and optional hint
|
||||
= $userAttr =~ m{ \A ([^:]+) (:?.*) }xms; # split user attr list entry in name and optional hint
|
||||
#Log3 $name, 5, "$name: ManageUserAttr compares userattr name $userAttrName with passed attr name $aName";
|
||||
if ($userAttrName eq $aName) {
|
||||
#Log3 $name, 5, "$name: ManageUserAttr compares hints from userattr $userAttrHint with hint from list $listAttrHint";
|
||||
$found = 1;
|
||||
if ($userAttrHint && $userAttrHint ne ($listAttrHint // '')) {
|
||||
$uaHash{$userAttr} = 1; # keep $userAttr with hint if module attr has no hint
|
||||
$uaHash{$userAttr} = 1; # keep $userAttr with hint if module attr has different or no hint
|
||||
#Log3 $name, 5, "$name: ManageUserAttr keeps userattr $userAttr with different hint";
|
||||
}
|
||||
} else {
|
||||
@ -523,10 +528,11 @@ sub ManageUserAttr {
|
||||
#Log3 $name, 5, "$name: ManageUserAttr keeps other existing userattr $userAttr";
|
||||
}
|
||||
}
|
||||
if (!$found && $listAttrHint) { # add userAttr with attr from module list
|
||||
$uaHash{$aName . $listAttrHint} = 1;
|
||||
#Log3 $name, 5, "$name: ManageUserAttr adds $aName$listAttrHint";
|
||||
}
|
||||
# this code is no longer necessary - fhem recognizes hints from regex attrs by itself now
|
||||
#if (!$found && $listAttrHint) { # add userAttr with attr from module list
|
||||
# $uaHash{$aName . $listAttrHint} = 1;
|
||||
# #Log3 $name, 5, "$name: ManageUserAttr adds $aName$listAttrHint";
|
||||
#}
|
||||
my $aString = join(" ", sort keys %uaHash); # reconstruct userAttr list string
|
||||
if ($aString) {
|
||||
$attr{$name}{userattr} = $aString;
|
||||
|
Loading…
Reference in New Issue
Block a user