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:
@@ -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,17 +234,21 @@ 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,29 +530,23 @@ 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( $owg_memory[2]==1 ){
|
if( $owgauto ){
|
||||||
my $memory;
|
my $msg = "OWCOUNT: In device $name, ";
|
||||||
my $model = $hash->{OW_MODEL};
|
if( $owg_memory[2]==1 ){
|
||||||
my $nomemory;
|
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( ($owg_memory[0]==1) && ($owg_memory[1]==1) ){
|
if( $attr{$name}{"model"} ne "DS2423");
|
||||||
$memory = "page 0..13 and midnight";
|
}elsif( ($owg_memory[0]==0) && ($owg_memory[1]==1) ){
|
||||||
$model = "DS2423";
|
Log 1, $msg."midnight store only, model should be DS2423enew"
|
||||||
$nomemory = 0;
|
if( $attr{$name}{"model"} ne "DS2423enew");
|
||||||
}elsif( ($owg_memory[0]==0) && ($owg_memory[1]==1) ){
|
}else{
|
||||||
$memory="midnight only";
|
Log 1, $msg."no memory pages and no midnight store found, model should be DS2423eold"
|
||||||
$model = "DS2423enew";
|
if( $attr{$name}{"model"} ne "DS2423eold");
|
||||||
$nomemory = 0;
|
}
|
||||||
}else{
|
$owg_memory[2]=0;
|
||||||
$memory="no pages, no midnight";
|
|
||||||
$model = "DS2423eold";
|
|
||||||
$nomemory = 1;
|
|
||||||
}
|
}
|
||||||
CommandAttr (undef,"$name model ".$model);
|
$owgauto=0;
|
||||||
CommandAttr (undef,"$name nomemory ".$nomemory);
|
|
||||||
readingsBulkUpdate($hash,"memory","$memory");
|
|
||||||
$owg_memory[2]=0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#-- formats for output
|
#-- formats for output
|
||||||
|
|||||||
@@ -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" => "",
|
||||||
@@ -211,7 +211,7 @@ sub OWID_Define ($$) {
|
|||||||
$modules{OWID}{defptr}{$id} = $hash;
|
$modules{OWID}{defptr}{$id} = $hash;
|
||||||
#--
|
#--
|
||||||
readingsSingleUpdate($hash,"state","Defined",1);
|
readingsSingleUpdate($hash,"state","Defined",1);
|
||||||
Log3 $name,1, "OWID: Device $name defined.";
|
Log3 $name,1, "OWID: Device $name defined.";
|
||||||
|
|
||||||
$hash->{NOTIFYDEV} = "global";
|
$hash->{NOTIFYDEV} = "global";
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|
||||||
@@ -295,10 +294,18 @@ sub OWLCD_Attr(@) {
|
|||||||
last;
|
last;
|
||||||
};
|
};
|
||||||
$key eq "lcdgeometry" and do {
|
$key eq "lcdgeometry" and do {
|
||||||
if( $value eq "0-32-64-96" ){
|
if( $value eq "0-32-64-96" ){
|
||||||
@lcdpage = (0,32,64,96);
|
@lcdpage = (0,32,64,96);
|
||||||
}elsif( $value eq "0-64-20-84" ){
|
}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;
|
last;
|
||||||
};
|
};
|
||||||
@@ -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,21 +1471,30 @@ sub OWXLCD_Trans($) {
|
|||||||
|
|
||||||
my ($msg) = @_;
|
my ($msg) = @_;
|
||||||
|
|
||||||
#-- replace umlaut chars for special codepage
|
#-- replace umlaut chars for special codepage of KS0073
|
||||||
$msg =~ s/ä/\x7B/g;
|
if( $lcdcontroller eq "KS0073") {
|
||||||
$msg =~ s/ö/\x7C/g;
|
$msg =~ s/ä/\x7B/g;
|
||||||
$msg =~ s/ü/\x7E/g;
|
$msg =~ s/ö/\x7C/g;
|
||||||
$msg =~ s/Ä/\x5B/g;
|
$msg =~ s/ü/\x7E/g;
|
||||||
$msg =~ s/Ö/\x5C/g;
|
$msg =~ s/Ä/\x5B/g;
|
||||||
$msg =~ s/Ü/\x5E/g;
|
$msg =~ s/Ö/\x5C/g;
|
||||||
$msg =~ s/ß/\xBE/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
|
#-- replace other special chars
|
||||||
$msg =~s/_/\xC4/g;
|
$msg =~s/_/\xC4/g;
|
||||||
#--take out HTML degree sign
|
|
||||||
if( $msg =~ m/.*\°\;.*/ ) {
|
|
||||||
my @ma = split(/\°\;/,$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 <name> lcdgeometry <string></code></a><br />
|
<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>
|
<li><a href="#readingFnAttributes">readingFnAttributes</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|||||||
@@ -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 <name> interval</code></a><br />Returns measurement interval in
|
<code>get <name> interval</code></a><br />Returns measurement interval in
|
||||||
seconds. </li>
|
seconds. </li>
|
||||||
<li><a name="owmulti_reading">
|
<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">
|
<li><a name="owmulti_temperature">
|
||||||
<code>get <name> temperature</code></a><br />Obtain the temperature value. </li>
|
<code>get <name> temperature</code></a><br />Obtain the temperature value. </li>
|
||||||
<li><a name="owmulti_vdd">
|
<li><a name="owmulti_vdd">
|
||||||
<code>get <name> VDD</code></a><br />Obtain the current supply voltage. </li>
|
<code>get <name> VDD</code></a><br />Obtain the current supply voltage. </li>
|
||||||
<li><a name="owmulti_raw">
|
<li><a name="owmulti_raw">
|
||||||
<code>get <name> V</code> or <code>get <name>
|
<code>get <name> 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>
|
||||||
|
|||||||
@@ -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");
|
||||||
@@ -1101,18 +1101,16 @@ 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 ){
|
||||||
}else{
|
$gpio &= ~(1<<$outfnd);
|
||||||
$gpio += ($hash->{owg_vax}->[$i]<<$i);
|
}else{
|
||||||
$gpio += (1<<$i)
|
$gpio |= (1<<$outfnd);
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user