2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-19 18:56:03 +00:00

12_HProtocolGateway / 12_HProtocolTank: minor bug fixes

git-svn-id: https://svn.fhem.de/fhem/trunk@17304 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
eisler 2018-09-09 10:56:23 +00:00
parent c84321fa73
commit 5b752bcb10
2 changed files with 12 additions and 11 deletions

View File

@ -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 <name> HProtocolGateway </dev/tty???>" 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);

View File

@ -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($$) {