From 1dff252da01e76819bde093711215fd30b83c4dc Mon Sep 17 00:00:00 2001 From: pahenning Date: Wed, 13 Feb 2013 06:09:28 +0000 Subject: [PATCH] git-svn-id: https://fhem.svn.sourceforge.net/svnroot/fhem/trunk/fhem@2715 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- FHEM/21_OWAD.pm | 2 +- FHEM/21_OWTHERM.pm | 41 +++++++++++++++------ contrib/15_EMX.pm | 89 +++++++++++++++++++++++++++++++--------------- 3 files changed, 92 insertions(+), 40 deletions(-) diff --git a/FHEM/21_OWAD.pm b/FHEM/21_OWAD.pm index 15b30cf50..b0d348f5f 100644 --- a/FHEM/21_OWAD.pm +++ b/FHEM/21_OWAD.pm @@ -320,7 +320,7 @@ sub OWAD_InitializeDevice($) { $owg_shigh[$i]=1; } } - #-- low alarm value + #-- low alarm value - no checking for correct parameters if( AttrVal($name,$owg_fixed[$i]."Low",undef) ){ $owg_vlow[$i] = $main::attr{$name}{$owg_fixed[$i]."Low"}; } diff --git a/FHEM/21_OWTHERM.pm b/FHEM/21_OWTHERM.pm index d622a0cff..9561a07bb 100755 --- a/FHEM/21_OWTHERM.pm +++ b/FHEM/21_OWTHERM.pm @@ -242,9 +242,9 @@ sub OWTHERM_InitializeDevice($) { my ($hash) = @_; my $name = $hash->{NAME}; - my @args; - my $ret; - my ($unit,$offset,$factor,$abbr,$vval,$vlow,$vhigh,$statef); + my $interface = $hash->{IODev}->{TYPE}; + my @a = ($name,"",0); + my ($unit,$offset,$factor,$abbr,$value); #-- attributes defined ? $stateal = defined($attr{$name}{stateAL}) ? $attr{$name}{stateAL} : "▾"; @@ -276,12 +276,31 @@ sub OWTHERM_InitializeDevice($) { #-- Set the attribute values if defined if( defined($attr{$name}{"tempLow"}) ){ - OWTHERM_Set( $hash,($name,"tempLow",$attr{$name}{"tempLow"})); + $value = $attr{$name}{"tempLow"}; + $a[1] = "tempLow"; + $a[2] = floor($value/$factor-$offset+0.5); + #-- put into device + #-- OWX interface + if( $interface eq "OWX" ){ + OWXTHERM_SetValues($hash,@a); + #-- OWFS interface + }elsif( $interface eq "OWServer" ){ + OWFSTHERM_SetValues($hash,@a); + } } if( defined($attr{$name}{"tempHigh"}) ){ - OWTHERM_Set( $hash,($name,"tempHigh",$attr{$name}{"tempHigh"}) ); + $value = $attr{$name}{"tempHigh"}; + $a[1] = "tempHigh"; + $a[2] = floor($value/$factor-$offset+0.5); + #-- put into device + #-- OWX interface + if( $interface eq "OWX" ){ + OWXTHERM_SetValues($hash,@a); + #-- OWFS interface + }elsif( $interface eq "OWServer" ){ + OWFSTHERM_SetValues($hash,@a); + } } - #-- Set state to initialized readingsSingleUpdate($hash,"state","initialized",1); } @@ -331,6 +350,10 @@ sub OWTHERM_FormatValues($) { #-- no change in any value if invalid reading return if( $owg_temp eq ""); + #-- check if device needs to be initialized + OWTHERM_InitializeDevice($hash) + if( $hash->{READINGS}{"state"}{VAL} eq "defined"); + #-- correct values for proper offset, factor $vval = ($owg_temp + $offset)*$factor; $vlow = floor(($owg_tl + $offset)*$factor+0.5); @@ -338,10 +361,6 @@ sub OWTHERM_FormatValues($) { $main::attr{$name}{"tempLow"} = $vlow; $main::attr{$name}{"tempHigh"} = $vhigh; - - #-- check if device needs to be initialized - OWTHERM_InitializeDevice($hash) - if( $hash->{READINGS}{"state"}{VAL} eq "defined"); #-- formats for output $statef = "T: %5.2f ".$abbr; @@ -599,7 +618,7 @@ sub OWTHERM_Set($@) { #-- process results $hash->{PRESENT} = 1; - #OWTHERM_FormatValues($hash); + OWTHERM_FormatValues($hash); Log 4, "OWTHERM: Set $hash->{NAME} $key $value"; return undef; diff --git a/contrib/15_EMX.pm b/contrib/15_EMX.pm index 731f0eab2..83dcd9720 100755 --- a/contrib/15_EMX.pm +++ b/contrib/15_EMX.pm @@ -2,16 +2,16 @@ # # 15_EMX.pm MUST be saved as 15_CUL_EM.pm !!! # -# FHEM module to read the data from an EM1000 S/IR power sensor +# FHEM module to read the data from an EM1000 WZ/EM/GZ power sensor # -# Version 1.0 - January 21, 2013 +# Version 1.1 - February, 2013 # # Prof. Dr. Peter A. Henning, 2011 # #---------------------------------------------------------------------------------------------------- # # Setup as: -# define EMX +# define EMX # # where # may be replaced by any name string @@ -27,20 +27,35 @@ # attr emx LogM EnergyM # attr emx LogY EnergyY # -# NOT YET OPERATIVE: -# # Basic fee per Month (€ per Month) -# attr emx FixedM +# attr emx CostM # -# Rate during daytime (€ per kWh) -# attr emx RateD +# Cost rate during daytime (€ per kWh) +# attr emx CrateD # -# Start and end of daytime rate - optional -# attr emx RateDStart