From 391805371fc28c63e050b3d317c1d76976c769a4 Mon Sep 17 00:00:00 2001 From: pahenning <> Date: Sun, 6 Jan 2013 20:00:45 +0000 Subject: [PATCH] git-svn-id: https://svn.fhem.de/fhem/trunk@2444 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/00_OWX.pm | 7 ++++--- fhem/FHEM/21_OWAD.pm | 24 ++++++++++++++++++------ fhem/FHEM/21_OWCOUNT.pm | 32 +++++++++++++++++++++----------- fhem/FHEM/21_OWID.pm | 9 ++++++--- fhem/FHEM/21_OWLCD.pm | 7 +++++-- fhem/FHEM/21_OWMULTI.pm | 13 +++++++++---- fhem/FHEM/21_OWSWITCH.pm | 11 ++++++----- fhem/FHEM/21_OWTHERM.pm | 14 ++++++++++---- 8 files changed, 79 insertions(+), 38 deletions(-) diff --git a/fhem/FHEM/00_OWX.pm b/fhem/FHEM/00_OWX.pm index 8f606f272..324393a44 100644 --- a/fhem/FHEM/00_OWX.pm +++ b/fhem/FHEM/00_OWX.pm @@ -336,7 +336,7 @@ sub OWX_Complex ($$$$) { }elsif( ($owx_interface eq "DS2480") || ($owx_interface eq "DS9097") ){ return OWX_Complex_SER($hash,$owx_dev,$data,$numread); - #-- here we treat the network-connected CUNO + #-- here we treat the CUNO/COC devices }elsif( $owx_interface eq "CUNO" ){ return OWX_Complex_CUNO($hash,$owx_dev,$data,$numread); @@ -2041,7 +2041,8 @@ sub OWX_Complex_CUNO ($$$$) { #-- has receive part if( $numread > 0 ){ #$numread += length($data); - Log 1,"CUNO is expected to deliver $numread bytes"; + Log 3,"CUNO is expected to deliver $numread bytes" + if( $owx_debug > 1); $res.=OWX_Receive_CUNO($hash,$numread); } Log 3,"OWX: returned from CUNO $res" @@ -2133,7 +2134,7 @@ sub OWX_Receive_CUNO ($$) { #-- 18 bytes received from CUNO }elsif( length($ob) == 18 ){ - my $res = "OWX: Receiving from CUNO: $ob\n"; + my $res = "OWX: Receiving 18 bytes from CUNO: $ob\n"; for(my $i=0;$i{IODev}->{INTERFACE}) ? sprintf("%02x",OWX_CRC("20.".$id."00")) : "00"; + # FF = family id follows from the model + # YY must be determined from id + if( $model eq "DS2450" ){ + $fam = "20"; + CommandAttr (undef,"$name model DS2450"); + }else{ + return "OWMULTI: Wrong 1-Wire device model $model"; + } + #-- determine CRC Code - 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} = "20.".$id.$crc; + $hash->{ROM_ID} = $fam.".".$id.$crc; $hash->{OW_ID} = $id; - $hash->{OW_FAMILY} = "20"; + $hash->{OW_FAMILY} = $fam; $hash->{PRESENT} = 0; $hash->{INTERVAL} = $interval; #-- Couple to I/O device AssignIoPort($hash); - if( !defined($hash->{IODev}->{NAME}) | !defined($hash->{IODev}) | ($hash->{IODev}->{PRESENT} != 1) ){ - return "OWAD: Warning, no 1-Wire I/O device found for $name."; + if( !defined($hash->{IODev}->{NAME}) | !defined($hash->{IODev}) | !defined($hash->{IODev}->{PRESENT}) ){ + return "OWSWITCH: Warning, no 1-Wire I/O device found for $name."; + } + if( $hash->{IODev}->{PRESENT} != 1 ){ + return "OWSWITCH: Warning, 1-Wire I/O device ".$hash->{IODev}->{NAME}." not present for $name."; } $modules{OWAD}{defptr}{$id} = $hash; #-- diff --git a/fhem/FHEM/21_OWCOUNT.pm b/fhem/FHEM/21_OWCOUNT.pm index f79d5a3c9..c743ee4a6 100644 --- a/fhem/FHEM/21_OWCOUNT.pm +++ b/fhem/FHEM/21_OWCOUNT.pm @@ -186,20 +186,32 @@ sub OWCOUNT_Define ($$) { } #-- 1-Wire ROM identifier in the form "FF.XXXXXXXXXXXX.YY" + # FF = family id follows from the model + # YY must be determined from id + if( $model eq "DS2423" ){ + $fam = "1D"; + CommandAttr (undef,"$name model DS2423"); + }else{ + return "OWMULTI: Wrong 1-Wire device model $model"; + } + # determine CRC Code - only if this is a direct interface - $crc = defined($hash->{IODev}->{INTERFACE}) ? sprintf("%02x",OWX_CRC("1D.".$id."00")) : "00"; + $crc = defined($hash->{IODev}->{INTERFACE}) ? sprintf("%02x",OWX_CRC($fam.".".$id."00")) : "00"; #-- Define device internals - $hash->{ROM_ID} = "1D.".$id.$crc; + $hash->{ROM_ID} = $fam.".".$id.$crc; $hash->{OW_ID} = $id; - $hash->{OW_FAMILY} = "1D"; + $hash->{OW_FAMILY} = $fam; $hash->{PRESENT} = 0; $hash->{INTERVAL} = $interval; #-- Couple to I/O device AssignIoPort($hash); - if( !defined($hash->{IODev}->{NAME}) | !defined($hash->{IODev}) | ($hash->{IODev}->{PRESENT} != 1) ){ - return "OWCOUNT: Warning, no 1-Wire I/O device found for $name."; + if( !defined($hash->{IODev}->{NAME}) | !defined($hash->{IODev}) | !defined($hash->{IODev}->{PRESENT}) ){ + return "OWSWITCH: Warning, no 1-Wire I/O device found for $name."; + } + if( $hash->{IODev}->{PRESENT} != 1 ){ + return "OWSWITCH: Warning, 1-Wire I/O device ".$hash->{IODev}->{NAME}." not present for $name."; } $modules{OWCOUNT}{defptr}{$id} = $hash; #-- @@ -210,7 +222,7 @@ sub OWCOUNT_Define ($$) { my $interface= $hash->{IODev}->{TYPE}; #-- Start timer for initialization in a few seconds - InternalTimer(time()+10, "OWCOUNT_InitializeDevice", $hash, 0); + InternalTimer(time()+5, "OWCOUNT_InitializeDevice", $hash, 0); #-- Start timer for updates InternalTimer(time()+$hash->{INTERVAL}, "OWCOUNT_GetValues", $hash, 0); @@ -286,8 +298,6 @@ sub OWCOUNT_InitializeDevice($) { if ($unarr[0].$runit eq "kWh/h" ); $hash->{READINGS}{"$owg_rate[$i]"}{UNITABBR} = "kW" if ($unarr[1].$runit eq "kWh/h" ); - #Log 1,"OWCOUNT InitializeDevice with period $period and UNITABBR = ".$hash->{READINGS}{"$owg_rate[$i]"}{UNITABBR}; - } #-- set status according to interface type @@ -348,7 +358,7 @@ sub OWCOUNT_FormatValues($) { $period = $hash->{READINGS}{"$owg_channel[$i]"}{PERIOD}; $runit = $hash->{READINGS}{"$owg_rate[$i]"}{UNITABBR}; - #-- skip som thing if undefined + #-- skip some thing if undefined if( $owg_val[$i] eq ""){ $svalue .= $owg_channel[$i].": ???"; }else{ @@ -443,10 +453,10 @@ sub OWCOUNT_FormatValues($) { #-- string buildup for return value and STATE #-- 1 decimal if( $factor == 1.0 ){ - $svalue .= sprintf( "%s: %5.1f %s (%5.2f %s)", $owg_channel[$i], $vval,$unit,$vrate,$runit); + $svalue .= sprintf( "%s: %5.1f %s / %5.2f %s", $owg_channel[$i], $vval,$unit,$vrate,$runit); #-- 3 decimals } else { - $svalue .= sprintf( "%s: %5.3f %s (%5.2f %s)", $owg_channel[$i], $vval,$unit,$vrate,$runit); + $svalue .= sprintf( "%s: %5.3f %s / %5.2f %s", $owg_channel[$i], $vval,$unit,$vrate,$runit); } } readingsBulkUpdate($hash,"$owg_channel[$i]",$vval); diff --git a/fhem/FHEM/21_OWID.pm b/fhem/FHEM/21_OWID.pm index b4ee3dabc..ec52753c9 100644 --- a/fhem/FHEM/21_OWID.pm +++ b/fhem/FHEM/21_OWID.pm @@ -77,7 +77,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 loglevel:0,1,2,3,4,5 "; + my $attlist = "IODev do_not_notify:0,1 showtime:0,1 model loglevel:0,1,2,3,4,5 "; $hash->{AttrList} = $attlist; } @@ -129,8 +129,11 @@ sub OWID_Define ($$) { #-- Couple to I/O device AssignIoPort($hash); - if( !defined($hash->{IODev}->{NAME}) | !defined($hash->{IODev}) | ($hash->{IODev}->{PRESENT} != 1) ){ - return "OWID: Warning, no 1-Wire I/O device found for $name."; + if( !defined($hash->{IODev}->{NAME}) | !defined($hash->{IODev}) | !defined($hash->{IODev}->{PRESENT}) ){ + return "OWSWITCH: Warning, no 1-Wire I/O device found for $name."; + } + if( $hash->{IODev}->{PRESENT} != 1 ){ + return "OWSWITCH: Warning, 1-Wire I/O device ".$hash->{IODev}->{NAME}." not present for $name."; } $modules{OWID}{defptr}{$id} = $hash; #-- diff --git a/fhem/FHEM/21_OWLCD.pm b/fhem/FHEM/21_OWLCD.pm index 900f07ae8..dcf6c2566 100644 --- a/fhem/FHEM/21_OWLCD.pm +++ b/fhem/FHEM/21_OWLCD.pm @@ -164,8 +164,11 @@ sub OWLCD_Define ($$) { #-- Couple to I/O device AssignIoPort($hash); - if( !defined($hash->{IODev}->{NAME}) | !defined($hash->{IODev}) | ($hash->{IODev}->{PRESENT} != 1) ){ - return "OWLCD: Warning, no 1-Wire I/O device found for $name."; + if( !defined($hash->{IODev}->{NAME}) | !defined($hash->{IODev}) | !defined($hash->{IODev}->{PRESENT}) ){ + return "OWSWITCH: Warning, no 1-Wire I/O device found for $name."; + } + if( $hash->{IODev}->{PRESENT} != 1 ){ + return "OWSWITCH: Warning, 1-Wire I/O device ".$hash->{IODev}->{NAME}." not present for $name."; } $modules{OWLCD}{defptr}{$id} = $hash; diff --git a/fhem/FHEM/21_OWMULTI.pm b/fhem/FHEM/21_OWMULTI.pm index 94cb7e2c1..154c0cad5 100644 --- a/fhem/FHEM/21_OWMULTI.pm +++ b/fhem/FHEM/21_OWMULTI.pm @@ -117,7 +117,7 @@ sub OWMULTI_Initialize ($) { $hash->{SetFn} = "OWMULTI_Set"; #tempOffset = a temperature offset added to the temperature reading for correction #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 model:DS2438 loglevel:0,1,2,3,4,5 ". "event-on-update-reading event-on-change-reading ". "tempOffset tempUnit:C,Celsius,F,Fahrenheit,K,Kelvin ". "VName VUnit VFunction"; @@ -176,10 +176,12 @@ sub OWMULTI_Define ($$) { # YY must be determined from id if( $model eq "DS2438" ){ $fam = "26"; + CommandAttr (undef,"$name model DS2438"); }else{ return "OWMULTI: 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"; #-- define device internals @@ -191,8 +193,11 @@ sub OWMULTI_Define ($$) { #-- Couple to I/O device AssignIoPort($hash); - if( !defined($hash->{IODev}->{NAME}) | !defined($hash->{IODev}) | ($hash->{IODev}->{PRESENT} != 1) ){ - return "OWMULTI: Warning, no 1-Wire I/O device found for $name."; + if( !defined($hash->{IODev}->{NAME}) | !defined($hash->{IODev}) | !defined($hash->{IODev}->{PRESENT}) ){ + return "OWSWITCH: Warning, no 1-Wire I/O device found for $name."; + } + if( $hash->{IODev}->{PRESENT} != 1 ){ + return "OWSWITCH: Warning, 1-Wire I/O device ".$hash->{IODev}->{NAME}." not present for $name."; } $modules{OWMULTI}{defptr}{$id} = $hash; #-- diff --git a/fhem/FHEM/21_OWSWITCH.pm b/fhem/FHEM/21_OWSWITCH.pm index 32dab9ead..0fe342d42 100644 --- a/fhem/FHEM/21_OWSWITCH.pm +++ b/fhem/FHEM/21_OWSWITCH.pm @@ -182,7 +182,7 @@ sub OWSWITCH_Define ($$) { } else { return "OWSWITCH: $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" # FF = family id follows from the model # YY must be determined from id if( $model eq "DS2413" ){ @@ -197,9 +197,7 @@ sub OWSWITCH_Define ($$) { }else{ return "OWSWITCH: Wrong 1-Wire device model $model"; } - - #-- 1-Wire ROM identifier in the form "FF.XXXXXXXXXXXX.YY" - # 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"; #-- Define device internals @@ -211,9 +209,12 @@ sub OWSWITCH_Define ($$) { #-- Couple to I/O device AssignIoPort($hash); - if( !defined($hash->{IODev}->{NAME}) | !defined($hash->{IODev}) | ($hash->{IODev}->{PRESENT} != 1) ){ + if( !defined($hash->{IODev}->{NAME}) | !defined($hash->{IODev}) | !defined($hash->{IODev}->{PRESENT}) ){ return "OWSWITCH: Warning, no 1-Wire I/O device found for $name."; } + if( $hash->{IODev}->{PRESENT} != 1 ){ + return "OWSWITCH: Warning, 1-Wire I/O device ".$hash->{IODev}->{NAME}." not present for $name."; + } $modules{OWSWITCH}{defptr}{$id} = $hash; #-- readingsSingleUpdate($hash,"state","defined",1); diff --git a/fhem/FHEM/21_OWTHERM.pm b/fhem/FHEM/21_OWTHERM.pm index 1ecb9a55d..67b1ed913 100755 --- a/fhem/FHEM/21_OWTHERM.pm +++ b/fhem/FHEM/21_OWTHERM.pm @@ -120,7 +120,7 @@ sub OWTHERM_Initialize ($) { $hash->{SetFn} = "OWTHERM_Set"; #tempOffset = a temperature offset added to the temperature reading for correction #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 model:DS1820,DS18B20,DS1822 loglevel:0,1,2,3,4,5 ". "event-on-update-reading event-on-change-reading ". "stateAL stateAH ". "tempOffset tempUnit:C,Celsius,F,Fahrenheit,K,Kelvin ". @@ -180,14 +180,17 @@ sub OWTHERM_Define ($$) { # YY must be determined from id if( $model eq "DS1820" ){ $fam = "10"; + CommandAttr (undef,"$name model DS1820"); }elsif( $model eq "DS1822" ){ $fam = "22"; + CommandAttr (undef,"$name model DS1822"); }elsif( $model eq "DS18B20" ){ $fam = "28"; + CommandAttr (undef,"$name model DS18B20"); }else{ 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"; #-- define device internals @@ -200,8 +203,11 @@ sub OWTHERM_Define ($$) { #-- Couple to I/O device, exit if not possible AssignIoPort($hash); - if( !defined($hash->{IODev}->{NAME}) | !defined($hash->{IODev}) | ($hash->{IODev}->{PRESENT} != 1) ){ - return "OWTHERM: Warning, no 1-Wire I/O device found for $name."; + if( !defined($hash->{IODev}->{NAME}) | !defined($hash->{IODev}) | !defined($hash->{IODev}->{PRESENT}) ){ + return "OWSWITCH: Warning, no 1-Wire I/O device found for $name."; + } + if( $hash->{IODev}->{PRESENT} != 1 ){ + return "OWSWITCH: Warning, 1-Wire I/O device ".$hash->{IODev}->{NAME}." not present for $name."; } $modules{OWTHERM}{defptr}{$id} = $hash; #--