mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 06:39:11 +00:00
FS10 added (from peter)
git-svn-id: https://svn.fhem.de/fhem/trunk@123 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
a333fd213c
commit
aa1e3e5206
166
fhem/FHEM/86_FS10.pm
Normal file
166
fhem/FHEM/86_FS10.pm
Normal file
@ -0,0 +1,166 @@
|
||||
##############################################
|
||||
package main;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Device::SerialPort;
|
||||
use IO::Socket::INET;
|
||||
|
||||
my $fs10data = "";
|
||||
my $pcwsdsocket;
|
||||
|
||||
|
||||
#####################################
|
||||
sub
|
||||
FS10_Initialize($)
|
||||
{
|
||||
my ($hash) = @_;
|
||||
|
||||
# Consumer
|
||||
$hash->{DefFn} = "FS10_Define";
|
||||
$hash->{AttrList}= "model:FS10 loglevel:0,1,2,3,4,5,6";
|
||||
}
|
||||
|
||||
#####################################
|
||||
sub
|
||||
FS10_Define($$)
|
||||
{
|
||||
my ($hash, $def) = @_;
|
||||
my @a = split("[ \t][ \t]*", $def);
|
||||
|
||||
Log 3, "FS10 Define: $a[0] $a[1] $a[2] $a[3]";
|
||||
|
||||
return "Define the host and portnr as a parameter i.e. 127.0.0.1 4711"
|
||||
if(@a != 4);
|
||||
|
||||
$hash->{Timer} = 600;
|
||||
$hash->{Host} = $a[2];
|
||||
$hash->{Port} = $a[3];
|
||||
$hash->{STATE} = "Initialized";
|
||||
|
||||
my $dev = $a[2];
|
||||
Log 1, "FS10 device is none, commands will be echoed only"
|
||||
if($dev eq "none");
|
||||
|
||||
$hash->{DeviceName} = $dev;
|
||||
|
||||
FS10_GetStatus($hash);
|
||||
return undef;
|
||||
}
|
||||
|
||||
|
||||
#####################################
|
||||
sub
|
||||
FS10_GetStatus($)
|
||||
{
|
||||
my ($hash) = @_;
|
||||
my $buf;
|
||||
#my $banner;
|
||||
my $reqcmd;
|
||||
my $fs10time;
|
||||
my $dt;
|
||||
my $x;
|
||||
my $result = "";
|
||||
|
||||
Log 3, "FS10_GetStatus";
|
||||
|
||||
# Call us in 5 minutes again.
|
||||
InternalTimer(gettimeofday()+300, "FS10_GetStatus", $hash, 0);
|
||||
|
||||
my $dnr = $hash->{DEVNR};
|
||||
my $name = $hash->{NAME};
|
||||
my $host = $hash->{Host};
|
||||
my $port = $hash->{Port};
|
||||
my %vals;
|
||||
my $pcwsd ="$host:$port";
|
||||
my $pcwsdsocket = IO::Socket::INET->new( $pcwsd )
|
||||
or return "FS10 Can't bind to pcwsd" if(!$pcwsdsocket);
|
||||
|
||||
my $banner = $pcwsdsocket->getline();
|
||||
my @x = split(" ", $banner);
|
||||
my @y;
|
||||
my $fs10name;
|
||||
|
||||
for(my $i = 0; $i < 8; $i++) #Outdoor
|
||||
{
|
||||
$fs10name ="Ta$i";
|
||||
$reqcmd = "get od2temp $i\r\n";
|
||||
$pcwsdsocket->print($reqcmd);
|
||||
$buf = $pcwsdsocket->getline();
|
||||
$result = "$result $buf";
|
||||
|
||||
@x = split(" ", $buf);
|
||||
$fs10time = FmtDateTime($x[1]);
|
||||
|
||||
$hash->{CHANGED}[$i] = "Ta$i: $x[0]";
|
||||
$hash->{READINGS}{$fs10name}{TIME} = $fs10time;
|
||||
$hash->{READINGS}{$fs10name}{VAL} = $x[0];
|
||||
}
|
||||
|
||||
$fs10name="Ti";
|
||||
$reqcmd = "get idtemp 7\r\n";
|
||||
$pcwsdsocket->print($reqcmd);
|
||||
$buf = $pcwsdsocket->getline();
|
||||
@x = split(" ", $buf);
|
||||
$fs10time = FmtDateTime($x[1]);
|
||||
|
||||
$hash->{CHANGED}[8] = "Ti: $x[0]";
|
||||
$hash->{READINGS}{$fs10name}{TIME} = $fs10time;
|
||||
$hash->{READINGS}{$fs10name}{VAL} = $x[0];
|
||||
|
||||
$fs10name="Rain";
|
||||
$reqcmd = "get rain 7\r\n";
|
||||
$pcwsdsocket->print($reqcmd);
|
||||
$buf = $pcwsdsocket->getline();
|
||||
@x = split(" ", $buf);
|
||||
$fs10time = FmtDateTime($x[1]);
|
||||
|
||||
$hash->{CHANGED}[9] = "Rain: $x[0]";
|
||||
$hash->{READINGS}{$fs10name}{TIME} = $fs10time;
|
||||
$hash->{READINGS}{$fs10name}{VAL} = $x[0];
|
||||
|
||||
$fs10name="Sun";
|
||||
$reqcmd = "get bright 7\r\n";
|
||||
$pcwsdsocket->print($reqcmd);
|
||||
$buf = $pcwsdsocket->getline();
|
||||
@x = split(" ", $buf);
|
||||
$fs10time = FmtDateTime($x[1]);
|
||||
|
||||
$hash->{CHANGED}[10] = "Sun: $x[0]";
|
||||
$hash->{READINGS}{$fs10name}{TIME} = $fs10time;
|
||||
$hash->{READINGS}{$fs10name}{VAL} = $x[0];
|
||||
|
||||
$fs10name="Windspeed";
|
||||
$reqcmd = "get wspd 7\r\n";
|
||||
$pcwsdsocket->print($reqcmd);
|
||||
$buf = $pcwsdsocket->getline();
|
||||
@x = split(" ", $buf);
|
||||
$fs10time = FmtDateTime($x[1]);
|
||||
|
||||
$hash->{CHANGED}[11] = "Windspeed: $x[0]";
|
||||
$hash->{READINGS}{$fs10name}{TIME} = $fs10time;
|
||||
$hash->{READINGS}{$fs10name}{VAL} = $x[0];
|
||||
|
||||
close($pcwsdsocket);
|
||||
|
||||
$result =~ s/[\r\n]//g;
|
||||
DoTrigger($name, undef) if($init_done);
|
||||
|
||||
$hash->{STATE} = "$result";
|
||||
Log 3,"FS10 Result: $result";
|
||||
return $hash->{STATE};
|
||||
}
|
||||
|
||||
#####################################
|
||||
sub
|
||||
FS10Log($$)
|
||||
{
|
||||
my ($a1, $a2) = @_;
|
||||
|
||||
#define n31 notify fs10 {FS10Log("@", "%")}
|
||||
#define here notify action
|
||||
|
||||
Log 2,"FS10 $a1 = $a2 old: $oldvalue{$a1}{TIME}=> $oldvalue{$a1}{VAL});";
|
||||
}
|
||||
|
||||
1;
|
@ -3,8 +3,12 @@
|
||||
http://english.ivt-hirschau.de/content.php?parent_id=CAT_64&doc_id=DOC_118
|
||||
- 80_M232.pm/81_M232Counter.pm
|
||||
Support for the M232 device from ELV by Boris.
|
||||
- 86_FS10.pm
|
||||
Support for FS10. Read README.FS10, you have to install pcwsd first.
|
||||
- 91_DbLog.pm
|
||||
Example to log data in a (DBI supported) database (MySQL, Oracle, etc)
|
||||
- 99_ALARM.pm
|
||||
Example for a Low Budget ALARM System by Martin
|
||||
- 99_SUNRISE.pm
|
||||
The original Sunrise/Sunset support. Uses DateTime::Event::Sunrise. Uses the
|
||||
99_SUNRISE_EL.pm module instead.
|
||||
@ -12,8 +16,6 @@
|
||||
Support foor computins sunrise/sunset times.
|
||||
- 99_Utils.pm
|
||||
skeleton for self-written perl funtions.
|
||||
- 99_ALARM.pm
|
||||
Example for a Low Budget ALARM System by Martin
|
||||
- 99_dummy.pm
|
||||
Used for programming
|
||||
- 99_weblink.pm
|
||||
@ -22,8 +24,8 @@
|
||||
Check header/function/crc of an FS20 hex message
|
||||
- crc.pl
|
||||
Computing CRC16 in perl
|
||||
- em1010.pl
|
||||
Standalone EM1010PC reader program
|
||||
- em1010.pl / em1010.gnuplot
|
||||
Standalone EM1010PC reader program and a gnuplot file to plot em1010 data
|
||||
- init-scripts
|
||||
RC scripts to be put into /etc/init.d and then symlinked to /etc/rc3.d or
|
||||
similar.
|
||||
|
35
fhem/docs/README.FS10
Normal file
35
fhem/docs/README.FS10
Normal file
@ -0,0 +1,35 @@
|
||||
86_FS10.pm is for reading ELV (www.elv.de) weather Sensors, using a Hardware
|
||||
(Part No. 68-390-61) and communicates with pcwsd from Sven Geggus.
|
||||
|
||||
Currently temperature, windspeed, rain and brightness sensors are supported.
|
||||
|
||||
For use with FHEM you have to compile pcwsd like usual, it can be found here
|
||||
http://geggus.net/sven/pcwsd/
|
||||
|
||||
Start pcwsd deamon with pcwsd -d /dev/ttyUSB4 -ld /var/log/fs10-
|
||||
A few minutes later you should see files with temperature values.
|
||||
|
||||
For use with FHEM define
|
||||
|
||||
define fs10 FS10 127.0.0.1 4711 which means pcwsd run on localhost, port 4711
|
||||
|
||||
If you only interested in viewing temperature values with a FHEM frontend like
|
||||
pgm3, 86_FS10.pm can be ommited.
|
||||
|
||||
To display a user defined FS10 temperature graphic in pgm3 define
|
||||
|
||||
########################
|
||||
#
|
||||
$sortnumber=7;
|
||||
$userdef[$sortnumber]['name']='IndoorTemp';
|
||||
$userdef[$sortnumber]['valuefield']=2;
|
||||
$userdef[$sortnumber]['gnuplottype']='temperature';
|
||||
$userdef[$sortnumber]['logpath']='/var/log/fs10/idtemp_7.gnu';
|
||||
$userdef[$sortnumber]['room']='indoor';
|
||||
$userdef[$sortnumber]['semlong']='Temp indor';
|
||||
$userdef[$sortnumber]['semshort']='°';
|
||||
$userdef[$sortnumber]['imagemax']=725;
|
||||
$userdef[$sortnumber]['imagemay']=52;
|
||||
$userdef[$sortnumber]['maxcount']=575;
|
||||
$userdef[$sortnumber]['XcorrectMainText']=25;
|
||||
$userdef[$sortnumber]['logrotatelines']=2050;
|
13
fhem/fhem.pl
13
fhem/fhem.pl
@ -56,6 +56,8 @@ sub ResolveDateWildcards($@);
|
||||
sub SemicolonEscape($);
|
||||
sub SignalHandling();
|
||||
sub TimeNow();
|
||||
sub FmtDateTime($);
|
||||
sub FmtTime($);
|
||||
sub WriteStatefile();
|
||||
sub XmlEscape($);
|
||||
sub fhem($);
|
||||
@ -135,7 +137,7 @@ my %intAt; # Internal at timer hash.
|
||||
my $intAtCnt=0;
|
||||
my $reread_active = 0;
|
||||
my $AttrList = "room comment";
|
||||
my $cvsid = '$Id: fhem.pl,v 1.31 2007-11-27 15:17:47 rudolfkoenig Exp $';
|
||||
my $cvsid = '$Id: fhem.pl,v 1.32 2007-12-13 15:26:27 rudolfkoenig Exp $';
|
||||
|
||||
$init_done = 0;
|
||||
|
||||
@ -1523,6 +1525,15 @@ TimeNow()
|
||||
$t[5]+1900, $t[4]+1, $t[3], $t[2], $t[1], $t[0]);
|
||||
}
|
||||
|
||||
#####################################
|
||||
sub
|
||||
FmtDateTime($)
|
||||
{
|
||||
my @t = localtime(shift);
|
||||
return sprintf("%04d-%02d-%02d %02d:%02d:%02d",
|
||||
$t[5]+1900, $t[4]+1, $t[3], $t[2], $t[1], $t[0]);
|
||||
}
|
||||
|
||||
sub
|
||||
FmtTime($)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user