diff --git a/fhem/CHANGED b/fhem/CHANGED
index e16b6f42a..997f4f8d1 100644
--- a/fhem/CHANGED
+++ b/fhem/CHANGED
@@ -1,12 +1,13 @@
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
# Do not insert empty lines here, update check depends on it.
+ - change: 10_OWServer: autoselecting OWNet module
- bugfix: 72_FB_CALLLIST: allow newlines in mapping attributes values
- feature: 74_XiaomiBTLESens: add new set command resetBatteryTimestamp
- bugfix: 93_DbRep: some perl warnings fixed
- fhem.pl: restoreDir restructured (Forum #85801)
- added: 88_xs1Bridge: added blacklist function
- feature: 93_DbLog: V3.9.0, syntax of attribute excludeDevs enhanced
- - update: 39_Talk2Fhem: Timephrases added, bugfixes and some changes
+ - update: 39_Talk2Fhem: Timephrases added, bugfixes and some changes
- bugfix: 74_AMADCommBridge: fix Commandref
- bugfix: 82_LGTV_WebOS: fix litte typos fix eval bug
- update: 21_HEOS: fix Use of uninitialized value {repeat}
@@ -17,8 +18,8 @@
and herold.at (austrian)
- change: 93_DbRep: V7.14.4, increased timeout of special function
- feature: 74_Unifi: added set updateClient, encrypt user and password
- - change: 49_TBot_List: deleteonly lists / internal changes
- - change: 50_TelegramBot: more silent cmds, caption formatting,several fixes
+ - change: 49_TBot_List: deleteonly lists / internal changes
+ - change: 50_TelegramBot: more silent cmds, caption formatting,several fixes
- change: lib/OWNet.pm: updated to latest version from
https://sourceforge.net/p/owfs/code/ci/master/tree/module/
ownet/perl5/OWNet/lib/OWNet.pm
diff --git a/fhem/FHEM/10_OWServer.pm b/fhem/FHEM/10_OWServer.pm
index 921219235..24bd8a08b 100644
--- a/fhem/FHEM/10_OWServer.pm
+++ b/fhem/FHEM/10_OWServer.pm
@@ -31,7 +31,10 @@ use warnings;
# this must be the latest OWNet from
# http://owfs.cvs.sourceforge.net/viewvc/owfs/owfs/module/ownet/perl5/OWNet/lib/OWNet.pm
# the version at CPAN is outdated and malfunctioning as at 2012-12-19
-use lib::OWNet;
+
+#use constant OWNet_version_default => "2.8p17";
+use constant OWNet_version_default => "3.1p5";
+use vars qw($OWNet_version);
use vars qw(%owfamily);
# 1-Wire devices (order by family code)
@@ -139,6 +142,7 @@ OWServer_Define($$)
$hash->{NOTIFYDEV} = "global";
+ $hash->{OWNET_VERSION}= OWServer_loadOWNet($hash);
if( $init_done ) {
OWServer_OpenDev($hash);
@@ -170,6 +174,58 @@ OWServer_Undef($$)
return undef;
}
+#####################################
+sub OWServer_loadOWNet($) {
+
+ my ($hash) = @_;
+ my $name = $hash->{NAME};
+
+ if(defined($OWNet_version)) {
+ Log3 $name, 3, "$name: owserver version not checked, using currently loaded OWNet version $OWNet_version";
+ return $OWNet_version;
+ }
+
+ $OWNet_version= OWNet_version_default;
+ my $libfilename= "lib/OWNet-" . $OWNet_version . "/OWNet.pm";
+ Log3 $name, 5, "$name: loading OWNet version $OWNet_version...";
+ require $libfilename;
+ Log3 $name, 3, "$name: OWNet version $OWNet_version loaded.";
+
+ my $owserver= OWServer_OpenDev($hash);
+ if(defined($owserver)) {
+ my $version= $owserver->read("/system/configuration/version");
+ Log3 $name, 3, "$name: owserver version $version found.";
+ $hash->{OWSERVER_VERSION}= $version;
+ if($OWNet_version eq $version) {
+ Log3 $name, 3, "$name: matching OWNet version already loaded.";
+ return $OWNet_version;
+ }
+ my $libfilename= "lib/OWNet-" . $version . "/OWNet.pm";
+ Log3 $name, 5, "$name: looking for OWNet version $version in $libfilename...";
+ if(-r $attr{global}{modpath}."/FHEM/$libfilename") {
+ # we temporarily disable the subroutine warning
+ my $handler= $SIG{__WARN__};
+ $SIG{__WARN__} = sub {
+ my $warning= shift;
+ warn $warning unless $warning =~ /Subroutine .* redefined at/;
+ };
+ Log3 $name, 5, "$name: loading OWNet version $version...";
+ require $libfilename;
+ $SIG{__WARN__}= $handler;
+ $OWNet_version= $version;
+ Log3 $name, 3, "$name: OWNet version $OWNet_version loaded.";
+ return $OWNet_version;
+ } else {
+ Log3 $name, 3, "$name: no matching OWNet version found, using default OWNet version $OWNet_version.";
+ }
+ } else {
+ Log3 $name, 2, "$name: could not connect to owserver, using default OWNet version $OWNet_version";
+ return $OWNet_version;
+ }
+ # we should not get here
+ return undef;
+}
+
#####################################
sub
OWServer_CloseDev($)
@@ -190,6 +246,7 @@ OWServer_OpenDev($)
my $name = $hash->{NAME};
OWServer_CloseDev($hash);
+
my $protocol= $hash->{fhem}{protocol};
Log3 $name, 3, "$name: Opening connection to OWServer $protocol...";
my $owserver= OWNet->new($protocol);
@@ -562,21 +619,35 @@ OWServer_Set($@)
define <name> OWServer <protocol>
- Defines a logical OWServer device. OWServer is the server component of the
- 1-Wire Filesystem. It serves as abstraction layer
+ Defines a logical OWServer device which connects to an owserver.
+ owserver is the server component of the
+ owfs 1-Wire Filesystem. It serves as abstraction layer
for any 1-wire devices on a host. <protocol> has
- format <hostname>:<port>. For details see
+ format <hostname>:<port>.
+ For details see
owserver documentation.
- You need OWNet.pm from owfs.org on Sourceforge, which is normally deployed with FHEM. As at 2012-12-23 the OWNet module - on CPAN has an issue which renders it useless for remote connections. + The OWServer device uses + OWNet.pm from Sourceforge + to connect to the owserver. + Currently, OWNet modules for versions 2.8p17 and 3.1p5 are deployed with FHEM. + The OWServer device autodetects the owserver version and chooses a matching + OWNet module from this list. If no matching OWNet module is found, + the default version 3.1p5 is used. The nightmare situation of two + OWServer devices connecting to owserver instances with different versions is + not handled correctly. The server and module versions are stored in the + internals of the OWServer device for your reference.
- The ow* version 2.9 packages provided with Debian Jessie in combination with OWNet.pm as deployed with FHEM have issues.
- For Debian Jessie please either unzip
+ The ow* version 3.1p5 packages provided with Debian Stretch and
+ the ow* version 2.8p17 packages provided with Debian Jessie are fine.
+ The ow* version 2.9 packages provided with Debian Jessie in combination with OWNet.pm as
+ deployed with FHEM might have issues.
+ For Debian Jessie you could unzip
owfs_2.8p17-1_all.zip and install
- owserver, dependencies and what else you require with dpkg -i <package>.deb
or use the latest OWNet.pm from Sourceforge.
+ owserver, dependencies and what else you require with dpkg -i <package>.deb
.
- The ow* version 3.1 packages provided with Debian Stretch are fine. + Please report issues related to versions in the + 1Wire board of the FHEM Forum.
A typical working configuration file /etc/owfs.conf
looks as follows: