2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 06:39:11 +00:00

Modify added. - removed

git-svn-id: https://svn.fhem.de/fhem/trunk@55 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2007-04-24 07:13:21 +00:00
parent 9a4281059b
commit 6374ae2f9d
8 changed files with 104 additions and 16 deletions

View File

@ -324,4 +324,6 @@
- ==DATE== (4.1)
- doc: linux.html (private udev-rules, not 50-..., ATTRS)
- bugfix: setting devices with "-" in their name did not work
- doc: fhem.pl and commandref.html (notifyon -> notify, correction of examples)
- doc: fhem.pl and commandref.html (notifyon -> notify, correction of examples)
- feature: modify command added
- feature: The "-" in the name is not allowed any more

View File

@ -25,7 +25,14 @@ at_Define($$)
my ($hash, $def) = @_;
my ($name, undef, $tm, $command) = split("[ \t]+", $def, 4);
return "Usage: define <name> at <timespec> <command>" if(!$command);
if(!$command) {
if($hash->{CMD}) {
$command = $hash->{CMD}; # Called from modify
$hash->{DEF} = "$tm $command";
} else {
return "Usage: define <name> at <timespec> <command>";
}
}
return "Wrong timespec, use \"[+][*[{count}]]<time or func>\""
if($tm !~ m/^(\+)?(\*({\d+})?)?(.*)$/);
my ($rel, $rep, $cnt, $tspec) = ($1, $2, $3, $4);

View File

@ -25,6 +25,14 @@ notify_Define($$)
my ($hash, $def) = @_;
my ($type, $name, $re, $command) = split("[ \t]+", $def, 4);
if(!$command) {
if($hash->{CMD}) {
$command = $hash->{CMD}; # Called from modify
$hash->{DEF} = "$re $command";
} else {
return "Usage: define <name> notify <regexp> <command>";
}
}
# Checking for misleading regexps
eval { "Hallo" =~ m/^$re$/ };
return "Bad regexp: $@" if($@);

View File

@ -87,3 +87,10 @@
- Pest, Sun Apr 15 14:54:30 MEST 2007
- doc: fhem.pl and commandref.html (notifyon -> notify, correction of examples)
- Rudi, Tue Apr 24 08:10:43 MEST 2007
- feature: modify command added. It helps change e.g. only the time component
for an at command, without deleting and creating it again and then
reapplying all the attributes.
- feature: the "-" character is disallowed in defined names. Use dot (.) or _
instead. The - is used to separate ranges in the set command.

View File

@ -10,6 +10,32 @@
<h2>fhem.pl command reference</h2>
<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="#delattr">delattr</a><br>
<a href="#delete">delete</a><br>
<a href="#get">get</a><br>
<a href="#include">include</a><br>
<a href="#inform">inform</a><br>
<a href="#list">list</a><br>
<a href="#modify">modify</a><br>
<a href="#quit">quit</a><br>
<a href="#reload">reload</a><br>
<a href="#rereadcfg">rereadcfg</a><br>
<a href="#save">save</a><br>
<a href="#set">set</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="#xmllist">xmllist</a><br>
<a href="#perl">Perl specials</a><br>
<a name="intro"></a>
<h3>Introduction</h3>
You can use all of the following commands in in two ways:
<ul>
<li>In the configuration file, which must be specified if you startup the
@ -957,13 +983,33 @@ split in multiple lines<br><br>
</ul>
<a name="modify"></a>
<h3>modify</h3>
<ul>
<code>modify &lt;name&gt; &lt;type-dependent-options&gt;</code>
<br><br>
Used to modify some definitions. Useful for changing some <a
href="#at">at</a> or <a href="#notify">notify</a> definitions. If specifying
one argument to an at type deinition, only the time part will be changed. In
case of a notify type definition, only the regex part will be changed. All
other values (state, attributes, etc) will remain intact.
<br><br>
Example:
<ul>
<code>define lampon at 19:00 set lamp on</code><br>
<code>modify lampon *19:00</code><br>
<code>modify lampon 19:00 set lamp on-for-timer 16</code><br>
</ul>
</ul>
<a name="quit"></a>
<h3>quit</h3>
<ul>
<code>quit</code>
<br><br>
If used in a TCP/IP session, terminate the client session.<br>
If used in a script, terminate the parsing of the script.
If used in a script, terminate the parsing of the current script.
<br><br>
Example:
<ul>

View File

