From 5b752bcb10ec469b34b5fa97fec7140aa852ed71 Mon Sep 17 00:00:00 2001 From: eisler Date: Sun, 9 Sep 2018 10:56:23 +0000 Subject: [PATCH] 12_HProtocolGateway / 12_HProtocolTank: minor bug fixes git-svn-id: https://svn.fhem.de/fhem/trunk@17304 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/12_HProtocolGateway.pm | 21 +++++++++++---------- fhem/FHEM/12_HProtocolTank.pm | 2 +- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/fhem/FHEM/12_HProtocolGateway.pm b/fhem/FHEM/12_HProtocolGateway.pm index 86eae226b..d0491207b 100644 --- a/fhem/FHEM/12_HProtocolGateway.pm +++ b/fhem/FHEM/12_HProtocolGateway.pm @@ -57,6 +57,7 @@ sub HProtocolGateway_Initialize($) { sub HProtocolGateway_Define($$) { my ($hash, $def) = @_; my @a = split("[ \t][ \t]*", $def); + my $name = $hash->{NAME}; return "Wrong syntax: use define HProtocolGateway " if(int(@a) != 3); @@ -64,6 +65,8 @@ sub HProtocolGateway_Define($$) { $hash->{Clients} = "HProtocolTank"; $hash->{STATE} = "Initialized"; + $attr{$name}{room} = "HProtocol"; + HProtocolGateway_DeviceConfig($hash); HProtocolGateway_Poll($hash) if defined(AttrVal($hash->{NAME}, 'pollIntervalMins', undef)); # if pollIntervalMins defind -> start timer @@ -73,33 +76,26 @@ sub HProtocolGateway_Define($$) { sub HProtocolGateway_Get($$@) { my ($hash, $name, $opt, @args) = @_; - return "\"get $name\" needs at least one argument" unless(defined($opt)); - if ($opt eq "update") { - HProtocolGateway_GetUpdate($hash); - return "Done."; + HProtocolGateway_GetUpdate($hash); + return "Done."; } else { # IMPORTANT! This defines the list of possible commands my $list = "update:noArg"; return "Unknown argument $opt, choose one of $list"; } - return -1; } sub HProtocolGateway_Set($@) { my ($hash, @a) = @_; - - my $name = $a[0]; + my $name = $a[0]; my $cmd = $a[1]; - if(!defined($sets{$cmd})) { return 'Unknown argument ' . $cmd . ', choose one of ' . join(' ', keys %sets) . ":noArg" } - if ($cmd eq 'readValues') { - RemoveInternalTimer($hash); InternalTimer(gettimeofday() + 1, 'HProtocolGateway_GetUpdate', $hash, 0); } @@ -196,6 +192,11 @@ sub HProtocolGateway_ParseMessage($$) { # convert to HEX $check = sprintf '%02X', $check; + # Unitronics Vision130 + if ($water == 0 && $temperature == 0 && $probe_offset == 0 && $version == 0 && $error == 0 && $checksum == 0 ) { + $check = 0; + } + return if($check ne $checksum); my ($filllevel,$volume,$ullage) = (0,0,0); diff --git a/fhem/FHEM/12_HProtocolTank.pm b/fhem/FHEM/12_HProtocolTank.pm index 3f1cce08f..8ccdebad8 100644 --- a/fhem/FHEM/12_HProtocolTank.pm +++ b/fhem/FHEM/12_HProtocolTank.pm @@ -32,7 +32,7 @@ sub HProtocolTank_Initialize($) { $hash->{ParseFn} = "HProtocolTank_Parse"; $hash->{FingerprintFn} = "HProtocolTank_Fingerprint"; $hash->{Match} = "^[a-zA-Z0-9_]+ [a-zA-Z0-9_]+ [+-]*[0-9]+([.][0-9]+)?"; - $hash->{AttrList} = "event-on-update-reading"; + $hash->{AttrList} = $readingFnAttributes; } sub HProtocolTank_Define($$) {