From a4040bf0b26b6f4af7ed12807fd8c4d65a808648 Mon Sep 17 00:00:00 2001
From: borisneubert <>
Date: Mon, 31 Dec 2012 12:45:40 +0000
Subject: [PATCH] added attributes polls and interfaces to OWDevice
git-svn-id: https://svn.fhem.de/fhem/trunk@2399 2b470e98-0d58-463d-a4d8-8e2adae1ed80
---
fhem/FHEM/10_OWServer.pm | 4 ++--
fhem/FHEM/11_OWDevice.pm | 30 +++++++++++++++++++++++++++++-
2 files changed, 31 insertions(+), 3 deletions(-)
diff --git a/fhem/FHEM/10_OWServer.pm b/fhem/FHEM/10_OWServer.pm
index 8b1ae9613..55f2c0454 100644
--- a/fhem/FHEM/10_OWServer.pm
+++ b/fhem/FHEM/10_OWServer.pm
@@ -280,8 +280,8 @@ OWServer_Set($@)
get <name> devices
- Lists the addresses and types of all 1-wire devices provided by the owserver, Also shows
- the corresponding OWDevice devices if defined.
+ Lists the addresses and types of all 1-wire devices provided by the owserver. Also shows
+ the corresponding OWDevice if one is defined for the respective 1-wire devices.
diff --git a/fhem/FHEM/11_OWDevice.pm b/fhem/FHEM/11_OWDevice.pm
index 5bb08eba5..54666d440 100644
--- a/fhem/FHEM/11_OWDevice.pm
+++ b/fhem/FHEM/11_OWDevice.pm
@@ -38,8 +38,9 @@ OWDevice_Initialize($)
$hash->{GetFn} = "OWDevice_Get";
$hash->{SetFn} = "OWDevice_Set";
$hash->{DefFn} = "OWDevice_Define";
+ $hash->{AttrFn} = "OWDevice_Attr";
- $hash->{AttrList} = "trimvalues loglevel:0,1,2,3,4,5";
+ $hash->{AttrList} = "trimvalues polls interfaces loglevel:0,1,2,3,4,5";
}
###################################
@@ -208,6 +209,31 @@ OWDevice_UpdateValues($) {
}
+###################################
+sub
+OWDevice_Attr($@)
+{
+ my ($cmd, $name, $attrName, $attrVal) = @_;
+ my $hash = $defs{$name};
+
+ $attrVal= "" unless defined($attrVal);
+ $attrVal= "" if($cmd eq "del");
+
+ if($attrName eq "polls") {
+ my @polls= split(",", $attrVal);
+ $hash->{fhem}{polls}= \@polls;
+ Log 5, "$name: polls: " . join(" ", @polls);
+ } elsif($attrName eq "interfaces") {
+ if($attrVal ne "") {
+ $hash->{fhem}{interfaces}= join(";",split(",",$attrVal));
+ Log 5, "$name: interfaces: " . $hash->{fhem}{interfaces};
+ } else {
+ delete $hash->{fhem}{interfaces} if(defined($hash->{fhem}{interfaces}));
+ Log 5, "$name: no interfaces";
+ }
+ }
+}
+
###################################
sub
OWDevice_Get($@)
@@ -419,6 +445,8 @@ OWDevice_Define($$)
Attributes
- trimvalues: removes leading and trailing whitespace from readings. Default is 1 (on).
+ - polls: a comma-separated list of readings to poll. This supersedes the list of default readings to poll.
+ - interfaces: supersedes the interfaces exposed by that device.
- loglevel
- eventMap
- event-on-update-reading