@ -111,7 +111,7 @@ description and <a href="faq.html">faq.html</a> for the F.A.Q.
See <a href="http://www.koeniglich.de/fhem/linux.html">
http://www.koeniglich.de/fhem/linux.html</a><br>
For kernels older then 2.6.x apply the patch from the doc directory to your
kernel, recompile it kernel and reboot or load/reload the ftdi_sio module.
kernel, recompile it and reboot or load/reload the ftdi_sio module.
</ul>
<h3>Perl modules</h3>
@ -140,7 +140,6 @@ description and <a href="faq.html">faq.html</a> for the F.A.Q.
parameters.</li>
<li>Delete the savefile if you are upgrading from an older version.</li>
<li>Start the server with <code>fhem.pl &lt;configfile&gt;</code></li>
<li>For using the WS300, look into the contrib/ws300 directory.</li>
</ul>
<h3>General Notes for Webfrontends:</h3>

View File

@ -73,6 +73,7 @@ sub CommandHelp($$);
sub CommandInclude($$);
sub CommandInform($$);
sub CommandList($$);
sub CommandModify($$);
sub CommandRereadCfg($$);
sub CommandRename($$);
sub CommandQuit($$);
@ -165,6 +166,8 @@ my %cmds = (
Hlp=>"{on|off},echo all commands and events to this client" },
"list" => { Fn=>"CommandList",
Hlp=>"[device],list definitions and status info" },
"modify" => { Fn=>"CommandModify",
Hlp=>"device <options>,modify the definition (e.g. at, notify)" },
"quit" => { Fn=>"CommandQuit",
Hlp=>",end the client session" },
"reload" => { Fn=>"CommandReload",
@ -884,8 +887,8 @@ CommandDefine($$)
}
return "$a[0] already defined, delete it first" if(defined($defs{$a[0]}));
return "Invalid characters in name (not A-Za-z0-9.:-): $a[0]"
if($a[0] !~ m/^[a-z0-9.:_-]*$/i);
return "Invalid characters in name (not A-Za-z0-9.:_): $a[0]"
if($a[0] !~ m/^[a-z0-9.:_]*$/i);
my %hash;
@ -910,6 +913,27 @@ CommandDefine($$)
return $ret;
}
#####################################
sub
CommandModify($$)
{
my ($cl, $def) = @_;
my @a = split("[ \t]+", $def, 2);
return "Usage: modify <name> <type dependent arguments>"
if(int(@a) < 2);
# Return a list of modules
return "Define $a[0] first" if(!defined($defs{$a[0]}));
my $hash = $defs{$a[0]};
my $odef = $hash->{DEF};
$hash->{DEF} = $a[1];
my $ret = CallFn($a[0], "DefFn", $hash, "$a[0] $hash->{TYPE} $a[1]");
$hash->{DEF} = $odef if($ret);
return $ret;
}
#############
# internal
sub

View File

@ -1,12 +1,13 @@
#Sun Apr 15 13:56:14 2007
#Sun Apr 22 14:04:14 2007
setstate FHZ fhtbuf: 1c
setstate FHZ 2006-02-12 14:03:39 fhtbuf 23
setstate FHZ 2006-03-26 08:47:36 init2 deadbeefdeadbe
setstate FHZ 2006-03-26 08:47:36 serial deadbeef
setstate blink Next: 14:04:17
setstate btn4 on
setstate btn4 2006-04-12 15:19:33 state on
setstate cellar on
setstate cellar 2007-04-15 13:53:21 state on
setstate cellar on-for-timer 2
setstate cellar 2007-04-22 14:04:12 state on-for-timer 2
setstate fl measured-temp: 21.6 (Celsius)
setstate fl 2006-03-29 23:02:30 actuator 00%
setstate fl 2006-03-26 08:50:54 day-temp 21.5 (Celsius)
@ -32,11 +33,7 @@ setstate fl 2006-03-26 08:50:55 unknown_85 4
setstate fl 2006-03-26 08:50:46 wed-from1 06:00
setstate fl 2006-03-26 08:50:46 wed-to1 23:00
setstate fl 2006-03-26 08:50:55 windowopen-temp 12.0 (Celsius)
setstate floor-lamp on
setstate floor-lamp 2006-03-29 12:05:34 state on
setstate global <no definition>
setstate living-light on
setstate living-light 2007-04-15 13:54:48 state on
setstate marqee on
setstate marqee 2006-04-01 12:46:02 state on
setstate n_btn4 active
@ -45,8 +42,6 @@ setstate tf1 2006-04-11 09:48:48 battery Bat: ok
setstate tf1 2006-04-11 09:48:48 humidity 31.3 (%)
setstate tf1 2006-04-11 09:48:48 temperature 20.3 (Celsius)
setstate tf1 2006-04-11 09:48:48 type HMS100TF
setstate window-lamp on
setstate window-lamp 2006-03-29 12:05:34 state on
setstate wz measured-temp: 22.4 (Celsius)
setstate wz 2006-03-29 23:04:17 actuator 00%
setstate wz 2006-03-26 08:52:30 day-temp 22.0 (Celsius)