From 279e549058e608e8e99fdc433531ec37e350f635 Mon Sep 17 00:00:00 2001 From: phenning <> Date: Sun, 29 Oct 2017 08:14:07 +0000 Subject: [PATCH] 21_OWAD.pm: Neue Version 7.01 21_OWCOUNT.pm: Neue Version 7.01 21_OWID.pm: Neue Version 7.01 21_OWLCD.pm: Neue Version 7.01 21_OWMULTI.pm: Neue Version 7.01 21_OWSWITCH.pm: Neue Version 7.01 21_OWTHERM.pm: Neue Version 7.01 21_OWVAR.pm: Neue Version 7.01 95_Alarm.pm: Neue Version git-svn-id: https://svn.fhem.de/fhem/trunk@15339 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/21_OWAD.pm | 35 +++++++++++++++++++++++----------- fhem/FHEM/21_OWCOUNT.pm | 41 +++++++++++++++++++++++++--------------- fhem/FHEM/21_OWID.pm | 14 ++++++++------ fhem/FHEM/21_OWLCD.pm | 36 +++++++++++++++++++++++------------ fhem/FHEM/21_OWMULTI.pm | 31 +++++++++++++++++++----------- fhem/FHEM/21_OWSWITCH.pm | 23 +++++++++++++++------- fhem/FHEM/21_OWTHERM.pm | 15 ++++++++------- fhem/FHEM/21_OWVAR.pm | 10 ++++++---- fhem/FHEM/95_Alarm.pm | 4 ++-- 9 files changed, 134 insertions(+), 75 deletions(-) diff --git a/fhem/FHEM/21_OWAD.pm b/fhem/FHEM/21_OWAD.pm index 63f9f4060..24c4bd65b 100644 --- a/fhem/FHEM/21_OWAD.pm +++ b/fhem/FHEM/21_OWAD.pm @@ -48,7 +48,7 @@ use ProtoThreads; no warnings 'deprecated'; sub Log3($$$); -my $owx_version="7.0"; +my $owx_version="7.01"; #-- fixed raw channel name, flexible channel name my @owg_fixed = ("A","B","C","D"); my @owg_channel = ("A","B","C","D"); @@ -60,11 +60,11 @@ my @owg_resoln; my @owg_range; my %gets = ( - "id" => "", - "reading" => "", - "alarm" => "", - "status" => "", - "version" => "" + "id" => ":noArg", + "reading" => ":noArg", + "alarm" => ":noArg", + "status" => ":noArg", + "version" => ":noArg" ); my %sets = ( @@ -218,6 +218,7 @@ sub OWAD_Define ($$) { $hash->{PRESENT} = 0; $hash->{INTERVAL} = $interval; $hash->{ERRCOUNT} = 0; + $hash->{ERRSTATE} = 0; #-- Couple to I/O device AssignIoPort($hash); @@ -534,7 +535,9 @@ sub OWAD_Get($@) { if(int(@a) != 2); #-- check argument - return "OWAD: Get with unknown argument $a[1], choose one of ".join(" ", sort keys %gets) + my $msg = "OWAD: Get with unknown argument $a[1], choose one of "; + $msg .= "$_$gets{$_} " foreach (keys%gets); + return $msg if(!defined($gets{$a[1]})); #-- get id @@ -548,6 +551,9 @@ sub OWAD_Get($@) { return "$name.version => $owx_version"; } + #-- reset current ERRSTATE + $hash->{ERRSTATE} = 0; + #-- get reading according to interface type if($a[1] eq "reading") { #-- OWX interface @@ -708,6 +714,9 @@ sub OWAD_GetValues($) { if( $hash->{INTERVAL} == 0 ); #-- restart timer for updates InternalTimer(time()+$hash->{INTERVAL}, "OWAD_GetValues", $hash, 0); + + #-- reset current ERRSTATE + $hash->{ERRSTATE} = 0; #-- Get readings, alarms and status according to interface type if( $interface eq "OWX" ){ @@ -1265,7 +1274,8 @@ sub OWXAD_BinValues($$$$$$$) { #-- hash of the busmaster my $master = $hash->{IODev}; my $name = $hash->{NAME}; - my $error = 0; + #-- inherit previous error + my $error = $hash->{ERRSTATE}; my @data = []; my $value; my $msg; @@ -1290,11 +1300,14 @@ sub OWXAD_BinValues($$$$$$$) { $msg ="$name: invalid CRC "; $error = 1; }else{ - $msg = "$name: no error "; + $msg = "$name: no local error, inheritance = $error "; } OWX_WDBGL($name,5-4*$error,"OWXAD_BinValues: context $context ".$msg,$res); - $hash->{ERRCOUNT}=$hash->{ERRCOUNT}+1 - if( $error ); + if( $error ){ + $hash->{ERRCOUNT}++; + $hash->{ERRSTATE} = 1; + }; + #=============== get the voltage reading =============================== if( $context =~ /^ds2450.getreading/ ){ diff --git a/fhem/FHEM/21_OWCOUNT.pm b/fhem/FHEM/21_OWCOUNT.pm index aa6dc374a..3a2540ca2 100644 --- a/fhem/FHEM/21_OWCOUNT.pm +++ b/fhem/FHEM/21_OWCOUNT.pm @@ -47,7 +47,7 @@ no warnings 'deprecated'; sub Log3($$$); -my $owx_version="7.0"; +my $owx_version="7.01"; #-- fixed raw channel name, flexible channel name my @owg_fixed = ("A","B"); my @owg_channel = ("A","B"); @@ -58,15 +58,15 @@ my $owgmodel; my $owgauto = 0; my %gets = ( - "id" => "", + "id" => ":noArg", "mcache" => "", "memory" => "", "midnight" => "", "raw" => "", - "counters" => "", - "month" => "", - "year" => "", - "version" => "" + "counters" => ":noArg", + "month" => ":noArg", + "year" => ":noArg", + "version" => ":noArg" ); my %sets = ( @@ -372,7 +372,13 @@ sub OWCOUNT_ChannelNames($) { my $state = $hash->{READINGS}{"state"}{VAL}; my ($cname,@cnama,$unit,@unarr,$runit,$period); - + + my $nomemory = defined($attr{$name}{"nomemory"}) ? $attr{$name}{"nomemory"} : 0; + $gets{"memory"} = ($nomemory) ? ":noArg" : ":0,1,2,3,4,5,6,7,8,9,10,11,12,13"; + $gets{"mcache"} = $gets{"memory"}; + + $gets{"midnight"}=":"; + for (my $i=0;$i{READINGS}{$owg_channel[$i]}{ABBR} = $cnama[1]; + $gets{"midnight"} .= $cnama[0]; + $gets{"midnight"} .= "," + if ($i<(int(@owg_fixed)-1)) + ; $hash->{READINGS}{$owg_channel[$i]}{UNIT} = $unit; $period = defined($attr{$name}{$owg_fixed[$i]."Period"}) ? $attr{$name}{$owg_fixed[$i]."Period"} : "hour"; @@ -426,6 +436,7 @@ sub OWCOUNT_ChannelNames($) { $hash->{READINGS}{$owg_rate[$i]}{ABBR} = $cnama[1]; $hash->{READINGS}{$owg_rate[$i]}{UNIT} = $unit; } + $gets{"raw"} = $gets{"midnight"}; } ######################################################################################## @@ -676,9 +687,12 @@ sub OWCOUNT_Get($@) { if(int(@a) < 2); #-- check argument - return "OWCOUNT: get $name with unknown argument $a[1], choose one of ".join(" ", sort keys %gets) + my $msg = "OWCOUNT: Get with unknown argument $a[1], choose one of "; + $msg .= "$_$gets{$_} " foreach (keys%gets); + return $msg if(!defined($gets{$a[1]})); + #-- get id if($a[1] eq "id") { $value = $hash->{ROM_ID}; @@ -1179,7 +1193,6 @@ sub OWCOUNT_ParseMidnight($$$) { } else { $strval = 0.0; } - #Log 1,"============> Parsed $name midnight value $strval"; $hash->{owg_midnight}->[$page-14] = $strval; } @@ -1323,8 +1336,6 @@ sub OWCOUNT_SetPage ($$$) { #-- check if memory usage has been disabled my $nomemory = defined($attr{$name}{"nomemory"}) ? $attr{$name}{"nomemory"} : 0; - #Log 1,"=========> device $name set page $page with nomemory=$nomemory and data of length ".length($data)." has data >$data< "; - $data=sprintf("%-32s",$data); if( $nomemory==0 ){ @@ -1607,7 +1618,7 @@ sub OWXCOUNT_BinValues($$$$$$$) { }else{ $msg = "$name: no error "; } - OWX_WDBGL($name,5-$error*4,"=====================> OWXCOUNT_BinValues getpage: ".$msg,$res); + OWX_WDBGL($name,5-$error*4,"OWXCOUNT_BinValues getpage: ".$msg,$res); #-- my $nomemory = defined($attr{$name}{"nomemory"}) ? $attr{$name}{"nomemory"} : 0; @@ -1627,7 +1638,7 @@ sub OWXCOUNT_BinValues($$$$$$$) { #if ( ($data[4] | $data[5] | $data[6] | $data[7]) ne "\x00" ){ # $error = 1; # my $msg = "$name: invalid data in counter page ".ord($data[4])." ".ord($data[5])." ".ord($data[6])." ".ord($data[7]); - # OWX_WDBGL($name,1,"=====================> OWXCOUNT_BinValues getpage counter: ".$msg,"") + # OWX_WDBGL($name,1,"OWXCOUNT_BinValues getpage counter: ".$msg,"") #} if( !$error ){ #-- counter value @@ -1656,7 +1667,7 @@ sub OWXCOUNT_BinValues($$$$$$$) { }else{ $msg = "$name: no error "; } - OWX_WDBGL($name,5-$error*4,"=====================> OWXCOUNT_BinValues: setpage ".$msg,$res); + OWX_WDBGL($name,5-$error*4,"OWXCOUNT_BinValues: setpage ".$msg,$res); #-- process results my $select="\x5A".substr($res,10,3); @@ -1678,7 +1689,7 @@ sub OWXCOUNT_BinValues($$$$$$$) { }else{ $msg = "$name: no error "; } - OWX_WDBGL($name,5-$error*4,"=====================> OWXCOUNT_BinValues: setpage.$page.final ".$msg,$res); + OWX_WDBGL($name,5-$error*4,"OWXCOUNT_BinValues: setpage.$page.final ".$msg,$res); } return undef; diff --git a/fhem/FHEM/21_OWID.pm b/fhem/FHEM/21_OWID.pm index 1c18e8b28..b42112b2e 100644 --- a/fhem/FHEM/21_OWID.pm +++ b/fhem/FHEM/21_OWID.pm @@ -49,12 +49,12 @@ use ProtoThreads; no warnings 'deprecated'; sub Log3($$$); -my $owx_version="7.0"; +my $owx_version="7.01"; #-- declare variables my %gets = ( - "present" => "", - "id" => "", - "version" => "" + "present" => ":noArg", + "id" => ":noArg", + "version" => ":noArg" ); my %sets = ( "interval" => "" @@ -301,12 +301,14 @@ sub OWID_Get($@) { my $offset; my $factor; - #-- check syntax + #-- check syntax return "OWID: Get argument is missing @a" if(int(@a) != 2); #-- check argument - return "OWID: Get with unknown argument $a[1], choose one of ".join(" ", sort keys %gets) + my $msg = "OWID: Get with unknown argument $a[1], choose one of "; + $msg .= "$_$gets{$_} " foreach (keys%gets); + return $msg if(!defined($gets{$a[1]})); #-- get id diff --git a/fhem/FHEM/21_OWLCD.pm b/fhem/FHEM/21_OWLCD.pm index 93b81305f..9ee34825c 100644 --- a/fhem/FHEM/21_OWLCD.pm +++ b/fhem/FHEM/21_OWLCD.pm @@ -78,7 +78,7 @@ no warnings 'deprecated'; sub Log3($$$); -my $owx_version="7.0"; +my $owx_version="7.01"; #-- controller may be HD44780 or KS0073 # these values can be changed by attribute for different display # geometries or memory maps @@ -89,11 +89,11 @@ my @lcdpage = (0,32,64,96); #-- declare variables my %gets = ( - "id" => "", - "memory" => "", - "gpio" => "", - "counter" => "", - "version" => "" + "id" => ":noArg", + "memory" => ":noArg", + "gpio" => ":noArg", + "counter" => ":noArg", + "version" => ":noArg" #"register" => "", #"data" => "" ); @@ -345,7 +345,9 @@ sub OWLCD_Get($@) { if(int(@a) < 2); #-- check argument - return "OWLCD: Get with unknown argument $a[1], choose one of ".join(" ", sort keys %gets) + my $msg = "OWLCD: Get with unknown argument $a[1], choose one of "; + $msg .= "$_$gets{$_} " foreach (keys%gets); + return $msg if(!defined($gets{$a[1]})); #-- get id @@ -504,7 +506,7 @@ sub OWLCD_Set($@) { } #-- check syntax for setting memory } elsif( $key eq "memory" ){ - return "OWLCD: Set needs two parameters when setting memory page: <#page> " + return "OWLCD: Set needs two parameters when setting memory page 0/1: <#page> " if( int(@a)<4 ); $line = ($a[2] =~ m/\d/) ? int($a[2]) : 0; $value = $a[3]; @@ -512,9 +514,9 @@ sub OWLCD_Set($@) { $value .= " ".$a[$i]; } #-- check syntax for setting icon - } elsif ( ($key eq "icon") || ($key eq "gpiobit") ){ + } elsif ( $key eq "icon" ){ if( ($a[2] ne "0") && ($a[2] ne "none") ){ - return "OWLCD: Set needs two parameters when setting icon value: <#icon> on/off/blink (resp. 0..5/off/blink for #16)" + return "OWLCD: Set needs two parameters when setting icon 0-16 value: <#icon> on/off/blink (resp. 0..5/off/blink for #16)" if( (int(@a)!=4) ); $icon = ($a[2] =~ m/\d\d?/) ? $a[2] : 0; $value = $a[3]; @@ -524,6 +526,14 @@ sub OWLCD_Set($@) { $icon = 0; $value = "OFF"; } + + #-- check syntax for setting gpiobit + } elsif ( $key eq "gpiobit" ){ + return "OWLCD: Set needs two parameters when setting gpiobit 1-3 value: <#bit> on/off" + if( (int(@a)!=4) ); + return "OWLCD: Set gpiobit 1-3 value: <#bit> on/off only possible for bits 1-3" + if( $a[2]>3 || $a[2]<1 ); + #-- check syntax for reset and test and initialize } elsif ( ($key eq "reset") || ($key eq "test") || ($key eq "initialize")){ return "OWLCD: Set needs no parameters when setting $key value" @@ -553,10 +563,12 @@ sub OWLCD_Set($@) { return GP_Catch($@) if $@; } } + #-- set single gpio bit from all off = 1 on = 0 + # contribution from ext323 if($key eq "gpiobit") { my $bit = $a[2]; - $value = lc($a[3]); + $value = lc($a[3]); $value =~ s/on/0/; $value =~ s/off/1/; my $vold = $value; @@ -569,7 +581,7 @@ sub OWLCD_Set($@) { if( $value == 1 ){ $value = 1<<($bit-1) | ReadingsVal($name,"gpio",0); }else{ - $value = 6<<($bit-1) & ReadingsVal($name,"gpio",0); + $value = ~(1<<($bit-1)) & ReadingsVal($name,"gpio",0); } #-- OWX interface if( $interface eq "OWX" ){ diff --git a/fhem/FHEM/21_OWMULTI.pm b/fhem/FHEM/21_OWMULTI.pm index e901d9aa3..61b320ed8 100644 --- a/fhem/FHEM/21_OWMULTI.pm +++ b/fhem/FHEM/21_OWMULTI.pm @@ -46,17 +46,17 @@ no warnings 'deprecated'; sub Log($$); -my $owx_version="7.0"; +my $owx_version="7.01"; #-- flexible channel name my ($owg_channel,$owg_schannel); my %gets = ( - "id" => "", - "reading" => "", - "temperature" => "", - "VDD" => "", - "raw" => "", - "version" => "" + "id" => ":noArg", + "reading" => ":noArg", + "temperature" => ":noArg", + "VDD" => ":noArg", + "raw" => ":noArg", + "version" => ":noArg" ); my %sets = ( @@ -473,7 +473,9 @@ sub OWMULTI_Get($@) { if(int(@a) != 2); #-- check argument - return "OWMULTI: Get with unknown argument $a[1], choose one of ".join(" ", sort keys %gets) + my $msg = "OWMULTI: Get with unknown argument $a[1], choose one of "; + $msg .= "$_$gets{$_} " foreach (keys%gets); + return $msg if(!defined($gets{$a[1]})); #-- get id @@ -492,6 +494,9 @@ sub OWMULTI_Get($@) { return "$name.version => $owx_version"; } + #-- reset current ERRSTATE + $hash->{ERRSTATE} = 0; + #-- for the other readings we need a new reading #-- OWX interface if( $interface eq "OWX" ){ @@ -566,6 +571,9 @@ sub OWMULTI_GetValues($) { #-- restart timer for updates InternalTimer(time()+$hash->{INTERVAL}, "OWMULTI_GetValues", $hash, 0); + #-- reset current ERRSTATE + $hash->{ERRSTATE} = 0; + #-- Get values according to interface type my $interface= $hash->{IODev}->{TYPE}; if( $interface eq "OWX" ){ @@ -803,7 +811,8 @@ sub OWXMULTI_BinValues($$$$$$$) { #-- hash of the busmaster my $master = $hash->{IODev}; my $name = $hash->{NAME}; - my $error = 0; + #-- inherit previous error + my $error = $hash->{ERRSTATE}; my @data = []; my ($value,$lsb,$msb,$sign); my $msg; @@ -886,8 +895,8 @@ sub OWXMULTI_BinValues($$$$$$$) { #-- and now from raw to formatted values if( $error ){ - $hash->{ERRCOUNT}=$hash->{ERRCOUNT}+1; - + $hash->{ERRCOUNT}++; + $hash->{ERRSTATE} = 1; }else{ $hash->{PRESENT} = 1; OWMULTI_FormatValues($hash); diff --git a/fhem/FHEM/21_OWSWITCH.pm b/fhem/FHEM/21_OWSWITCH.pm index d6954232d..887dd9212 100644 --- a/fhem/FHEM/21_OWSWITCH.pm +++ b/fhem/FHEM/21_OWSWITCH.pm @@ -47,16 +47,16 @@ no warnings 'deprecated'; sub Log($$); -my $owx_version="7.0"; +my $owx_version="7.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"); my %gets = ( - "id" => "", + "id" => ":noArg", "input" => "", - "gpio" => "", - "version" => "" + "gpio" => ":noArg", + "version" => ":noArg" ); my %sets = ( @@ -324,6 +324,8 @@ sub OWSWITCH_ChannelNames($) { my $state = $hash->{READINGS}{"state"}{VAL}; my ($cname,@cnama,$unit,@unarr); + + $gets{"input"}=":"; for (my $i=0;$i<$cnumber{$attr{$name}{"model"}};$i++){ #-- name @@ -332,9 +334,12 @@ sub OWSWITCH_ChannelNames($) { if( int(@cnama)!=2){ push(@cnama,$cnama[0]); } - #-- put into readings + #-- put into readings and array for display $owg_channel[$i] = $cnama[0]; - $hash->{READINGS}{$owg_channel[$i]}{ABBR} = $cnama[1]; + $hash->{READINGS}{$owg_channel[$i]}{ABBR} = $cnama[1]; + $gets{"input"} .= $cnama[0]; + $gets{"input"} .= "," + if ($i<$cnumber{$attr{$name}{"model"}}-1); #-- unit my $unit = defined($attr{$name}{$owg_fixed[$i]."Unit"}) ? $attr{$name}{$owg_fixed[$i]."Unit"} : "ON|OFF"; @@ -348,6 +353,8 @@ sub OWSWITCH_ChannelNames($) { #-- put into readings $hash->{READINGS}{$owg_channel[$i]}{UNIT} = $unit; } + $sets{"output"}=$gets{"input"}; + } ######################################################################################## @@ -438,7 +445,9 @@ sub OWSWITCH_Get($@) { if(int(@a) < 2); #-- check argument - return "OWSWITCH: Get with unknown argument $a[1], choose one of ".join(" ", sort keys %gets) + my $msg = "OWSWITCH: Get with unknown argument $a[1], choose one of "; + $msg .= "$_$gets{$_} " foreach (keys%gets); + return $msg if(!defined($gets{$a[1]})); #-- get id diff --git a/fhem/FHEM/21_OWTHERM.pm b/fhem/FHEM/21_OWTHERM.pm index 515f9e526..b1d6b6112 100644 --- a/fhem/FHEM/21_OWTHERM.pm +++ b/fhem/FHEM/21_OWTHERM.pm @@ -5,7 +5,6 @@ # FHEM module to commmunicate with 1-Wire temperature sensors DS1820, DS18S20, DS18B20, DS1822 # # Prof. Dr. Peter A. Henning -# Norbert Truchsess # # $Id$ # @@ -48,13 +47,13 @@ no warnings 'deprecated'; sub Log3($$$); sub AttrVal($$$); -my $owx_version="7.0"; +my $owx_version="7.01"; my %gets = ( - "id" => "", - "temperature" => "", - "alarm" => "", - "version" => "" + "id" => ":noArg", + "temperature" => ":noArg", + "alarm" => ":noArg", + "version" => ":noArg" ); my %sets = ( @@ -421,7 +420,9 @@ sub OWTHERM_Get($@) { if(int(@a) != 2); #-- check argument - return "OWTHERM: Get with unknown argument $a[1], choose one of ".join(" ", sort keys %gets) + my $msg = "OWTHERM: Get with unknown argument $a[1], choose one of "; + $msg .= "$_$gets{$_} " foreach (keys%gets); + return $msg if(!defined($gets{$a[1]})); #-- get id diff --git a/fhem/FHEM/21_OWVAR.pm b/fhem/FHEM/21_OWVAR.pm index 6e0aa7d30..19744d808 100644 --- a/fhem/FHEM/21_OWVAR.pm +++ b/fhem/FHEM/21_OWVAR.pm @@ -51,9 +51,9 @@ my $owx_version="7.0"; my $owg_channel = ""; my %gets = ( - "id" => "", - "value" => "", - "version" => "" + "id" => ":noArg", + "value" => ":noArg", + "version" => ":noArg" ); my %sets = ( @@ -364,7 +364,9 @@ sub OWVAR_Get($@) { if(int(@a) < 2); #-- check argument - return "OWVAR: Get with unknown argument $a[1], choose one of ".join(" ", sort keys %gets) + my $msg = "OWVAR: Get with unknown argument $a[1], choose one of "; + $msg .= "$_$gets{$_} " foreach (keys%gets); + return $msg if(!defined($gets{$a[1]})); #-- get id diff --git a/fhem/FHEM/95_Alarm.pm b/fhem/FHEM/95_Alarm.pm index 29c921786..8d0b8b715 100644 --- a/fhem/FHEM/95_Alarm.pm +++ b/fhem/FHEM/95_Alarm.pm @@ -51,7 +51,7 @@ my %alarm_transtable_EN = ( "status" => "Status", "notstarted" => "Not started", "next" => "Next", - "arm " => "Arm", + "arm" => "Arm", "disarm" => "Disarm", "armbutton" => "Arming", "disarmbutton" => "Disarming", @@ -1185,7 +1185,7 @@ sub Alarm_Html($)

Alarm

-Deutsche Dokumentation im Wiki vorhanden, die englische Version gibt es hier: Alarm +Deutsche Dokumentation im Wiki vorhanden, die englische Version gibt es hier: Alarm =end html_DE =cut