mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 06:39:11 +00:00
defattr changed to setdefaultattr
git-svn-id: https://svn.fhem.de/fhem/trunk@138 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
443495f1d1
commit
fbc464d55f
@ -370,6 +370,7 @@
|
||||
- doc: linux.html: Introduction (Peter S.)
|
||||
- feature: contrib/82_M232Voltage.pm (by Boris, 24.12)
|
||||
- feature: delattr renamed to deleteattr (Rudi, 29.12)
|
||||
- feature: defattr renamed to setdefaultattr (Rudi, 29.12)
|
||||
- feature: device spec (list/range/regexp) for most commands implemented
|
||||
- feature: %NAME, %EVENT, %TYPE parameters in notify definition
|
||||
|
||||
|
@ -165,7 +165,9 @@
|
||||
- linux.html: Introduction refinement.
|
||||
|
||||
- Rudi Sat Dec 29 16:27:14 MET 2007
|
||||
- delattr renamed to deleteattr
|
||||
- delattr renamed to deleteattr, as del should complete to delete and not to
|
||||
delattr
|
||||
- defattr renamed to setdefaultattr (same as before for def)
|
||||
- devicespec introduced:
|
||||
it may contain a list of devices, a range of devices, or multiple devices
|
||||
identified by regexp. Following commands take a devicespec as argument:
|
||||
|
@ -13,10 +13,9 @@
|
||||
<a href="#intro">Introduction</a><br>
|
||||
<a href="#help">?,help</a><br>
|
||||
<a href="#attr">attr</a><br>
|
||||
<a href="#defattr">defattr</a><br>
|
||||
<a href="#define">define</a><br>
|
||||
<a href="#deleteattr">deleteattr</a><br>
|
||||
<a href="#delete">delete</a><br>
|
||||
<a href="#deleteattr">deleteattr</a><br>
|
||||
<a href="#get">get</a><br>
|
||||
<a href="#include">include</a><br>
|
||||
<a href="#inform">inform</a><br>
|
||||
@ -27,11 +26,13 @@
|
||||
<a href="#rereadcfg">rereadcfg</a><br>
|
||||
<a href="#save">save</a><br>
|
||||
<a href="#set">set</a><br>
|
||||
<a href="#setdefaultattr">setdefaultattr</a><br>
|
||||
<a href="#setstate">setstate</a><br>
|
||||
<a href="#shutdown">shutdown</a><br>
|
||||
<a href="#trigger">trigger</a><br>
|
||||
<a href="#sleep">sleep</a><br>
|
||||
<a href="#trigger">trigger</a><br>
|
||||
<a href="#xmllist">xmllist</a><br>
|
||||
|
||||
<a href="#devspec">Device specification</a><br>
|
||||
<a href="#perl">Perl specials</a><br>
|
||||
|
||||
@ -477,10 +478,10 @@ split in multiple lines<br><br>
|
||||
</ul>
|
||||
</ul>
|
||||
|
||||
<a name="defattr"></a>
|
||||
<h3>defattr</h3>
|
||||
<a name="setdefaultattr"></a>
|
||||
<h3>setdefaultattr</h3>
|
||||
<ul>
|
||||
<code>defattr [<attrname> [<value>]] </code><br>
|
||||
<code>setdefaultattr [<attrname> [<value>]] </code><br>
|
||||
|
||||
<br>Set the default attribute. Each device defined from now on will receive
|
||||
this attribute (see the <a href="#attr">attr</a> entry for details on
|
||||
@ -491,12 +492,12 @@ split in multiple lines<br><br>
|
||||
Example to set the attribute "room kitchen" and "loglevel 4" to
|
||||
each of the lamps:
|
||||
<ul>
|
||||
<code>defattr room kitchen</code><br>
|
||||
<code>defattr loglevel 4</code><br>
|
||||
<code>setdefaultattr room kitchen</code><br>
|
||||
<code>setdefaultattr loglevel 4</code><br>
|
||||
<code>define lamp1 FS20 1234 11</code><br>
|
||||
<code>define lamp2 FS20 1234 12</code><br>
|
||||
<code>define lamp3 FS20 1234 13</code><br>
|
||||
<code>defattr</code><br>
|
||||
<code>setdefaultattr</code><br>
|
||||
</ul>
|
||||
<br>
|
||||
|
||||
|
28
fhem/fhem.pl
28
fhem/fhem.pl
@ -67,7 +67,7 @@ sub PrintHash($$);
|
||||
sub devspec2array($);
|
||||
|
||||
sub CommandAttr($$);
|
||||
sub CommandDefAttr($$);
|
||||
sub CommandDefaultAttr($$);
|
||||
sub CommandDefine($$);
|
||||
sub CommandDeleteAttr($$);
|
||||
sub CommandDelete($$);
|
||||
@ -133,12 +133,12 @@ my $sig_term = 0; # if set to 1, terminate (saving the state)
|
||||
my $modpath_set; # Check if modpath was used, and report if not.
|
||||
my $global_cl; # To use from perl snippets
|
||||
my $devcount = 0; # To sort the devices
|
||||
my %defattr; # Default attributes
|
||||
my %defaultattr; # Default attributes
|
||||
my %intAt; # Internal at timer hash.
|
||||
my $intAtCnt=0;
|
||||
my $reread_active = 0;
|
||||
my $AttrList = "room comment";
|
||||
my $cvsid = '$Id: fhem.pl,v 1.33 2007-12-29 15:57:42 rudolfkoenig Exp $';
|
||||
my $cvsid = '$Id: fhem.pl,v 1.34 2007-12-29 16:25:02 rudolfkoenig Exp $';
|
||||
|
||||
$init_done = 0;
|
||||
|
||||
@ -154,8 +154,6 @@ my %cmds = (
|
||||
Hlp=>",get this help" },
|
||||
"attr" => { Fn=>"CommandAttr",
|
||||
Hlp=>"<devspec> <attrname> [<attrval>],set attribute for <devspec>" },
|
||||
"defattr" => { Fn=>"CommandDefAttr",
|
||||
Hlp=>"<attrname> <attrvalue>,set attr for following definitions" },
|
||||
"define" => { Fn=>"CommandDefine",
|
||||
Hlp=>"<name> <type> <options>,define a device/at/notify entity" },
|
||||
"deleteattr" => { Fn=>"CommandDeleteAttr",
|
||||
@ -188,6 +186,8 @@ my %cmds = (
|
||||
Hlp=>"<devspec> <type dependent>,transmit code for <devspec>" },
|
||||
"setstate"=> { Fn=>"CommandSetstate",
|
||||
Hlp=>"<devspec> <state>,set the state shown in the command list" },
|
||||
"setdefaultattr" => { Fn=>"CommandDefaultAttr",
|
||||
Hlp=>"<attrname> <attrvalue>,set attr for following definitions" },
|
||||
"shutdown"=> { Fn=>"CommandShutdown",
|
||||
Hlp=>",terminate the server" },
|
||||
"sleep" => { Fn=>"CommandSleep",
|
||||
@ -498,6 +498,8 @@ AnalyzeCommand($$)
|
||||
my ($fn, $param) = split("[ \t][ \t]*", $cmd, 2);
|
||||
return if(!$fn);
|
||||
|
||||
$fn = "setdefaultattr" if($fn eq "defattr"); # Compatibility mode
|
||||
|
||||
#############
|
||||
# Search for abbreviation
|
||||
if(!defined($cmds{$fn})) {
|
||||
@ -777,7 +779,7 @@ CommandSave($$)
|
||||
}
|
||||
|
||||
foreach my $r (sort keys %rooms) {
|
||||
print SFH "\ndefattr" . ($r ne "~" ? " room $r" : "") . "\n";
|
||||
print SFH "\nsetdefaultattr" . ($r ne "~" ? " room $r" : "") . "\n";
|
||||
foreach my $d (sort keys %{$rooms{$r}} ) {
|
||||
next if($defs{$d}{VOLATILE});
|
||||
if($defs{$d}{DEF}) {
|
||||
@ -794,7 +796,7 @@ CommandSave($$)
|
||||
}
|
||||
}
|
||||
|
||||
print SFH "defattr\n"; # Delete the last default attribute.
|
||||
print SFH "setdefaultattr\n"; # Delete the last default attribute.
|
||||
|
||||
print SFH "include $attr{global}{lastinclude}\n"
|
||||
if($attr{global}{lastinclude});
|
||||
@ -957,8 +959,8 @@ CommandDefine($$)
|
||||
if($ret) {
|
||||
delete $defs{$a[0]}
|
||||
} else {
|
||||
foreach my $da (sort keys (%defattr)) { # Default attributes
|
||||
CommandAttr($cl, "$a[0] $da $defattr{$da}");
|
||||
foreach my $da (sort keys (%defaultattr)) { # Default attributes
|
||||
CommandAttr($cl, "$a[0] $da $defaultattr{$da}");
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
@ -1423,17 +1425,17 @@ CommandAttr($$)
|
||||
#####################################
|
||||
# Default Attr
|
||||
sub
|
||||
CommandDefAttr($$)
|
||||
CommandDefaultAttr($$)
|
||||
{
|
||||
my ($cl, $param) = @_;
|
||||
|
||||
my @a = split(" ", $param, 2);
|
||||
if(int(@a) == 0) {
|
||||
%defattr = ();
|
||||
%defaultattr = ();
|
||||
} elsif(int(@a) == 1) {
|
||||
$defattr{$a[0]} = 1;
|
||||
$defaultattr{$a[0]} = 1;
|
||||
} else {
|
||||
$defattr{$a[0]} = $a[1];
|
||||
$defaultattr{$a[0]} = $a[1];
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ attr global verbose 3
|
||||
|
||||
define FHZ FHZ none
|
||||
|
||||
defattr
|
||||
define btn4 FS20 1234 03
|
||||
define cellar FS20 1234 13
|
||||
define fl FHT 1236
|
||||
@ -19,4 +18,3 @@ define tf1 HMS 1237
|
||||
define window.lamp FS20 1234 02
|
||||
define wz FHT 1235
|
||||
define x SCIVT none
|
||||
defattr
|
||||
|
Loading…
Reference in New Issue
Block a user