mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 12:49:34 +00:00
- Pest, Mon May 28 19:39:22 MEST 2007
- Added 62_EMEM.pm to support EM1000-EM devices. - doc: Update of commandref.htm (typos and EMEM). git-svn-id: https://svn.fhem.de/fhem/trunk@67 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
43770b4247
commit
85b05ba34d
@ -332,4 +332,4 @@
|
|||||||
- bugfix: deleted FS20 items are still logging (zombie) (Gerhard, 16.5)
|
- bugfix: deleted FS20 items are still logging (zombie) (Gerhard, 16.5)
|
||||||
- bugfix: added FS20S8, removed stty_parmrk (Martin, 24.5)
|
- bugfix: added FS20S8, removed stty_parmrk (Martin, 24.5)
|
||||||
- feature: added archivedir/archivecmd to the FileLog
|
- feature: added archivedir/archivecmd to the FileLog
|
||||||
- feature: added EM1010PC/EM1000WZ support
|
- feature: added EM1010PC/EM1000WZ/EM1000EM support
|
||||||
|
137
fhem/FHEM/62_EMEM.pm
Executable file
137
fhem/FHEM/62_EMEM.pm
Executable file
@ -0,0 +1,137 @@
|
|||||||
|
##############################################
|
||||||
|
package main;
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use Time::HiRes qw(gettimeofday);
|
||||||
|
|
||||||
|
sub EMEM_Get($@);
|
||||||
|
sub EMEM_Set($@);
|
||||||
|
sub EMEM_Define($$);
|
||||||
|
sub EMEM_GetStatus($);
|
||||||
|
|
||||||
|
###################################
|
||||||
|
sub
|
||||||
|
EMEM_Initialize($)
|
||||||
|
{
|
||||||
|
my ($hash) = @_;
|
||||||
|
|
||||||
|
$hash->{GetFn} = "EMEM_Get";
|
||||||
|
$hash->{DefFn} = "EMEM_Define";
|
||||||
|
|
||||||
|
$hash->{AttrList} = "dummy:1,0 model;EM1000EM loglevel:0,1,2,3,4,5,6";
|
||||||
|
}
|
||||||
|
|
||||||
|
###################################
|
||||||
|
sub
|
||||||
|
EMEM_GetStatus($)
|
||||||
|
{
|
||||||
|
my ($hash) = @_;
|
||||||
|
|
||||||
|
if(!$hash->{LOCAL}) {
|
||||||
|
InternalTimer(gettimeofday()+300, "EMEM_GetStatus", $hash);
|
||||||
|
}
|
||||||
|
|
||||||
|
my $dnr = $hash->{DEVNR};
|
||||||
|
my $name = $hash->{NAME};
|
||||||
|
|
||||||
|
my $d = IOWrite($hash, sprintf("7a%02x", $dnr-1));
|
||||||
|
if(!defined($d)) {
|
||||||
|
my $msg = "EMWZ $name read error";
|
||||||
|
Log GetLogLevel($name,2), $msg;
|
||||||
|
return $msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if($d eq ((pack('H*',"00") x 45) . pack('H*',"FF") x 6)) {
|
||||||
|
my $msg = "EMEM no device no. $dnr present";
|
||||||
|
Log GetLogLevel($name,2), $msg;
|
||||||
|
return $msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
my $pulses=w($d,13);
|
||||||
|
my $ec=w($d,49) / 10;
|
||||||
|
if($ec != 0) {
|
||||||
|
my $msg = "EMEM read error";
|
||||||
|
Log GetLogLevel($name,2), $msg;
|
||||||
|
return $msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
my $iec = 1000;
|
||||||
|
my $cur_power = $pulses / 100;
|
||||||
|
|
||||||
|
if($cur_power > 100) {
|
||||||
|
my $msg = "EMEM Bogus reading: curr. power is reported to be $cur_power";
|
||||||
|
Log GetLogLevel($name,2), $msg;
|
||||||
|
return $msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
my %vals;
|
||||||
|
$vals{"5min_pulses"} = $pulses;
|
||||||
|
$vals{"energy"} = sprintf("%0.3f kWh/h", dw($d,33) / $iec);
|
||||||
|
$vals{"power"} = sprintf("%.3f", $cur_power);
|
||||||
|
$vals{"alarm_PA"} = w($d,45) . " Watt";
|
||||||
|
$vals{"price_CF"} = sprintf("%.3f", w($d,47)/10000);
|
||||||
|
$vals{"RperKW_EC"} = $ec;
|
||||||
|
|
||||||
|
my $tn = TimeNow();
|
||||||
|
my $idx = 0;
|
||||||
|
foreach my $k (keys %vals) {
|
||||||
|
my $v = $vals{$k};
|
||||||
|
$hash->{CHANGED}[$idx++] = "$k: $v";
|
||||||
|
$hash->{READINGS}{$k}{TIME} = $tn;
|
||||||
|
$hash->{READINGS}{$k}{VAL} = $v
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!$hash->{LOCAL}) {
|
||||||
|
DoTrigger($name, undef) if($init_done);
|
||||||
|
}
|
||||||
|
|
||||||
|
$hash->{STATE} = "$cur_power kWh";
|
||||||
|
|
||||||
|
return $hash->{STATE};
|
||||||
|
}
|
||||||
|
|
||||||
|
###################################
|
||||||
|
sub
|
||||||
|
EMEM_Get($@)
|
||||||
|
{
|
||||||
|
my ($hash, @a) = @_;
|
||||||
|
|
||||||
|
return "argument is missing" if(int(@a) != 2);
|
||||||
|
|
||||||
|
my $d = $hash->{DEVNR};
|
||||||
|
my $msg;
|
||||||
|
|
||||||
|
if($a[1] ne "status") {
|
||||||
|
return "unknown get value, valid is status";
|
||||||
|
}
|
||||||
|
$hash->{LOCAL} = 1;
|
||||||
|
my $v = EMEM_GetStatus($hash);
|
||||||
|
delete $hash->{LOCAL};
|
||||||
|
|
||||||
|
return "$a[0] $a[1] => $v";
|
||||||
|
}
|
||||||
|
|
||||||
|
#############################
|
||||||
|
sub
|
||||||
|
EMEM_Define($$)
|
||||||
|
{
|
||||||
|
my ($hash, $def) = @_;
|
||||||
|
my @a = split("[ \t][ \t]*", $def);
|
||||||
|
|
||||||
|
return "syntax: define <name> EMEM devicenumber"
|
||||||
|
if(@a != 3 || $a[2] !~ m,^[5-8]$,);
|
||||||
|
$hash->{DEVNR} = $a[2];
|
||||||
|
AssignIoPort($hash);
|
||||||
|
|
||||||
|
|
||||||
|
# InternalTimer blocks if init_done is not true
|
||||||
|
my $oid = $init_done;
|
||||||
|
$init_done = 1;
|
||||||
|
EMEM_GetStatus($hash);
|
||||||
|
$init_done = $oid;
|
||||||
|
return undef;
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
@ -100,3 +100,7 @@
|
|||||||
archive directory. See the attributes archivedir/archivecmd.
|
archive directory. See the attributes archivedir/archivecmd.
|
||||||
- Added EM1010PC suppoort (right now only with EM1000WZ). Support added
|
- Added EM1010PC suppoort (right now only with EM1000WZ). Support added
|
||||||
for displaying logs in the fhemweb.pl (webfrontends/pgm2)
|
for displaying logs in the fhemweb.pl (webfrontends/pgm2)
|
||||||
|
|
||||||
|
- Pest, Mon May 28 19:39:22 MEST 2007
|
||||||
|
- Added 62_EMEM.pm to support EM1000-EM devices.
|
||||||
|
- doc: Update of commandref.htm (typos and EMEM).
|
||||||
|
@ -672,19 +672,38 @@ split in multiple lines<br><br>
|
|||||||
<code>define <name> EMWZ <device-number></code>
|
<code>define <name> EMWZ <device-number></code>
|
||||||
<br><br>
|
<br><br>
|
||||||
|
|
||||||
Define up two 4 EM1000WZ attached to the EM1010PC. The device number must
|
Define up to 4 EM1000WZ attached to the EM1010PC. The device number must
|
||||||
be between 1 and 4 (else you have a differnt device connected to the
|
be between 1 and 4 (else you have a differnt device connected to the
|
||||||
EM1010PC). Defining an EMWZ will schedule an internal task, which reads the
|
EM1010PC). Defining an EMWZ will schedule an internal task, which reads the
|
||||||
status of the device every 5 minutes, and triggers notify/filelog commands.
|
status of the device every 5 minutes, and triggers notify/filelog commands.
|
||||||
<br><br>
|
<br><br>
|
||||||
|
|
||||||
Examples:
|
Example:
|
||||||
<ul>
|
<ul>
|
||||||
<code>define emwz EMWZ 1</code><br>
|
<code>define emwz EMWZ 1</code><br>
|
||||||
</ul>
|
</ul>
|
||||||
<br>
|
<br>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
<a name="EMEM"></a>
|
||||||
|
<h4>Type EMEM</h4>
|
||||||
|
<ul>
|
||||||
|
<code>define <name> EMEM <device-number></code>
|
||||||
|
<br><br>
|
||||||
|
|
||||||
|
Define up to 4 EM1000EM attached to the EM1010PC. The device number must
|
||||||
|
be between 5 and 8.
|
||||||
|
Defining an EMEM will schedule an internal task, which reads the
|
||||||
|
status of the device every 5 minutes, and triggers notify/filelog commands.
|
||||||
|
<br>Note: Currently this device does not support a "set" function.
|
||||||
|
<br><br>
|
||||||
|
|
||||||
|
Example:
|
||||||
|
<ul>
|
||||||
|
<code>define emem EMEM 5</code><br>
|
||||||
|
</ul>
|
||||||
|
<br>
|
||||||
|
</ul>
|
||||||
|
|
||||||
<a name="FileLog"></a>
|
<a name="FileLog"></a>
|
||||||
<h4>Type FileLog</h4>
|
<h4>Type FileLog</h4>
|
||||||
|
@ -11,7 +11,7 @@ attr global logfile /tmp/fhem-%Y-%m.log
|
|||||||
attr global statefile /tmp/fhem.save # where to save the state of the devices
|
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 verbose 3 # "normal" verbosity (min 1, max 5)
|
||||||
attr global port 7072 # our TCP/IP port (localhost only)
|
attr global port 7072 # our TCP/IP port (localhost only)
|
||||||
attr global modpath /usr/local/lib # where our FHEM directory is
|
attr global modpath /usr/local/libusr/local/lib # where our FHEM directory is
|
||||||
|
|
||||||
define FHZ FHZ /dev/tts/USB0 # the serial port of an FHZ 1000 PC
|
define FHZ FHZ /dev/tts/USB0 # the serial port of an FHZ 1000 PC
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ attr global logfile /tmp/fhem-%Y-%m.log
|
|||||||
attr global statefile /tmp/fhem.save # where to save the state of the devices
|
attr global statefile /tmp/fhem.save # where to save the state of the devices
|
||||||
attr global verbose 3 # "normal" verbosity
|
attr global verbose 3 # "normal" verbosity
|
||||||
attr global port 7072 # our TCP/IP port (localhost only)
|
attr global port 7072 # our TCP/IP port (localhost only)
|
||||||
attr global modpath /usr/local/lib # where our FHEM directory is
|
attr global modpath /usr/local/libusr/local/lib # where our FHEM directory is
|
||||||
|
|
||||||
define FHZ FHZ /dev/tts/USB0 # the serial port of an FHZ 1000 PC
|
define FHZ FHZ /dev/tts/USB0 # the serial port of an FHZ 1000 PC
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ attr global logfile /tmp/fhem-%Y-%m.log
|
|||||||
attr global statefile /tmp/fhem.save # where to save the state of the devices
|
attr global statefile /tmp/fhem.save # where to save the state of the devices
|
||||||
attr global verbose 3 # "normal" verbosity
|
attr global verbose 3 # "normal" verbosity
|
||||||
attr global port 7072 # our TCP/IP port (localhost only)
|
attr global port 7072 # our TCP/IP port (localhost only)
|
||||||
attr global modpath /usr/local/lib # where our FHEM directory is
|
attr global modpath /usr/local/libusr/local/lib # where our FHEM directory is
|
||||||
define FHZ FHZ /dev/tts/USB0 # the serial port of an FHZ 1000 PC
|
define FHZ FHZ /dev/tts/USB0 # the serial port of an FHZ 1000 PC
|
||||||
|
|
||||||
define wz FHT 3232 # type FHT, transmitter code 3232 (default value)
|
define wz FHT 3232 # type FHT, transmitter code 3232 (default value)
|
||||||
|
@ -8,7 +8,7 @@ attr global logfile /tmp/fhem-%Y-%m.log
|
|||||||
attr global statefile /tmp/fhem.save # where to save the state of the devices
|
attr global statefile /tmp/fhem.save # where to save the state of the devices
|
||||||
attr global verbose 3 # "normal" verbosity
|
attr global verbose 3 # "normal" verbosity
|
||||||
attr global port 7072 # our TCP/IP port (localhost only)
|
attr global port 7072 # our TCP/IP port (localhost only)
|
||||||
attr global modpath /usr/local/lib # where our FHEM directory is
|
attr global modpath /usr/local/libusr/local/lib # where our FHEM directory is
|
||||||
define FHZ FHZ /dev/tts/USB0 # the serial port of an FHZ 1000 PC
|
define FHZ FHZ /dev/tts/USB0 # the serial port of an FHZ 1000 PC
|
||||||
|
|
||||||
define wz FHT 3232 # type FHT, transmitter code 3232 (default value)
|
define wz FHT 3232 # type FHT, transmitter code 3232 (default value)
|
||||||
|
@ -12,7 +12,7 @@ attr global logfile /tmp/fhem-%Y-%m.log
|
|||||||
attr global statefile /tmp/fhem.save # where to save the state of the devices
|
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 verbose 3 # "normal" verbosity (min 1, max 5)
|
||||||
attr global port 7072 # our TCP/IP port (localhost only)
|
attr global port 7072 # our TCP/IP port (localhost only)
|
||||||
attr global modpath /usr/local/lib # where our FHEM directory is
|
attr global modpath /usr/local/libusr/local/lib # where our FHEM directory is
|
||||||
|
|
||||||
define FHZ FHZ /dev/tts/USB0 # the serial port of an FHZ 1000 PC
|
define FHZ FHZ /dev/tts/USB0 # the serial port of an FHZ 1000 PC
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user