mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-12 16:46:35 +00:00
git-svn-id: https://svn.fhem.de/fhem/trunk@1383 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
39872762b2
commit
30310e6664
@ -6,7 +6,7 @@
|
||||
# via an active DS2480/DS2490/DS9097U bus master interface or
|
||||
# via a passive DS9097 interface
|
||||
#
|
||||
# Version 1.09 - March, 2012
|
||||
# Version 1.10 - March, 2012
|
||||
#
|
||||
# Prof. Dr. Peter A. Henning, 2012
|
||||
#
|
||||
@ -118,7 +118,7 @@ sub OWX_Initialize ($) {
|
||||
my ($hash) = @_;
|
||||
#-- Provider
|
||||
#$hash->{Clients} = ":OWCOUNT:OWHUB:OWLCD:OWMULTI:OWSWITCH:OWTEMP:";
|
||||
$hash->{Clients} = ":OWAD:OWID:OWTEMP:";
|
||||
$hash->{Clients} = ":OWAD:OWID:OWLCD:OWTEMP:";
|
||||
|
||||
#-- Normal Devices
|
||||
$hash->{DefFn} = "OWX_Define";
|
||||
@ -313,7 +313,10 @@ sub OWX_Define ($$) {
|
||||
my ($hash, $def) = @_;
|
||||
my @a = split("[ \t][ \t]*", $def);
|
||||
|
||||
if(@a == 3){
|
||||
if(int(@a) >= 3){
|
||||
#-- check syntax
|
||||
Log 1,"OWX: Warning - Some parameter(s) ignored, must be define <name> OWX"
|
||||
if(int(@a) > 3);
|
||||
#-- If this line contains 3 parameters, it is the bus master definition
|
||||
my $dev = $a[2];
|
||||
$hash->{DeviceName} = $dev;
|
||||
@ -366,7 +369,10 @@ sub OWX_Define ($$) {
|
||||
$init_done = $oid;
|
||||
$hash->{STATE} = "Active";
|
||||
return undef;
|
||||
}
|
||||
} else {
|
||||
#-- check syntax
|
||||
return "OWX: Syntax error - must be define <name> OWX"
|
||||
}
|
||||
}
|
||||
|
||||
########################################################################################
|
||||
@ -402,7 +408,7 @@ sub OWX_Detect ($) {
|
||||
#Log 1, $ress;
|
||||
|
||||
#-- process 4/5-byte string for detection
|
||||
if( $res eq "\x16\x44\x5A\x00\x93"){
|
||||
if( ($res eq "\x16\x44\x5A\x00\x90") || ($res eq "\x16\x44\x5A\x00\x93")){
|
||||
Log 1, "OWX: 1-Wire bus master DS2480 detected for the first time";
|
||||
$owx_interface="DS2480";
|
||||
$ret=1;
|
||||
@ -482,15 +488,26 @@ sub OWX_Discover ($) {
|
||||
#-- all OW types start with OW
|
||||
next if( substr($main::defs{$fhem_dev}{TYPE},0,2) ne "OW");
|
||||
my $id_fhem = substr($main::defs{$fhem_dev}{ROM_ID},0,15);
|
||||
#-- testing if present in defined devices
|
||||
if( $id_fhem eq $id_owx ){
|
||||
#-- skip interface device
|
||||
next if( length($id_fhem) != 15 );
|
||||
#-- testing if present in defined devices
|
||||
# even with improper family
|
||||
#print " FHEM-Device = ".substr($id_fhem,3,12)." OWX discovered device ".substr($id_owx,3,12)."\n";
|
||||
if( substr($id_fhem,3,12) eq substr($id_owx,3,12) ) {
|
||||
#-- warn if improper family id
|
||||
if( substr($id_fhem,0,2) ne substr($id_owx,0,2) ){
|
||||
Log 1, "OWX: Warning, $fhem_dev is defined with improper family id ".substr($id_fhem,0,2).
|
||||
", correcting to ".substr($id_owx,0,2);
|
||||
$main::defs{$fhem_dev}{OW_FAMILY} = substr($id_owx,0,2);
|
||||
}
|
||||
push(@owx_names,$main::defs{$fhem_dev}{NAME});
|
||||
#-- replace the ROM ID by the proper value
|
||||
#-- replace the ROM ID by the proper value including CRC
|
||||
$main::defs{$fhem_dev}{ROM_ID}=$owx_dev;
|
||||
$main::defs{$fhem_dev}{PRESENT}=1;
|
||||
$main::defs{$fhem_dev}{PRESENT}=1;
|
||||
$match = 1;
|
||||
last;
|
||||
}
|
||||
#
|
||||
}
|
||||
|
||||
#-- autocreate the device
|
||||
@ -508,7 +525,10 @@ sub OWX_Discover ($) {
|
||||
CommandDefine(undef,"$name OWTEMP DS1822 $owx_rnf");
|
||||
#-- Family 10 28 = Temperature sensor, assume DS18B20 as default
|
||||
}elsif( $owx_f eq "28" ){
|
||||
CommandDefine(undef,"$name OWTEMP DS18B20 $owx_rnf");
|
||||
CommandDefine(undef,"$name OWTEMP DS18B20 $owx_rnf");
|
||||
#-- Family FF = LCD display
|
||||
}elsif( $owx_f eq "FF" ){
|
||||
CommandDefine(undef,"$name OWLCD $owx_rnf");
|
||||
#-- All unknown families are ID only
|
||||
} else {
|
||||
CommandDefine(undef,"$name OWID $owx_f $owx_rnf");
|
||||
|
@ -14,7 +14,7 @@
|
||||
#
|
||||
# Prof. Dr. Peter A. Henning, 2012
|
||||
#
|
||||
# Version 1.09 - March, 2012
|
||||
# Version 1.10 - March, 2012
|
||||
#
|
||||
# Setup bus device in fhem.cfg as
|
||||
#
|
||||
@ -206,13 +206,13 @@ sub OWAD_Define ($$) {
|
||||
}
|
||||
|
||||
#-- 1-Wire ROM identifier in the form "FF.XXXXXXXXXXXX.YY"
|
||||
# YY must be determined from id
|
||||
$crc = sprintf("%02x",OWX_CRC("20.".$id."00"));
|
||||
# determine CRC Code - only if this is a direct interface
|
||||
$crc = defined($hash->{IODev}->{INTERFACE}) ? sprintf("%02x",OWX_CRC("20.".$id."00")) : "00";
|
||||
|
||||
#-- Define device internals
|
||||
$hash->{ROM_ID} = "20.".$id.$crc;
|
||||
$hash->{OW_ID} = $id;
|
||||
$hash->{OW_FAMILY} = 20;
|
||||
$hash->{OW_FAMILY} = "20";
|
||||
$hash->{PRESENT} = 0;
|
||||
$hash->{INTERVAL} = $interval;
|
||||
|
||||
@ -300,7 +300,9 @@ sub OWAD_InitializeDevice($) {
|
||||
my $interface= $hash->{IODev}->{TYPE};
|
||||
|
||||
#-- OWX interface
|
||||
if( $interface eq "OWX" ){
|
||||
if( !defined($interface) ){
|
||||
return "OWAD: Interface missing";
|
||||
} elsif( $interface eq "OWX" ){
|
||||
OWXAD_SetPage($hash,"alarm");
|
||||
OWXAD_SetPage($hash,"status");
|
||||
#-- OWFS interface
|
||||
@ -957,9 +959,6 @@ sub OWXAD_SetPage($$) {
|
||||
|
||||
my ($hash,$page) = @_;
|
||||
|
||||
#-- For now, switch on conversion command
|
||||
my $con=1;
|
||||
|
||||
my ($select, $res, $res2, $res3, @data);
|
||||
|
||||
#-- ID of the device
|
||||
@ -982,7 +981,7 @@ sub OWXAD_SetPage($$) {
|
||||
}
|
||||
|
||||
#=============== set the alarm values ===============================
|
||||
if ( $page eq "alarm" ) {
|
||||
if ( $page eq "test" ) {
|
||||
#-- issue the match ROM command \x55 and the set alarm page command
|
||||
# \x55\x10\x00 reading 8 data bytes and 2 CRC bytes
|
||||
$select=sprintf("\x55%c%c%c%c%c%c%c%c\x55\x10\x00",
|
||||
@ -990,7 +989,6 @@ sub OWXAD_SetPage($$) {
|
||||
for( $i=0;$i<4;$i++){
|
||||
$select .= sprintf "%c\xFF\xFF\xFF",int($owg_vlow[$i]*255000/$owg_range[$i]);
|
||||
$select .= sprintf "%c\xFF\xFF\xFF",int($owg_vhigh[$i]*255000/$owg_range[$i]);
|
||||
#print "XXXXXX> Setting alarm values to ".int($owg_vlow[$i]*255000/$owg_range[$i])." ".int($owg_vhigh[$i]*255000/$owg_range[$i])."\n";
|
||||
}
|
||||
#=============== set the status ===============================
|
||||
} elsif ( $page eq "status" ) {
|
||||
@ -1015,9 +1013,8 @@ sub OWXAD_SetPage($$) {
|
||||
}
|
||||
$select .= sprintf "%c\xFF\xFF\xFF",$sb1;
|
||||
$select .= sprintf "%c\xFF\xFF\xFF",$sb2;
|
||||
#print "YYYYYYYYYYY>setting status bytes $sb1 $sb2\n";
|
||||
}
|
||||
#=============== wrong value requested ===============================
|
||||
#=============== wrong pag ewrit eattempt ===============================
|
||||
} else {
|
||||
return "OWXAD: Wrong memory page write attempt";
|
||||
}
|
||||
@ -1027,7 +1024,7 @@ sub OWXAD_SetPage($$) {
|
||||
|
||||
#-- process results
|
||||
if( $res eq 0 ){
|
||||
return "OWXAD: Device $owx_dev not accessible for initialization";
|
||||
return "OWXAD: Device $owx_dev not accessible for writing";
|
||||
}
|
||||
|
||||
return undef;
|
||||
|
@ -12,7 +12,7 @@
|
||||
#
|
||||
# Prof. Dr. Peter A. Henning, 2012
|
||||
#
|
||||
# Version 1.09 - March, 2012
|
||||
# Version 1.10 - March, 2012
|
||||
#
|
||||
# Setup bus device in fhem.cfg as
|
||||
#
|
||||
@ -109,7 +109,7 @@ sub OWID_Define ($$) {
|
||||
$ret = "";
|
||||
|
||||
#-- check syntax
|
||||
return "OWID: Wrong syntax, must be define <name> OWID <id>"
|
||||
return "OWID: Wrong syntax, must be define <name> OWID <fam> <id>"
|
||||
if(int(@a) !=4 );
|
||||
|
||||
#-- check id
|
||||
@ -125,8 +125,8 @@ sub OWID_Define ($$) {
|
||||
}
|
||||
|
||||
#-- 1-Wire ROM identifier in the form "FF.XXXXXXXXXXXX.YY"
|
||||
# YY must be determined from id
|
||||
$crc = sprintf("%02x",OWX_CRC($fam.".".$id."00"));
|
||||
# determine CRC Code YY - only if this is a direct interface
|
||||
$crc = defined($hash->{IODev}->{INTERFACE}) ? sprintf("%02x",OWX_CRC($fam.".".$id."00")) : "00";
|
||||
|
||||
#-- Define device internals
|
||||
$hash->{ROM_ID} = $fam.".".$id.$crc;
|
||||
|
@ -13,10 +13,10 @@
|
||||
# OWFS = 1-Wire file system (Martin Fischer)
|
||||
# OWX = 1-Wire bus master interface (Peter Henning)
|
||||
#
|
||||
# Martin Fischer, 2011
|
||||
# Prof. Dr. Peter A. Henning, 2012
|
||||
# Martin Fischer, 2011
|
||||
#
|
||||
# Version 1.09 - March, 2012
|
||||
# Version 1.10 - March, 2012
|
||||
#
|
||||
# Setup bus device in fhem.cfg as
|
||||
#
|
||||
@ -69,9 +69,6 @@
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
########################################################################################
|
||||
#
|
||||
# TODO: offset in alarm values
|
||||
#
|
||||
package main;
|
||||
|
||||
#-- Prototypes to make komodo happy
|
||||
@ -190,11 +187,11 @@ sub OWTEMP_Define ($$) {
|
||||
# FF = family id follows from the model
|
||||
# YY must be determined from id
|
||||
if( $model eq "DS1820" ){
|
||||
$fam = 10;
|
||||
$fam = "10";
|
||||
}elsif( $model eq "DS1822" ){
|
||||
$fam = 22;
|
||||
$fam = "22";
|
||||
}elsif( $model eq "DS18B20" ){
|
||||
$fam = 28;
|
||||
$fam = "28";
|
||||
}else{
|
||||
return "OWTEMP: Wrong 1-Wire device model $model";
|
||||
}
|
||||
|
@ -14,9 +14,8 @@
|
||||
# where nt5000 may be replaced by any name string and <device>
|
||||
# is a serial (USB) device or the keyword "emulator".
|
||||
# In the latter case, a 4.5 kWP solar installation is simulated
|
||||
#
|
||||
# Attributes are set as (examples !)
|
||||
#
|
||||
# Additional attributes are defined in fhem.cfg as
|
||||
# attr nt5000 room Solaranlage
|
||||
# Area of solar installation
|
||||
# attr nt5000 Area 32.75
|
||||
@ -63,14 +62,14 @@ use strict;
|
||||
use warnings;
|
||||
use Device::SerialPort;
|
||||
|
||||
# Prototypes to make komodo happy
|
||||
#-- Prototypes to make komodo happy
|
||||
use vars qw{%attr %defs};
|
||||
sub Log($$);
|
||||
|
||||
# Line counter
|
||||
#-- Line counter
|
||||
my $cline=0;
|
||||
|
||||
# These we may get on request
|
||||
#-- These we may get on request
|
||||
my %gets = (
|
||||
"reading" => "R",
|
||||
"month" => "M",
|
||||
@ -79,12 +78,12 @@ my %gets = (
|
||||
"proto" => "P"
|
||||
);
|
||||
|
||||
# These occur in a pulldown menu as settable values
|
||||
#-- These occur in a pulldown menu as settable values
|
||||
my %sets = (
|
||||
"time" => "T"
|
||||
);
|
||||
|
||||
# These we may get on request
|
||||
#-- These we may get on request
|
||||
my %attrs = (
|
||||
"Wyx" => "R",
|
||||
);
|
||||
@ -113,7 +112,10 @@ sub NT5000_Initialize ($) {
|
||||
# which is the following one.
|
||||
# WxM1 .. WxM12 = Expected yield from January .. December
|
||||
# WxY = Expected yield per year
|
||||
$hash->{AttrList}= "Area PSP MERR Wx_M1 Wx_M2 Wx_M3 Wx_M4 Wx_M5 Wx_M6 Wx_M7 Wx_M8 Wx_M9 Wx_M10 Wx_M11 Wx_M12 Wx_Y loglevel:0,1,2,3,4,5,6";
|
||||
$hash->{AttrList}= "Area PSP MERR ".
|
||||
"Wx_M1 Wx_M2 Wx_M3 Wx_M4 Wx_M5 Wx_M6 Wx_M7 Wx_M8 Wx_M9 Wx_M10 Wx_M11 Wx_M12 ".
|
||||
"Wx_Y ".
|
||||
"loglevel:0,1,2,3,4,5,6";
|
||||
}
|
||||
|
||||
#######################################################################################
|
||||
@ -152,22 +154,16 @@ sub NT5000_Define($$) {
|
||||
|
||||
}
|
||||
|
||||
$hash->{DeviceName} = $dev;
|
||||
$hash->{Timer} = 60; # call every 60 seconds
|
||||
$hash->{Cmd} = "reading"; # get all data, min/max unchange
|
||||
$hash->{DeviceName} = $dev;
|
||||
$hash->{Timer} = 60; # call every 60 seconds
|
||||
$hash->{Cmd} = "reading"; # get all data, min/max unchange
|
||||
$hash->{SerialNumber} = "";
|
||||
$hash->{Protocol} = "";
|
||||
$hash->{Firmware} = "";
|
||||
$hash->{STATE} = "offline";
|
||||
$hash->{Protocol} = "";
|
||||
$hash->{Firmware} = "";
|
||||
$hash->{STATE} = "offline";
|
||||
my $tn = TimeNow();
|
||||
#$hash->{READINGS}{"freq"}{TIME} = $tn;
|
||||
#$hash->{READINGS}{"freq"}{VAL} = $hash->{Timer};
|
||||
#$hash->{READINGS}{"cmd"}{TIME} = $tn;
|
||||
#$hash->{READINGS}{"cmd"}{VAL} = $hash->{Cmd};
|
||||
#$hash->{CHANGED}[$main::cline++] = "freq: $hash->{Timer}";
|
||||
#$hash->{CHANGED}[$main::cline++] = "cmd: $hash->{Cmd}";
|
||||
|
||||
# InternalTimer blocks if init_done is not true
|
||||
#-- InternalTimer blocks if init_done is not true
|
||||
my $oid = $init_done;
|
||||
$init_done = 1;
|
||||
NT5000_GetStatus($hash);
|
||||
@ -303,7 +299,7 @@ sub NT5000_GetStatus ($) {
|
||||
my $tn = TimeNow();
|
||||
my @names = ("Udc", "Idc", "Pdc", "Uac", "Iac", "Pac", "Temp", "S", "Wd", "Wtot", "Eta");
|
||||
|
||||
if( $hash->{STATE} ne "online" ) {
|
||||
if( !($hash->{STATE} =~ m/.*kW/) ) {
|
||||
# we have turned online recently
|
||||
Log GetLogLevel($name,2), "NT5000 inverter is online";
|
||||
$hash->{STATE} = "starting";
|
||||
@ -315,8 +311,8 @@ sub NT5000_GetStatus ($) {
|
||||
my $proto = NT5000_GetLine($hash, "proto");
|
||||
$proto =~ s/^.*P://;
|
||||
$proto =~ s/[\r\n ]//g;
|
||||
$hash->{Protocol} = substr($proto,0,1).".".substr($proto,1,1);
|
||||
$hash->{Firmware} = substr($proto,2,1).".".substr($proto,4,2);
|
||||
$hash->{Firmware} = substr($proto,0,1).".".substr($proto,1,1);
|
||||
$hash->{Protocol} = substr($proto,2,1).".".substr($proto,4,2);
|
||||
|
||||
# Obtain monthly readings in 70 seconds - only once
|
||||
InternalTimer(gettimeofday()+ 20, "NT5000_GetMonth", $hash,1);
|
||||
@ -331,11 +327,7 @@ sub NT5000_GetStatus ($) {
|
||||
}
|
||||
$hash->{CHANGED}[$main::cline++] = "$resmod";
|
||||
};
|
||||
|
||||
$hash->{STATE} = "online";
|
||||
#$result =~ s/^.*R://;
|
||||
#$result =~ s/[\r\n ]//g;
|
||||
#$result=~ s/,/./g;
|
||||
|
||||
#-- Log level 5
|
||||
Log GetLogLevel($name,5), "NT5000 online result = $result";
|
||||
|
||||
@ -346,10 +338,11 @@ sub NT5000_GetStatus ($) {
|
||||
|
||||
#-- split result for writing into hash
|
||||
my @data = split(' ',$result);
|
||||
$hash->{STATE} = sprintf("%5.3f kW",$data[5]);
|
||||
for(my $i = 0; $i < int(@names); $i++) {
|
||||
# This puts individual pairs into the tabular view
|
||||
$hash->{READINGS}{$names[$i]}{TIME} = $tn;
|
||||
$hash->{READINGS}{$names[$i]}{VAL} = $data[$i];
|
||||
$hash->{READINGS}{$names[$i]}{TIME} = $tn;
|
||||
}
|
||||
|
||||
DoTrigger($name, undef) if($init_done);
|
||||
|
Loading…
x
Reference in New Issue
Block a user