mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-06 12:18:46 +00:00
Autocreate modifications
git-svn-id: https://svn.fhem.de/fhem/trunk@521 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
f839a723f2
commit
25747ccd51
@ -80,7 +80,7 @@ FileLog_Log($$)
|
||||
if($n =~ m/^$re$/ || "$n:$s" =~ m/^$re$/) {
|
||||
my $t = TimeNow();
|
||||
$t = $dev->{CHANGETIME}[$i] if(defined($dev->{CHANGETIME}[$i]));
|
||||
$t =~ s/ /_/; # Makes it easier to parse with gnuplot
|
||||
$t =~ s/ /_/o; # Makes it easier to parse with gnuplot
|
||||
|
||||
my $fh = $log->{FH};
|
||||
my @t = localtime;
|
||||
@ -182,7 +182,7 @@ FileLog_Get($@)
|
||||
if($inf eq "-") {
|
||||
$inf = $hash->{currentlogfile};
|
||||
} else {
|
||||
my $linf = "$1/$inf" if($hash->{currentlogfile} =~ m,^(.*)/[^/]*$,);
|
||||
my $linf = "$1/$inf" if($hash->{currentlogfile} =~ m,^(.*)/[^/]*$,o);
|
||||
if(!-f $linf) {
|
||||
$linf = $attr{$hash->{NAME}}{archivedir} . "/" . $inf;
|
||||
return "Error: File-not-found" if(!-f $linf);
|
||||
@ -214,7 +214,7 @@ FileLog_Get($@)
|
||||
$h{didx} = 10 if($fld[3] && $fld[3] eq "delta-d"); # delta idx, substr len
|
||||
$h{didx} = 13 if($fld[3] && $fld[3] eq "delta-h");
|
||||
|
||||
if($fld[0] =~ m/"(.*)"/) {
|
||||
if($fld[0] =~ m/"(.*)"/o) {
|
||||
$h{col} = $1;
|
||||
$h{type} = 0;
|
||||
} else {
|
||||
@ -281,7 +281,7 @@ FileLog_Get($@)
|
||||
$lastdate{$hd} = $fld[0];
|
||||
|
||||
} elsif($t == 3) { # int function
|
||||
$val = $1 if($fld[$col] =~ m/^([0-9]+).*/);
|
||||
$val = $1 if($fld[$col] =~ m/^(\d+).*/o);
|
||||
|
||||
} else { # evaluate
|
||||
$val = eval($h->{fn});
|
||||
@ -380,7 +380,7 @@ seekTo($$$$)
|
||||
$last = $next;
|
||||
last;
|
||||
}
|
||||
if($data !~ m/^\d\d\d\d-\d\d-\d\d_\d\d:\d\d:\d\d /) {
|
||||
if($data !~ m/^\d\d\d\d-\d\d-\d\d_\d\d:\d\d:\d\d /o) {
|
||||
$next = $fh->tell;
|
||||
$data = <$fh>;
|
||||
if(!$data) {
|
||||
|
173
fhem/FHEM/98_autocreate.pm
Normal file
173
fhem/FHEM/98_autocreate.pm
Normal file
@ -0,0 +1,173 @@
|
||||
##############################################
|
||||
package main;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
# Problems:
|
||||
# - Not all CUL_EM devices return a power
|
||||
# - Not all CUL_WS devices return a temperature
|
||||
# - No plot files for BS/CUL_FHTTK/USF1000/X10/WS300
|
||||
# - check "UNDEFINED" parameters for BS/USF1000/X10
|
||||
|
||||
my %flogpar = (
|
||||
"CUL_EM:.*" => { GPLOT => "cul_em:Power,", FILTER => "%NAME:CNT:.*" },
|
||||
"CUL_WS:.*" => { GPLOT => "cul_ws:Temp,", FILTER => "%NAME" },
|
||||
"FHT:.*" => { GPLOT => "fht:Temp/Act,", FILTER => "%NAME" },
|
||||
"HMS:HMS100T.*" => { GPLOT => "hms:Temp/Hum,", FILTER => "%NAME:T:.*" },
|
||||
"KS300:.*" => { GPLOT => "ks300:Temp/Rain,ks300_2:Wind/Hum,",
|
||||
FILTER => "%NAME:T:.*" },
|
||||
);
|
||||
|
||||
#####################################
|
||||
sub
|
||||
autocreate_Initialize($)
|
||||
{
|
||||
my ($hash) = @_;
|
||||
$hash->{DefFn} = "autocreate_Define";
|
||||
$hash->{NotifyFn} = "autocreate_Notify";
|
||||
$hash->{AttrList}= "loglevel:0,1,2,3,4,5,6 " .
|
||||
"autosave filelog device_room weblink weblink_room";
|
||||
}
|
||||
|
||||
#####################################
|
||||
sub
|
||||
autocreate_Define($$)
|
||||
{
|
||||
my ($hash, $def) = @_;
|
||||
my $name = $hash->{NAME};
|
||||
$hash->{STATE} = "active";
|
||||
$attr{global}{autoload_undefined_devices} = 1; # Make sure we work correctly
|
||||
return undef;
|
||||
}
|
||||
|
||||
sub
|
||||
replace_wildcards($$)
|
||||
{
|
||||
my ($hash, $str) = @_;
|
||||
return "" if(!$str);
|
||||
my $t = $hash->{TYPE}; $str =~ s/%TYPE/$t/g;
|
||||
my $n = $hash->{NAME}; $str =~ s/%NAME/$n/g;
|
||||
return $str;
|
||||
}
|
||||
|
||||
#####################################
|
||||
sub
|
||||
autocreate_Notify($$)
|
||||
{
|
||||
my ($ntfy, $dev) = @_;
|
||||
|
||||
my $me = $ntfy->{NAME};
|
||||
my $max = int(@{$dev->{CHANGED}});
|
||||
my $ret = "";
|
||||
my $nrcreated;
|
||||
|
||||
for (my $i = 0; $i < $max; $i++) {
|
||||
|
||||
my $s = $dev->{CHANGED}[$i];
|
||||
$s = "" if(!defined($s));
|
||||
|
||||
################
|
||||
if($s =~ m/^UNDEFINED ([^ ]*) ([^ ]*) (.*)$/) {
|
||||
my ($name, $type, $arg) = ($1, $2, $3);
|
||||
my $lctype = lc($type);
|
||||
|
||||
####################
|
||||
my $cmd = "$name $type $arg";
|
||||
Log GetLogLevel($me,2), "autocreate: define $cmd";
|
||||
my $ret = CommandDefine(undef, $cmd);
|
||||
if($ret) {
|
||||
Log GetLogLevel($me,1), "ERROR: $ret";
|
||||
last;
|
||||
}
|
||||
my $hash = $defs{$name};
|
||||
$nrcreated++;
|
||||
my $room = replace_wildcards($hash, $attr{$me}{device_room});
|
||||
$attr{$name}{room} = $room if($room);
|
||||
|
||||
####################
|
||||
my $fl = replace_wildcards($hash, $attr{$me}{filelog});
|
||||
next if(!$fl);
|
||||
my $flname = "FileLog_$name";
|
||||
my ($gplot, $filter) = ("", $name);
|
||||
foreach my $k (keys %flogpar) {
|
||||
next if("$type:$name" !~ m/^$k$/);
|
||||
$gplot = $flogpar{$k}{GPLOT};
|
||||
$filter = replace_wildcards($hash, $flogpar{$k}{FILTER});
|
||||
}
|
||||
$cmd = "$flname FileLog $fl $filter";
|
||||
Log GetLogLevel($me,2), "autocreate: define $cmd";
|
||||
$ret = CommandDefine(undef, $cmd);
|
||||
if($ret) {
|
||||
Log GetLogLevel($me,1), "ERROR: $ret";
|
||||
last;
|
||||
}
|
||||
$attr{$flname}{room} = $room if($room);
|
||||
$attr{$flname}{logtype} = "${gplot}text";
|
||||
|
||||
|
||||
####################
|
||||
next if(!$attr{$me}{weblink} || !$gplot);
|
||||
$room = replace_wildcards($hash, $attr{$me}{weblink_room});
|
||||
my $wlname = "weblink_$name";
|
||||
$cmd = "$wlname weblink fileplot $flname:$lctype:CURRENT";
|
||||
Log GetLogLevel($me,2), "autocreate: define $cmd";
|
||||
$ret = CommandDefine(undef, $cmd);
|
||||
if($ret) {
|
||||
Log GetLogLevel($me,1), "ERROR: $ret";
|
||||
last;
|
||||
}
|
||||
$attr{$wlname}{room} = $room if($room);
|
||||
$attr{$wlname}{label} = '"' . $name .
|
||||
' Min $data{min1}, Max $data{max1}, Last $data{currval1}"';
|
||||
}
|
||||
|
||||
|
||||
################
|
||||
if($s =~ m/^RENAMED ([^ ]*) ([^ ]*)$/) {
|
||||
my ($old, $new) = ($1, $2);
|
||||
|
||||
if($defs{"FileLog_$old"}) {
|
||||
CommandRename(undef, "FileLog_$old FileLog_$new");
|
||||
my $hash = $defs{"FileLog_$new"};
|
||||
my $oldlogfile = $hash->{currentlogfile};
|
||||
|
||||
$hash->{REGEXP} =~ s/$old/$new/g;
|
||||
$hash->{logfile} =~ s/$old/$new/g;
|
||||
$hash->{currentlogfile} =~ s/$old/$new/g;
|
||||
$hash->{DEF} =~ s/$old/$new/g;
|
||||
|
||||
rename($oldlogfile, $hash->{currentlogfile});
|
||||
Log GetLogLevel($me,2),
|
||||
"autocreate: renamed FileLog_$old to FileLog_$new";
|
||||
$nrcreated++;
|
||||
}
|
||||
|
||||
if($defs{"weblink_$old"}) {
|
||||
CommandRename(undef, "weblink_$old weblink_$new");
|
||||
my $hash = $defs{"weblink_$new"};
|
||||
$hash->{LINK} =~ s/$old/$new/g;
|
||||
$hash->{DEF} =~ s/$old/$new/g;
|
||||
$attr{"weblink_$new"}{label} =~ s/$old/$new/g;
|
||||
Log GetLogLevel($me,2),
|
||||
"autocreate: renamed weblink_$old to weblink_$new";
|
||||
$nrcreated++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
CommandSave(undef, undef) if(!$ret && $nrcreated && $attr{$me}{autosave});
|
||||
return $ret;
|
||||
}
|
||||
|
||||
#####################################
|
||||
# Test code. Use {dp "xxx"} to fake a device specific message
|
||||
# FS20: 81xx04yy0101a00180c1020013
|
||||
sub
|
||||
dp($)
|
||||
{
|
||||
Dispatch($defs{CUL}, shift, undef);
|
||||
}
|
||||
|
||||
1;
|
@ -2,8 +2,8 @@ BINDIR=/usr/local/bin
|
||||
MODDIR=/usr/local/lib
|
||||
VARDIR=/var/log/fhem
|
||||
|
||||
VERS=4.8
|
||||
DATE=2009-11-28
|
||||
VERS=4.9
|
||||
DATE=2009-12-23
|
||||
|
||||
all:
|
||||
@echo Nothing to do for all.
|
||||
|
@ -1,4 +1,4 @@
|
||||
die("Usage: crc HEX-MESSAGE\n") if(int(@ARGV) != 2);
|
||||
die("Usage: crc <HEX-MESSAGE> <CRC>\n") if(int(@ARGV) != 2);
|
||||
my $msg = $ARGV[0];
|
||||
$msg =~ s/ //g;
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
<h2>FHEMWEB Howto</h2>
|
||||
|
||||
<a href="#starting">Starting</a><br/>
|
||||
<a href="#FHZ">Attaching an FHZ device</a><br/>
|
||||
<a href="#FHZ">Attaching an FHZ/CUL</a><br/>
|
||||
<a href="#FS20rx">Configuring FS20 receivers</a><br/>
|
||||
<a href="#FS20tx">Configuring FS20 transmitters</a><br/>
|
||||
<a href="#FHT">Configuring FHT devices</a><br/>
|
||||
@ -41,7 +41,7 @@
|
||||
|
||||
|
||||
<a name="FHZ"/>
|
||||
<h3>Attaching an FHZ device</h3>
|
||||
<h3>Attaching an FHZ/CUL</h3>
|
||||
<ul>
|
||||
Attach the FHZ1000 or FHZ1300 to your computer, and look for a file named
|
||||
/dev/ttyUSB0 or /dev/tts/USB0 (or /var/elv on the Fritz!Box).
|
||||
@ -51,13 +51,27 @@
|
||||
You can find details <a href="commandref.html#define">here</a> and
|
||||
<a href="commandref.html#FHZ">here</a>. Instead of an FHZ you can also
|
||||
use a <a href="commandref.html#CUL">CUL</a> with slightly different
|
||||
parameters.
|
||||
parameters (define CUL CUL /dev/ttyACM0 1234).
|
||||
|
||||
<br><br>
|
||||
<b>Note:</b> Don't forget to type "save" in the "Fhem cmd" input field of
|
||||
the browser after defining a device or setting its attribute. Otherwise
|
||||
the changes will disappear after the next start.</br><br> </ul>
|
||||
|
||||
<a name="autocreate"/>
|
||||
<h3>Automatically creating transmitters</h3>
|
||||
<ul>
|
||||
The sample configuration file installed via "make install-pgm2" has
|
||||
configured an <a href="commandref.html#autocreate">autocreate</a>
|
||||
instance. This will automatically create fhem devices upon reception
|
||||
of a message form this device (typically a sensor like S300 or FHT).
|
||||
Just wait for a while, and re-check your browser for newly appeared
|
||||
devices. You can use <a href="commandref.html#rename"> rename</a> to
|
||||
rename the automatically created device, e.g. type in the input field of
|
||||
the web frontend:<pre>
|
||||
rename FHT_1234 fht.kitchen</pre>
|
||||
</ul>
|
||||
|
||||
|
||||
<a name="FS20rx"/>
|
||||
<h3>Configuring FS20 receivers</h3>
|
||||
|
@ -32,6 +32,7 @@
|
||||
<a href="#modify">modify</a>
|
||||
<a href="#quit">quit</a>
|
||||
<a href="#reload">reload</a>
|
||||
<a href="#rename">rename</a>
|
||||
<a href="#rereadcfg">rereadcfg</a>
|
||||
<a href="#save">save</a>
|
||||
<a href="#set">set</a>
|
||||
@ -93,12 +94,14 @@
|
||||
<a href="#PachLog">PachLog</a>
|
||||
<a href="#SUNRISE_EL">SUNRISE_EL</a>
|
||||
<a href="#at">at</a>
|
||||
<a href="#autocreate">autocreate</a>
|
||||
<a href="#dummy">dummy</a>
|
||||
<a href="#dumpdef">dumpdef</a>
|
||||
<a href="#holiday">holiday</a>
|
||||
<a href="#notify">notify</a>
|
||||
<a href="#watchdog">watchdog</a>
|
||||
<a href="#weblink">weblink</a>
|
||||
|
||||
</ul>
|
||||
|
||||
<br>
|
||||
@ -365,7 +368,9 @@ A line ending with \ will be concatenated with the next one, so long lines
|
||||
Define a device. You need devices if you want to manipulate them (e.g.
|
||||
set on/off), and the logfile is also more readable if it contains e.g.
|
||||
"lamp off" instead of "Device 5673, Button 00, Code 00 (off)". <br>
|
||||
Use "define <name> ?" to get a list of possible types.
|
||||
Use "define <name> ?" to get a list of possible types.<br>
|
||||
After definition, the global event "DEFINED" will be generated, see the
|
||||
notify section for details.<br>
|
||||
<br><br>
|
||||
|
||||
Each device takes different additional arguments at definition, see the
|
||||
@ -401,6 +406,8 @@ A line ending with \ will be concatenated with the next one, so long lines
|
||||
Delete something created with the <a href="#define">define</a> command.
|
||||
See the <a href="#devspec">Device specification</a> section for details on
|
||||
<devspec>.<br>
|
||||
After deletion, the global event "DELETED" will be generated, see the notify
|
||||
section for details.<br>
|
||||
Examples:
|
||||
<ul>
|
||||
<code>delete lamp</code><br>
|
||||
@ -592,6 +599,22 @@ A line ending with \ will be concatenated with the next one, so long lines
|
||||
</ul>
|
||||
</ul>
|
||||
|
||||
<a name="rename"></a>
|
||||
<h3>rename</h3>
|
||||
<ul>
|
||||
<code>rename <oldname> <newname></code>
|
||||
<br><br>
|
||||
Rename a device from the <oldname> to <newname>, together with
|
||||
its attributes. The global event RENAMED will be generated, see the notify
|
||||
section for details.
|
||||
<br><br>
|
||||
Example:
|
||||
<ul>
|
||||
<code>rename FHT_1234 fht.kitchen</code>
|
||||
</ul>
|
||||
</ul>
|
||||
|
||||
|
||||
<a name="rereadcfg"></a>
|
||||
<h3>rereadcfg</h3>
|
||||
<ul>
|
||||
@ -758,6 +781,15 @@ A line ending with \ will be concatenated with the next one, so long lines
|
||||
|
||||
<b>Attributes</b>
|
||||
<ul>
|
||||
<a name="autoload_undefined_devices"></a>
|
||||
<li>autoload_undefined_devices<br>
|
||||
If set, automatically load the corresponding module when a message
|
||||
of this type is received. This is used by the <a href="#autocreate">
|
||||
autocreate</a> device, to automatically create a fhem device upon
|
||||
receiving a corresponding message.
|
||||
</li><br>
|
||||
|
||||
|
||||
<a name="allowfrom"></a>
|
||||
<li>allowfrom<br>
|
||||
Comma (,) separated list of ip-addresses or hostnames. If set,
|
||||
@ -3312,7 +3344,8 @@ A line ending with \ will be concatenated with the next one, so long lines
|
||||
<a name="weblinkdefine"></a>
|
||||
<b>Define</b>
|
||||
<ul>
|
||||
<code>define <name> weblink [link|fileplot] <argument></code>
|
||||
<code>define <name> weblink [link|fileplot|image]
|
||||
<argument></code>
|
||||
<br><br>
|
||||
This is a placeholder used with webpgm2 to be able to integrate links
|
||||
into it, and to be able to put more than one gnuplot/SVG picture on one
|
||||
@ -3320,8 +3353,9 @@ A line ending with \ will be concatenated with the next one, so long lines
|
||||
|
||||
Examples:
|
||||
<ul>
|
||||
<code>define wl_1 weblink link http://www.fhem.de</code><br>
|
||||
<code>define wl_2 weblink fileplot <logdevice>:<gnuplot-file>:<logfile></code><br>
|
||||
<code>define homepage weblink link http://www.fhem.de</code><br>
|
||||
<code>define MyPlot weblink fileplot <logdevice>:<gnuplot-file>:<logfile></code><br>
|
||||
<code>define webcam weblink image http://w.x.y.z/current.jpg</code><br>
|
||||
</ul>
|
||||
<br>
|
||||
|
||||
@ -3332,9 +3366,8 @@ A line ending with \ will be concatenated with the next one, so long lines
|
||||
<a href="#logtype">logtype</a>) and convert it to weblink. Now you
|
||||
can group these weblinks by putting them into rooms. If you convert
|
||||
the current logfile to a weblink, it will always refer to the current
|
||||
file (and not the one you originally specified).</li>
|
||||
</ul>
|
||||
</ul>
|
||||
file, even if its name changes regularly (and not the one you
|
||||
originally specified).</li> </ul> </ul>
|
||||
|
||||
<b>Set</b> <ul>N/A</ul><br>
|
||||
|
||||
@ -3575,6 +3608,82 @@ A line ending with \ will be concatenated with the next one, so long lines
|
||||
|
||||
</ul>
|
||||
|
||||
<a name="autocreate"></a>
|
||||
<h3>autocreate</h3>
|
||||
<ul>
|
||||
|
||||
Automatically create not yet defined fhem devices upon reception of a message
|
||||
generated by this device. Note: devices which are polled (like the EMEM/EMWZ
|
||||
accessed through the EM1010PC) will NOT be automatically created.
|
||||
|
||||
<br>
|
||||
|
||||
<a name="autocreatedefine"></a>
|
||||
<b>Define</b>
|
||||
<ul>
|
||||
<code>define <name> autocreate</code><br>
|
||||
<br>
|
||||
<ul>
|
||||
It makes no sense to create more than one instance of this module.
|
||||
By defining an instance, the global attribute <a href=
|
||||
"#autoload_undefined_devices">autoload_undefined_devices</a>
|
||||
is set, so that modules for unknnown devices are automatically loaded.
|
||||
The autocreate module intercepts the UNDEFINED event generated by each
|
||||
module, creates a device and optionally also FileLog and weblink
|
||||
entries.<br>
|
||||
<b>Note:</b>devices will be created with a unique name, which contains
|
||||
the type and a unique id for this type. When <a href="#rename">renaming
|
||||
</a> the device, the automatically created filelog and weblink devices
|
||||
will also be renamed.
|
||||
|
||||
</ul>
|
||||
<br>
|
||||
|
||||
Example:<PRE>
|
||||
define autocreate autocreate
|
||||
attr autocreate autosave
|
||||
attr autocreate device_room %TYPE
|
||||
attr autocreate filelog test2/log/%NAME-%Y.log
|
||||
attr autocreate weblink
|
||||
attr autocreate weblink_room Plots
|
||||
</PRE>
|
||||
</ul>
|
||||
|
||||
|
||||
<b>Set</b> <ul>N/A</ul><br>
|
||||
<b>Get</b> <ul>N/A</ul><br>
|
||||
|
||||
<b>Attributes</b>
|
||||
<ul>
|
||||
<a name="autosave"></a>
|
||||
<li>autosave<br>
|
||||
After creating a device, automatically save the config file with the
|
||||
command <a href="#save">save</a> command.</li><br>
|
||||
|
||||
<a name="device_room"></a>
|
||||
<li>device_room<br>
|
||||
"Put" the newly created device in this room. The name can contain the
|
||||
wildcards %TYPE and %NAME, see the example above.</li><br>
|
||||
|
||||
<a name="filelog"></a>
|
||||
<li>filelog<br>
|
||||
Create a filelog associated with the device. The filename can contain
|
||||
the wildcards %TYPE and %NAME, see the example above. The filelog will
|
||||
be "put" in the same room as the device.</li><br>
|
||||
|
||||
<a name="weblink"></a>
|
||||
<li>weblink<br>
|
||||
Create a weblinkn associated with the device/filelog.</li><br>
|
||||
|
||||
<a name="weblink_room"></a>
|
||||
<li>weblink_room<br>
|
||||
"Put" the newly weblink in this room. The name can contain the
|
||||
wildcards %TYPE and %NAME, see the example above.</li><br>
|
||||
</ul>
|
||||
<br>
|
||||
|
||||
</ul>
|
||||
|
||||
<a name="holiday"></a>
|
||||
<h3>holiday</h3>
|
||||
<ul>
|
||||
@ -3726,21 +3835,21 @@ A line ending with \ will be concatenated with the next one, so long lines
|
||||
<li>To use database logging, copy the file contrib/91_DbLog.pm into your
|
||||
modules directory, and change the $dbconn parameter in the file.</li>
|
||||
|
||||
<li>Each undefined device (FS20, HMS, FHT) will be reported with the
|
||||
device name "UNDEFINED". The % parameter will contain the type (FS20,
|
||||
HMS100T, etc) and device number, separated by a space.</li>
|
||||
|
||||
<li>After defining a device, the event "DEFINED" will be triggered. This
|
||||
can be used in the fhem.cfg to set some values of the device.</li>
|
||||
|
||||
<li>After initialization finished, the event "INITIALIZED" for the device
|
||||
"global" will be triggered.</li>
|
||||
<li>Following special events will be generated for the device "global"
|
||||
<ul>
|
||||
<li>INITIALIZED after initialization is finished.
|
||||
<li>DEFINED <devname> after a device is defined.
|
||||
<li>DELETED <devname> after a device was deleted.
|
||||
<li>RENAMED <old> <new> after a device was renamed.
|
||||
<li>UNDEFINED <defspec> upon reception of a message for an
|
||||
undefined device.
|
||||
</ul>
|
||||
|
||||
<li>Notify can be used to store macros for manual execution. Use the <a
|
||||
href="#trigger">trigger</a> command to execute the macro. E.g.<br>
|
||||
<pre>
|
||||
fhem> define MyMacro notify MyMacro { Log 1, "Hello"}
|
||||
fhem> trigger MyMacro</pre>
|
||||
href="#trigger">trigger</a> command to execute the macro.
|
||||
E.g.<br>
|
||||
<code>fhem> define MyMacro notify MyMacro { Log 1, "Hello"}</code><br>
|
||||
<code>fhem> trigger MyMacro</pre></code><br>
|
||||
|
||||
|
||||
</ul>
|
||||
@ -4032,7 +4141,7 @@ A line ending with \ will be concatenated with the next one, so long lines
|
||||
define FileLog fhtlog1 fht1:.*(temp|actuator).*
|
||||
/var/log/fht1-%Y-%U.log
|
||||
</li>
|
||||
<li>ks300_1<br>
|
||||
<li>ks300<br>
|
||||
Plots the temperature and rain (per hour and per day) of a
|
||||
ks300. The corresponding filelog definitions (for the KS300
|
||||
device named ks300) looks like:<br>
|
||||
|
@ -26,7 +26,7 @@ attr wzlog logtype fht:Temp
|
||||
# ks300 log
|
||||
define kslog FileLog /var/log/wz-%Y-%U.log ks1:.*H:.*
|
||||
define avglog FileLog /var/log/avg.log ks1:.*avg.*
|
||||
attr kslog logtype ks300_1:Temp/Hum,ks300_2:Rain/Wind
|
||||
attr kslog logtype ks300:Temp/Hum,ks300_2:Rain/Wind
|
||||
|
||||
##############################
|
||||
# Alternative log method. It does the same, but it is somewhat slower as it
|
||||
|
@ -1,15 +1,25 @@
|
||||
#
|
||||
# Minimalistic fhem.pl & pgm2 configfile. Take a look at the other examples for
|
||||
# more.
|
||||
# pgm2 / autocreate configfile. Take a look at the other examples for more.
|
||||
#
|
||||
attr global logfile /tmp/fhem-%Y-%m.log
|
||||
attr global modpath . # where our FHEM directory is
|
||||
attr global port 7072 # our TCP/IP port (localhost only)
|
||||
attr global statefile /tmp/fhem.save # where to save the state of the devices
|
||||
attr global verbose 3 # "normal" verbosity (min 1, max 5)
|
||||
attr global port 7072 # our TCP/IP port (localhost only)
|
||||
attr global modpath . # where our FHEM directory is
|
||||
|
||||
#define CUL CUL /dev/ttyACM0
|
||||
#define FHEM FHEM /dev/USB0
|
||||
|
||||
define WEB FHEMWEB 8083 global
|
||||
attr WEB plotmode SVG
|
||||
attr WEB plotsize 800,160
|
||||
|
||||
# Fake logfile, to access the global log
|
||||
define Logfile FileLog /tmp/fhem-%Y-%m.log fakelog
|
||||
|
||||
define autocreate autocreate
|
||||
attr autocreate autosave
|
||||
attr autocreate device_room %TYPE
|
||||
attr autocreate filelog /tmp/%NAME-%Y.log
|
||||
attr autocreate weblink
|
||||
attr autocreate weblink_room Plots
|
||||
|
15
fhem/fhem.pl
15
fhem/fhem.pl
@ -157,7 +157,7 @@ my $nextat; # Time when next timer will be triggered.
|
||||
my $intAtCnt=0;
|
||||
my %duplicate; # Pool of received msg for multi-fhz/cul setups
|
||||
my $duplidx=0; # helper for the above pool
|
||||
my $cvsid = '$Id: fhem.pl,v 1.92 2009-12-21 18:03:56 rudolfkoenig Exp $';
|
||||
my $cvsid = '$Id: fhem.pl,v 1.93 2009-12-22 11:00:54 rudolfkoenig Exp $';
|
||||
my $namedef =
|
||||
"where <name> is either:\n" .
|
||||
"- a single device name\n" .
|
||||
@ -863,29 +863,20 @@ CommandSave($$)
|
||||
return "Cannot open $param: $!";
|
||||
}
|
||||
|
||||
my $oldroom = "";
|
||||
foreach my $d (sort { $defs{$a}{NR} <=> $defs{$b}{NR} } keys %defs) {
|
||||
next if($defs{$d}{TEMPORARY} || # e.g. WEBPGM connections
|
||||
$defs{$d}{VOLATILE}); # e.g at, will be saved to the statefile
|
||||
|
||||
my $room = ($attr{$d} ? $attr{$d}{room} : "");
|
||||
$room = "" if(!$room);
|
||||
if($room ne $oldroom) {
|
||||
print SFH "\nsetdefaultattr" . ($room ? " room $room" : "") . "\n";
|
||||
$oldroom = $room;
|
||||
}
|
||||
|
||||
if($d ne "global") {
|
||||
if($defs{$d}{DEF}) {
|
||||
my $def = $defs{$d}{DEF};
|
||||
$def =~ s/;/;;/g;
|
||||
print SFH "define $d $defs{$d}{TYPE} $def\n";
|
||||
print SFH "\ndefine $d $defs{$d}{TYPE} $def\n";
|
||||
} else {
|
||||
print SFH "define $d $defs{$d}{TYPE}\n";
|
||||
print SFH "\ndefine $d $defs{$d}{TYPE}\n";
|
||||
}
|
||||
}
|
||||
foreach my $a (sort keys %{$attr{$d}}) {
|
||||
next if($a eq "room");
|
||||
next if($d eq "global" &&
|
||||
($a eq "configfile" || $a eq "version"));
|
||||
print SFH "attr $d $a $attr{$d}{$a}\n";
|
||||
|
@ -1,8 +1,7 @@
|
||||
############################
|
||||
# Display the power reported by the EM1010
|
||||
# Corresponding FileLog definition:
|
||||
# define ememlog FileLog /var/log/fhem/em-%Y.log emem:power.*
|
||||
# define emwzlog FileLog /var/log/fhem/em-%Y.log emwz:power.*
|
||||
# define <filelogname> FileLog /var/log/fhem/em-%Y.log <emdevname>:CNT:.*
|
||||
|
||||
set terminal png transparent size <SIZE> crop
|
||||
set output '<OUT>.png'
|
||||
@ -10,7 +9,7 @@ set xdata time
|
||||
set timefmt "%Y-%m-%d_%H:%M:%S"
|
||||
set xlabel " "
|
||||
|
||||
set title '<TL>'
|
||||
set title '<L1>'
|
||||
set ylabel "Power (KW)"
|
||||
set y2label "Power (KW)"
|
||||
set grid
|
||||
@ -19,8 +18,6 @@ set y2tics
|
||||
set format y "%.1f"
|
||||
set format y2 "%.1f"
|
||||
|
||||
#FileLog 8:emem:0:
|
||||
#FileLog 8:emwz:0:
|
||||
#FileLog 8::0:
|
||||
|
||||
plot "<grep emem <IN>" using 1:8 title 'EMEM' with lines,\
|
||||
"<grep emwz <IN>" using 1:8 title 'EMWZ' with lines
|
||||
plot "<IN>" using 1:8 title 'Power' with lines
|
||||
|
@ -8,7 +8,7 @@ set xdata time
|
||||
set timefmt "%Y-%m-%d_%H:%M:%S"
|
||||
set xlabel "Energiemonitor EM1000EM"
|
||||
|
||||
set title '<TL>'
|
||||
set title '<L1>'
|
||||
set ylabel "Power (kW)"
|
||||
set y2label "Power (kWh)"
|
||||
set grid
|
||||
|
@ -1,7 +1,7 @@
|
||||
############################
|
||||
# Display the s300th data reported by the CUL
|
||||
# Corresponding FileLog definition:
|
||||
# define ememlog FileLog /var/log/fhem/s300th-%Y.log s300th.*
|
||||
# define <filelogname> FileLog /var/log/fhem/s300th-%Y.log <s300name>
|
||||
|
||||
set terminal png transparent size <SIZE> crop
|
||||
set output '<OUT>.png'
|
||||
@ -9,7 +9,7 @@ set xdata time
|
||||
set timefmt "%Y-%m-%d_%H:%M:%S"
|
||||
set xlabel " "
|
||||
|
||||
set title '<TL>'
|
||||
set title '<L1>'
|
||||
set ylabel "Temp (C)"
|
||||
set y2label "Temp (C)"
|
||||
set grid
|
||||
@ -18,10 +18,6 @@ set y2tics
|
||||
set format y "%.1f"
|
||||
set format y2 "%.1f"
|
||||
|
||||
#FileLog 4:s300th1:0:
|
||||
#FileLog 4:s300th3:0:
|
||||
#FileLog 4:s300th5:0:
|
||||
#FileLog 4::0:
|
||||
|
||||
plot "<grep s300th1 <IN>" using 1:8 title '1' with lines,\
|
||||
"<grep s300th3 <IN>" using 1:8 title '3' with lines,\
|
||||
"<grep s300th5 <IN>" using 1:8 title '5' with lines
|
||||
plot "<IN>" using 1:4 title 'Temperature' with lines
|
||||
|
@ -1,7 +1,7 @@
|
||||
############################
|
||||
# Display the measured temp and the actuator.
|
||||
# Corresponding FileLog definition:
|
||||
# define fhtlog1 FileLog /var/log/fhem/fht1-%Y-%U.log fht1:.*(temp|actuator).*
|
||||
# define <filelogname> FileLog /var/log/fhem/fht-%Y.log <fhtname>
|
||||
|
||||
set terminal png transparent size <SIZE> crop
|
||||
set output '<OUT>.png'
|
||||
@ -11,19 +11,15 @@ set xlabel " "
|
||||
set ytics nomirror
|
||||
set y2tics
|
||||
#set ytics
|
||||
set title '<TL>'
|
||||
set title '<L1>'
|
||||
set grid xtics y2tics
|
||||
|
||||
set y2label "Temperature in C"
|
||||
set ylabel "Actuator (%)"
|
||||
|
||||
#FileLog 4:measured:0:
|
||||
##FileLog 4:desired:0:
|
||||
#FileLog 4:actuator.*[0-9]+%:0:int
|
||||
|
||||
# "< awk '/desired/ {print $1, $4+0}' <IN>"\
|
||||
# using 1:2 axes x1y2 title 'Desired temperature' with steps,\
|
||||
|
||||
plot \
|
||||
"< awk '/measured/{print $1, $4}' <IN>"\
|
||||
using 1:2 axes x1y2 title 'Measured temperature' with lines lw 2,\
|
||||
|
@ -1,9 +1,7 @@
|
||||
#
|
||||
# Display the measured temp and the humidity.
|
||||
# FileLog definition:
|
||||
# define UGHygrolog FileLog /var/tmp/UGHygro.log UGHygro:.*T:.*
|
||||
# attr UGHygrolog logtype hms_tf
|
||||
# define wl_11 weblink fileplot UGHygrolog:hms_tf:CURRENT
|
||||
# define <filelogname> FileLog /var/log/fhem/hmsname-%Y.log <hmsname>:T:.*
|
||||
#
|
||||
# Logfile record example:
|
||||
# 2008-07-24_02:20:57 UGHygro T: 17.2 H: 77.6 Bat: ok
|
||||
@ -21,7 +19,7 @@ set xlabel " "
|
||||
set ytics nomirror
|
||||
set y2tics
|
||||
#set ytics
|
||||
set title '<TL>'
|
||||
set title '<L1>'
|
||||
set grid xtics y2tics
|
||||
|
||||
set y2label "Temperature in C"
|
||||
@ -35,7 +33,3 @@ plot \
|
||||
using 1:2 axes x1y2 title 'Measured temperature' with lines lw 2,\
|
||||
"< awk '/H:/ {print $1, $6}' <IN>"\
|
||||
using 1:2 axes x1y1 title 'Humidity (%)' with lines lw 1\
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,9 +1,7 @@
|
||||
############################
|
||||
# Display the temperature and the humidity values of a KS300.
|
||||
# Corresponding FileLog definition:
|
||||
# define ks300log FileLog /var/log/fhem/ks300-%Y-%U.log ks300:.*H:.*
|
||||
# or (SVG/gnuplot-scroll)
|
||||
# define ks300log FileLog /var/log/fhem/ks300-%Y.log ks300:.*H:.*
|
||||
# define <filelogname> FileLog /var/log/fhem/hms-%Y.log <ks300name>:T:.*
|
||||
|
||||
set terminal png transparent size <SIZE> crop
|
||||
set output '<OUT>.png'
|
||||
@ -12,7 +10,7 @@ set timefmt "%Y-%m-%d_%H:%M:%S"
|
||||
set xlabel " "
|
||||
set ytics nomirror
|
||||
set y2tics
|
||||
set title '<TL>'
|
||||
set title '<L1>'
|
||||
set grid
|
||||
|
||||
set y2label "Temperature in C"
|
||||
|
@ -1,9 +1,7 @@
|
||||
############################
|
||||
# Display the Wind and the Rain values of a KS300.
|
||||
# Corresponding FileLog definition:
|
||||
# define ks300log FileLog /var/log/fhem/ks300-%Y-%U.log ks300:.*H:.*
|
||||
# or (SVG/gnuplot-scroll)
|
||||
# define ks300log FileLog /var/log/fhem/ks300-%Y.log ks300:.*H:.*
|
||||
# define <filelogname> FileLog /var/log/fhem/hms-%Y.log <ks300name>:T:.*
|
||||
|
||||
set terminal png transparent size <SIZE> crop
|
||||
set output '<OUT>.png'
|
||||
|
Loading…
x
Reference in New Issue
Block a user