diff --git a/fhem/FHEM/21_OWCOUNT.pm b/fhem/FHEM/21_OWCOUNT.pm index 34154d1a6..0e02fe257 100644 --- a/fhem/FHEM/21_OWCOUNT.pm +++ b/fhem/FHEM/21_OWCOUNT.pm @@ -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{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 diff --git a/fhem/FHEM/21_OWID.pm b/fhem/FHEM/21_OWID.pm index d3728513b..a4426fbf5 100644 --- a/fhem/FHEM/21_OWID.pm +++ b/fhem/FHEM/21_OWID.pm @@ -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"; diff --git a/fhem/FHEM/21_OWLCD.pm b/fhem/FHEM/21_OWLCD.pm index 82f6a904e..0b87e2fe5 100644 --- a/fhem/FHEM/21_OWLCD.pm +++ b/fhem/FHEM/21_OWLCD.pm @@ -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($$$) { diff --git a/fhem/FHEM/21_OWMULTI.pm b/fhem/FHEM/21_OWMULTI.pm index ff4cb86f0..601e8d2e1 100644 --- a/fhem/FHEM/21_OWMULTI.pm +++ b/fhem/FHEM/21_OWMULTI.pm @@ -28,7 +28,7 @@ # get reading => measurement value obtained from VFunction # get temperature => temperature measurement # get VDD => supply voltage measurement -# get V|I|raw => external voltage/external current/raw measurement +# get raw => raw measurement voltages # get version => OWX version number # # set 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($@) { get <name> interval
Returns measurement interval in seconds.
  • - get <name> reading
    Obtain the measurement values
  • + get <name> reading
    Obtain all three measurement values.
  • get <name> temperature
    Obtain the temperature value.
  • get <name> VDD
    Obtain the current supply voltage.
  • - get <name> V or get <name> - raw
    Obtain the raw external voltage and external sense measurement.
  • + get <name> raw
    Obtain the raw readings for V and W.

    Attributes

    diff --git a/fhem/FHEM/21_OWSWITCH.pm b/fhem/FHEM/21_OWSWITCH.pm index 53e60fdfd..855ea73e0 100644 --- a/fhem/FHEM/21_OWSWITCH.pm +++ b/fhem/FHEM/21_OWSWITCH.pm @@ -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); }