2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-07 19:04:20 +00:00

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
This commit is contained in:
phenning 2017-10-29 08:14:07 +00:00
parent c2e72e7b59
commit 279e549058
9 changed files with 134 additions and 75 deletions

View File

@ -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
@ -709,6 +715,9 @@ sub OWAD_GetValues($) {
#-- 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" ){
$ret1 = OWXAD_GetPage($hash,"reading",0);
@ -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/ ){

View File

@ -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 = (
@ -373,6 +373,12 @@ sub OWCOUNT_ChannelNames($) {
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<int(@owg_fixed);$i++){
#-- name
$cname = defined($attr{$name}{$owg_fixed[$i]."Name"}) ? $attr{$name}{$owg_fixed[$i]."Name"} : "$owg_fixed[$i]";
@ -391,6 +397,10 @@ sub OWCOUNT_ChannelNames($) {
#-- put into readings
$owg_channel[$i]=$cnama[0];
$hash->{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;

View File

@ -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" => ""
@ -306,7 +306,9 @@ sub OWID_Get($@) {
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

View File

@ -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> <string>"
return "OWLCD: Set needs two parameters when setting memory page 0/1: <#page> <string>"
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,7 +563,9 @@ 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]);
@ -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" ){

View File

@ -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);

View File

@ -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 = (
@ -325,6 +325,8 @@ sub OWSWITCH_ChannelNames($) {
my ($cname,@cnama,$unit,@unarr);
$gets{"input"}=":";
for (my $i=0;$i<$cnumber{$attr{$name}{"model"}};$i++){
#-- name
$cname = defined($attr{$name}{$owg_fixed[$i]."Name"}) ? $attr{$name}{$owg_fixed[$i]."Name"} : "$owg_fixed[$i]";
@ -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];
$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

View File

@ -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

View File

@ -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

View File

@ -1185,7 +1185,7 @@ sub Alarm_Html($)
<a name="Alarm"></a>
<h3>Alarm</h3>
<a href="https://wiki.fhem.de/wiki/Modul_Alarm">Deutsche Dokumentation im Wiki</a> vorhanden, die englische Version gibt es hier: <a href="/fhem/commandref.html#Alarm">Alarm</a>
<a href="https://wiki.fhem.de/wiki/Modul_Alarm">Deutsche Dokumentation im Wiki</a> vorhanden, die englische Version gibt es hier: <a href="/fhem/docs/commandref.html#Alarm">Alarm</a>
=end html_DE
=cut