2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-10 09:16:53 +00:00

git-svn-id: https://svn.fhem.de/fhem/trunk@1700 2b470e98-0d58-463d-a4d8-8e2adae1ed80

This commit is contained in:
pahenning 2012-07-08 06:11:16 +00:00
parent 83374af515
commit 7c38334e4b
3 changed files with 197 additions and 169 deletions

View File

@ -9,7 +9,7 @@
# Internally these interfaces are vastly different, read the corresponding Wiki pages # Internally these interfaces are vastly different, read the corresponding Wiki pages
# http://fhemwiki.de/wiki/Interfaces_f%C3%BCr_1-Wire # http://fhemwiki.de/wiki/Interfaces_f%C3%BCr_1-Wire
# #
# Version 2.03 - July, 2012 # Version 2.04 - July, 2012
# #
# Prof. Dr. Peter A. Henning, 2012 # Prof. Dr. Peter A. Henning, 2012
# #
@ -82,8 +82,7 @@ my %attrs = (
); );
#-- some globals needed for the 1-Wire module #-- some globals needed for the 1-Wire module
my $owx_serport; my $owx_hwdevice;
my $owx_cuno;
#-- baud rate serial interface #-- baud rate serial interface
my $owx_baud=9600; my $owx_baud=9600;
#-- Debugging 0,1,2,3 #-- Debugging 0,1,2,3
@ -105,7 +104,6 @@ my $owx_LastDiscrepancy = 0;
my $owx_LastFamilyDiscrepancy = 0; my $owx_LastFamilyDiscrepancy = 0;
my $owx_LastDeviceFlag = 0; my $owx_LastDeviceFlag = 0;
######################################################################################## ########################################################################################
# #
# The following subroutines are independent of the bus interface # The following subroutines are independent of the bus interface
@ -121,7 +119,7 @@ my $owx_LastDeviceFlag = 0;
sub OWX_Initialize ($) { sub OWX_Initialize ($) {
my ($hash) = @_; my ($hash) = @_;
#-- Provider #-- Provider
$hash->{Clients} = ":OWAD:OWCOUNT:OWID:OWLCD:OWSWITCH:OWTEMP:"; $hash->{Clients} = ":OWAD:OWCOUNT:OWID:OWLCD:OWSWITCH:OWTHERM:";
#-- Normal Devices #-- Normal Devices
$hash->{DefFn} = "OWX_Define"; $hash->{DefFn} = "OWX_Define";
@ -197,6 +195,10 @@ sub OWX_Alarms ($) {
sub OWX_Complex ($$$$) { sub OWX_Complex ($$$$) {
my ($hash,$owx_dev,$data,$numread) =@_; my ($hash,$owx_dev,$data,$numread) =@_;
#-- get the interface
$owx_interface = $hash->{INTERFACE};
$owx_hwdevice = $hash->{HWDEVICE};
#-- here we treat the directly connected serial interfaces #-- here we treat the directly connected serial interfaces
if( ($owx_interface eq "DS2480") || ($owx_interface eq "DS9097") ){ if( ($owx_interface eq "DS2480") || ($owx_interface eq "DS9097") ){
return OWX_Complex_SER($hash,$owx_dev,$data,$numread); return OWX_Complex_SER($hash,$owx_dev,$data,$numread);
@ -340,30 +342,36 @@ sub OWX_Define ($$) {
if ( $dev =~ m/.*USB.*/){ if ( $dev =~ m/.*USB.*/){
#-- Second step in case of serial device: open the serial device to test it #-- Second step in case of serial device: open the serial device to test it
my $msg = "OWX: Serial device $dev"; my $msg = "OWX: Serial device $dev";
$owx_serport = new Device::SerialPort ($dev); $owx_hwdevice = new Device::SerialPort ($dev);
if($owx_serport){ if($owx_hwdevice){
Log 1,$msg." defined"; Log 1,$msg." defined";
}else{ }else{
Log 1, $msg." not defined"; Log 1, $msg." not defined";
return "OWX: Can't open serial device $dev: $!" return "OWX: Can't open serial device $dev: $!"
} }
$owx_serport->reset_error(); $owx_hwdevice->reset_error();
$owx_serport->baudrate(9600); $owx_hwdevice->baudrate(9600);
$owx_serport->databits(8); $owx_hwdevice->databits(8);
$owx_serport->parity('none'); $owx_hwdevice->parity('none');
$owx_serport->stopbits(1); $owx_hwdevice->stopbits(1);
$owx_serport->handshake('none'); $owx_hwdevice->handshake('none');
$owx_serport->write_settings; $owx_hwdevice->write_settings;
#-- store with OWX device
$hash->{INTERFACE} = "serial";
$hash->{HWDEVICE} = $owx_hwdevice;
#-- sleeping for some time #-- sleeping for some time
select(undef,undef,undef,0.1); select(undef,undef,undef,0.1);
} else { } else {
#-- Second step in case of CUNO: See if we can open it #-- Second step in case of CUNO: See if we can open it
my $msg = "OWX: CUNO device $dev"; my $msg = "OWX: CUNO device $dev";
$owx_cuno = $main::defs{$dev}; $owx_hwdevice = $main::defs{$dev};
if($owx_cuno){ if($owx_hwdevice){
Log 1,$msg." defined"; Log 1,$msg." defined";
#-- store with OWX device
$hash->{INTERFACE} = "CUNO";
$hash->{HWDEVICE} = $owx_hwdevice;
#-- reset the 1-Wire system in CUNO #-- reset the 1-Wire system in CUNO
CUL_SimpleWrite($owx_cuno, "Oi"); CUL_SimpleWrite($owx_hwdevice, "Oi");
}else{ }else{
Log 1, $msg." not defined"; Log 1, $msg." not defined";
return "OWX: Can't open cuno device $dev: $!" return "OWX: Can't open cuno device $dev: $!"
@ -390,7 +398,6 @@ sub OWX_Define ($$) {
my $oid = $init_done; my $oid = $init_done;
$hash->{PRESENT} = 1; $hash->{PRESENT} = 1;
$hash->{STATE} = "Initialized"; $hash->{STATE} = "Initialized";
$hash->{INTERFACE} = $owx_interface;
$init_done = 1; $init_done = 1;
#-- Intiate first alarm detection and eventually conversion in a minute or so #-- Intiate first alarm detection and eventually conversion in a minute or so
@ -423,8 +430,12 @@ sub OWX_Detect ($) {
my ($i,$j,$k,$l,$res,$ret,$ress); my ($i,$j,$k,$l,$res,$ret,$ress);
#-- get the interface
$owx_interface = $hash->{INTERFACE};
$owx_hwdevice = $hash->{HWDEVICE};
#-- here we treat the directly connected serial interfaces #-- here we treat the directly connected serial interfaces
if($owx_serport){ if($owx_interface eq "serial"){
#-- timing byte for DS2480 #-- timing byte for DS2480
OWX_Query_2480($hash,"\xC1"); OWX_Query_2480($hash,"\xC1");
@ -462,30 +473,32 @@ sub OWX_Detect ($) {
select(undef,undef,undef,0.5); select(undef,undef,undef,0.5);
} }
if( $ret == 0 ){ if( $ret == 0 ){
$owx_interface=undef;
$ress = "OWX: No 1-Wire bus interface detected, answer was "; $ress = "OWX: No 1-Wire bus interface detected, answer was ";
for($i=0;$i<length($res);$i++){ for($i=0;$i<length($res);$i++){
$j=int(ord(substr($res,$i,1))/16); $j=int(ord(substr($res,$i,1))/16);
$k=ord(substr($res,$i,1))%16; $k=ord(substr($res,$i,1))%16;
$ress.=sprintf "0x%1x%1x ",$j,$k; $ress.=sprintf "0x%1x%1x ",$j,$k;
} }
Log 1, $ress;
return $ret;
} }
#-- here we treat the network-connected CUNO #-- here we treat the network-connected CUNO
} else { } else {
Log 1,"ORM"; CUL_SimpleWrite($owx_hwdevice, "ORm");
CUL_SimpleWrite($owx_cuno, "ORm"); my $ob = DevIo_SimpleRead($owx_hwdevice);
my $ob = DevIo_SimpleRead($owx_cuno);
if( $ob =~ m/OK.*/){ if( $ob =~ m/OK.*/){
Log 1, "OWX: 1-Wire bus interface DS2482 detected in $owx_cuno->{NAME}";
$owx_interface="CUNO"; $owx_interface="CUNO";
$ress="OWX: 1-Wire bus interface DS2482 detected in $owx_hwdevice->{NAME}";
$ret=1; $ret=1;
} else { } else {
Log 1, "OWX: 1-Wire bus interface in $owx_cuno->{NAME} could not be addressed"; $owx_interface=undef;
$ress="OWX: 1-Wire bus interface in $owx_hwdevice->{NAME} could not be addressed";
$ret=0; $ret=0;
} }
} }
return $ret; #-- store with OWX device
$hash->{INTERFACE} = $owx_interface;
Log 1, $ress;
return $ret;
} }
######################################################################################## ########################################################################################
@ -504,22 +517,26 @@ sub OWX_Discover ($) {
my ($hash) = @_; my ($hash) = @_;
my $res; my $res;
#-- get the interface
$owx_interface = $hash->{INTERFACE};
$owx_hwdevice = $hash->{HWDEVICE};
#-- Discover all devices on the 1-Wire bus #-- Discover all devices on the 1-Wire bus
@owx_devs=(); @owx_devs=();
my @owx_names=(); my @owx_names=();
#-- directly connected interface #-- directly connected interface
if( $owx_serport ){ if( $owx_interface =~ m/DS.*/ ){
$res = OWX_First_SER($hash,"discover"); $res = OWX_First_SER($hash,"discover");
while( $owx_LastDeviceFlag==0 && $res!=0 ){ while( $owx_LastDeviceFlag==0 && $res!=0 ){
$res = $res & OWX_Next_SER($hash,"discover"); $res = $res & OWX_Next_SER($hash,"discover");
} }
#-- Ask the cuno #-- Ask the cuno
}else { }else {
CUL_SimpleWrite($owx_cuno, "OCf"); CUL_SimpleWrite($owx_hwdevice, "OCf");
#-- sleeping for some time #-- sleeping for some time
select(undef,undef,undef,3); select(undef,undef,undef,3);
CUL_SimpleWrite($owx_cuno, "Oc"); CUL_SimpleWrite($owx_hwdevice, "Oc");
my $ob = DevIo_SimpleRead($owx_cuno); my $ob = DevIo_SimpleRead($owx_hwdevice);
if( $ob ){ if( $ob ){
foreach my $dx (split(/\n/,$ob)){ foreach my $dx (split(/\n/,$ob)){
$dx =~ s/\d+\://; $dx =~ s/\d+\://;
@ -533,9 +550,9 @@ sub OWX_Discover ($) {
} }
} }
} }
#-- Check, which of these is already defined in the cfg file #-- Go through all devices found on this bus
foreach my $owx_dev (@owx_devs) { foreach my $owx_dev (@owx_devs) {
#-- two pieces of the ROM ID found on the bus #-- three pieces of the ROM ID found on the bus
my $owx_rnf = substr($owx_dev,3,12); my $owx_rnf = substr($owx_dev,3,12);
my $owx_f = substr($owx_dev,0,2); my $owx_f = substr($owx_dev,0,2);
my $owx_crc = substr($owx_dev,15,3); my $owx_crc = substr($owx_dev,15,3);
@ -548,13 +565,13 @@ sub OWX_Discover ($) {
#-- skip if busmaster #-- skip if busmaster
# next if( $hash->{NAME} eq $main::defs{$fhem_dev}{NAME} ); # next if( $hash->{NAME} eq $main::defs{$fhem_dev}{NAME} );
#-- all OW types start with OW #-- all OW types start with OW
next if( substr($main::defs{$fhem_dev}{TYPE},0,2) ne "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); my $id_fhem = substr($main::defs{$fhem_dev}{ROM_ID},0,15);
#-- skip interface device #-- skip interface device
next if( length($id_fhem) != 15 ); next if( length($id_fhem) != 15 );
#-- testing if present in defined devices #-- testing if equal to the one found here
# even with improper family # even with improper family
#Log 1, " FHEM-Device = ".substr($id_fhem,3,12)." OWX discovered device ".substr($id_owx,3,12); # Log 1, " FHEM-Device = ".substr($id_fhem,3,12)." OWX discovered device ".substr($id_owx,3,12);
if( substr($id_fhem,3,12) eq substr($id_owx,3,12) ) { if( substr($id_fhem,3,12) eq substr($id_owx,3,12) ) {
#-- warn if improper family id #-- warn if improper family id
if( substr($id_fhem,0,2) ne substr($id_owx,0,2) ){ if( substr($id_fhem,0,2) ne substr($id_owx,0,2) ){
@ -604,7 +621,7 @@ sub OWX_Discover ($) {
#-- yes, it is on the bus and therefore present #-- yes, it is on the bus and therefore present
push(@owx_names,$name); push(@owx_names,$name);
$main::defs{$name}{PRESENT}=1; $main::defs{$name}{PRESENT}=1;
#-- default room #-- THIS IODev, default room
CommandAttr (undef,"$name IODev $hash->{NAME}"); CommandAttr (undef,"$name IODev $hash->{NAME}");
CommandAttr (undef,"$name room OWX"); CommandAttr (undef,"$name room OWX");
#-- replace the ROM ID by the proper value #-- replace the ROM ID by the proper value
@ -612,15 +629,16 @@ sub OWX_Discover ($) {
} }
} }
#-- final step: Undefine all 1-Wire devices which are not on the bus #-- final step: Undefine all 1-Wire devices which are not on this bus but have this IODev
# TODO: IF WE HAVE MULTIPLE IO Devices ??? foreach my $fhem_dev (sort keys %main::defs) {
foreach my $fhem_dev (sort keys %main::defs) {
#-- skip if malformed device #-- skip if malformed device
#next if( !defined($main::defs{$fhem_dev}{NAME}) ); #next if( !defined($main::defs{$fhem_dev}{NAME}) );
#-- all OW types start with OW #-- all OW types start with OW
next if( substr($main::defs{$fhem_dev}{TYPE},0,2) ne "OW"); next if( substr($main::defs{$fhem_dev}{TYPE},0,2) ne "OW");
#-- skip if the device is present. #-- skip if the device is present.
next if( $main::defs{$fhem_dev}{PRESENT} == 1); next if( $main::defs{$fhem_dev}{PRESENT} == 1);
#-- skip if different IODev
next if( $main::defs{$fhem_dev}{IODev}{NAME} ne $hash->{NAME} );
Log 1, "OWX: Deleting unused 1-Wire device $main::defs{$fhem_dev}{NAME} of type $main::defs{$fhem_dev}{TYPE}"; Log 1, "OWX: Deleting unused 1-Wire device $main::defs{$fhem_dev}{NAME} of type $main::defs{$fhem_dev}{TYPE}";
CommandDelete(undef,$main::defs{$fhem_dev}{NAME}); CommandDelete(undef,$main::defs{$fhem_dev}{NAME});
} }
@ -707,6 +725,10 @@ sub OWX_Kick($) {
sub OWX_Reset ($) { sub OWX_Reset ($) {
my ($hash)=@_; my ($hash)=@_;
#-- get the interface
$owx_interface = $hash->{INTERFACE};
$owx_hwdevice = $hash->{HWDEVICE};
if( $owx_interface eq "DS2480" ){ if( $owx_interface eq "DS2480" ){
return OWX_Reset_2480($hash); return OWX_Reset_2480($hash);
}elsif( $owx_interface eq "DS9097" ){ }elsif( $owx_interface eq "DS9097" ){
@ -799,7 +821,12 @@ sub OWX_Undef ($$) {
sub OWX_Verify ($$) { sub OWX_Verify ($$) {
my ($hash,$dev) = @_; my ($hash,$dev) = @_;
my $i; my $i;
#-- directly connected interface
#-- get the interface
$owx_interface = $hash->{INTERFACE};
$owx_hwdevice = $hash->{HWDEVICE};
#-- directly connected interface
if( ($owx_interface eq "DS2480") || ($owx_interface eq "DS9097") ){ if( ($owx_interface eq "DS2480") || ($owx_interface eq "DS9097") ){
return OWX_Verify_SER($hash,$dev) return OWX_Verify_SER($hash,$dev)
#-- Ask the cuno #-- Ask the cuno
@ -1185,8 +1212,8 @@ sub OWX_Query_2480 ($$) {
my ($i,$j,$k); my ($i,$j,$k);
my $dev = $hash->{DeviceName}; my $dev = $hash->{DeviceName};
$owx_serport->baudrate($owx_baud); $owx_hwdevice->baudrate($owx_baud);
$owx_serport->write_settings; $owx_hwdevice->write_settings;
if( $owx_debug > 2){ if( $owx_debug > 2){
my $res = "OWX: Sending out "; my $res = "OWX: Sending out ";
@ -1198,14 +1225,14 @@ sub OWX_Query_2480 ($$) {
Log 3, $res; Log 3, $res;
} }
my $count_out = $owx_serport->write($cmd); my $count_out = $owx_hwdevice->write($cmd);
Log 1, "OWX: Write incomplete $count_out ne ".(length($cmd))."" if ( $count_out != length($cmd) ); Log 1, "OWX: Write incomplete $count_out ne ".(length($cmd))."" if ( $count_out != length($cmd) );
#-- sleeping for some time #-- sleeping for some time
select(undef,undef,undef,0.04); select(undef,undef,undef,0.04);
#-- read the data #-- read the data
my ($count_in, $string_in) = $owx_serport->read(48); my ($count_in, $string_in) = $owx_hwdevice->read(48);
if( $owx_debug > 2){ if( $owx_debug > 2){
my $res = "OWX: Receiving "; my $res = "OWX: Receiving ";
@ -1220,7 +1247,7 @@ sub OWX_Query_2480 ($$) {
#-- sleeping for some time #-- sleeping for some time
select(undef,undef,undef,0.04); select(undef,undef,undef,0.04);
#$owx_serport->close(); #$owx_hwdevice->close();
return($string_in); return($string_in);
} }
@ -1468,8 +1495,8 @@ sub OWX_Query_9097 ($$) {
my ($i,$j,$k); my ($i,$j,$k);
my $dev = $hash->{DeviceName}; my $dev = $hash->{DeviceName};
$owx_serport->baudrate($owx_baud); $owx_hwdevice->baudrate($owx_baud);
$owx_serport->write_settings; $owx_hwdevice->write_settings;
if( $owx_debug > 2){ if( $owx_debug > 2){
my $res = "OWX: Sending out "; my $res = "OWX: Sending out ";
@ -1481,14 +1508,14 @@ sub OWX_Query_9097 ($$) {
Log 3, $res; Log 3, $res;
} }
my $count_out = $owx_serport->write($cmd); my $count_out = $owx_hwdevice->write($cmd);
Log 1, "OWX: Write incomplete $count_out ne ".(length($cmd))."" if ( $count_out != length($cmd) ); Log 1, "OWX: Write incomplete $count_out ne ".(length($cmd))."" if ( $count_out != length($cmd) );
#-- sleeping for some time #-- sleeping for some time
select(undef,undef,undef,0.01); select(undef,undef,undef,0.01);
#-- read the data #-- read the data
my ($count_in, $string_in) = $owx_serport->read(48); my ($count_in, $string_in) = $owx_hwdevice->read(48);
if( $owx_debug > 2){ if( $owx_debug > 2){
my $res = "OWX: Receiving "; my $res = "OWX: Receiving ";
@ -1503,7 +1530,7 @@ sub OWX_Query_9097 ($$) {
#-- sleeping for some time #-- sleeping for some time
select(undef,undef,undef,0.01); select(undef,undef,undef,0.01);
#$owx_serport->close(); #$owx_hwdevice->close();
return($string_in); return($string_in);
} }
@ -1800,8 +1827,8 @@ sub OWX_Complex_CUNO ($$$$) {
$select=sprintf("Om%s%s%s%s%s%s%s%s",@owx_ROM_ID); $select=sprintf("Om%s%s%s%s%s%s%s%s",@owx_ROM_ID);
Log 3,"OWX: Sending match ROM to CUNO ".$select Log 3,"OWX: Sending match ROM to CUNO ".$select
if( $owx_debug > 1); if( $owx_debug > 1);
CUL_SimpleWrite($owx_cuno, $select); CUL_SimpleWrite($owx_hwdevice, $select);
my $ob = DevIo_SimpleRead($owx_cuno); my $ob = DevIo_SimpleRead($owx_hwdevice);
#-- padding first 9 bytes into result string, since we have this #-- padding first 9 bytes into result string, since we have this
# in the serial interfaces as well # in the serial interfaces as well
$res .= "000000000"; $res .= "000000000";
@ -1836,8 +1863,8 @@ sub OWX_Receive_CUNO ($$) {
for( for(
my $i=0;$i<$numread;$i++){ my $i=0;$i<$numread;$i++){
CUL_SimpleWrite($owx_cuno, "OrB"); CUL_SimpleWrite($owx_hwdevice, "OrB");
my $ob = DevIo_SimpleRead($owx_cuno); my $ob = DevIo_SimpleRead($owx_hwdevice);
#-- process results #-- process results
if( !(defined($ob)) ){ if( !(defined($ob)) ){
return ""; return "";
@ -1870,8 +1897,8 @@ sub OWX_Receive_CUNO ($$) {
######################################################################################## ########################################################################################
sub OWX_Reset_CUNO ($) { sub OWX_Reset_CUNO ($) {
CUL_SimpleWrite($owx_cuno, "ORb"); CUL_SimpleWrite($owx_hwdevice, "ORb");
my $ob = DevIo_SimpleRead($owx_cuno); my $ob = DevIo_SimpleRead($owx_hwdevice);
if( substr($ob,0,4) eq "OK:1" ){ if( substr($ob,0,4) eq "OK:1" ){
return 1; return 1;
}else{ }else{
@ -1901,7 +1928,7 @@ sub OWX_Send_CUNO ($$) {
$k=ord(substr($data,$i,1))%16; $k=ord(substr($data,$i,1))%16;
$res =sprintf "OwB%1x%1x ",$j,$k; $res =sprintf "OwB%1x%1x ",$j,$k;
$res2.=sprintf "0x%1x%1x ",$j,$k; $res2.=sprintf "0x%1x%1x ",$j,$k;
CUL_SimpleWrite($owx_cuno, $res); CUL_SimpleWrite($owx_hwdevice, $res);
} }
Log 3,"OWX: Send to CUNO $res2" Log 3,"OWX: Send to CUNO $res2"
if( $owx_debug > 1); if( $owx_debug > 1);
@ -1923,11 +1950,11 @@ sub OWX_Verify_CUNO ($$) {
my $i; my $i;
#-- Ask the cuno #-- Ask the cuno
CUL_SimpleWrite($owx_cuno, "OCf"); CUL_SimpleWrite($owx_hwdevice, "OCf");
#-- sleeping for some time #-- sleeping for some time
select(undef,undef,undef,3); select(undef,undef,undef,3);
CUL_SimpleWrite($owx_cuno, "Oc"); CUL_SimpleWrite($owx_hwdevice, "Oc");
my $ob = DevIo_SimpleRead($owx_cuno); my $ob = DevIo_SimpleRead($owx_hwdevice);
if( $ob ){ if( $ob ){
foreach my $dx (split(/\n/,$ob)){ foreach my $dx (split(/\n/,$ob)){
$dx =~ s/\d+\://; $dx =~ s/\d+\://;

View File

@ -1,6 +1,6 @@
######################################################################################## ########################################################################################
# #
# OWTEMP.pm # OWTHERM.pm
# #
# FHEM module to commmunicate with 1-Wire temperature sensors DS1820, DS18S20, DS18B20, DS1822 # FHEM module to commmunicate with 1-Wire temperature sensors DS1820, DS18S20, DS18B20, DS1822
# #
@ -19,7 +19,7 @@
# #
# Setup bus device in fhem.cfg as # Setup bus device in fhem.cfg as
# #
# define <name> OWTEMP [<model>] <ROM_ID> [interval] # define <name> OWTHERM [<model>] <ROM_ID> [interval]
# #
# where <name> may be replaced by any name string # where <name> may be replaced by any name string
# #
@ -109,23 +109,23 @@ my %updates = (
# #
# The following subroutines are independent of the bus interface # The following subroutines are independent of the bus interface
# #
# Prefix = OWTEMP # Prefix = OWTHERM
# #
######################################################################################## ########################################################################################
# #
# OWTEMP_Initialize # OWTHERM_Initialize
# #
# Parameter hash = hash of device addressed # Parameter hash = hash of device addressed
# #
######################################################################################## ########################################################################################
sub OWTEMP_Initialize ($) { sub OWTHERM_Initialize ($) {
my ($hash) = @_; my ($hash) = @_;
$hash->{DefFn} = "OWTEMP_Define"; $hash->{DefFn} = "OWTHERM_Define";
$hash->{UndefFn} = "OWTEMP_Undef"; $hash->{UndefFn} = "OWTHERM_Undef";
$hash->{GetFn} = "OWTEMP_Get"; $hash->{GetFn} = "OWTHERM_Get";
$hash->{SetFn} = "OWTEMP_Set"; $hash->{SetFn} = "OWTHERM_Set";
#tempOffset = a temperature offset added to the temperature reading for correction #tempOffset = a temperature offset added to the temperature reading for correction
#tempUnit = a unit of measure: C/F/K #tempUnit = a unit of measure: C/F/K
$hash->{AttrList}= "IODev do_not_notify:0,1 showtime:0,1 loglevel:0,1,2,3,4,5 ". $hash->{AttrList}= "IODev do_not_notify:0,1 showtime:0,1 loglevel:0,1,2,3,4,5 ".
@ -136,17 +136,17 @@ sub OWTEMP_Initialize ($) {
######################################################################################## ########################################################################################
# #
# OWTEMP_Define - Implements DefFn function # OWTHERM_Define - Implements DefFn function
# #
# Parameter hash = hash of device addressed, def = definition string # Parameter hash = hash of device addressed, def = definition string
# #
######################################################################################## ########################################################################################
sub OWTEMP_Define ($$) { sub OWTHERM_Define ($$) {
my ($hash, $def) = @_; my ($hash, $def) = @_;
# define <name> OWTEMP [<model>] <id> [interval] # define <name> OWTHERM [<model>] <id> [interval]
# e.g.: define flow OWTEMP 525715020000 300 # e.g.: define flow OWTHERM 525715020000 300
my @a = split("[ \t][ \t]*", $def); my @a = split("[ \t][ \t]*", $def);
my ($name,$model,$fam,$id,$crc,$interval,$ret); my ($name,$model,$fam,$id,$crc,$interval,$ret);
@ -158,28 +158,28 @@ sub OWTEMP_Define ($$) {
$ret = ""; $ret = "";
#-- check syntax #-- check syntax
return "OWTEMP: Wrong syntax, must be define <name> OWTEMP [<model>] <id> [interval]" return "OWTHERM: Wrong syntax, must be define <name> OWTHERM [<model>] <id> [interval]"
if(int(@a) < 2 || int(@a) > 6); if(int(@a) < 2 || int(@a) > 6);
#-- check if this is an old style definition, e.g. <model> is missing #-- check if this is an old style definition, e.g. <model> is missing
my $a2 = $a[2]; my $a2 = $a[2];
my $a3 = defined($a[3]) ? $a[3] : ""; my $a3 = defined($a[3]) ? $a[3] : "";
if( ($a2 eq "none") || ($a3 eq "none") ) { if( ($a2 eq "none") || ($a3 eq "none") ) {
return "OWTEMP: ID = none is obsolete now, please redefine"; return "OWTHERM: ID = none is obsolete now, please redefine";
} elsif( $a2 =~ m/^[0-9|a-f|A-F]{12}$/ ) { } elsif( $a2 =~ m/^[0-9|a-f|A-F]{12}$/ ) {
$model = "DS1820"; $model = "DS1820";
$id = $a[2]; $id = $a[2];
if(int(@a)>=4) { $interval = $a[3]; } if(int(@a)>=4) { $interval = $a[3]; }
Log 1, "OWTEMP: Parameter [alarminterval] is obsolete now - must be set with I/O-Device" Log 1, "OWTHERM: Parameter [alarminterval] is obsolete now - must be set with I/O-Device"
if(int(@a) == 5); if(int(@a) == 5);
} elsif( $a3 =~ m/^[0-9|a-f|A-F]{12}$/ ) { } elsif( $a3 =~ m/^[0-9|a-f|A-F]{12}$/ ) {
$model = $a[2]; $model = $a[2];
$id = $a[3]; $id = $a[3];
if(int(@a)>=5) { $interval = $a[4]; } if(int(@a)>=5) { $interval = $a[4]; }
Log 1, "OWTEMP: Parameter [alarminterval] is obsolete now - must be set with I/O-Device" Log 1, "OWTHERM: Parameter [alarminterval] is obsolete now - must be set with I/O-Device"
if(int(@a) == 6); if(int(@a) == 6);
} else { } else {
return "OWTEMP: $a[0] ID $a[2] invalid, specify a 12 digit value"; return "OWTHERM: $a[0] ID $a[2] invalid, specify a 12 digit value";
} }
#-- 1-Wire ROM identifier in the form "FF.XXXXXXXXXXXX.YY" #-- 1-Wire ROM identifier in the form "FF.XXXXXXXXXXXX.YY"
@ -192,7 +192,7 @@ sub OWTEMP_Define ($$) {
}elsif( $model eq "DS18B20" ){ }elsif( $model eq "DS18B20" ){
$fam = "28"; $fam = "28";
}else{ }else{
return "OWTEMP: Wrong 1-Wire device model $model"; return "OWTHERM: Wrong 1-Wire device model $model";
} }
# determine CRC Code - only if this is a direct interface # determine CRC Code - only if this is a direct interface
$crc = defined($hash->{IODev}->{INTERFACE}) ? sprintf("%02x",OWX_CRC($fam.".".$id."00")) : "00"; $crc = defined($hash->{IODev}->{INTERFACE}) ? sprintf("%02x",OWX_CRC($fam.".".$id."00")) : "00";
@ -207,30 +207,30 @@ sub OWTEMP_Define ($$) {
#-- Couple to I/O device #-- Couple to I/O device
AssignIoPort($hash); AssignIoPort($hash);
Log 3, "OWTEMP: Warning, no 1-Wire I/O device found for $name." Log 3, "OWTHERM: Warning, no 1-Wire I/O device found for $name."
if(!defined($hash->{IODev}->{NAME})); if(!defined($hash->{IODev}->{NAME}));
$modules{OWTEMP}{defptr}{$id} = $hash; $modules{OWTHERM}{defptr}{$id} = $hash;
$hash->{STATE} = "Defined"; $hash->{STATE} = "Defined";
Log 3, "OWTEMP: Device $name defined."; Log 3, "OWTHERM: Device $name defined.";
#-- Start timer for initialization in a few seconds #-- Start timer for initialization in a few seconds
InternalTimer(time()+1, "OWTEMP_InitializeDevice", $hash, 0); InternalTimer(time()+1, "OWTHERM_InitializeDevice", $hash, 0);
#-- Start timer for updates #-- Start timer for updates
InternalTimer(time()+$hash->{INTERVAL}, "OWTEMP_GetValues", $hash, 0); InternalTimer(time()+$hash->{INTERVAL}, "OWTHERM_GetValues", $hash, 0);
return undef; return undef;
} }
######################################################################################## ########################################################################################
# #
# OWTEMP_InitializeDevice - delayed setting of initial readings and channel names # OWTHERM_InitializeDevice - delayed setting of initial readings and channel names
# #
# Parameter hash = hash of device addressed # Parameter hash = hash of device addressed
# #
######################################################################################## ########################################################################################
sub OWTEMP_InitializeDevice($) { sub OWTHERM_InitializeDevice($) {
my ($hash) = @_; my ($hash) = @_;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
@ -248,18 +248,18 @@ sub OWTEMP_InitializeDevice($) {
$owg_th = 70.0; $owg_th = 70.0;
#-- Initialize all the display stuff #-- Initialize all the display stuff
OWTEMP_FormatValues($hash); OWTHERM_FormatValues($hash);
} }
######################################################################################## ########################################################################################
# #
# OWTEMP_FormatValues - put together various format strings # OWTHERM_FormatValues - put together various format strings
# #
# Parameter hash = hash of device addressed, fs = format string # Parameter hash = hash of device addressed, fs = format string
# #
######################################################################################## ########################################################################################
sub OWTEMP_FormatValues($) { sub OWTHERM_FormatValues($) {
my ($hash) = @_; my ($hash) = @_;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
@ -286,7 +286,7 @@ sub OWTEMP_FormatValues($) {
$factor = 1.8; $factor = 1.8;
} else { } else {
$abbr="?"; $abbr="?";
Log 1, "OWTEMP_FormatValues: unknown unit $unit"; Log 1, "OWTHERM_FormatValues: unknown unit $unit";
} }
#-- these values are rather coplex to obtain, therefore save them in the hash #-- these values are rather coplex to obtain, therefore save them in the hash
$hash->{READINGS}{"temperature"}{UNIT} = $unit; $hash->{READINGS}{"temperature"}{UNIT} = $unit;
@ -341,13 +341,13 @@ sub OWTEMP_FormatValues($) {
######################################################################################## ########################################################################################
# #
# OWTEMP_Get - Implements GetFn function # OWTHERM_Get - Implements GetFn function
# #
# Parameter hash = hash of device addressed, a = argument array # Parameter hash = hash of device addressed, a = argument array
# #
######################################################################################## ########################################################################################
sub OWTEMP_Get($@) { sub OWTHERM_Get($@) {
my ($hash, @a) = @_; my ($hash, @a) = @_;
my $reading = $a[1]; my $reading = $a[1];
@ -357,11 +357,11 @@ sub OWTEMP_Get($@) {
my $ret = ""; my $ret = "";
#-- check syntax #-- check syntax
return "OWTEMP: Get argument is missing @a" return "OWTHERM: Get argument is missing @a"
if(int(@a) != 2); if(int(@a) != 2);
#-- check argument #-- check argument
return "OWTEMP: Get with unknown argument $a[1], choose one of ".join(",", sort keys %gets) return "OWTHERM: Get with unknown argument $a[1], choose one of ".join(",", sort keys %gets)
if(!defined($gets{$a[1]})); if(!defined($gets{$a[1]}));
#-- get id #-- get id
@ -383,7 +383,7 @@ sub OWTEMP_Get($@) {
$hash->{PRESENT} = $value; $hash->{PRESENT} = $value;
return "$a[0] $reading => $value"; return "$a[0] $reading => $value";
} else { } else {
return "OWTEMP: Verification not yet implemented for interface $interface"; return "OWTHERM: Verification not yet implemented for interface $interface";
} }
} }
@ -399,28 +399,28 @@ sub OWTEMP_Get($@) {
#-- OWX interface #-- OWX interface
if( $interface eq "OWX" ){ if( $interface eq "OWX" ){
#-- not different from getting all values .. #-- not different from getting all values ..
$ret = OWXTEMP_GetValues($hash); $ret = OWXTHERM_GetValues($hash);
#-- OWFS interface #-- OWFS interface
}elsif( $interface eq "OWFS" ){ }elsif( $interface eq "OWFS" ){
$ret = OWFSTEMP_GetValues($hash); $ret = OWFSTHERM_GetValues($hash);
#-- Unknown interface #-- Unknown interface
}else{ }else{
return "OWTEMP: Get with wrong IODev type $interface"; return "OWTHERM: Get with wrong IODev type $interface";
} }
#-- process results #-- process results
if( defined($ret) ){ if( defined($ret) ){
return "OWTEMP: Could not get values from device $name, return was $ret"; return "OWTHERM: Could not get values from device $name, return was $ret";
} }
$hash->{PRESENT} = 1; $hash->{PRESENT} = 1;
OWTEMP_FormatValues($hash); OWTHERM_FormatValues($hash);
#-- return the special reading #-- return the special reading
if ($reading eq "temperature") { if ($reading eq "temperature") {
return "OWTEMP: $name.temperature => ". return "OWTHERM: $name.temperature => ".
$hash->{READINGS}{"temperature"}{VAL}; $hash->{READINGS}{"temperature"}{VAL};
} elsif ($reading eq "alarm") { } elsif ($reading eq "alarm") {
return "OWTEMP: $name.alarm => L ".$hash->{READINGS}{"tempLow"}{VAL}. return "OWTHERM: $name.alarm => L ".$hash->{READINGS}{"tempLow"}{VAL}.
" H ".$hash->{READINGS}{"tempHigh"}{VAL}; " H ".$hash->{READINGS}{"tempHigh"}{VAL};
} }
return undef; return undef;
@ -428,13 +428,13 @@ sub OWTEMP_Get($@) {
####################################################################################### #######################################################################################
# #
# OWTEMP_GetValues - Updates the readings from device # OWTHERM_GetValues - Updates the readings from device
# #
# Parameter hash = hash of device addressed # Parameter hash = hash of device addressed
# #
######################################################################################## ########################################################################################
sub OWTEMP_GetValues($@) { sub OWTHERM_GetValues($@) {
my $hash = shift; my $hash = shift;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
@ -443,7 +443,7 @@ sub OWTEMP_GetValues($@) {
#-- restart timer for updates #-- restart timer for updates
RemoveInternalTimer($hash); RemoveInternalTimer($hash);
InternalTimer(time()+$hash->{INTERVAL}, "OWTEMP_GetValues", $hash, 1); InternalTimer(time()+$hash->{INTERVAL}, "OWTHERM_GetValues", $hash, 1);
#-- reset presence #-- reset presence
$hash->{PRESENT} = 0; $hash->{PRESENT} = 0;
@ -451,19 +451,19 @@ sub OWTEMP_GetValues($@) {
#-- Get values according to interface type #-- Get values according to interface type
my $interface= $hash->{IODev}->{TYPE}; my $interface= $hash->{IODev}->{TYPE};
if( $interface eq "OWX" ){ if( $interface eq "OWX" ){
$ret = OWXTEMP_GetValues($hash); $ret = OWXTHERM_GetValues($hash);
}elsif( $interface eq "OWFS" ){ }elsif( $interface eq "OWFS" ){
$ret = OWFSTEMP_GetValues($hash); $ret = OWFSTHERM_GetValues($hash);
}else{ }else{
return "OWTEMP: GetValues with wrong IODev type $interface"; return "OWTHERM: GetValues with wrong IODev type $interface";
} }
#-- process results #-- process results
if( defined($ret) ){ if( defined($ret) ){
return "OWTEMP: Could not get values from device $name"; return "OWTHERM: Could not get values from device $name";
} }
$hash->{PRESENT} = 1; $hash->{PRESENT} = 1;
$value=OWTEMP_FormatValues($hash); $value=OWTHERM_FormatValues($hash);
#--logging #--logging
Log 5, $value; Log 5, $value;
$hash->{CHANGED}[0] = $value; $hash->{CHANGED}[0] = $value;
@ -475,23 +475,23 @@ sub OWTEMP_GetValues($@) {
####################################################################################### #######################################################################################
# #
# OWTEMP_Set - Set one value for device # OWTHERM_Set - Set one value for device
# #
# Parameter hash = hash of device addressed # Parameter hash = hash of device addressed
# a = argument string # a = argument string
# #
######################################################################################## ########################################################################################
sub OWTEMP_Set($@) { sub OWTHERM_Set($@) {
my ($hash, @a) = @_; my ($hash, @a) = @_;
#-- for the selector: which values are possible #-- for the selector: which values are possible
return join(" ", sort keys %sets) if(@a == 2); return join(" ", sort keys %sets) if(@a == 2);
#-- check syntax #-- check syntax
return "OWTEMP: Set needs one parameter" return "OWTHERM: Set needs one parameter"
if(int(@a) != 3); if(int(@a) != 3);
#-- check argument #-- check argument
return "OWTEMP: Set with unknown argument $a[1], choose one of ".join(",", sort keys %sets) return "OWTHERM: Set with unknown argument $a[1], choose one of ".join(",", sort keys %sets)
if(!defined($sets{$a[1]})); if(!defined($sets{$a[1]}));
#-- define vars #-- define vars
@ -504,12 +504,12 @@ sub OWTEMP_Set($@) {
#-- set new timer interval #-- set new timer interval
if($key eq "interval") { if($key eq "interval") {
# check value # check value
return "OWTEMP: Set with short interval, must be > 1" return "OWTHERM: Set with short interval, must be > 1"
if(int($value) < 1); if(int($value) < 1);
# update timer # update timer
$hash->{INTERVAL} = $value; $hash->{INTERVAL} = $value;
RemoveInternalTimer($hash); RemoveInternalTimer($hash);
InternalTimer(gettimeofday()+$hash->{INTERVAL}, "OWTEMP_GetValues", $hash, 1); InternalTimer(gettimeofday()+$hash->{INTERVAL}, "OWTHERM_GetValues", $hash, 1);
return undef; return undef;
} }
@ -521,7 +521,7 @@ sub OWTEMP_Set($@) {
#-- find upper and lower boundaries for given offset/factor #-- find upper and lower boundaries for given offset/factor
my $mmin = (-55+$offset)*$factor; my $mmin = (-55+$offset)*$factor;
my $mmax = (125+$offset)*$factor; my $mmax = (125+$offset)*$factor;
return sprintf("OWTEMP: Set with wrong value $value for $key, range is [%3.1f,%3.1f]",$mmin,$mmax) return sprintf("OWTHERM: Set with wrong value $value for $key, range is [%3.1f,%3.1f]",$mmin,$mmax)
if($value < $mmin || $value > $mmax); if($value < $mmin || $value > $mmax);
#-- seems to be ok, put into the device #-- seems to be ok, put into the device
@ -529,36 +529,37 @@ sub OWTEMP_Set($@) {
#-- OWX interface #-- OWX interface
if( $interface eq "OWX" ){ if( $interface eq "OWX" ){
$ret = OWXTEMP_SetValues($hash,@a); $ret = OWXTHERM_SetValues($hash,@a);
return $ret $ret = OWXTHERM_GetValues($hash);
if(defined($ret));
#-- OWFS interface #-- OWFS interface
}elsif( $interface eq "OWFS" ){ }elsif( $interface eq "OWFS" ){
$ret = OWFSTEMP_SetValues($hash,@a); $ret = OWFSTHERM_SetValues($hash,@a);
$ret = OWFSTHERM_GetValues($hash);
return $ret return $ret
if(defined($ret)); if(defined($ret));
} else { } else {
return "OWTEMP: Set with wrong IODev type $interface"; return "OWTHERM: Set with wrong IODev type $interface";
} }
OWTEMP_FormatValues($hash); #-- careful: globals may come from a different device
OWTHERM_FormatValues($hash);
Log 4, "OWTEMP: Set $hash->{NAME} $key $value"; Log 4, "OWTHERM: Set $hash->{NAME} $key $value";
return undef; return undef;
} }
######################################################################################## ########################################################################################
# #
# OWTEMP_Undef - Implements UndefFn function # OWTHERM_Undef - Implements UndefFn function
# #
# Parameter hash = hash of device addressed # Parameter hash = hash of device addressed
# #
######################################################################################## ########################################################################################
sub OWTEMP_Undef ($) { sub OWTHERM_Undef ($) {
my ($hash) = @_; my ($hash) = @_;
delete($modules{OWTEMP}{defptr}{$hash->{OW_ID}}); delete($modules{OWTHERM}{defptr}{$hash->{OW_ID}});
RemoveInternalTimer($hash); RemoveInternalTimer($hash);
return undef; return undef;
} }
@ -568,17 +569,17 @@ sub OWTEMP_Undef ($) {
# The following subroutines in alphabetical order are only for a 1-Wire bus connected # The following subroutines in alphabetical order are only for a 1-Wire bus connected
# via OWFS # via OWFS
# #
# Prefix = OWFSTEMP # Prefix = OWFSTHERM
# #
######################################################################################## ########################################################################################
# #
# OWFSTEMP_GetValues - Get reading from one device # OWFSTHERM_GetValues - Get reading from one device
# #
# Parameter hash = hash of device addressed # Parameter hash = hash of device addressed
# #
######################################################################################## ########################################################################################
sub OWFSTEMP_GetValues($) sub OWFSTHERM_GetValues($)
{ {
my ($hash) = @_; my ($hash) = @_;
@ -600,14 +601,14 @@ sub OWFSTEMP_GetValues($)
####################################################################################### #######################################################################################
# #
# OWFSTEMP_SetValues - Implements SetFn function # OWFSTHERM_SetValues - Implements SetFn function
# #
# Parameter hash = hash of device addressed # Parameter hash = hash of device addressed
# a = argument array # a = argument array
# #
######################################################################################## ########################################################################################
sub OWFSTEMP_SetValues($@) { sub OWFSTHERM_SetValues($@) {
my ($hash, @a) = @_; my ($hash, @a) = @_;
#-- define vars #-- define vars
@ -622,17 +623,17 @@ sub OWFSTEMP_SetValues($@) {
# The following subroutines in alphabetical order are only for a 1-Wire bus connected # The following subroutines in alphabetical order are only for a 1-Wire bus connected
# directly to the FHEM server # directly to the FHEM server
# #
# Prefix = OWXTEMP # Prefix = OWXTHERM
# #
######################################################################################## ########################################################################################
# #
# OWXTEMP_GetValues - Get reading from one device # OWXTHERM_GetValues - Get reading from one device
# #
# Parameter hash = hash of device addressed # Parameter hash = hash of device addressed
# #
######################################################################################## ########################################################################################
sub OWXTEMP_GetValues($) { sub OWXTHERM_GetValues($) {
my ($hash) = @_; my ($hash) = @_;
@ -657,7 +658,7 @@ sub OWXTEMP_GetValues($) {
OWX_Reset($master); OWX_Reset($master);
#-- issue the match ROM command \x55 and the start conversion command #-- issue the match ROM command \x55 and the start conversion command
if( OWX_Complex($master,$owx_dev,"\x44",0) eq 0 ){ if( OWX_Complex($master,$owx_dev,"\x44",0) eq 0 ){
return "OWXTEMP: Device $owx_dev not accessible"; return "OWXTHERM: Device $owx_dev not accessible";
} }
#-- conversion needs some 950 ms - but we may also do it in shorter time ! #-- conversion needs some 950 ms - but we may also do it in shorter time !
select(undef,undef,undef,1.0); select(undef,undef,undef,1.0);
@ -668,13 +669,13 @@ sub OWXTEMP_GetValues($) {
#-- issue the match ROM command \x55 and the read scratchpad command \xBE #-- issue the match ROM command \x55 and the read scratchpad command \xBE
#-- reading 9 + 1 + 8 data bytes and 1 CRC byte = 19 bytes #-- reading 9 + 1 + 8 data bytes and 1 CRC byte = 19 bytes
my $res=OWX_Complex($master,$owx_dev,"\xBE",9); my $res=OWX_Complex($master,$owx_dev,"\xBE",9);
#Log 1,"OWXTEMP: data length from reading device is ".length($res)." bytes"; #Log 1,"OWXTHERM: data length from reading device is ".length($res)." bytes";
#-- process results #-- process results
if( $res eq 0 ){ if( $res eq 0 ){
return "OWXTEMP: Device $owx_dev not accessible in 2nd step"; return "OWXTHERM: Device $owx_dev not accessible in 2nd step";
} }
#my $res2 = "====> OWXTEMP Received "; #my $res2 = "====> OWXTHERM Received ";
#for(my $i=0;$i<19;$i++){ #for(my $i=0;$i<19;$i++){
# my $j=int(ord(substr($res,$i,1))/16); # my $j=int(ord(substr($res,$i,1))/16);
# my $k=ord(substr($res,$i,1))%16; # my $k=ord(substr($res,$i,1))%16;
@ -711,7 +712,7 @@ sub OWXTEMP_GetValues($) {
$owg_tl = ord($data[13]) > 127 ? 128-ord($data[13]) : ord($data[13]); $owg_tl = ord($data[13]) > 127 ? 128-ord($data[13]) : ord($data[13]);
return undef; return undef;
} else { } else {
return "OWXTEMP: Device $owx_dev returns invalid data"; return "OWXTHERM: Device $owx_dev returns invalid data";
} }
} elsif ( ($hash->{OW_FAMILY} eq "22") || ($hash->{OW_FAMILY} eq "28") ) { } elsif ( ($hash->{OW_FAMILY} eq "22") || ($hash->{OW_FAMILY} eq "28") ) {
if ( (@data == 19) && (ord($data[17])>0) ){ if ( (@data == 19) && (ord($data[17])>0) ){
@ -734,23 +735,23 @@ sub OWXTEMP_GetValues($) {
$owg_tl = ord($data[13]) > 127 ? 128-ord($data[13]) : ord($data[13]); $owg_tl = ord($data[13]) > 127 ? 128-ord($data[13]) : ord($data[13]);
return undef; return undef;
} else { } else {
return "OWXTEMP: Device $owx_dev returns invalid data"; return "OWXTHERM: Device $owx_dev returns invalid data";
} }
} else { } else {
return "OWXTEMP: Unknown device family $hash->{OW_FAMILY}\n"; return "OWXTHERM: Unknown device family $hash->{OW_FAMILY}\n";
} }
} }
####################################################################################### #######################################################################################
# #
# OWXTEMP_SetValues - Implements SetFn function # OWXTHERM_SetValues - Implements SetFn function
# #
# Parameter hash = hash of device addressed # Parameter hash = hash of device addressed
# a = argument array # a = argument array
# #
######################################################################################## ########################################################################################
sub OWXTEMP_SetValues($@) { sub OWXTHERM_SetValues($@) {
my ($hash, @a) = @_; my ($hash, @a) = @_;
my ($i,$j,$k); my ($i,$j,$k);
@ -785,7 +786,7 @@ sub OWXTEMP_SetValues($@) {
my $res=OWX_Complex($master,$owx_dev,$select,0); my $res=OWX_Complex($master,$owx_dev,$select,0);
if( $res eq 0 ){ if( $res eq 0 ){
return "OWXTEMP: Device $owx_dev not accessible"; return "OWXTHERM: Device $owx_dev not accessible";
} }
DoTrigger($name, undef) if($init_done); DoTrigger($name, undef) if($init_done);

View File

@ -530,23 +530,23 @@
</ul> </ul>
</ul> </ul>
<!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--> <!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
<a name="OWTEMP"></a> <a name="OWTHERM"></a>
<h3>OWTEMP</h3> <h3>OWTHERM</h3>
<ul>FHEM module to commmunicate with 1-Wire bus digital thermometer devices<br /><br /> <ul>FHEM module to commmunicate with 1-Wire bus digital thermometer devices<br /><br />
Note:<br /> This is the only 1-Wire module which so far works with both the OWFS and the Note:<br /> This is the only 1-Wire module which so far works with both the OWFS and the
OWX interface module. Please define an <a href="#OWFS">OWFS</a> device or an <a OWX interface module. Please define an <a href="#OWFS">OWFS</a> device or an <a
href="#OWX">OWX</a> device first. <br /> href="#OWX">OWX</a> device first. <br />
<br /><b>Example</b><br /> <br /><b>Example</b><br />
<ul> <ul>
<code>define OWX_T OWTEMP DS18B20 E8D09B030000 300</code> <code>define OWX_T OWTHERM DS18B20 E8D09B030000 300</code>
<br /> <br />
<code>attr OWX_T tempUnit Kelvin</code> <code>attr OWX_T tempUnit Kelvin</code>
<br /> <br />
</ul><br /> </ul><br />
<a name="OWTEMPdefine"></a> <a name="OWTHERMdefine"></a>
<b>Define</b> <b>Define</b>
<ul> <ul>
<code>define &lt;name&gt; OWTEMP [&lt;model&gt;] &lt;id&gt; <code>define &lt;name&gt; OWTHERM [&lt;model&gt;] &lt;id&gt;
[&lt;interval&gt;]</code> [&lt;interval&gt;]</code>
<br /><br /> Define a 1-Wire digital thermometer device.<br /><br /> <br /><br /> Define a 1-Wire digital thermometer device.<br /><br />
<li> <li>
@ -566,73 +566,73 @@
<code>&lt;interval&gt;</code> <code>&lt;interval&gt;</code>
<br /> Temperature measurement interval in seconds. The default is 300 seconds. </li> <br /> Temperature measurement interval in seconds. The default is 300 seconds. </li>
<br /> Example: <br /> <br /> Example: <br />
<code>define Temp1 OWTEMP 14B598010800 300 </code><br /> <code>define Temp1 OWTHERM 14B598010800 300 </code><br />
</ul> </ul>
<br /> <br />
<a name="OWTEMPset"> <a name="OWTHERMset">
<b>Set</b></a> <b>Set</b></a>
<ul> <ul>
<li><a name="owtemp_interval"> <li><a name="owtherm_interval">
<code>set &lt;name&gt; interval &lt;int&gt;</code></a><br /> Temperature <code>set &lt;name&gt; interval &lt;int&gt;</code></a><br /> Temperature
measurement intervall in seconds. The default is 300 seconds.</li> measurement intervall in seconds. The default is 300 seconds.</li>
<li><a name="owtemp_tempHigh"> <li><a name="owtherm_tempHigh">
<code>set &lt;name&gt; tempHigh &lt;float&gt;</code></a> <code>set &lt;name&gt; tempHigh &lt;float&gt;</code></a>
<br /> The high alarm temperature (on the temperature scale chosen by the <br /> The high alarm temperature (on the temperature scale chosen by the
attribute value) </li> attribute value) </li>
<li><a name="owtemp_tempLow"> <li><a name="owtherm_tempLow">
<code>set &lt;name&gt; tempLow &lt;float&gt;</code></a> <code>set &lt;name&gt; tempLow &lt;float&gt;</code></a>
<br /> The low alarm temperature (on the temperature scale chosen by the <br /> The low alarm temperature (on the temperature scale chosen by the
attribute value) </li> attribute value) </li>
</ul> </ul>
<br /> <br />
<a name="OWTEMPget"> <a name="OWTHERMget">
<b>Get</b></a> <b>Get</b></a>
<ul> <ul>
<li><a name="owtemp_id"> <li><a name="owtherm_id">
<code>get &lt;name&gt; id</code></a> <code>get &lt;name&gt; id</code></a>
<br /> Returns the full 1-Wire device id OW_FAMILY.ROM_ID.CRC </li> <br /> Returns the full 1-Wire device id OW_FAMILY.ROM_ID.CRC </li>
<li><a name="owtemp_present"> <li><a name="owtherm_present">
<code>get &lt;name&gt; present</code></a> <code>get &lt;name&gt; present</code></a>
<br /> Returns 1 if this 1-Wire device is present, otherwise 0. </li> <br /> Returns 1 if this 1-Wire device is present, otherwise 0. </li>
<li><a name="owtemp_interval2"> <li><a name="owtherm_interval2">
<code>get &lt;name&gt; interval</code></a><br />Returns temperature <code>get &lt;name&gt; interval</code></a><br />Returns temperature
measurement interval in seconds.</li> measurement interval in seconds.</li>
<li><a name="owtemp_temperature"> <li><a name="owtherm_temperature">
<code>get &lt;name&gt; temperature</code></a><br />Obtain the temperature. </li> <code>get &lt;name&gt; temperature</code></a><br />Obtain the temperature. </li>
<li><a name="owtemp_alarm"> <li><a name="owtherm_alarm">
<code>get &lt;name&gt; alarm</code></a><br />Obtain the alarm temperature <code>get &lt;name&gt; alarm</code></a><br />Obtain the alarm temperature
values. </li> values. </li>
</ul> </ul>
<br /> <br />
<a name="OWTEMPattr"> <a name="OWTHERMattr">
<b>Attributes</b></a> <b>Attributes</b></a>
<ul> <ul>
<li><a name="owtemp_stateAL"><code>attr &lt;name&gt; stateAL &lt;string&gt;</code> <li><a name="owtherm_stateAL"><code>attr &lt;name&gt; stateAL &lt;string&gt;</code>
</a> </a>
<br />character string for denoting low alarm condition, default is red down <br />character string for denoting low alarm condition, default is red down
triangle, e.g. the code &lt;span style="color:red"&gt;&amp;#x25BE;&lt;/span&gt; triangle, e.g. the code &lt;span style="color:red"&gt;&amp;#x25BE;&lt;/span&gt;
leading to the sign <span style="color:red">&#x25BE;</span> leading to the sign <span style="color:red">&#x25BE;</span>
</li> </li>
<li><a name="owtemp_stateAH"><code>attr &lt;name&gt; stateAH &lt;string&gt;</code> <li><a name="owtherm_stateAH"><code>attr &lt;name&gt; stateAH &lt;string&gt;</code>
</a> </a>
<br />character string for denoting high alarm condition, default is red upward <br />character string for denoting high alarm condition, default is red upward
triangle, e.g. the code &lt;span style="color:red"&gt;&amp;#x25B4;&lt;/span&gt; triangle, e.g. the code &lt;span style="color:red"&gt;&amp;#x25B4;&lt;/span&gt;
leading to the sign <span style="color:red">&#x25B4;</span> leading to the sign <span style="color:red">&#x25B4;</span>
</li> </li>
<li><a name="owtemp_tempOffset"><code>attr &lt;name&gt; tempOffset <li><a name="owtherm_tempOffset"><code>attr &lt;name&gt; tempOffset
&lt;float&gt;</code> &lt;float&gt;</code>
</a> </a>
<br />temperature offset in &deg;C added to the raw temperature reading. </li> <br />temperature offset in &deg;C added to the raw temperature reading. </li>
<li><a name="owtemp_tempUnit"><code>attr &lt;name&gt; tempUnit <li><a name="owtherm_tempUnit"><code>attr &lt;name&gt; tempUnit
Celsius|Kelvin|Fahrenheit|C|K|F</code> Celsius|Kelvin|Fahrenheit|C|K|F</code>
</a> </a>
<br />unit of measurement (temperature scale), default is Celsius = &deg;C </li> <br />unit of measurement (temperature scale), default is Celsius = &deg;C </li>
<li><a name="owtemp_tempHigh2"> <li><a name="owtherm_tempHigh2">
<code>attr &lt;name&gt; tempHigh &lt;float&gt;</code> <code>attr &lt;name&gt; tempHigh &lt;float&gt;</code>
</a> </a>
<br /> high alarm temperature (on the temperature scale chosen by the attribute <br /> high alarm temperature (on the temperature scale chosen by the attribute
value). </li> value). </li>
<li><a name="owtemp_tempLow2"> <li><a name="owtherm_tempLow2">
<code>attr &lt;name&gt; tempLow &lt;float&gt;</code> <code>attr &lt;name&gt; tempLow &lt;float&gt;</code>
</a> </a>
<br /> low alarm temperature (on the temperature scale chosen by the attribute <br /> low alarm temperature (on the temperature scale chosen by the attribute