mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-11 14:37:59 +00:00
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:
parent
42ffc3a2d0
commit
2431cd3a4a
@ -99,13 +99,15 @@ no warnings 'deprecated';
|
||||
|
||||
sub Log3($$$);
|
||||
|
||||
my $owx_version="6.0";
|
||||
my $owx_version="6.01";
|
||||
#-- fixed raw channel name, flexible channel name
|
||||
my @owg_fixed = ("A","B");
|
||||
my @owg_channel = ("A","B");
|
||||
my @owg_rate = ("A_rate","B_rate");
|
||||
#-- initially assume that both memory types (low, high) are present
|
||||
my @owg_memory = (1,1,0);
|
||||
my $owgmodel;
|
||||
my $owgauto = 0;
|
||||
|
||||
my %gets = (
|
||||
"id" => "",
|
||||
@ -208,7 +210,8 @@ sub OWCOUNT_Define ($$) {
|
||||
#-- no model, 12 characters
|
||||
if( $a2 =~ m/^[0-9|a-f|A-F]{12}$/ ) {
|
||||
$model = "DS2423";
|
||||
CommandAttr (undef,"$name model DS2423");
|
||||
$owgauto =1;
|
||||
#CommandAttr (undef,"$name model DS2423");
|
||||
$fam = "1D";
|
||||
$id = $a[2];
|
||||
if(int(@a)>=4) { $interval = $a[3]; }
|
||||
@ -219,7 +222,8 @@ sub OWCOUNT_Define ($$) {
|
||||
if(int(@a)>=4) { $interval = $a[3]; }
|
||||
if( $fam eq "1D" ){
|
||||
$model = "DS2423";
|
||||
CommandAttr (undef,"$name model DS2423");
|
||||
$owgauto =1;
|
||||
#CommandAttr (undef,"$name model DS2423");
|
||||
}else{
|
||||
return "OWCOUNT: Wrong 1-Wire device family $fam";
|
||||
}
|
||||
@ -230,23 +234,29 @@ sub OWCOUNT_Define ($$) {
|
||||
if(int(@a)>=5) { $interval = $a[4]; }
|
||||
if( $model eq "DS2423" ){
|
||||
$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);
|
||||
}elsif( $model eq "DS2423enew" ){
|
||||
$fam = "1D";
|
||||
@owg_memory = (1,1,0);
|
||||
CommandAttr (undef,"$name model DS2423enew");
|
||||
#CommandAttr (undef,"$name model DS2423enew");
|
||||
}elsif( $model eq "DS2423eold" ){
|
||||
$fam = "1D";
|
||||
CommandAttr (undef,"$name model DS2423eold");
|
||||
CommandAttr (undef,"$name nomemory 1");
|
||||
@owg_memory = (0,0,0);
|
||||
#CommandAttr (undef,"$name model DS2423eold");
|
||||
#CommandAttr (undef,"$name nomemory 1");
|
||||
@owg_memory = (0,0,0);
|
||||
}else{
|
||||
return "OWCOUNT: Wrong 1-Wire device model $model";
|
||||
}
|
||||
} else {
|
||||
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
|
||||
$crc = sprintf("%02x",OWX_CRC($fam.".".$id."00"));
|
||||
@ -267,6 +277,10 @@ sub OWCOUNT_Define ($$) {
|
||||
}
|
||||
|
||||
$modules{OWCOUNT}{defptr}{$id} = $hash;
|
||||
|
||||
|
||||
|
||||
|
||||
#--
|
||||
readingsSingleUpdate($hash,"state","defined",1);
|
||||
Log3 $name, 3, "OWCOUNT: Device $name defined.";
|
||||
@ -333,6 +347,11 @@ sub OWCOUNT_InitializeDevice($) {
|
||||
my ($olddata1,$olddata2);
|
||||
my $newdata = "OWCOUNT ".$owx_version;
|
||||
my $ret;
|
||||
|
||||
#-- post-define: check model
|
||||
if( !defined($attr{$hash->{NAME}}{"model"}) ){
|
||||
CommandAttr (undef,$hash->{NAME}." model $owgmodel");
|
||||
}
|
||||
|
||||
#-- initial values
|
||||
for( my $i=0;$i<int(@owg_fixed);$i++) {
|
||||
@ -341,19 +360,6 @@ sub OWCOUNT_InitializeDevice($) {
|
||||
$hash->{owg_midnight}->[$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
|
||||
readingsSingleUpdate($hash,"state","initialized",1);
|
||||
@ -524,29 +530,23 @@ sub OWCOUNT_FormatValues($) {
|
||||
#-- put into READING
|
||||
readingsBeginUpdate($hash);
|
||||
|
||||
#-- Check memory string
|
||||
if( $owg_memory[2]==1 ){
|
||||
my $memory;
|
||||
my $model = $hash->{OW_MODEL};
|
||||
my $nomemory;
|
||||
|
||||
if( ($owg_memory[0]==1) && ($owg_memory[1]==1) ){
|
||||
$memory = "page 0..13 and midnight";
|
||||
$model = "DS2423";
|
||||
$nomemory = 0;
|
||||
}elsif( ($owg_memory[0]==0) && ($owg_memory[1]==1) ){
|
||||
$memory="midnight only";
|
||||
$model = "DS2423enew";
|
||||
$nomemory = 0;
|
||||
}else{
|
||||
$memory="no pages, no midnight";
|
||||
$model = "DS2423eold";
|
||||
$nomemory = 1;
|
||||
}
|
||||
CommandAttr (undef,"$name model ".$model);
|
||||
CommandAttr (undef,"$name nomemory ".$nomemory);
|
||||
readingsBulkUpdate($hash,"memory","$memory");
|
||||
$owg_memory[2]=0;
|
||||
#-- 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[0]==1) && ($owg_memory[1]==1) ){
|
||||
Log 1, $msg."memory pages 0..13 and midnight store present, model should be DS2423"
|
||||
if( $attr{$name}{"model"} ne "DS2423");
|
||||
}elsif( ($owg_memory[0]==0) && ($owg_memory[1]==1) ){
|
||||
Log 1, $msg."midnight store only, model should be DS2423enew"
|
||||
if( $attr{$name}{"model"} ne "DS2423enew");
|
||||
}else{
|
||||
Log 1, $msg."no memory pages and no midnight store found, model should be DS2423eold"
|
||||
if( $attr{$name}{"model"} ne "DS2423eold");
|
||||
}
|
||||
$owg_memory[2]=0;
|
||||
}
|
||||
$owgauto=0;
|
||||
}
|
||||
|
||||
#-- formats for output
|
||||
|
@ -68,7 +68,7 @@ use ProtoThreads;
|
||||
no warnings 'deprecated';
|
||||
sub Log3($$$);
|
||||
|
||||
my $owx_version="6.0beta6";
|
||||
my $owx_version="6.01";
|
||||
#-- declare variables
|
||||
my %gets = (
|
||||
"present" => "",
|
||||
@ -211,7 +211,7 @@ sub OWID_Define ($$) {
|
||||
$modules{OWID}{defptr}{$id} = $hash;
|
||||
#--
|
||||
readingsSingleUpdate($hash,"state","Defined",1);
|
||||
Log3 $name,1, "OWID: Device $name defined.";
|
||||
Log3 $name,1, "OWID: Device $name defined.";
|
||||
|
||||
$hash->{NOTIFYDEV} = "global";
|
||||
|
||||
|
@ -79,14 +79,13 @@ no warnings 'deprecated';
|
||||
|
||||
sub Log3($$$);
|
||||
|
||||
my $owx_version="6.0beta6";
|
||||
my $owx_version="6.01";
|
||||
#-- 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
|
||||
my $lcdcontroller = "KS0073";
|
||||
my $lcdlines = 4;
|
||||
my $lcdchars = 20;
|
||||
|
||||
my @lcdpage = (0,32,64,96);
|
||||
|
||||
#-- declare variables
|
||||
@ -139,7 +138,7 @@ sub OWLCD_Initialize ($) {
|
||||
$hash->{InitFn} = "OWLCD_Init";
|
||||
$hash->{AttrFn} = "OWLCD_Attr";
|
||||
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;
|
||||
$hash->{AttrList} = $attlist;
|
||||
|
||||
@ -295,10 +294,18 @@ sub OWLCD_Attr(@) {
|
||||
last;
|
||||
};
|
||||
$key eq "lcdgeometry" and do {
|
||||
if( $value eq "0-32-64-96" ){
|
||||
@lcdpage = (0,32,64,96);
|
||||
if( $value eq "0-32-64-96" ){
|
||||
@lcdpage = (0,32,64,96);
|
||||
}elsif( $value eq "0-64-20-84" ){
|
||||
@lcdpage = (0,64,20,84);
|
||||
@lcdpage = (0,64,20,84);
|
||||
}
|
||||
last;
|
||||
};
|
||||
$key eq "lcdcontroller" and do {
|
||||
if( $value eq "KS0073," ){
|
||||
$lcdcontroller = "KS0073";
|
||||
}elsif( $value eq "HD44780" ){
|
||||
$lcdcontroller = "HD44780";
|
||||
}
|
||||
last;
|
||||
};
|
||||
@ -345,9 +352,6 @@ sub OWLCD_Get($@) {
|
||||
return "$name.id => $value";
|
||||
}
|
||||
|
||||
#-- hash of the busmaster
|
||||
my $master = $hash->{IODev};
|
||||
|
||||
#-- get present
|
||||
if($a[1] eq "present") {
|
||||
#-- asynchronous mode
|
||||
@ -1467,21 +1471,30 @@ sub OWXLCD_Trans($) {
|
||||
|
||||
my ($msg) = @_;
|
||||
|
||||
#-- replace umlaut chars for special codepage
|
||||
$msg =~ s/ä/\x7B/g;
|
||||
$msg =~ s/ö/\x7C/g;
|
||||
$msg =~ s/ü/\x7E/g;
|
||||
$msg =~ s/Ä/\x5B/g;
|
||||
$msg =~ s/Ö/\x5C/g;
|
||||
$msg =~ s/Ü/\x5E/g;
|
||||
$msg =~ s/ß/\xBE/g;
|
||||
#-- replace umlaut chars for special codepage of KS0073
|
||||
if( $lcdcontroller eq "KS0073") {
|
||||
$msg =~ s/ä/\x7B/g;
|
||||
$msg =~ s/ö/\x7C/g;
|
||||
$msg =~ s/ü/\x7E/g;
|
||||
$msg =~ s/Ä/\x5B/g;
|
||||
$msg =~ s/Ö/\x5C/g;
|
||||
$msg =~ s/Ü/\x5E/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
|
||||
$msg =~s/_/\xC4/g;
|
||||
#--take out HTML degree sign
|
||||
if( $msg =~ m/.*\°\;.*/ ) {
|
||||
my @ma = split(/\°\;/,$msg);
|
||||
$msg = $ma[0]."\x80".$ma[1];
|
||||
}
|
||||
return $msg;
|
||||
}
|
||||
|
||||
@ -2122,7 +2135,10 @@ sub OWXLCD_PT_SetMemory($$$) {
|
||||
<ul>
|
||||
<li><a name="owlcd_lcdgeometry">
|
||||
<code>attr <name> lcdgeometry <string></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 <name> lcdcontroller <string></code></a><br />
|
||||
LCD geometry, values are KS0073 (default) HD44780</li>
|
||||
<li><a href="#readingFnAttributes">readingFnAttributes</a></li>
|
||||
</ul>
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
# get <name> reading => measurement value obtained from VFunction
|
||||
# get <name> temperature => temperature 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
|
||||
#
|
||||
# set <name> interval => set period for measurement
|
||||
@ -87,7 +87,7 @@ no warnings 'deprecated';
|
||||
|
||||
sub Log($$);
|
||||
|
||||
my $owx_version="6.0";
|
||||
my $owx_version="6.01";
|
||||
#-- flexible channel name
|
||||
my ($owg_channel,$owg_schannel);
|
||||
|
||||
@ -1462,14 +1462,13 @@ sub OWXMULTI_PT_SetValues($@) {
|
||||
<code>get <name> interval</code></a><br />Returns measurement interval in
|
||||
seconds. </li>
|
||||
<li><a name="owmulti_reading">
|
||||
<code>get <name> reading</code></a><br />Obtain the measurement values </li>
|
||||
<code>get <name> reading</code></a><br />Obtain all three measurement values. </li>
|
||||
<li><a name="owmulti_temperature">
|
||||
<code>get <name> temperature</code></a><br />Obtain the temperature value. </li>
|
||||
<li><a name="owmulti_vdd">
|
||||
<code>get <name> VDD</code></a><br />Obtain the current supply voltage. </li>
|
||||
<li><a name="owmulti_raw">
|
||||
<code>get <name> V</code> or <code>get <name>
|
||||
raw</code></a><br />Obtain the raw external voltage and external sense measurement. </li>
|
||||
<code>get <name> raw</code></a><br />Obtain the raw readings for V and W.</li>
|
||||
</ul>
|
||||
<a name="OWMULTIattr"></a>
|
||||
<h4>Attributes</h4>
|
||||
|
@ -87,7 +87,7 @@ no warnings 'deprecated';
|
||||
|
||||
sub Log($$);
|
||||
|
||||
my $owx_version="6.0";
|
||||
my $owx_version="6.01";
|
||||
#-- fixed raw channel name, flexible channel name
|
||||
my @owg_fixed = ("A","B","C","D","E","F","G","H");
|
||||
my @owg_channel = ("A","B","C","D","E","F","G","H");
|
||||
@ -1101,18 +1101,16 @@ sub OWXSWITCH_BinValues($$$$$$$) {
|
||||
};
|
||||
#-- now only if data has to be overwritten
|
||||
if( $cmd eq "mod" ){
|
||||
my $gpio = 0;
|
||||
#--
|
||||
my $gpio = 0;
|
||||
for (my $i=0;$i<$cnumber{$attr{$name}{"model"}};$i++){
|
||||
if( $outval==0 ){
|
||||
$gpio += ($hash->{owg_vax}->[$i]<<$i)
|
||||
if( $i != $outfnd );
|
||||
}else{
|
||||
$gpio += ($hash->{owg_vax}->[$i]<<$i);
|
||||
$gpio += (1<<$i)
|
||||
if( $i == $outfnd );
|
||||
}
|
||||
}
|
||||
$gpio += ($hash->{owg_vax}->[$i]<<$i)
|
||||
};
|
||||
if( $outval==0 ){
|
||||
$gpio &= ~(1<<$outfnd);
|
||||
}else{
|
||||
$gpio |= (1<<$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
|
||||
OWXSWITCH_SetState($hash,$gpio);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user