Initialisation erweitert. Optional kann jetzt ein filename (oder
path/filename) angegeben werden. Dieser wird dann anstelle des DAQ00001.DAQ verwendet.
This commit is contained in:
parent
7a5e0f5e54
commit
0024ac1e84
|
@ -46,18 +46,27 @@ sub HGNanopk_Define($$) {
|
|||
my ($hash, $def) = @_;
|
||||
my @a = split("[ \t]+", $def);
|
||||
|
||||
if(@a != 4) {
|
||||
return "wrong syntax: define <name> HGNanopk <hostname> <interval>";
|
||||
if(@a <= 3) {
|
||||
return "wrong syntax: define <name> HGNanopk <hostname> <interval> <DAQ_Basename>";
|
||||
}
|
||||
|
||||
my $name= $a[0];
|
||||
my $hostname= $a[2];
|
||||
my $interval= $a[3];
|
||||
my $filename;
|
||||
if ($a[4] eq "") {
|
||||
$filename = "DAQ00001.DAQ";
|
||||
print "using default filename $filename\n";
|
||||
} else {
|
||||
$filename = $a[4];
|
||||
print "set filename to given argument $filename\n";
|
||||
}
|
||||
|
||||
$hash->{DeviceName} = $name;
|
||||
$hash->{Device} = $hostname;
|
||||
$hash->{STATE} = 'Initialized';
|
||||
$hash->{interval} = $interval;
|
||||
$hash->{filename} = $filename;
|
||||
|
||||
|
||||
Log 4,"HGNanopk_Define -> $name at $hostname (Update every $interval seconds)";
|
||||
|
@ -97,6 +106,13 @@ sub HGNanopk_GetUpdate($)
|
|||
{
|
||||
my ($hash) = @_;
|
||||
my $name = $hash->{NAME};
|
||||
my $hginfofile = $hash->{filename};
|
||||
my @buffer = split(/\./,$hginfofile);
|
||||
my $hgtransfile;
|
||||
my $hgstatefile;
|
||||
|
||||
$hgtransfile = "$buffer[0]" . ".translation";
|
||||
$hgstatefile = "$buffer[0]" . ".states";
|
||||
|
||||
sub query_bit($$) {
|
||||
my ( $bitarray, $bit ) = @_;
|
||||
|
@ -152,10 +168,10 @@ sub HGNanopk_GetUpdate($)
|
|||
return ( ( $bitarray & 2**$bit ) ? 1 : 0);
|
||||
}
|
||||
|
||||
if ( -e "DAQ00001.translation" ) {
|
||||
if ( -e "$hgtransfile" ) {
|
||||
my @filebuffer;
|
||||
|
||||
open(TRANSLATE,'<','DAQ00001.translation') or $translation=0;
|
||||
open(TRANSLATE,'<',$hgtransfile) or $translation=0;
|
||||
while(<TRANSLATE>) {
|
||||
push(@filebuffer,$_);
|
||||
}
|
||||
|
@ -175,8 +191,8 @@ sub HGNanopk_GetUpdate($)
|
|||
$translation=0;
|
||||
}
|
||||
|
||||
if ( -e "DAQ00001.states" ) {
|
||||
open(STATUSCODE,"<","DAQ00001.states" ) or $states=0
|
||||
if ( -e "$hgstatefile" ) {
|
||||
open(STATUSCODE,"<",$hgstatefile ) or $states=0
|
||||
} else {
|
||||
$states=0;
|
||||
}
|
||||
|
@ -199,7 +215,7 @@ sub HGNanopk_GetUpdate($)
|
|||
}
|
||||
}
|
||||
}
|
||||
open(HGDATA,'<','DAQ00001.DAQ') or die "File DAQ00001.DAQ not found in FHEM Root dir";
|
||||
open(HGDATA,'<',$hginfofile) or die "File $hginfofile not found in FHEM Root dir";
|
||||
while (<HGDATA>) {
|
||||
push(@databuff,$_);
|
||||
}
|
||||
|
@ -257,7 +273,7 @@ sub HGNanopk_GetUpdate($)
|
|||
}
|
||||
}
|
||||
if ( $translation eq "0" ) {
|
||||
open(TRANSLATE,'>','DAQ00001.translation') or die "could not open new translation file for Hargassner Module\n";
|
||||
open(TRANSLATE,'>',$hgtransfile) or die "could not open new translation file ($hgtransfile)for Hargassner Module\n";
|
||||
foreach(@HG_HEADER_ANALOG) {
|
||||
my @data=split /;/,$_;
|
||||
if ( $data[1] ne "DUMMY" ) {
|
||||
|
@ -413,13 +429,16 @@ sub HGNanopk_Attr($$$) {
|
|||
<a name="HGNanopk_define"></a>
|
||||
<b>Define</b>
|
||||
<ul>
|
||||
<code>define <name> HGNanopk <hostname> <interval></code>
|
||||
<code>define <name> HGNanopk <hostname> <interval> [<filename;>]</code>
|
||||
<br />
|
||||
<br />
|
||||
<hostname> is the name or ip address of the HGNanopk Pellet Heating.
|
||||
<br />
|
||||
<br />
|
||||
<interval> is the interval in seconds between fhem try to get new data from heating. (e.g. 60)
|
||||
<br />
|
||||
<br />
|
||||
<filename> is a optional parameter for the filename of DAQ00001.DAQ file. <br />If not given the defaultname will be used, else the path/name of this argument. <br /> Attention: there should be no "." char in the pathnames (just one in filename)
|
||||
<br /><br />
|
||||
<b>installation</b>
|
||||
<br />
|
||||
|
@ -450,8 +469,9 @@ sub HGNanopk_Attr($$$) {
|
|||
|
||||
Actual readings vary with the oven and the Software version.
|
||||
<br />
|
||||
the readings are dynamically generated based on the <code>DAQ00001.DAQ</code> file, which must (!) be installed
|
||||
<br /> in the root of your fhem installation.
|
||||
the readings are dynamically generated based on the <code>DAQ00001.DAQ</code> file. per default this
|
||||
<br /> must be installed in the root of your fhem installation. Alternativly use the optional
|
||||
<br /> filename argument in the definition
|
||||
<br />
|
||||
|
||||
</ul>
|
||||
|
|
Loading…
Reference in New Issue