mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-01 20:20:10 +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:
parent
c84321fa73
commit
5b752bcb10
@ -57,6 +57,7 @@ sub HProtocolGateway_Initialize($) {
|
|||||||
sub HProtocolGateway_Define($$) {
|
sub HProtocolGateway_Define($$) {
|
||||||
my ($hash, $def) = @_;
|
my ($hash, $def) = @_;
|
||||||
my @a = split("[ \t][ \t]*", $def);
|
my @a = split("[ \t][ \t]*", $def);
|
||||||
|
my $name = $hash->{NAME};
|
||||||
|
|
||||||
return "Wrong syntax: use define <name> HProtocolGateway </dev/tty???>" if(int(@a) != 3);
|
return "Wrong syntax: use define <name> HProtocolGateway </dev/tty???>" if(int(@a) != 3);
|
||||||
|
|
||||||
@ -64,6 +65,8 @@ sub HProtocolGateway_Define($$) {
|
|||||||
$hash->{Clients} = "HProtocolTank";
|
$hash->{Clients} = "HProtocolTank";
|
||||||
$hash->{STATE} = "Initialized";
|
$hash->{STATE} = "Initialized";
|
||||||
|
|
||||||
|
$attr{$name}{room} = "HProtocol";
|
||||||
|
|
||||||
HProtocolGateway_DeviceConfig($hash);
|
HProtocolGateway_DeviceConfig($hash);
|
||||||
|
|
||||||
HProtocolGateway_Poll($hash) if defined(AttrVal($hash->{NAME}, 'pollIntervalMins', undef)); # if pollIntervalMins defind -> start timer
|
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($$@) {
|
sub HProtocolGateway_Get($$@) {
|
||||||
my ($hash, $name, $opt, @args) = @_;
|
my ($hash, $name, $opt, @args) = @_;
|
||||||
|
|
||||||
return "\"get $name\" needs at least one argument" unless(defined($opt));
|
return "\"get $name\" needs at least one argument" unless(defined($opt));
|
||||||
|
|
||||||
if ($opt eq "update") {
|
if ($opt eq "update") {
|
||||||
HProtocolGateway_GetUpdate($hash);
|
HProtocolGateway_GetUpdate($hash);
|
||||||
return "Done.";
|
return "Done.";
|
||||||
} else {
|
} else {
|
||||||
# IMPORTANT! This defines the list of possible commands
|
# IMPORTANT! This defines the list of possible commands
|
||||||
my $list = "update:noArg";
|
my $list = "update:noArg";
|
||||||
return "Unknown argument $opt, choose one of $list";
|
return "Unknown argument $opt, choose one of $list";
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub HProtocolGateway_Set($@) {
|
sub HProtocolGateway_Set($@) {
|
||||||
my ($hash, @a) = @_;
|
my ($hash, @a) = @_;
|
||||||
|
my $name = $a[0];
|
||||||
my $name = $a[0];
|
|
||||||
my $cmd = $a[1];
|
my $cmd = $a[1];
|
||||||
|
|
||||||
if(!defined($sets{$cmd})) {
|
if(!defined($sets{$cmd})) {
|
||||||
return 'Unknown argument ' . $cmd . ', choose one of ' . join(' ', keys %sets) . ":noArg"
|
return 'Unknown argument ' . $cmd . ', choose one of ' . join(' ', keys %sets) . ":noArg"
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($cmd eq 'readValues') {
|
if ($cmd eq 'readValues') {
|
||||||
|
|
||||||
RemoveInternalTimer($hash);
|
RemoveInternalTimer($hash);
|
||||||
InternalTimer(gettimeofday() + 1, 'HProtocolGateway_GetUpdate', $hash, 0);
|
InternalTimer(gettimeofday() + 1, 'HProtocolGateway_GetUpdate', $hash, 0);
|
||||||
}
|
}
|
||||||
@ -196,6 +192,11 @@ sub HProtocolGateway_ParseMessage($$) {
|
|||||||
# convert to HEX
|
# convert to HEX
|
||||||
$check = sprintf '%02X', $check;
|
$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);
|
return if($check ne $checksum);
|
||||||
|
|
||||||
my ($filllevel,$volume,$ullage) = (0,0,0);
|
my ($filllevel,$volume,$ullage) = (0,0,0);
|
||||||
|
@ -32,7 +32,7 @@ sub HProtocolTank_Initialize($) {
|
|||||||
$hash->{ParseFn} = "HProtocolTank_Parse";
|
$hash->{ParseFn} = "HProtocolTank_Parse";
|
||||||
$hash->{FingerprintFn} = "HProtocolTank_Fingerprint";
|
$hash->{FingerprintFn} = "HProtocolTank_Fingerprint";
|
||||||
$hash->{Match} = "^[a-zA-Z0-9_]+ [a-zA-Z0-9_]+ [+-]*[0-9]+([.][0-9]+)?";
|
$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($$) {
|
sub HProtocolTank_Define($$) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user