2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 12:49:34 +00:00

git-svn-id: https://svn.fhem.de/fhem/trunk@2030 2b470e98-0d58-463d-a4d8-8e2adae1ed80

This commit is contained in:
pahenning 2012-10-28 16:57:04 +00:00
parent ae8c212d93
commit cd86005034
5 changed files with 139 additions and 113 deletions

View File

@ -13,7 +13,7 @@
# Internally these interfaces are vastly different, read the corresponding Wiki pages
# http://fhemwiki.de/wiki/Interfaces_f%C3%BCr_1-Wire
#
# Version 2.24 - October, 2012
# Version 2.25 - October, 2012
#
# Prof. Dr. Peter A. Henning, 2012
#
@ -616,8 +616,15 @@ sub OWX_Discover ($) {
}
}
}
#-- Go through all devices found on this bus
foreach my $owx_dev (@owx_devs) {
#-- ignore those which do not have the proper pattern
if( !($owx_dev =~ m/[0-9A-F]{2}\.[0-9A-F]{12}\.[0-9A-F]{2}/) ){
Log 3,"OWX: Invalid 1-Wire device ID $owx_dev, ignoring it";
next;
}
#-- three pieces of the ROM ID found on the bus
my $owx_rnf = substr($owx_dev,3,12);
my $owx_f = substr($owx_dev,0,2);

View File

@ -16,7 +16,7 @@
#
# Prof. Dr. Peter A. Henning, 2012
#
# Version 2.24 - October, 2012
# Version 2.25 - October, 2012
#
# Setup bus device in fhem.cfg as
#
@ -44,10 +44,14 @@
#
# attr <name> event on-change/on-update = when to write an event (default= on-update)
#
# attr <name> stateAL0 "<string>" = character string for denoting low normal condition, default is green down triangle
# attr <name> stateAH0 "<string>" = character string for denoting high normal condition, default is green up triangle
# attr <name> stateAL1 "<string>" = character string for denoting low alarm condition, default is red down triangle
# attr <name> stateAH1 "<string>" = character string for denoting high alarm condition, default is red up triangle
# attr <name> stateAL0 "<string>" = character string for denoting low normal condition, default is empty,
# overwritten by attribute setting green down triangle
# attr <name> stateAH0 "<string>" = character string for denoting high normal condition, default is empty,
# overwritten by attribute setting green up triangle
# attr <name> stateAL1 "<string>" = character string for denoting low alarm condition, default is l,
# overwritten by attributre setting red down triangle
# attr <name> stateAH1 "<string>" = character string for denoting high alarm condition, default is h,
# overwritten by attributre setting red up triangle
# attr <name> <channel>Name <string>|<string> = name for the channel | a type description for the measured value
# attr <name> <channel>Unit <string>|<string> = unit of measurement for this channel | its abbreviation
# attr <name> <channel>Offset <float> = offset added to the reading in this channel
@ -102,8 +106,6 @@ my @owg_shigh;
#-- alarm values - always the raw values committed to the device
my @owg_vlow;
my @owg_vhigh;
#-- variables for display strings
my ($stateal1,$stateah1,$stateal0,$stateah0);
my %gets = (
"id" => "",
@ -254,10 +256,11 @@ sub OWAD_InitializeDevice($) {
my $name = $hash->{NAME};
$stateal1 = defined($attr{$name}{stateAL1}) ? $attr{$name}{stateAL1} : "<span style=\"color:red\">&#x25BE;</span>";
$stateah1 = defined($attr{$name}{stateAH1}) ? $attr{$name}{stateAH1} : "<span style=\"color:red\">&#x25B4;</span>";
$stateal0 = defined($attr{$name}{stateAL0}) ? $attr{$name}{stateAL0} : "<span style=\"color:green\">&#x25BE;</span>";
$stateah0 = defined($attr{$name}{stateAH0}) ? $attr{$name}{stateAH0} : "<span style=\"color:green\">&#x25B4;</span>";
#-- more colorful alarm signatures
CommandAttr (undef,"$name stateAL1 <span style=\"color:red\">&#x25BE;</span>");
CommandAttr (undef,"$name stateAH1 <span style=\"color:red\">&#x25B4;</span>");
CommandAttr (undef,"$name stateAL0 <span style=\"color:green\">&#x25BE;</span>");
CommandAttr (undef,"$name stateAH0 <span style=\"color:green\">&#x25B4;</span>");
#-- Initial readings
@owg_val = (0.0,0.0,0.0,0.0);
@ -346,6 +349,12 @@ sub OWAD_FormatValues($) {
my $tn = TimeNow();
#-- alarm signatures
my $stateal1 = defined($attr{$name}{stateAL1}) ? $attr{$name}{stateAL1} : "l";
my $stateah1 = defined($attr{$name}{stateAH1}) ? $attr{$name}{stateAH1} : "h";
my $stateal0 = defined($attr{$name}{stateAL0}) ? $attr{$name}{stateAL0} : "";
my $stateah0 = defined($attr{$name}{stateAH0}) ? $attr{$name}{stateAH0} : "";
#-- formats for output
for (my $i=0;$i<int(@owg_fixed);$i++){
my $cname = defined($attr{$name}{$owg_fixed[$i]."Name"}) ? $attr{$name}{$owg_fixed[$i]."Name"} : $owg_fixed[$i]."|voltage";

View File

@ -14,7 +14,7 @@
#
# Prof. Dr. Peter A. Henning, 2012
#
# Version 2.24 - October, 2012
# Version 2.25 - October, 2012
#
# Setup bus device in fhem.cfg as
#

View File

@ -17,7 +17,7 @@
#
# Prof. Dr. Peter A. Henning, 2012
#
# Version 2.24 - October, 2012
# Version 2.25 - October, 2012
#
# Setup bus device in fhem.cfg as
#
@ -52,9 +52,11 @@
#
# attr <name> event on-change/on-update = when to write an event (default= on-update)
#
# attr <name> stateS <string> = character string denoting external shortening condition, default is (ext)
# overwritten by an attribute setting "red angled arrow downwward"
#
# attr <name> <channel>Name <string>|<string> = name for the channel | a type description for the measured value
# attr <name> <channel>Unit <string>|<string> = values to display in state variable for on|off condition
# attr <name> <channel>stateS <string> = character string denoting external shortening condition
#
########################################################################################
#
@ -138,14 +140,13 @@ sub OWSWITCH_Initialize ($) {
$hash->{SetFn} = "OWSWITCH_Set";
my $attlist = "IODev do_not_notify:0,1 showtime:0,1 model:DS2413,DS2406,DS2408 loglevel:0,1,2,3,4,5 ".
"event:on-update,on-change";
"event:on-update,on-change stateS ";
#TODO: correct number of channels
for( my $i=0;$i<8;$i++ ){
$attlist .= " ".$owg_fixed[$i]."Name";
$attlist .= " ".$owg_fixed[$i]."Unit";
$attlist .= " ".$owg_fixed[$i]."stateS";
}
$hash->{AttrList} = $attlist;
}
@ -251,6 +252,9 @@ sub OWSWITCH_InitializeDevice($) {
my $name = $hash->{NAME};
#-- more colorful shortening signature
CommandAttr (undef,"$name stateS <span style=\"color:red\">&#x2607;</span>");
#-- Set channel names, channel units
for( my $i=0;$i<$cnumber{$attr{$name}{"model"}} ;$i++) {
#-- Initial readings OFF
@ -315,6 +319,9 @@ sub OWSWITCH_FormatValues($) {
my $tn = TimeNow();
#-- external shortening signature
my $sname = defined($attr{$name}{"stateS"}) ? $attr{$name}{"stateS"} : "(ext)";
#-- formats for output
for (my $i=0;$i<$cnumber{$attr{$name}{"model"}};$i++){
$cname = defined($attr{$name}{$owg_fixed[$i]."Name"}) ? $attr{$name}{$owg_fixed[$i]."Name"} : $owg_fixed[$i];
@ -328,9 +335,9 @@ sub OWSWITCH_FormatValues($) {
#-- string buildup for return value and STATE
@unarr= split(/\|/,$hash->{READINGS}{"$owg_channel[$i]"}{UNIT});
$cname = defined($attr{$name}{$owg_fixed[$i]."stateS"}) ? $attr{$name}{$owg_fixed[$i]."stateS"} : "<span style=\"color:red\">&#x2607;</span>";
$vstr = $unarr[$vval];
$vstr .= $cname if( ($vval == 0) && ($vvax == 1) );
$vstr .= $sname if( ($vval == 0) && ($vvax == 1) );
$vstr = "ERR" if( ($vval == 1) && ($vvax == 0) );
$value1 .= sprintf( "%s: %s", $owg_channel[$i], $vstr);
@ -623,8 +630,8 @@ sub OWSWITCH_Set($@) {
#-- set state
}elsif( $key eq "gpio" ){
#-- check value and write to device
return "OWSWITCH: Set with wrong value for gpio port, must be 0 <= gpio <= ".(1 << $cnumber{$attr{$name}{"model"}} - 1)
if( ! ((int($value) >= 0) && (int($value) <= (1 << $cnumber{$attr{$name}{"model"}} -1 ))) );
return "OWSWITCH: Set with wrong value for gpio port, must be 0 <= gpio <= ".((1 << $cnumber{$attr{$name}{"model"}})-1)
if( ! ((int($value) >= 0) && (int($value) <= ((1 << $cnumber{$attr{$name}{"model"}})-1 ))) );
if( $interface eq "OWX" ){
$ret = OWXSWITCH_SetState($hash,int($value));

View File

@ -45,8 +45,10 @@
#
# attr <name> event on-change/on-update = when to write an event (default= on-update)
#
# attr <name> stateAL "<string>" = character string for denoting low alarm condition, default is red down triangle
# attr <name> stateAH "<string>" = character string for denoting high alarm condition, default is red up triangle
# attr <name> stateAL "<string>" = character string for denoting low alarm condition, default is (-),
# overwritten by attribute setting red down triangle
# attr <name> stateAH "<string>" = character string for denoting high alarm condition, default is (+),
# overwritten by attribute setting red up triangle
# attr <name> tempOffset <float> = temperature offset in degree Celsius added to the raw temperature reading
# attr <name> tempUnit <string> = unit of measurement, e.g. Celsius/Kelvin/Fahrenheit or C/K/F, default is Celsius
# attr <name> tempLow <float> = value for low alarm
@ -239,8 +241,9 @@ sub OWTHERM_InitializeDevice($) {
my $name = $hash->{NAME};
my @args;
$stateal = defined($attr{$name}{stateAL}) ? $attr{$name}{stateAL} : "<span style=\"color:red\">&#x25BE;</span>";
$stateah = defined($attr{$name}{stateAH}) ? $attr{$name}{stateAH} : "<span style=\"color:red\">&#x25B4;</span>";
#-- more colorful alarm signatures
CommandAttr (undef,"$name stateAL <span style=\"color:red\">&#x25BE;</span>");
CommandAttr (undef,"$name stateAH <span style=\"color:red\">&#x25B4;</span>");
#-- unit attribute defined ?
$hash->{READINGS}{"temperature"}{UNIT} = defined($attr{$name}{"tempUnit"}) ? $attr{$name}{"tempUnit"} : "Celsius";
@ -278,8 +281,8 @@ sub OWTHERM_FormatValues($) {
my $tn = TimeNow();
#-- attributes defined ?
$stateal = defined($attr{$name}{stateAL}) ? $attr{$name}{stateAL} : "<span style=\"color:red\">&#x25BE;</span>";
$stateah = defined($attr{$name}{stateAH}) ? $attr{$name}{stateAH} : "<span style=\"color:red\">&#x25B4;</span>";
$stateal = defined($attr{$name}{stateAL}) ? $attr{$name}{stateAL} : "(-)";
$stateah = defined($attr{$name}{stateAH}) ? $attr{$name}{stateAH} : "(+)";
$unit = defined($attr{$name}{"tempUnit"}) ? $attr{$name}{"tempUnit"} : $hash->{READINGS}{"temperature"}{UNIT};
$offset = defined($attr{$name}{"tempOffset"}) ? $attr{$name}{"tempOffset"} : 0.0 ;
$factor = 1.0;