mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-10 03:06:37 +00:00
Minor Fixes
git-svn-id: https://svn.fhem.de/fhem/trunk@1319 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
f94707cbfc
commit
befb64d650
@ -6,11 +6,11 @@
|
||||
# via an active DS2480/DS2490/DS9097U bus master interface or
|
||||
# via a passive DS9097 interface
|
||||
#
|
||||
# Version 1.02 - February 29, 2012
|
||||
# Version 1.04 - March, 2012
|
||||
#
|
||||
# Prof. Dr. Peter A. Henning, 2011
|
||||
# Prof. Dr. Peter A. Henning, 2012
|
||||
#
|
||||
# Setup bus master as:
|
||||
# Setup interface as:
|
||||
# define <name> OWX <device>
|
||||
#
|
||||
# where <name> may be replaced by any name string
|
||||
@ -22,7 +22,7 @@
|
||||
# set interval => set period for temperature conversion and alarm testing
|
||||
#
|
||||
# attr <name> buspower real/parasitic - whether the 1-Wire bus is really powered or
|
||||
# the devices take their power from the data wire (parasitic is default !)
|
||||
# the 1-Wire devices take their power from the data wire (parasitic is default !)
|
||||
#
|
||||
# Ordering of subroutines in this module
|
||||
# 1. Subroutines independent of bus interface type
|
||||
@ -499,7 +499,7 @@ sub OWX_Discover ($) {
|
||||
CommandDefine(undef,"$name OWAD DS2450 $owx_rnf");
|
||||
#-- All unknown families are ID only
|
||||
} else {
|
||||
CommandDefine(undef,"$name OWID $owx_rnf");
|
||||
CommandDefine(undef,"$name OWID $owx_f $owx_rnf");
|
||||
}
|
||||
#-- yes, it is on the bus and therefore present
|
||||
push(@owx_names,$name);
|
||||
@ -605,7 +605,7 @@ sub OWX_Kick($) {
|
||||
OWX_Reset($hash);
|
||||
|
||||
#-- Only if we have real power on the bus
|
||||
if( defined($attr{$hash->{NAME}}{buspower}) || ($attr{$hash->{NAME}}{buspower} eq "real") ){
|
||||
if( defined($attr{$hash->{NAME}}{buspower}) && ($attr{$hash->{NAME}}{buspower} eq "real") ){
|
||||
#-- issue the skip ROM command \xCC followed by start conversion command \x44
|
||||
$ret = OWX_Block($hash,"\xCC\x44");
|
||||
if( $ret eq 0 ){
|
||||
@ -959,17 +959,7 @@ sub OWX_Query_2480 ($$) {
|
||||
my ($i,$j,$k);
|
||||
my $dev = $hash->{DeviceName};
|
||||
|
||||
#Log 3, "OWX opening device $dev";
|
||||
#my $owx_serport = new Device::SerialPort ($dev);
|
||||
#return "OWX: Can't open $dev: $!" if(!$owx_serport);
|
||||
#Log 4, "OWX: Opened device $dev";
|
||||
|
||||
#$owx_serport->reset_error();
|
||||
$owx_serport->baudrate($owx_baud);
|
||||
#$owx_serport->databits(8) || die "failed setting databits";
|
||||
#$owx_serport->parity('none') || die "failed setting parity";
|
||||
#$owx_serport->stopbits(1) || die "failed setting stopbits";
|
||||
#$owx_serport->handshake('none') || die "failed setting handshake";
|
||||
$owx_serport->write_settings;
|
||||
|
||||
if( $owx_debug > 1){
|
||||
@ -1248,19 +1238,8 @@ sub OWX_Query_9097 ($$) {
|
||||
my ($hash,$cmd) = @_;
|
||||
my ($i,$j,$k);
|
||||
my $dev = $hash->{DeviceName};
|
||||
|
||||
|
||||
#Log 3, "OWX opening device $dev";
|
||||
#my $owx_serport = new Device::SerialPort ($dev);
|
||||
#return "OWX: Can't open $dev: $!" if(!$owx_serport);
|
||||
#Log 4, "OWX: Opened device $dev";
|
||||
|
||||
#$owx_serport->reset_error();
|
||||
$owx_serport->baudrate($owx_baud);
|
||||
#$owx_serport->databits(8) || die "failed setting databits";
|
||||
#$owx_serport->parity('none') || die "failed setting parity";
|
||||
#$owx_serport->stopbits(1) || die "failed setting stopbits";
|
||||
#$owx_serport->handshake('none') || die "failed setting handshake";
|
||||
$owx_serport->write_settings;
|
||||
|
||||
if( $owx_debug > 1){
|
||||
@ -1508,7 +1487,7 @@ sub OWX_TouchByte_9097 ($$) {
|
||||
for( $loop=0; $loop < 8; $loop++ ){
|
||||
#-- shift result to get ready for the next bit
|
||||
$result >>=1;
|
||||
#-- if sending a 1 then read a bit else write a 0
|
||||
#-- if sending a 1 then read a bit else write 0
|
||||
if( $byte & 0x01 ){
|
||||
if( OWX_ReadBit_9097($hash) ){
|
||||
$result |= 0x80;
|
||||
|
@ -14,7 +14,7 @@
|
||||
#
|
||||
# Prof. Dr. Peter A. Henning, 2012
|
||||
#
|
||||
# Version 1.03 - March, 2012
|
||||
# Version 1.04 - March, 2012
|
||||
#
|
||||
# Setup bus device in fhem.cfg as
|
||||
# define <name> OWAD [<model>] <ROM_ID> [interval]
|
||||
@ -27,12 +27,12 @@
|
||||
# without Family ID, e.g. A2D90D000800
|
||||
# [interval] is an optional query interval in seconds
|
||||
#
|
||||
# Additional attributes are defined in fhem.cfg as
|
||||
# Additional attributes are defined in fhem.cfg per channel, where <channel>=A,B,C,D
|
||||
#
|
||||
# attr <name> <channel>Name string = a name for the channel, where <channel>=A,B,C,D
|
||||
# attr <name> <channel>Name <string> = a name for the channel
|
||||
# attr <name> <channel>Offset <float> = an offset added to the reading in this channel
|
||||
# attr <name> <channel>Factor <float> = a factor multiplied to (reading+offset) in this channel
|
||||
# attr <name> <channel>Unit <string> = a scale description for this channel
|
||||
# attr <name> <channel>Unit <string> = a unit of measurement for this channel
|
||||
#
|
||||
########################################################################################
|
||||
#
|
||||
@ -129,10 +129,10 @@ sub OWAD_Initialize ($) {
|
||||
my $attlist = "IODev do_not_notify:0,1 showtime:0,1 model:DS2450 loglevel:0,1,2,3,4,5 ".
|
||||
"channels ";
|
||||
for( my $i=0;$i<4;$i++ ){
|
||||
$attlist .= " ".$owg_fixed[$i]."name";
|
||||
$attlist .= " ".$owg_fixed[$i]."offset";
|
||||
$attlist .= " ".$owg_fixed[$i]."factor";
|
||||
$attlist .= " ".$owg_fixed[$i]."unit";
|
||||
$attlist .= " ".$owg_fixed[$i]."Name";
|
||||
$attlist .= " ".$owg_fixed[$i]."Offset";
|
||||
$attlist .= " ".$owg_fixed[$i]."Factor";
|
||||
$attlist .= " ".$owg_fixed[$i]."Unit";
|
||||
}
|
||||
$hash->{AttrList} = $attlist;
|
||||
}
|
||||
@ -241,8 +241,8 @@ sub OWAD_InitializeDevice($) {
|
||||
my $name = $hash->{NAME};
|
||||
#-- name attribute present ?
|
||||
for( my $i=0;$i<4;$i++) {
|
||||
if( defined($attr{$name}{$owg_fixed[$i]."name"}) ){
|
||||
$owg_channel[$i]= $attr{$name}{$owg_fixed[$i]."name"};
|
||||
if( defined($attr{$name}{$owg_fixed[$i]."Name"}) ){
|
||||
$owg_channel[$i]= $attr{$name}{$owg_fixed[$i]."Name"};
|
||||
}
|
||||
}
|
||||
|
||||
@ -341,8 +341,8 @@ sub OWAD_Get($@) {
|
||||
|
||||
for (my $i=0;$i<4;$i++){
|
||||
#-- correct values for proper offset, factor
|
||||
$offset = $attr{$name}{$owg_fixed[$i]."offset"};
|
||||
$factor = $attr{$name}{$owg_fixed[$i]."factor"};
|
||||
$offset = $attr{$name}{$owg_fixed[$i]."Offset"};
|
||||
$factor = $attr{$name}{$owg_fixed[$i]."Factor"};
|
||||
$owg_val[$i] += $offset if ($offset );
|
||||
$owg_val[$i] *= $factor if ($factor );
|
||||
|
||||
@ -377,8 +377,8 @@ sub OWAD_Get($@) {
|
||||
|
||||
for (my $i=0;$i<4;$i++){
|
||||
#-- correct alarm values for proper offset, factor
|
||||
$offset = $attr{$name}{$owg_fixed[$i]."offset"};
|
||||
$factor = $attr{$name}{$owg_fixed[$i]."factor"};
|
||||
$offset = $attr{$name}{$owg_fixed[$i]."Offset"};
|
||||
$factor = $attr{$name}{$owg_fixed[$i]."Factor"};
|
||||
$owg_low[$i] += $offset if ($offset );
|
||||
$owg_low[$i] *= $factor if ($factor );
|
||||
$owg_high[$i] += $offset if ($offset );
|
||||
@ -494,8 +494,8 @@ sub OWAD_GetValues($@) {
|
||||
|
||||
for (my $i=0;$i<4;$i++){
|
||||
#-- correct values for proper offset, factor
|
||||
$offset = $attr{$name}{$owg_fixed[$i]."offset"};
|
||||
$factor = $attr{$name}{$owg_fixed[$i]."factor"};
|
||||
$offset = $attr{$name}{$owg_fixed[$i]."Offset"};
|
||||
$factor = $attr{$name}{$owg_fixed[$i]."Factor"};
|
||||
$owg_val[$i] += $offset if ($offset );
|
||||
$owg_val[$i] *= $factor if ($factor );
|
||||
#-- correct alarm values for proper offset, factor
|
||||
@ -644,8 +644,8 @@ sub OWAD_Set($@) {
|
||||
return "OWAD: Set with wrong IODev type $interface";
|
||||
}
|
||||
}elsif( $key =~ m/(.*)(Low|High)/ ) {
|
||||
$offset = $attr{$name}{$owg_fixed[$channo]."offset"};
|
||||
$factor = $attr{$name}{$owg_fixed[$channo]."factor"};
|
||||
$offset = $attr{$name}{$owg_fixed[$channo]."Offset"};
|
||||
$factor = $attr{$name}{$owg_fixed[$channo]."Factor"};
|
||||
|
||||
#-- find upper and lower boundaries for given offset/factor
|
||||
my $mmin = 0.0;
|
||||
|
@ -2,7 +2,7 @@
|
||||
#
|
||||
# OWID.pm
|
||||
#
|
||||
# FHEM module to commmunicate with 1-Wire ID-ROMS
|
||||
# FHEM module to commmunicate with general 1-Wire ID-ROMS
|
||||
#
|
||||
# Attention: This module may communicate with the OWX module,
|
||||
# but currently not with the 1-Wire File System OWFS
|
||||
@ -12,14 +12,15 @@
|
||||
#
|
||||
# Prof. Dr. Peter A. Henning, 2012
|
||||
#
|
||||
# Version 1.03 - March, 2012
|
||||
# Version 1.04 - March, 2012
|
||||
#
|
||||
# Setup bus device in fhem.cfg as
|
||||
# define <name> OWID [<model>] <ROM_ID>
|
||||
# define <name> OWID <FAM_ID> <ROM_ID>
|
||||
#
|
||||
# where <name> may be replaced by any name string
|
||||
#
|
||||
# <model> is a 1-Wire device type. If omitted, we assume this to be a DS2502
|
||||
#
|
||||
# <FAM_ID> is a 2 character (1 byte) 1-Wire Family ID
|
||||
#
|
||||
# <ROM_ID> is a 12 character (6 byte) 1-Wire ROM ID
|
||||
# without Family ID, e.g. A2D90D000800
|
||||
#
|
||||
@ -80,7 +81,7 @@ sub OWID_Initialize ($) {
|
||||
$hash->{UndefFn} = "OWID_Undef";
|
||||
$hash->{GetFn} = "OWID_Get";
|
||||
$hash->{SetFn} = undef;
|
||||
my $attlist = "IODev do_not_notify:0,1 showtime:0,1 model:DS2502 loglevel:0,1,2,3,4,5 ";
|
||||
my $attlist = "IODev do_not_notify:0,1 showtime:0,1 loglevel:0,1,2,3,4,5 ";
|
||||
$hash->{AttrList} = $attlist;
|
||||
}
|
||||
|
||||
@ -95,43 +96,39 @@ sub OWID_Initialize ($) {
|
||||
sub OWID_Define ($$) {
|
||||
my ($hash, $def) = @_;
|
||||
|
||||
# define <name> OWID [<model>] <id>
|
||||
# e.g.: define flow OWID 525715020000
|
||||
#-- define <name> OWID <id>
|
||||
my @a = split("[ \t][ \t]*", $def);
|
||||
|
||||
my ($name,$model,$id,$scale,$ret);
|
||||
my ($name,$fam,$id,$ret);
|
||||
|
||||
#-- default
|
||||
$name = $a[0];
|
||||
$ret = "";
|
||||
|
||||
#-- check syntax
|
||||
return "OWID: Wrong syntax, must be define <name> OWID [<model>] <id>"
|
||||
if(int(@a) < 2 || int(@a) > 4);
|
||||
return "OWID: Wrong syntax, must be define <name> OWID <id>"
|
||||
if(int(@a) !=4 );
|
||||
|
||||
#-- check if this is an old style definition, e.g. <model> is missing
|
||||
my $a2 = lc($a[2]);
|
||||
my $a3 = defined($a[3]) ? lc($a[3]) : "";
|
||||
if( $a2 =~ m/^[0-9|a-f]{12}$/ ) {
|
||||
$model = "DS2502";
|
||||
$id = $a[2];
|
||||
} elsif( $a3 =~ m/^[0-9|a-f]{12}$/ ) {
|
||||
$model = $a[2];
|
||||
return "OWID: Wrong 1-Wire device model $model"
|
||||
if( $model ne "DS2502");
|
||||
#-- check id
|
||||
if( $a[2] =~ m/^[0-9|a-f]{2}$/ ) {
|
||||
$fam = $a[2];
|
||||
} else {
|
||||
return "OWID: $a[0] ID $a[2] invalid, specify a 2 digit value";
|
||||
}
|
||||
if( $a[3] =~ m/^[0-9|a-f]{12}$/ ) {
|
||||
$id = $a[3];
|
||||
} else {
|
||||
return "OWID: $a[0] ID $a[2] invalid, specify a 12 digit value";
|
||||
return "OWID: $a[0] ID $a[3] invalid, specify a 12 digit value";
|
||||
}
|
||||
|
||||
#-- 1-Wire ROM identifier in the form "FF.XXXXXXXXXXXX.YY"
|
||||
# YY must be determined from id
|
||||
my $crc = sprintf("%02x",OWX_CRC("09.".$id."00"));
|
||||
my $crc = sprintf("%02x",OWX_CRC($fam.".".$id."00"));
|
||||
|
||||
#-- Define device internals
|
||||
$hash->{ROM_ID} = "09.".$id.$crc;
|
||||
$hash->{ROM_ID} = $fam.".".$id.$crc;
|
||||
$hash->{OW_ID} = $id;
|
||||
$hash->{OW_FAMILY} = 9;
|
||||
$hash->{OW_FAMILY} = $fam;
|
||||
$hash->{PRESENT} = 0;
|
||||
|
||||
#-- Couple to I/O device
|
||||
@ -141,54 +138,12 @@ sub OWID_Define ($$) {
|
||||
|
||||
$modules{OWID}{defptr}{$id} = $hash;
|
||||
|
||||
#-- Take channel names from $owg_channel
|
||||
#my $channels;
|
||||
|
||||
#foreach my $a (sort keys %attr) {
|
||||
# print "attr $a $attr{$a}\n";
|
||||
# foreach my $b (sort keys %{$attr{$a}}) {
|
||||
# print "============> attr $a $b $attr{$a}{$b}\n";
|
||||
# }
|
||||
#}
|
||||
#if ( $channels ){
|
||||
# my $i=0;
|
||||
# $channels =~ s/(\w+)/$owg_channel[$i++]=$1/gse;
|
||||
#}
|
||||
|
||||
#print "$name channels = ".join(" ",@owg_channel)."\n";
|
||||
|
||||
$hash->{STATE} = "Defined";
|
||||
Log 3, "OWID: Device $name defined.";
|
||||
|
||||
#-- Initialization reading according to interface type
|
||||
my $interface= $hash->{IODev}->{TYPE};
|
||||
#-- OWX interface
|
||||
#if( $interface eq "OWX" ){
|
||||
# OWXAD_SetPage($hash,"alarm");
|
||||
# OWXAD_SetPage($hash,"status");
|
||||
#-- OWFS interface
|
||||
#}elsif( $interface eq "OWFS" ){
|
||||
# $ret = OWFSAD_GetPage($hash,"reading");
|
||||
#-- Unknown interface
|
||||
#}else{
|
||||
# return "OWID: Define with wrong IODev type $interface";
|
||||
#}
|
||||
|
||||
#-- redefine attributes according to channel names
|
||||
#my $attlist = "IODev do_not_notify:0,1 showtime:0,1 model:DS2450 loglevel:0,1,2,3,4,5 ".
|
||||
# "channels ";
|
||||
#for( my $i=0;$i<4;$i++ ){
|
||||
# $attlist .= " ".$owg_channel[$i]."Offset";
|
||||
# $attlist .= " ".$owg_channel[$i]."Factor";
|
||||
# $attlist .= " ".$owg_channel[$i]."Scale";
|
||||
#}
|
||||
#$hash->{AttrList} = $attlist;
|
||||
|
||||
#-- Start timer for updates
|
||||
#InternalTimer(time()+$hash->{INTERVAL}, "OWID_GetValues", $hash, 0);
|
||||
|
||||
#-- InternalTimer blocks if init_done is not true
|
||||
#my $oid = $init_done;
|
||||
$hash->{STATE} = "Initialized";
|
||||
return undef;
|
||||
}
|
||||
|
@ -16,7 +16,7 @@
|
||||
# Martin Fischer, 2011
|
||||
# Prof. Dr. Peter A. Henning, 2012
|
||||
#
|
||||
# Version 1.03 - March, 2012
|
||||
# Version 1.04 - March, 2012
|
||||
#
|
||||
# Setup bus device in fhem.cfg as
|
||||
# define <name> OWTEMP [<model>] <ROM_ID> [interval]
|
||||
@ -31,7 +31,8 @@
|
||||
#
|
||||
# Additional attributes are defined in fhem.cfg as
|
||||
#
|
||||
# attr <name> offset <float> = a temperature offset added to the temperature reading
|
||||
# attr <name> tempOffset <float> = a temperature offset added to the temperature reading
|
||||
# attr <name> tempUnit <string> = a a unit of measurement, e.g. Celsius/Kelvin/Fahrenheit/Reaumur
|
||||
#
|
||||
########################################################################################
|
||||
#
|
||||
@ -111,7 +112,7 @@ sub OWTEMP_Initialize ($) {
|
||||
#offset = a temperature offset added to the temperature reading for correction
|
||||
#scale = a unit of measure: C/F/K/R
|
||||
$hash->{AttrList}= "IODev do_not_notify:0,1 showtime:0,1 model:DS18S20 loglevel:0,1,2,3,4,5 ".
|
||||
"tempOffset tempScale:Celsius,Fahrenheit,Kelvin,Reaumur";
|
||||
"tempOffset tempUnit:Celsius,Fahrenheit,Kelvin,Reaumur";
|
||||
}
|
||||
|
||||
########################################################################################
|
||||
@ -570,7 +571,7 @@ sub OWXTEMP_GetValues($) {
|
||||
my ($hash) = @_;
|
||||
|
||||
#-- For default, perform the conversion NOT now
|
||||
my $con=0;
|
||||
my $con=1;
|
||||
|
||||
#-- ID of the device
|
||||
my $owx_dev = $hash->{ROM_ID};
|
||||
@ -592,8 +593,8 @@ sub OWXTEMP_GetValues($) {
|
||||
}
|
||||
|
||||
#-- check, if the conversion has been called before - only on devices with real power
|
||||
if( defined($attr{$hash->{IODev}->{NAME}}{buspower}) && ( $attr{$hash->{IODev}->{NAME}}{buspower} eq "parasitic") ){
|
||||
$con=1;
|
||||
if( defined($attr{$hash->{IODev}->{NAME}}{buspower}) && ( $attr{$hash->{IODev}->{NAME}}{buspower} eq "real") ){
|
||||
$con=0;
|
||||
}
|
||||
|
||||
#-- if the conversion has not been called before
|
||||
|
Loading…
x
Reference in New Issue
Block a user