OWCOUNT.pm: Bereinigung model test

OWID.pm: Minor Fix
OWLCD.pm: Neue Attribute
OWMULTI.pm: Bereinigung Doku
OWSWITCH.pm: Bugfix wiederholtes Setzen

git-svn-id: https://svn.fhem.de/fhem/trunk@11196 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
pahenning
2016-04-06 18:56:28 +00:00
parent 5d8329df26
commit 067a560498
5 changed files with 100 additions and 87 deletions

View File

@@ -99,13 +99,15 @@ no warnings 'deprecated';
sub Log3($$$); sub Log3($$$);
my $owx_version="6.0"; my $owx_version="6.01";
#-- fixed raw channel name, flexible channel name #-- fixed raw channel name, flexible channel name
my @owg_fixed = ("A","B"); my @owg_fixed = ("A","B");
my @owg_channel = ("A","B"); my @owg_channel = ("A","B");
my @owg_rate = ("A_rate","B_rate"); my @owg_rate = ("A_rate","B_rate");
#-- initially assume that both memory types (low, high) are present #-- initially assume that both memory types (low, high) are present
my @owg_memory = (1,1,0); my @owg_memory = (1,1,0);
my $owgmodel;
my $owgauto = 0;
my %gets = ( my %gets = (
"id" => "", "id" => "",
@@ -208,7 +210,8 @@ sub OWCOUNT_Define ($$) {
#-- no model, 12 characters #-- no model, 12 characters
if( $a2 =~ m/^[0-9|a-f|A-F]{12}$/ ) { if( $a2 =~ m/^[0-9|a-f|A-F]{12}$/ ) {
$model = "DS2423"; $model = "DS2423";
CommandAttr (undef,"$name model DS2423"); $owgauto =1;
#CommandAttr (undef,"$name model DS2423");
$fam = "1D"; $fam = "1D";
$id = $a[2]; $id = $a[2];
if(int(@a)>=4) { $interval = $a[3]; } if(int(@a)>=4) { $interval = $a[3]; }
@@ -219,7 +222,8 @@ sub OWCOUNT_Define ($$) {
if(int(@a)>=4) { $interval = $a[3]; } if(int(@a)>=4) { $interval = $a[3]; }
if( $fam eq "1D" ){ if( $fam eq "1D" ){
$model = "DS2423"; $model = "DS2423";
CommandAttr (undef,"$name model DS2423"); $owgauto =1;
#CommandAttr (undef,"$name model DS2423");
}else{ }else{
return "OWCOUNT: Wrong 1-Wire device family $fam"; return "OWCOUNT: Wrong 1-Wire device family $fam";
} }
@@ -230,16 +234,20 @@ sub OWCOUNT_Define ($$) {
if(int(@a)>=5) { $interval = $a[4]; } if(int(@a)>=5) { $interval = $a[4]; }
if( $model eq "DS2423" ){ if( $model eq "DS2423" ){
$fam = "1D"; $fam = "1D";
CommandAttr (undef,"$name model DS2423"); #CommandAttr (undef,"$name model DS2423");
#-- Check, if name might be from autocreate -> checking memory
if( $name =~ /OWX\_$fam\_$id/ ){
$owgauto=1;
}
@owg_memory = (1,1,0); @owg_memory = (1,1,0);
}elsif( $model eq "DS2423enew" ){ }elsif( $model eq "DS2423enew" ){
$fam = "1D"; $fam = "1D";
@owg_memory = (1,1,0); @owg_memory = (1,1,0);
CommandAttr (undef,"$name model DS2423enew"); #CommandAttr (undef,"$name model DS2423enew");
}elsif( $model eq "DS2423eold" ){ }elsif( $model eq "DS2423eold" ){
$fam = "1D"; $fam = "1D";
CommandAttr (undef,"$name model DS2423eold"); #CommandAttr (undef,"$name model DS2423eold");
CommandAttr (undef,"$name nomemory 1"); #CommandAttr (undef,"$name nomemory 1");
@owg_memory = (0,0,0); @owg_memory = (0,0,0);
}else{ }else{
return "OWCOUNT: Wrong 1-Wire device model $model"; return "OWCOUNT: Wrong 1-Wire device model $model";
@@ -248,6 +256,8 @@ sub OWCOUNT_Define ($$) {
return "OWCOUNT: $a[0] ID $a[2] invalid, specify a 12 or 2.12 digit value"; return "OWCOUNT: $a[0] ID $a[2] invalid, specify a 12 or 2.12 digit value";
} }
$owgmodel=$model;
# determine CRC Code - only if this is a direct interface # determine CRC Code - only if this is a direct interface
$crc = sprintf("%02x",OWX_CRC($fam.".".$id."00")); $crc = sprintf("%02x",OWX_CRC($fam.".".$id."00"));
@@ -267,6 +277,10 @@ sub OWCOUNT_Define ($$) {
} }
$modules{OWCOUNT}{defptr}{$id} = $hash; $modules{OWCOUNT}{defptr}{$id} = $hash;
#-- #--
readingsSingleUpdate($hash,"state","defined",1); readingsSingleUpdate($hash,"state","defined",1);
Log3 $name, 3, "OWCOUNT: Device $name defined."; Log3 $name, 3, "OWCOUNT: Device $name defined.";
@@ -334,6 +348,11 @@ sub OWCOUNT_InitializeDevice($) {
my $newdata = "OWCOUNT ".$owx_version; my $newdata = "OWCOUNT ".$owx_version;
my $ret; my $ret;
#-- post-define: check model
if( !defined($attr{$hash->{NAME}}{"model"}) ){
CommandAttr (undef,$hash->{NAME}." model $owgmodel");
}
#-- initial values #-- initial values
for( my $i=0;$i<int(@owg_fixed);$i++) { for( my $i=0;$i<int(@owg_fixed);$i++) {
#-- initial readings #-- initial readings
@@ -342,19 +361,6 @@ sub OWCOUNT_InitializeDevice($) {
$hash->{owg_str}->[$i] = ""; $hash->{owg_str}->[$i] = "";
} }
#-- Check memory string
my $memory;
if( ($owg_memory[0]==1) && ($owg_memory[1]==1) ){
$memory="page 0..13 and midnight";
}elsif( ($owg_memory[0]==0) && ($owg_memory[1]==1) ){
$memory="midnight only";
}elsif( ($owg_memory[0]==1) && ($owg_memory[1]==0) ){
$memory="page 0..13 only";
}else{
$memory="no pages, no midnight";
}
readingsSingleUpdate($hash,"memory","$memory",0);
#-- Set state to initialized #-- Set state to initialized
readingsSingleUpdate($hash,"state","initialized",1); readingsSingleUpdate($hash,"state","initialized",1);
@@ -524,30 +530,24 @@ sub OWCOUNT_FormatValues($) {
#-- put into READING #-- put into READING
readingsBeginUpdate($hash); readingsBeginUpdate($hash);
#-- Check memory string #-- Check memory string only if model is defined automatically
if( $owgauto ){
my $msg = "OWCOUNT: In device $name, ";
if( $owg_memory[2]==1 ){ if( $owg_memory[2]==1 ){
my $memory;
my $model = $hash->{OW_MODEL};
my $nomemory;
if( ($owg_memory[0]==1) && ($owg_memory[1]==1) ){ if( ($owg_memory[0]==1) && ($owg_memory[1]==1) ){
$memory = "page 0..13 and midnight"; Log 1, $msg."memory pages 0..13 and midnight store present, model should be DS2423"
$model = "DS2423"; if( $attr{$name}{"model"} ne "DS2423");
$nomemory = 0;
}elsif( ($owg_memory[0]==0) && ($owg_memory[1]==1) ){ }elsif( ($owg_memory[0]==0) && ($owg_memory[1]==1) ){
$memory="midnight only"; Log 1, $msg."midnight store only, model should be DS2423enew"
$model = "DS2423enew"; if( $attr{$name}{"model"} ne "DS2423enew");
$nomemory = 0;
}else{ }else{
$memory="no pages, no midnight"; Log 1, $msg."no memory pages and no midnight store found, model should be DS2423eold"
$model = "DS2423eold"; if( $attr{$name}{"model"} ne "DS2423eold");
$nomemory = 1;
} }
CommandAttr (undef,"$name model ".$model);
CommandAttr (undef,"$name nomemory ".$nomemory);
readingsBulkUpdate($hash,"memory","$memory");
$owg_memory[2]=0; $owg_memory[2]=0;
} }
$owgauto=0;
}
#-- formats for output #-- formats for output
for (my $i=0;$i<int(@owg_fixed);$i++){ for (my $i=0;$i<int(@owg_fixed);$i++){

View File

@@ -68,7 +68,7 @@ use ProtoThreads;
no warnings 'deprecated'; no warnings 'deprecated';
sub Log3($$$); sub Log3($$$);
my $owx_version="6.0beta6"; my $owx_version="6.01";
#-- declare variables #-- declare variables
my %gets = ( my %gets = (
"present" => "", "present" => "",

View File

@@ -79,14 +79,13 @@ no warnings 'deprecated';
sub Log3($$$); sub Log3($$$);
my $owx_version="6.0beta6"; my $owx_version="6.01";
#-- controller may be HD44780 or KS0073 #-- controller may be HD44780 or KS0073
# these values have to be changed for different display # these values can be changed by attribute for different display
# geometries or memory maps # geometries or memory maps
my $lcdcontroller = "KS0073"; my $lcdcontroller = "KS0073";
my $lcdlines = 4; my $lcdlines = 4;
my $lcdchars = 20; my $lcdchars = 20;
my @lcdpage = (0,32,64,96); my @lcdpage = (0,32,64,96);
#-- declare variables #-- declare variables
@@ -139,7 +138,7 @@ sub OWLCD_Initialize ($) {
$hash->{InitFn} = "OWLCD_Init"; $hash->{InitFn} = "OWLCD_Init";
$hash->{AttrFn} = "OWLCD_Attr"; $hash->{AttrFn} = "OWLCD_Attr";
my $attlist = "IODev do_not_notify:0,1 showtime:0,1 ". my $attlist = "IODev do_not_notify:0,1 showtime:0,1 ".
"lcdgeometry:0-32-64-96,0-64-20-84 ". "lcdgeometry:0-32-64-96,0-64-20-84 lcdcontroller:KS0073,HD44780 ".
$readingFnAttributes; $readingFnAttributes;
$hash->{AttrList} = $attlist; $hash->{AttrList} = $attlist;
@@ -302,6 +301,14 @@ sub OWLCD_Attr(@) {
} }
last; last;
}; };
$key eq "lcdcontroller" and do {
if( $value eq "KS0073," ){
$lcdcontroller = "KS0073";
}elsif( $value eq "HD44780" ){
$lcdcontroller = "HD44780";
}
last;
};
}; };
#} elsif ( $do eq "del" ) { #} elsif ( $do eq "del" ) {
# ARGUMENT_HANDLER: { # ARGUMENT_HANDLER: {
@@ -345,9 +352,6 @@ sub OWLCD_Get($@) {
return "$name.id => $value"; return "$name.id => $value";
} }
#-- hash of the busmaster
my $master = $hash->{IODev};
#-- get present #-- get present
if($a[1] eq "present") { if($a[1] eq "present") {
#-- asynchronous mode #-- asynchronous mode
@@ -1467,7 +1471,8 @@ sub OWXLCD_Trans($) {
my ($msg) = @_; my ($msg) = @_;
#-- replace umlaut chars for special codepage #-- replace umlaut chars for special codepage of KS0073
if( $lcdcontroller eq "KS0073") {
$msg =~ s/ä/\x7B/g; $msg =~ s/ä/\x7B/g;
$msg =~ s/ö/\x7C/g; $msg =~ s/ö/\x7C/g;
$msg =~ s/ü/\x7E/g; $msg =~ s/ü/\x7E/g;
@@ -1475,13 +1480,21 @@ sub OWXLCD_Trans($) {
$msg =~ s/Ö/\x5C/g; $msg =~ s/Ö/\x5C/g;
$msg =~ s/Ü/\x5E/g; $msg =~ s/Ü/\x5E/g;
$msg =~ s/ß/\xBE/g; $msg =~ s/ß/\xBE/g;
$msg =~ s/°/\x80/g;
#-- replace umlaut chars for special codepage of HD44780
}elsif( $lcdcontroller eq "HD44780") {
$msg =~ s/ä/\xE1/g;
$msg =~ s/ö/\xEF/g;
$msg =~ s/ü/\xF5/g;
$msg =~ s/Ü/\x03/g;
$msg =~ s/Ö/\x02/g;
$msg =~ s/Ä/\x01/g;
$msg =~ s/ß/\xE2/g;
$msg =~ s/°/\xDF/g;
}
#-- replace other special chars #-- replace other special chars
$msg =~s/_/\xC4/g; $msg =~s/_/\xC4/g;
#--take out HTML degree sign
if( $msg =~ m/.*\&deg\;.*/ ) {
my @ma = split(/\&deg\;/,$msg);
$msg = $ma[0]."\x80".$ma[1];
}
return $msg; return $msg;
} }
@@ -2122,7 +2135,10 @@ sub OWXLCD_PT_SetMemory($$$) {
<ul> <ul>
<li><a name="owlcd_lcdgeometry"> <li><a name="owlcd_lcdgeometry">
<code>attr &lt;name&gt; lcdgeometry &lt;string&gt;</code></a><br /> <code>attr &lt;name&gt; lcdgeometry &lt;string&gt;</code></a><br />
LCD geometry, values are 0-32-64-96 or 0-64-20-84</li> LCD geometry, values are 0-32-64-96 (default) or 0-64-20-84</li>
<li><a name="owlcd_lcdgcontroller">
<code>attr &lt;name&gt; lcdcontroller &lt;string&gt;</code></a><br />
LCD geometry, values are KS0073 (default) HD44780</li>
<li><a href="#readingFnAttributes">readingFnAttributes</a></li> <li><a href="#readingFnAttributes">readingFnAttributes</a></li>
</ul> </ul>

View File

@@ -28,7 +28,7 @@
# get <name> reading => measurement value obtained from VFunction # get <name> reading => measurement value obtained from VFunction
# get <name> temperature => temperature measurement # get <name> temperature => temperature measurement
# get <name> VDD => supply voltage measurement # get <name> VDD => supply voltage measurement
# get <name> V|I|raw => external voltage/external current/raw measurement # get <name> raw => raw measurement voltages
# get <name> version => OWX version number # get <name> version => OWX version number
# #
# set <name> interval => set period for measurement # set <name> interval => set period for measurement
@@ -87,7 +87,7 @@ no warnings 'deprecated';
sub Log($$); sub Log($$);
my $owx_version="6.0"; my $owx_version="6.01";
#-- flexible channel name #-- flexible channel name
my ($owg_channel,$owg_schannel); my ($owg_channel,$owg_schannel);
@@ -1462,14 +1462,13 @@ sub OWXMULTI_PT_SetValues($@) {
<code>get &lt;name&gt; interval</code></a><br />Returns measurement interval in <code>get &lt;name&gt; interval</code></a><br />Returns measurement interval in
seconds. </li> seconds. </li>
<li><a name="owmulti_reading"> <li><a name="owmulti_reading">
<code>get &lt;name&gt; reading</code></a><br />Obtain the measurement values </li> <code>get &lt;name&gt; reading</code></a><br />Obtain all three measurement values. </li>
<li><a name="owmulti_temperature"> <li><a name="owmulti_temperature">
<code>get &lt;name&gt; temperature</code></a><br />Obtain the temperature value. </li> <code>get &lt;name&gt; temperature</code></a><br />Obtain the temperature value. </li>
<li><a name="owmulti_vdd"> <li><a name="owmulti_vdd">
<code>get &lt;name&gt; VDD</code></a><br />Obtain the current supply voltage. </li> <code>get &lt;name&gt; VDD</code></a><br />Obtain the current supply voltage. </li>
<li><a name="owmulti_raw"> <li><a name="owmulti_raw">
<code>get &lt;name&gt; V</code> or <code>get &lt;name&gt; <code>get &lt;name&gt; raw</code></a><br />Obtain the raw readings for V and W.</li>
raw</code></a><br />Obtain the raw external voltage and external sense measurement. </li>
</ul> </ul>
<a name="OWMULTIattr"></a> <a name="OWMULTIattr"></a>
<h4>Attributes</h4> <h4>Attributes</h4>

View File

@@ -87,7 +87,7 @@ no warnings 'deprecated';
sub Log($$); sub Log($$);
my $owx_version="6.0"; my $owx_version="6.01";
#-- fixed raw channel name, flexible channel name #-- fixed raw channel name, flexible channel name
my @owg_fixed = ("A","B","C","D","E","F","G","H"); my @owg_fixed = ("A","B","C","D","E","F","G","H");
my @owg_channel = ("A","B","C","D","E","F","G","H"); my @owg_channel = ("A","B","C","D","E","F","G","H");
@@ -1102,17 +1102,15 @@ sub OWXSWITCH_BinValues($$$$$$$) {
#-- now only if data has to be overwritten #-- now only if data has to be overwritten
if( $cmd eq "mod" ){ if( $cmd eq "mod" ){
my $gpio = 0; my $gpio = 0;
#--
for (my $i=0;$i<$cnumber{$attr{$name}{"model"}};$i++){ for (my $i=0;$i<$cnumber{$attr{$name}{"model"}};$i++){
if( $outval==0 ){
$gpio += ($hash->{owg_vax}->[$i]<<$i) $gpio += ($hash->{owg_vax}->[$i]<<$i)
if( $i != $outfnd ); };
if( $outval==0 ){
$gpio &= ~(1<<$outfnd);
}else{ }else{
$gpio += ($hash->{owg_vax}->[$i]<<$i); $gpio |= (1<<$outfnd);
$gpio += (1<<$i)
if( $i == $outfnd );
}
} }
#Log 1,"DEBUGGING OWXNG : After reading old gpio as $old, with outval=$outval and outfnd=$outfnd we are setting a new gpio as $gpio";
#-- re-set the state #-- re-set the state
OWXSWITCH_SetState($hash,$gpio); OWXSWITCH_SetState($hash,$gpio);
} }